mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1160407 - Redirect links within the Pocket panel to open in non-private windows when temporary Private Browsing is used. r=dolske
This commit is contained in:
parent
dfdef1a51f
commit
237251067d
@ -400,7 +400,7 @@
|
||||
#ifndef XP_MACOSX
|
||||
class="menuitem-iconic"
|
||||
#endif
|
||||
oncommand="openUILink(Pocket.listURL, event);"/>
|
||||
oncommand="window.pktUI.openTabWithUrl(Pocket.listURL);"/>
|
||||
<menuseparator id="menu_pocketSeparator"/>
|
||||
<menuitem id="menu_bookmarkThisPage"
|
||||
command="Browser:AddBookmarkAs"
|
||||
|
@ -3,7 +3,7 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
browser.jar:
|
||||
content/browser/pocket/main.js (main.js)
|
||||
* content/browser/pocket/main.js (main.js)
|
||||
content/browser/pocket/pktApi.js (pktApi.js)
|
||||
content/browser/pocket/panels/saved.html (panels/saved.html)
|
||||
content/browser/pocket/panels/signup.html (panels/signup.html)
|
||||
|
@ -42,7 +42,12 @@
|
||||
// TODO : [nice to have] - Immediately save, buffer the actions in a local queue and send (so it works offline, works like our native extensions)
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ReaderMode", "resource://gre/modules/ReaderMode.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
|
||||
"resource://gre/modules/AppConstants.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
|
||||
"resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ReaderMode",
|
||||
"resource://gre/modules/ReaderMode.jsm");
|
||||
|
||||
var pktUI = (function() {
|
||||
|
||||
@ -616,11 +621,38 @@ var pktUI = (function() {
|
||||
* Open a new tab with a given url and notify the iframe panel that it was opened
|
||||
*/
|
||||
|
||||
function openTabWithUrl(url, activate) {
|
||||
var tab = gBrowser.addTab(url);
|
||||
if (activate) {
|
||||
gBrowser.selectedTab = tab;
|
||||
function openTabWithUrl(url) {
|
||||
let recentWindow = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
if (!recentWindow) {
|
||||
if (this.AppConstants.platform == "macosx") {
|
||||
let hiddenWindow = Services.appShell.hiddenDOMWindow;
|
||||
// If there are no open browser windows, open a new one.
|
||||
hiddenWindow.openDialog("chrome://browser/content/", "_blank",
|
||||
"chrome,all,dialog=no", url);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// If the user is in permanent private browsing than this is not an issue,
|
||||
// since the current window will always share the same cookie jar as the other
|
||||
// windows.
|
||||
if (!PrivateBrowsingUtils.isWindowPrivate(recentWindow) ||
|
||||
PrivateBrowsingUtils.permanentPrivateBrowsing) {
|
||||
recentWindow.openUILinkIn(url, "tab");
|
||||
return;
|
||||
}
|
||||
|
||||
let windows = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windows.hasMoreElements()) {
|
||||
let win = windows.getNext();
|
||||
if (!PrivateBrowsingUtils.isWindowPrivate(win)) {
|
||||
win.openUILinkIn(url, "tab");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If there were no non-private windows opened already.
|
||||
recentWindow.openUILinkIn(url, "window");
|
||||
}
|
||||
|
||||
|
||||
@ -789,6 +821,8 @@ var pktUI = (function() {
|
||||
onLoad: onLoad,
|
||||
getPanelFrame: getPanelFrame,
|
||||
|
||||
openTabWithUrl: openTabWithUrl,
|
||||
|
||||
pocketButtonOnCommand: pocketButtonOnCommand,
|
||||
pocketPanelDidShow: pocketPanelDidShow,
|
||||
pocketPanelDidHide: pocketPanelDidHide,
|
||||
|
Loading…
Reference in New Issue
Block a user