mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 962212 (part 2) - Basic private browsing in Metro, preffed off [r=ally]
This commit is contained in:
parent
36bb6d6b94
commit
9acefe9f31
@ -123,6 +123,9 @@ var Appbar = {
|
||||
onMenuButton: function(aEvent) {
|
||||
let typesArray = [];
|
||||
|
||||
if (BrowserUI.isPrivateBrowsingEnabled) {
|
||||
typesArray.push("private-browsing");
|
||||
}
|
||||
if (!BrowserUI.isStartTabVisible) {
|
||||
typesArray.push("find-in-page");
|
||||
if (ContextCommands.getPageSource())
|
||||
|
@ -86,6 +86,8 @@ var BrowserUI = {
|
||||
Services.prefs.addObserver(debugServerStateChanged, this, false);
|
||||
Services.prefs.addObserver(debugServerPortChanged, this, false);
|
||||
Services.prefs.addObserver("app.crashreporter.autosubmit", this, false);
|
||||
Services.prefs.addObserver("metro.private_browsing.enabled", this, false);
|
||||
this.updatePrivateBrowsingUI();
|
||||
|
||||
Services.obs.addObserver(this, "handle-xul-text-link", false);
|
||||
|
||||
@ -192,6 +194,7 @@ var BrowserUI = {
|
||||
Services.prefs.removeObserver(debugServerStateChanged, this);
|
||||
Services.prefs.removeObserver(debugServerPortChanged, this);
|
||||
Services.prefs.removeObserver("app.crashreporter.autosubmit", this);
|
||||
Services.prefs.removeObserver("metro.private_browsing.enabled", this);
|
||||
|
||||
Services.obs.removeObserver(this, "handle-xul-text-link");
|
||||
|
||||
@ -416,9 +419,26 @@ var BrowserUI = {
|
||||
* Open a new tab in the foreground in response to a user action.
|
||||
* See Browser.addTab for more documentation.
|
||||
*/
|
||||
addAndShowTab: function (aURI, aOwner) {
|
||||
addAndShowTab: function (aURI, aOwner, aParams) {
|
||||
ContextUI.peekTabs(kForegroundTabAnimationDelay);
|
||||
return Browser.addTab(aURI || kStartURI, true, aOwner);
|
||||
return Browser.addTab(aURI || kStartURI, true, aOwner, aParams);
|
||||
},
|
||||
|
||||
addAndShowPrivateTab: function (aURI, aOwner) {
|
||||
return this.addAndShowTab(aURI, aOwner, { private: true });
|
||||
},
|
||||
|
||||
get isPrivateBrowsingEnabled() {
|
||||
return Services.prefs.getBoolPref("metro.private_browsing.enabled");
|
||||
},
|
||||
|
||||
updatePrivateBrowsingUI: function () {
|
||||
let command = document.getElementById("cmd_newPrivateTab");
|
||||
if (this.isPrivateBrowsingEnabled) {
|
||||
command.removeAttribute("disabled");
|
||||
} else {
|
||||
command.setAttribute("disabled", "true");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -614,8 +634,9 @@ var BrowserUI = {
|
||||
BrowserUI.submitLastCrashReportOrShowPrompt;
|
||||
#endif
|
||||
break;
|
||||
|
||||
|
||||
case "metro.private_browsing.enabled":
|
||||
this.updatePrivateBrowsingUI();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -853,29 +874,33 @@ var BrowserUI = {
|
||||
referrerURI = Services.io.newURI(json.referrer, null, null);
|
||||
this.goToURI(json.uri);
|
||||
break;
|
||||
case "Content:StateChange":
|
||||
let currBrowser = Browser.selectedBrowser;
|
||||
if (this.shouldCaptureThumbnails(currBrowser)) {
|
||||
PageThumbs.captureAndStore(currBrowser);
|
||||
let currPage = currBrowser.currentURI.spec;
|
||||
case "Content:StateChange": {
|
||||
let tab = Browser.selectedTab;
|
||||
if (this.shouldCaptureThumbnails(tab)) {
|
||||
PageThumbs.captureAndStore(tab.browser);
|
||||
let currPage = tab.browser.currentURI.spec;
|
||||
Services.obs.notifyObservers(null, "Metro:RefreshTopsiteThumbnail", currPage);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
},
|
||||
|
||||
// Private Browsing is not supported on metro at this time, when it is added
|
||||
// this function must be updated to skip capturing those pages
|
||||
shouldCaptureThumbnails: function shouldCaptureThumbnails(aBrowser) {
|
||||
shouldCaptureThumbnails: function shouldCaptureThumbnails(aTab) {
|
||||
// Capture only if it's the currently selected tab.
|
||||
if (aBrowser != Browser.selectedBrowser) {
|
||||
if (aTab != Browser.selectedTab) {
|
||||
return false;
|
||||
}
|
||||
// Skip private tabs
|
||||
if (aTab.isPrivate) {
|
||||
return false;
|
||||
}
|
||||
// FIXME Bug 720575 - Don't capture thumbnails for SVG or XML documents as
|
||||
// that currently regresses Talos SVG tests.
|
||||
let doc = aBrowser.contentDocument;
|
||||
let browser = aTab.browser;
|
||||
let doc = browser.contentDocument;
|
||||
if (doc instanceof SVGDocument || doc instanceof XMLDocument) {
|
||||
return false;
|
||||
}
|
||||
@ -888,17 +913,17 @@ var BrowserUI = {
|
||||
return false;
|
||||
}
|
||||
// There's no point in taking screenshot of loading pages.
|
||||
if (aBrowser.docShell.busyFlags != Ci.nsIDocShell.BUSY_FLAGS_NONE) {
|
||||
if (browser.docShell.busyFlags != Ci.nsIDocShell.BUSY_FLAGS_NONE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't take screenshots of about: pages.
|
||||
if (aBrowser.currentURI.schemeIs("about")) {
|
||||
if (browser.currentURI.schemeIs("about")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// No valid document channel. We shouldn't take a screenshot.
|
||||
let channel = aBrowser.docShell.currentDocumentChannel;
|
||||
let channel = browser.docShell.currentDocumentChannel;
|
||||
if (!channel) {
|
||||
return false;
|
||||
}
|
||||
|
@ -476,6 +476,7 @@ var Browser = {
|
||||
* is closed, we will return to a parent or "sibling" tab if possible.
|
||||
* @param aParams Object (optional) with optional properties:
|
||||
* index: Number specifying where in the tab list to insert the new tab.
|
||||
* private: If true, the new tab should be have Private Browsing active.
|
||||
* flags, postData, charset, referrerURI: See loadURIWithFlags.
|
||||
*/
|
||||
addTab: function browser_addTab(aURI, aBringFront, aOwner, aParams) {
|
||||
@ -1255,6 +1256,13 @@ function Tab(aURI, aParams, aOwner) {
|
||||
this._eventDeferred = null;
|
||||
this._updateThumbnailTimeout = null;
|
||||
|
||||
this._private = false;
|
||||
if ("private" in aParams) {
|
||||
this._private = aParams.private;
|
||||
} else if (aOwner) {
|
||||
this._private = aOwner.private;
|
||||
}
|
||||
|
||||
this.owner = aOwner || null;
|
||||
|
||||
// Set to 0 since new tabs that have not been viewed yet are good tabs to
|
||||
@ -1282,6 +1290,10 @@ Tab.prototype = {
|
||||
return this._chromeTab;
|
||||
},
|
||||
|
||||
get isPrivate() {
|
||||
return this._private;
|
||||
},
|
||||
|
||||
get pageShowPromise() {
|
||||
return this._eventDeferred ? this._eventDeferred.promise : null;
|
||||
},
|
||||
@ -1307,6 +1319,10 @@ Tab.prototype = {
|
||||
this._eventDeferred = Promise.defer();
|
||||
|
||||
this._chromeTab = Elements.tabList.addTab(aParams.index);
|
||||
if (this.isPrivate) {
|
||||
this._chromeTab.setAttribute("private", "true");
|
||||
}
|
||||
|
||||
this._id = Browser.createTabId();
|
||||
let browser = this._createBrowser(aURI, null);
|
||||
|
||||
@ -1461,6 +1477,11 @@ Tab.prototype = {
|
||||
// let the content area manager know about this browser.
|
||||
ContentAreaObserver.onBrowserCreated(browser);
|
||||
|
||||
if (this.isPrivate) {
|
||||
let ctx = browser.docShell.QueryInterface(Ci.nsILoadContext);
|
||||
ctx.usePrivateBrowsing = true;
|
||||
}
|
||||
|
||||
// stop about:blank from loading
|
||||
browser.stop();
|
||||
|
||||
@ -1485,7 +1506,9 @@ Tab.prototype = {
|
||||
},
|
||||
|
||||
updateThumbnail: function updateThumbnail() {
|
||||
PageThumbs.captureToCanvas(this.browser.contentWindow, this._chromeTab.thumbnailCanvas);
|
||||
if (!this.isPrivate) {
|
||||
PageThumbs.captureToCanvas(this.browser.contentWindow, this._chromeTab.thumbnailCanvas);
|
||||
}
|
||||
},
|
||||
|
||||
updateFavicon: function updateFavicon() {
|
||||
|
@ -85,6 +85,7 @@
|
||||
#ifdef MOZ_SERVICES_SYNC
|
||||
<command id="cmd_remoteTabs" oncommand="CommandUpdater.doCommand(this.id);"/>
|
||||
#endif
|
||||
<command id="cmd_newPrivateTab" oncommand="BrowserUI.addAndShowPrivateTab();"/>
|
||||
|
||||
<!-- misc -->
|
||||
<command id="cmd_close" oncommand="CommandUpdater.doCommand(this.id);"/>
|
||||
@ -162,6 +163,7 @@ Desktop browser's sync prefs.
|
||||
<key id="key_closeTab" key="&closeTab.key;" modifiers="accel" command="cmd_closeTab"/>
|
||||
<key id="key_closeTab2" keycode="VK_F4" modifiers="accel" command="cmd_closeTab"/>
|
||||
<key id="key_undoCloseTab" key="&newTab.key;" modifiers="accel,shift" command="cmd_undoCloseTab"/>
|
||||
<key id="key_newPrivateTab" key="&newPrivateTab.key;" modifiers="accel,shift" command="cmd_newPrivateTab"/>
|
||||
|
||||
<!-- tab selection -->
|
||||
<key id="key_nextTab" oncommand="BrowserUI.selectNextTab();" keycode="VK_TAB" modifiers="accel"/>
|
||||
@ -813,6 +815,9 @@ Desktop browser's sync prefs.
|
||||
</richlistitem>
|
||||
|
||||
<!-- standard buttons -->
|
||||
<richlistitem id="context-newprivatetab" type="private-browsing" onclick="BrowserUI.addAndShowPrivateTab()">
|
||||
<label value="&newPrivateTab.label;"/>
|
||||
</richlistitem>
|
||||
<richlistitem id="context-findinpage" type="find-in-page" onclick="ContextCommands.findInPage();">
|
||||
<label value="&appbarFindInPage2.label;"/>
|
||||
</richlistitem>
|
||||
|
@ -0,0 +1,27 @@
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
function test() {
|
||||
runTests();
|
||||
}
|
||||
|
||||
gTests.push({
|
||||
desc: "Private tab sanity check",
|
||||
run: function() {
|
||||
let tab = Browser.addTab("about:mozilla");
|
||||
is(tab.isPrivate, false, "Tabs are not private by default");
|
||||
is(tab.chromeTab.hasAttribute("private"), false,
|
||||
"non-private tab has no private attribute");
|
||||
Browser.closeTab(tab, { forceClose: true });
|
||||
|
||||
tab = Browser.addTab("about:mozilla", false, null, { private: true });
|
||||
is(tab.isPrivate, true, "Create a private tab");
|
||||
is(tab.chromeTab.getAttribute("private"), "true",
|
||||
"private tab has private attribute");
|
||||
Browser.closeTab(tab, { forceClose: true });
|
||||
}
|
||||
});
|
@ -53,6 +53,7 @@ support-files =
|
||||
[browser_mouse_events.js]
|
||||
[browser_onscreen_keyboard.js]
|
||||
[browser_prefs_ui.js]
|
||||
[browser_private_browsing.js]
|
||||
[browser_prompt.js]
|
||||
[browser_remotetabs.js]
|
||||
[browser_snappedState.js]
|
||||
|
@ -553,15 +553,17 @@ SessionStore.prototype = {
|
||||
},
|
||||
|
||||
_getTabData: function(aWindow) {
|
||||
return aWindow.Browser.tabs.map(tab => {
|
||||
let browser = tab.browser;
|
||||
if (browser.__SS_data) {
|
||||
let tabData = browser.__SS_data;
|
||||
if (browser.__SS_extdata)
|
||||
tabData.extData = browser.__SS_extdata;
|
||||
return tabData;
|
||||
}
|
||||
});
|
||||
return aWindow.Browser.tabs
|
||||
.filter(tab => !tab.isPrivate)
|
||||
.map(tab => {
|
||||
let browser = tab.browser;
|
||||
if (browser.__SS_data) {
|
||||
let tabData = browser.__SS_data;
|
||||
if (browser.__SS_extdata)
|
||||
tabData.extData = browser.__SS_extdata;
|
||||
return tabData;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_collectWindowData: function ss__collectWindowData(aWindow) {
|
||||
|
@ -9,6 +9,7 @@
|
||||
<!ENTITY back.label "Back">
|
||||
<!ENTITY forward.label "Forward">
|
||||
<!ENTITY newtab.label "New Tab">
|
||||
<!ENTITY newPrivateTab.label "New Private Tab">
|
||||
<!ENTITY closetab.label "Close Tab">
|
||||
|
||||
<!ENTITY autocompleteResultsHeader.label "Your Results">
|
||||
@ -103,6 +104,8 @@
|
||||
<!ENTITY newTab.key "t">
|
||||
<!ENTITY newTab2.key "n">
|
||||
<!ENTITY closeTab.key "w">
|
||||
<!-- Private browsing (control+shift+key) -->
|
||||
<!ENTITY newPrivateTab.key "p">
|
||||
|
||||
<!-- DEVELOPER SHORTCUTS (control+shift+key) -->
|
||||
<!ENTITY jsConsole.key "j">
|
||||
|
@ -33,10 +33,12 @@ pref("metro.debug.selection.displayRanges", false);
|
||||
pref("metro.debug.selection.dumpRanges", false);
|
||||
pref("metro.debug.selection.dumpEvents", false);
|
||||
|
||||
// Private browsing is disabled by default until implementation and testing are complete
|
||||
pref("metro.private_browsing.enabled", false);
|
||||
|
||||
// Enable tab-modal prompts
|
||||
pref("prompts.tab_modal.enabled", true);
|
||||
|
||||
|
||||
// Enable off main thread compositing
|
||||
pref("layers.offmainthreadcomposition.enabled", true);
|
||||
pref("layers.async-pan-zoom.enabled", true);
|
||||
|
@ -163,6 +163,12 @@ documenttab[closing] > .documenttab-container {
|
||||
background-image: none!important;
|
||||
}
|
||||
|
||||
/* TODO: Decide how and where to display private tabs.
|
||||
* For now, display them in the main tab strip but hide the thumbnail. */
|
||||
documenttab[private] .documenttab-thumbnail {
|
||||
background-color: purple;
|
||||
}
|
||||
|
||||
.documenttab-title {
|
||||
margin: @metro_spacing_normal@ @metro_spacing_snormal@;
|
||||
margin-top: 0;
|
||||
|
Loading…
Reference in New Issue
Block a user