Bug 826644 - Hide "Open in New Tab" context menu option in private tabs. r=mfinkle
authorBrian Nicholson <bnicholson@mozilla.com>
Fri, 18 Jan 2013 14:38:43 -0800
changeset 119308 86e23bc67300fd6d1b6114ca53e44c187ea6d470
parent 119307 f21022822e4962f7d173b9a9794b7da6fc2f914d
child 119309 bc71821fcb9fd85d2f9ef39ae9abdc27d3a36932
push id24195
push userMs2ger@gmail.com
push dateSat, 19 Jan 2013 16:10:11 +0000
treeherdermozilla-central@02e12a80aef9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs826644
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 826644 - Hide "Open in New Tab" context menu option in private tabs. r=mfinkle
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -321,17 +321,17 @@ var BrowserApp = {
       return savedmstone ? "upgrade" : "new";
     }
     return "";
   },
 
   initContextMenu: function ba_initContextMenu() {
     // TODO: These should eventually move into more appropriate classes
     NativeWindow.contextmenus.add(Strings.browser.GetStringFromName("contextmenu.openInNewTab"),
-      NativeWindow.contextmenus.linkOpenableContext,
+      NativeWindow.contextmenus.linkOpenableNonPrivateContext,
       function(aTarget) {
         let url = NativeWindow.contextmenus._getLinkURL(aTarget);
         BrowserApp.addTab(url, { selected: false, parentId: BrowserApp.selectedTab.id });
 
         let newtabStrings = Strings.browser.GetStringFromName("newtabpopup.opened");
         let label = PluralForm.get(1, newtabStrings).replace("#1", 1);
         NativeWindow.toast.show(label, "short");
       });
@@ -1424,16 +1424,27 @@ var NativeWindow = {
         matches: function(aElt) {
           if (aElt.mozMatchesSelector)
             return aElt.mozMatchesSelector(aSelector);
           return false;
         }
       }
     },
 
+    linkOpenableNonPrivateContext: {
+      matches: function linkOpenableNonPrivateContextMatches(aElement) {
+        let doc = aElement.ownerDocument;
+        if (!doc || PrivateBrowsingUtils.isWindowPrivate(doc.defaultView)) {
+          return false;
+        }
+
+        return NativeWindow.contextmenus.linkOpenableContext.matches(aElement);
+      }
+    },
+
     linkOpenableContext: {
       matches: function linkOpenableContextMatches(aElement) {
         let uri = NativeWindow.contextmenus._getLink(aElement);
         if (uri) {
           let scheme = uri.scheme;
           let dontOpen = /^(javascript|mailto|news|snews|tel)$/;
           return (scheme && !dontOpen.test(scheme));
         }