Bug 1069059 - [e10s] Convert isWindowPrivate calls to isBrowserPrivate/isContentWindowPrivate as appropriate (r=mconley,margaret)

This commit is contained in:
Bill McCloskey 2014-09-23 15:48:52 -07:00
parent 3351de0867
commit 91adbce542
15 changed files with 33 additions and 22 deletions

View File

@ -312,7 +312,7 @@ var PlacesCommandHook = {
PlacesUtils.transactionManager.doTransaction(txn); PlacesUtils.transactionManager.doTransaction(txn);
itemId = txn.item.id; itemId = txn.item.id;
// Set the character-set // Set the character-set
if (charset && !PrivateBrowsingUtils.isWindowPrivate(aBrowser.contentWindow)) if (charset && !PrivateBrowsingUtils.isBrowserPrivate(aBrowser))
PlacesUtils.setCharsetForURI(uri, charset); PlacesUtils.setCharsetForURI(uri, charset);
} }

View File

@ -157,7 +157,7 @@ let AboutHomeListener = {
onUpdate: function(aData) { onUpdate: function(aData) {
let doc = content.document; let doc = content.document;
if (aData.showRestoreLastSession && !PrivateBrowsingUtils.isWindowPrivate(content)) if (aData.showRestoreLastSession && !PrivateBrowsingUtils.isContentWindowPrivate(content))
doc.getElementById("launcher").setAttribute("session", "true"); doc.getElementById("launcher").setAttribute("session", "true");
// Inject search engine and snippets URL. // Inject search engine and snippets URL.

View File

@ -65,7 +65,7 @@ function test()
info("private tab opened"); info("private tab opened");
privateBrowser.selectedBrowser.removeEventListener("load", onLoad, true); privateBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
privateContent = privateBrowser.selectedBrowser.contentWindow; privateContent = privateBrowser.selectedBrowser.contentWindow;
ok(PrivateBrowsingUtils.isWindowPrivate(privateContent), "tab window is private"); ok(PrivateBrowsingUtils.isBrowserPrivate(privateBrowser.selectedBrowser), "tab window is private");
openConsole(privateTab, consoleOpened); openConsole(privateTab, consoleOpened);
}, true); }, true);
} }

View File

@ -278,7 +278,7 @@ this.ContentSearch = {
// been destroyed by the time we receive this message, and as a result // been destroyed by the time we receive this message, and as a result
// contentWindow is undefined. // contentWindow is undefined.
if (!msg.target.contentWindow || if (!msg.target.contentWindow ||
PrivateBrowsingUtils.isWindowPrivate(msg.target.contentWindow)) { PrivateBrowsingUtils.isBrowserPrivate(msg.target)) {
return Promise.resolve(); return Promise.resolve();
} }
let browserData = this._suggestionDataForBrowser(msg.target, true); let browserData = this._suggestionDataForBrowser(msg.target, true);

View File

@ -3,10 +3,10 @@
<script> <script>
// Make sure that we cannot open private browsing windows from unprivileged content // Make sure that we cannot open private browsing windows from unprivileged content
var win = window.open("about:blank", "_blank", "private"); var win = window.open("about:blank", "_blank", "private");
ok(!SpecialPowers.isWindowPrivate(win)); ok(!SpecialPowers.isContentWindowPrivate(win));
win.close(); win.close();
// Also, make sure that passing non-private doesn't make any difference either // Also, make sure that passing non-private doesn't make any difference either
win = window.open("about:blank", "_blank", "non-private"); win = window.open("about:blank", "_blank", "non-private");
ok(!SpecialPowers.isWindowPrivate(win)); ok(!SpecialPowers.isContentWindowPrivate(win));
win.close(); win.close();
</script> </script>

View File

@ -44,7 +44,7 @@ var MemoryObserver = {
// If this browser is already a zombie, fallback to the session data // If this browser is already a zombie, fallback to the session data
let currentURL = browser.__SS_restore ? data.entries[0].url : browser.currentURI.spec; let currentURL = browser.__SS_restore ? data.entries[0].url : browser.currentURI.spec;
let sibling = browser.nextSibling; let sibling = browser.nextSibling;
let isPrivate = PrivateBrowsingUtils.isWindowPrivate(browser.contentWindow); let isPrivate = PrivateBrowsingUtils.isBrowserPrivate(browser);
tab.destroy(); tab.destroy();
tab.create(currentURL, { sibling: sibling, zombifying: true, delayLoad: true, isPrivate: isPrivate }); tab.create(currentURL, { sibling: sibling, zombifying: true, delayLoad: true, isPrivate: isPrivate });

View File

@ -948,7 +948,7 @@ var SelectionHandler = {
if (selectedText.length) { if (selectedText.length) {
let req = Services.search.defaultEngine.getSubmission(selectedText); let req = Services.search.defaultEngine.getSubmission(selectedText);
let parent = BrowserApp.selectedTab; let parent = BrowserApp.selectedTab;
let isPrivate = PrivateBrowsingUtils.isWindowPrivate(parent.browser.contentWindow); let isPrivate = PrivateBrowsingUtils.isBrowserPrivate(parent.browser);
// Set current tab as parent of new tab, and set new tab as private if the parent is. // Set current tab as parent of new tab, and set new tab as private if the parent is.
BrowserApp.addTab(req.uri.spec, {parentId: parent.id, BrowserApp.addTab(req.uri.spec, {parentId: parent.id,
selected: true, selected: true,

View File

@ -1209,7 +1209,7 @@ var BrowserApp = {
webBrowserPrint.cancel(); webBrowserPrint.cancel();
} }
} }
let isPrivate = PrivateBrowsingUtils.isWindowPrivate(aBrowser.contentWindow); let isPrivate = PrivateBrowsingUtils.isBrowserPrivate(aBrowser);
let download = dm.addDownload(Ci.nsIDownloadManager.DOWNLOAD_TYPE_DOWNLOAD, let download = dm.addDownload(Ci.nsIDownloadManager.DOWNLOAD_TYPE_DOWNLOAD,
aBrowser.currentURI, aBrowser.currentURI,
Services.io.newFileURI(file), "", mimeInfo, Services.io.newFileURI(file), "", mimeInfo,
@ -1629,7 +1629,7 @@ var BrowserApp = {
this.isSearch = true; this.isSearch = true;
// Don't store queries in private browsing mode. // Don't store queries in private browsing mode.
let isPrivate = PrivateBrowsingUtils.isWindowPrivate(this.selectedTab.browser.contentWindow); let isPrivate = PrivateBrowsingUtils.isBrowserPrivate(this.selectedTab.browser);
let query = isPrivate ? "" : aData; let query = isPrivate ? "" : aData;
let engine = aSubject.QueryInterface(Ci.nsISearchEngine); let engine = aSubject.QueryInterface(Ci.nsISearchEngine);
@ -2108,7 +2108,7 @@ var NativeWindow = {
linkOpenableNonPrivateContext: { linkOpenableNonPrivateContext: {
matches: function linkOpenableNonPrivateContextMatches(aElement) { matches: function linkOpenableNonPrivateContextMatches(aElement) {
let doc = aElement.ownerDocument; let doc = aElement.ownerDocument;
if (!doc || PrivateBrowsingUtils.isWindowPrivate(doc.defaultView)) { if (!doc || PrivateBrowsingUtils.isContentWindowPrivate(doc.defaultView)) {
return false; return false;
} }
@ -2979,7 +2979,7 @@ nsBrowserAccess.prototype = {
let parent = BrowserApp.getTabForWindow(aOpener.top); let parent = BrowserApp.getTabForWindow(aOpener.top);
if (parent) { if (parent) {
parentId = parent.id; parentId = parent.id;
isPrivate = PrivateBrowsingUtils.isWindowPrivate(parent.browser.contentWindow); isPrivate = PrivateBrowsingUtils.isBrowserPrivate(parent.browser);
} }
} }
@ -6347,7 +6347,7 @@ var PopupBlockerObserver = {
let popupName = pageReport[i].popupWindowName; let popupName = pageReport[i].popupWindowName;
let parent = BrowserApp.selectedTab; let parent = BrowserApp.selectedTab;
let isPrivate = PrivateBrowsingUtils.isWindowPrivate(parent.browser.contentWindow); let isPrivate = PrivateBrowsingUtils.isBrowserPrivate(parent.browser);
BrowserApp.addTab(popupURIspec, { parentId: parent.id, isPrivate: isPrivate }); BrowserApp.addTab(popupURIspec, { parentId: parent.id, isPrivate: isPrivate });
} }
} }

View File

@ -930,7 +930,7 @@ SessionStore.prototype = {
throw (Components.returnCode = Cr.NS_ERROR_INVALID_ARG); throw (Components.returnCode = Cr.NS_ERROR_INVALID_ARG);
let closedTabs = this._windows[aWindow.__SSID].closedTabs; let closedTabs = this._windows[aWindow.__SSID].closedTabs;
let isPrivate = PrivateBrowsingUtils.isWindowPrivate(aWindow.BrowserApp.selectedBrowser.contentWindow); let isPrivate = PrivateBrowsingUtils.isBrowserPrivate(aWindow.BrowserApp.selectedBrowser);
let tabs = closedTabs let tabs = closedTabs
.filter(tab => tab.isPrivate == isPrivate) .filter(tab => tab.isPrivate == isPrivate)

View File

@ -318,8 +318,8 @@ TabTracker.prototype = {
onTab: function onTab(event) { onTab: function onTab(event) {
if (event.originalTarget.linkedBrowser) { if (event.originalTarget.linkedBrowser) {
let win = event.originalTarget.linkedBrowser.contentWindow; let browser = event.originalTarget.linkedBrowser;
if (PrivateBrowsingUtils.isWindowPrivate(win) && if (PrivateBrowsingUtils.isBrowserPrivate(browser) &&
!PrivateBrowsingUtils.permanentPrivateBrowsing) { !PrivateBrowsingUtils.permanentPrivateBrowsing) {
this._log.trace("Ignoring tab event from private browsing."); this._log.trace("Ignoring tab event from private browsing.");
return; return;

View File

@ -1803,8 +1803,8 @@ SpecialPowersAPI.prototype = {
return file.mozFullPath; return file.mozFullPath;
}, },
isWindowPrivate: function(win) { isContentWindowPrivate: function(win) {
return PrivateBrowsingUtils.isWindowPrivate(win); return PrivateBrowsingUtils.isContentWindowPrivate(win);
}, },
notifyObserversInParentProcess: function(subject, topic, data) { notifyObserversInParentProcess: function(subject, topic, data) {

View File

@ -248,7 +248,7 @@ var LoginManagerContent = {
loginsFound: function({ form, loginsFound }) { loginsFound: function({ form, loginsFound }) {
let doc = form.ownerDocument; let doc = form.ownerDocument;
let autofillForm = gAutofillForms && !PrivateBrowsingUtils.isWindowPrivate(doc.defaultView); let autofillForm = gAutofillForms && !PrivateBrowsingUtils.isContentWindowPrivate(doc.defaultView);
this._fillForm(form, autofillForm, false, false, false, loginsFound); this._fillForm(form, autofillForm, false, false, false, loginsFound);
}, },
@ -481,7 +481,7 @@ var LoginManagerContent = {
var doc = form.ownerDocument; var doc = form.ownerDocument;
var win = doc.defaultView; var win = doc.defaultView;
if (PrivateBrowsingUtils.isWindowPrivate(win)) { if (PrivateBrowsingUtils.isContentWindowPrivate(win)) {
// We won't do anything in private browsing mode anyway, // We won't do anything in private browsing mode anyway,
// so there's no need to perform further checks. // so there's no need to perform further checks.
log("(form submission ignored in private browsing mode)"); log("(form submission ignored in private browsing mode)");

View File

@ -253,7 +253,7 @@ LoginManagerPrompter.prototype = {
// Whether we are in private browsing mode // Whether we are in private browsing mode
get _inPrivateBrowsing() { get _inPrivateBrowsing() {
if (this._window) { if (this._window) {
return PrivateBrowsingUtils.isWindowPrivate(this._window); return PrivateBrowsingUtils.isContentWindowPrivate(this._window);
} else { } else {
// If we don't that we're in private browsing mode if the caller did // If we don't that we're in private browsing mode if the caller did
// not provide a window. The callers which really care about this // not provide a window. The callers which really care about this

View File

@ -104,7 +104,7 @@ var satchelFormListener = {
if (!this.enabled) if (!this.enabled)
return; return;
if (PrivateBrowsingUtils.isWindowPrivate(domWin)) if (PrivateBrowsingUtils.isContentWindowPrivate(domWin))
return; return;
this.log("Form submit observer notified."); this.log("Form submit observer notified.");

View File

@ -19,6 +19,17 @@ this.PrivateBrowsingUtils = {
// Rather than passing content windows to this function, please use // Rather than passing content windows to this function, please use
// isBrowserPrivate since it works with e10s. // isBrowserPrivate since it works with e10s.
isWindowPrivate: function pbu_isWindowPrivate(aWindow) { isWindowPrivate: function pbu_isWindowPrivate(aWindow) {
if (!(aWindow instanceof Components.interfaces.nsIDOMChromeWindow)) {
dump("WARNING: content window passed to PrivateBrowsingUtils.isWindowPrivate. " +
"Use isContentWindowPrivate instead (but only for frame scripts).\n"
+ new Error().stack);
}
return this.privacyContextFromWindow(aWindow).usePrivateBrowsing;
},
// This should be used only in frame scripts.
isContentWindowPrivate: function pbu_isWindowPrivate(aWindow) {
return this.privacyContextFromWindow(aWindow).usePrivateBrowsing; return this.privacyContextFromWindow(aWindow).usePrivateBrowsing;
}, },