Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EIP-1102 updates #6006

Merged
merged 2 commits into from
Jan 30, 2019
Merged

EIP-1102 updates #6006

merged 2 commits into from
Jan 30, 2019

Conversation

bitpshr
Copy link
Contributor

@bitpshr bitpshr commented Jan 9, 2019

This pull request includes a few bugfixes around EIP-1102:

  • Background <-> dapp messages are parametrized by tab ID
  • The privacy notice verbiage was updated to be more accurate
  • The "privacy mode" settings option description was updated

Fixes #5941
Fixes #5951
Fixes #5959
Fixes #5993

brunobar79
brunobar79 previously approved these changes Jan 10, 2019
Copy link
Contributor

@brunobar79 brunobar79 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks solid to me 💪
(You might have to rerun the tests)

@rachelhamlin
Copy link

Hey @bitpshr, Status here. What's your target date lately for enabling privacy mode by default? We were planning to do so in our next release (~early Feb).

Copy link
Contributor

@whymarrh whymarrh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few quick comments (also, small nitpick, could we rename tabID to tabId?)

@@ -65,9 +65,11 @@ class ExtensionPlatform {
}

sendMessage (message, query = {}) {
extension.tabs.query(query, tabs => {
const id = query.id
delete query.id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we deleting the id from the query here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Querying tabs worked oddly in Chrome and Firefox. If the id was not deleted before querying, no tabs would ever be returned. This is why this roundabout method of sending to a specific ID is used: if an id is present on a query, we cache it, delete it, run the rest of the query, then only send the resulting message to tabs matching the cached id.

tabs.forEach(tab => {
extension.tabs.sendMessage(tab.id, message)
extension.tabs.sendMessage(id || tab.id, message)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the id is passed in and we're querying all the tabs, will this send the same message to the same tab multiple times?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be sending a message to tab id if that's passed in, else iterate all the tabs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like a query with multiple properties should hit tabs that satisfy all properties, not just some. This is why we 1) query without the ID, then 2) iterate through the results and further filter by ID. If we detected ID first then bailed, that implies an ID takes precedence over all other query properties.

Copy link
Contributor

@whymarrh whymarrh Jan 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, maybe I don't understand what these APIs are doing well enough. If we call platform.sendMessage(foo, 42), we'll in turn be calling extension.tabs.sendMessage(42, foo) multiple times (once for each tab returned in the query), no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whymarrh's concern made sense to me, and then I tried to word it and understood Paul's point:

The tabs.query method does not take an id parameter and filter for it, and so this basically allows our own platform.sendMessage() method to accept an id in its query, and then only send to that tab.

danfinlay
danfinlay previously approved these changes Jan 17, 2019
Copy link
Contributor

@danfinlay danfinlay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, great to close so many issues with one PR!

approveProviderRequest: origin => dispatch(approveProviderRequest(origin)),
rejectProviderRequest: origin => dispatch(rejectProviderRequest(origin)),
approveProviderRequest: tabID => dispatch(approveProviderRequest(tabID)),
rejectProviderRequest: tabID => dispatch(rejectProviderRequest(tabID)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would normally raise a concern about mixing platform-specific details (like tab ID) in with the UI, but I have a proposal for a revised approach to this I want to share with you soon (maybe tomorrow?), that I think will help clean up a lot of this tab management logic.

@danfinlay
Copy link
Contributor

You'll have to pull in latest develop to fix (disable) the broken drizzle/beta tests.

@metamaskbot
Copy link
Collaborator

Builds ready [13258ea]: mascara, chrome, firefox, edge, opera

@danfinlay danfinlay merged commit db776b5 into develop Jan 30, 2019
@danfinlay danfinlay deleted the 1102-updates branch January 30, 2019 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants