Bug 1167756 - Switch to openUILink for the Pocket menubar item to avoid using and leaking AppConstants. r=jaws, a=sledru
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Fri, 22 May 2015 14:07:00 -0700
changeset 274763 b500a8efdc29243aff69335aca91bc3724108210
parent 274762 b08fab71b4f2412baae78228b51a16e37fd1529c
child 274764 26f06cf226703ffce12890f83210d60df80ca821
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws, sledru
bugs1167756
milestone40.0a2
Bug 1167756 - Switch to openUILink for the Pocket menubar item to avoid using and leaking AppConstants. r=jaws, a=sledru
browser/base/content/browser-menubar.inc
browser/components/pocket/main.js
--- a/browser/base/content/browser-menubar.inc
+++ b/browser/base/content/browser-menubar.inc
@@ -395,17 +395,17 @@
                 label="&showAllBookmarks2.label;"
                 command="Browser:ShowAllBookmarks"
                 key="manBookmarkKb"/>
       <menuseparator id="organizeBookmarksSeparator"/>
       <menuitem id="menu_pocket" label="&pocketMenuitem.label;"
 #ifndef XP_MACOSX
                 class="menuitem-iconic"
 #endif
-                oncommand="window.pktUI.openTabWithUrl(Pocket.listURL);"/>
+                oncommand="openUILink(Pocket.listURL, event);"/>
       <menuseparator id="menu_pocketSeparator"/>
       <menuitem id="menu_bookmarkThisPage"
                 command="Browser:AddBookmarkAs"
                 observes="bookmarkThisPageBroadcaster"
                 key="addBookmarkAsKb"/>
       <menuitem id="subscribeToPageMenuitem"
 #ifndef XP_MACOSX
                 class="menuitem-iconic"
--- a/browser/components/pocket/main.js
+++ b/browser/components/pocket/main.js
@@ -37,18 +37,16 @@
 
 // TODO : Get the toolbar icons from Firefox's build (Nikki needs to give us a red saved icon)
 // TODO : [needs clarificaiton from Fx] Firefox's plan was to hide Pocket from context menus until the user logs in. Now that it's an extension I'm wondering if we still need to do this.
 // TODO : [needs clarificaiton from Fx] Reader mode (might be a something they need to do since it's in html, need to investigate their code)
 // TODO : [needs clarificaiton from Fx] Move prefs within pktApi.s to sqlite or a local file so it's not editable (and is safer)
 // 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, "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() {
 
 	// -- Initialization (on startup and new windows) -- //
@@ -619,22 +617,17 @@ var pktUI = (function() {
 
 	/**
      * Open a new tab with a given url and notify the iframe panel that it was opened
      */
 
 	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);
-          }
+          Cu.reportError("Pocket: No open browser windows to openTabWithUrl");
           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) {