Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Using temporarySiteSettings to store private tab preferences #4469

Merged
merged 3 commits into from
Oct 4, 2016

Conversation

darkdh
Copy link
Member

@darkdh darkdh commented Oct 3, 2016

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).

fix #4468

Auditors: @diracdeltas , @bridiver

Test Plan:
Test bravery panel, site permissions, mixed content, flash in private tabs and the preferences should not write to disk and affect regular tabs


There is a better way to achieve this but require architectural change.
We plan to supersede siteSettings and temporarySiteSettings by reading and writing user prefs directly. Private sessions will keep in-memory overlaid user prefs, but still be able to read the normal session prefs that haven’t been changed in private tabs.

fix #4468

Auditors: @bbondy, @bridiver

Test Plan:
Test bravery panel, site permissions, mixed content, flash in private tabs and the preferences should not write to disk and affect regular tabs
}
}
hostSettingsToContentSettings(appState.get('siteSettings').toJS(), contentSettings)
hostSettingsToContentSettings(appState.get('temporarySiteSettings').toJS(), contentSettings)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is going to send the private settings to the non-private tabs. We can't sync all the sessions, we have to send the temp + regular to the private session and just the regular to the regular session. Probably use setUserPref with the incognito flag instead of registerUserPrefs

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed in 7de0c05.

}
}
hostSettingsToContentSettings(appState.get('siteSettings').toJS(), contentSettings)
hostSettingsToContentSettings(appState.get('temporarySiteSettings').toJS(), contentSettings)
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't temporarySiteSettings get added only if the content settings are being sent to a private frame?

Copy link
Member

Choose a reason for hiding this comment

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

nvm @bridiver made the same comment above

const activeFrame = FrameStateUtil.getActiveFrame(this.props.windowState)
if (activeFrame && activeFrame.get('isPrivate')) {
return this.props.appState.get('temporarySiteSettings')
}
Copy link
Member

Choose a reason for hiding this comment

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

need to be careful here that the allSiteSettings frame property is consistent with what is being sent in js/state/contentSettings.js and also registerPermissionHandler in app/filtering.js. the expected behavior is that private context inheirit settings from regular contexts but not vice-versa, so I think what you want here is a merge of temporarySiteSettings and siteSettings for private frames.

Copy link
Member Author

Choose a reason for hiding this comment

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

Address in 7de0c05.

const regularSettings = hostSettingsToContentSettings(appState.get('siteSettings').toJS(), contentSettings)
if (isPrivate) {
const privateSettings =
hostSettingsToContentSettings(appState.get('siteSettings').merge(appState.get('temporarySiteSettings')).toJS(),
Copy link
Member

Choose a reason for hiding this comment

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

s/merge/mergeDeep

Copy link
Collaborator

Choose a reason for hiding this comment

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

sorry I missed this earlier, but the deep merge is not required or desirable. The overlay pref store already handles this correctly if you set the regular settings for the regular profile and only the private settings for the private profile

Copy link
Collaborator

Choose a reason for hiding this comment

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

bool OverlayUserPrefStore::GetValue(const std::string& key,
                                    const base::Value** result) const {
  // If the |key| shall NOT be stored in the overlay store, there must not
  // be an entry.
  DCHECK(ShallBeStoredInOverlay(key) || !overlay_.GetValue(key, NULL));

  if (overlay_.GetValue(key, result))
    return true;
  return underlay_->GetValue(GetUnderlayKey(key), result);
}

@diracdeltas
Copy link
Member

thanks a ton, this is mostly working! i did find one bug:

  1. open http://homestarrunner.com/ in a regular tab and in a private tab
  2. right-click and choose 'allow once' in the private tab
  3. the regular tab also reloads and Flash is allowed in it

i am pretty sure this is because you need to edit js/contextMenus.js to keep track of whether the Flash right-click context menu is being opened in a private tab.

also, please add a private tab test to braveryPanelTest.js.

@bbondy
Copy link
Member

bbondy commented Oct 4, 2016

@darkdh going to merge this in so we can get some testing, but please do the last comments in a follow up bug.

@bbondy bbondy merged commit 8efb11f into master Oct 4, 2016
@darkdh
Copy link
Member Author

darkdh commented Oct 4, 2016

will do

@luixxiul luixxiul added this to the 0.12.4dev milestone Oct 6, 2016
@cndouglas cndouglas deleted the private_pref branch October 8, 2016 21:32
darkdh added a commit that referenced this pull request Nov 7, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Private tab preferences
5 participants