Backed out changeset 12357ab6e997 (bug 1164942) for b2g build orange
authorWes Kocher <wkocher@mozilla.com>
Fri, 15 May 2015 15:15:06 -0700
changeset 244169 d41f771a3927444b1c32ce2a6ec9cf8f4aaf021e
parent 244168 12357ab6e99738b6e16009df50d703a8ac332c95
child 244170 06ced37f6c2bea0bcd359a534291a75f8e1d4947
push id28768
push userphilringnalda@gmail.com
push dateSat, 16 May 2015 16:40:26 +0000
treeherdermozilla-central@2f6ea66057fe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1164942
milestone41.0a1
backs out12357ab6e99738b6e16009df50d703a8ac332c95
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
Backed out changeset 12357ab6e997 (bug 1164942) for b2g build orange
browser/base/content/browser.js
browser/base/content/browser.xul
browser/components/customizableui/CustomizableWidgets.jsm
browser/components/customizableui/content/panelUI.js
browser/components/pocket/Pocket.jsm
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -50,39 +50,16 @@ XPCOMUtils.defineLazyServiceGetter(this,
 XPCOMUtils.defineLazyServiceGetter(this, "gDNSService",
                                    "@mozilla.org/network/dns-service;1",
                                    "nsIDNSService");
 XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager",
                                   "resource://gre/modules/LightweightThemeManager.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Pocket",
                                   "resource:///modules/Pocket.jsm");
 
-// Can't use XPCOMUtils for these because the scripts try to define the variables
-// on window, and so the defineProperty inside defineLazyGetter fails.
-Object.defineProperty(window, "pktApi", {
-  get: function() {
-    // Avoid this getter running again:
-    delete window.pktApi;
-    Services.scriptloader.loadSubScript("chrome://browser/content/pocket/pktApi.js", window);
-    return window.pktApi;
-  },
-  configurable: true,
-  enumerable: true
-});
-Object.defineProperty(window, "pktUI", {
-  get: function() {
-    // Avoid this getter running again:
-    delete window.pktUI;
-    Services.scriptloader.loadSubScript("chrome://browser/content/pocket/main.js", window);
-    return window.pktUI;
-  },
-  configurable: true,
-  enumerable: true
-});
-
 const nsIWebNavigation = Ci.nsIWebNavigation;
 
 var gLastBrowserCharset = null;
 var gProxyFavIcon = null;
 var gLastValidURLStr = "";
 var gInPrintPreviewMode = false;
 var gContextMenu = null; // nsContextMenu instance
 var gMultiProcessBrowser =
@@ -4189,16 +4166,17 @@ var XULBrowserWindow = {
       }
 
       if (gURLBar) {
         URLBarSetURI(aLocationURI);
 
         BookmarkingUI.onLocationChange();
         SocialUI.updateState(location);
         UITour.onLocationChange(location);
+        Pocket.onLocationChange(browser, aLocationURI);
       }
 
       // Utility functions for disabling find
       var shouldDisableFind = function shouldDisableFind(aDocument) {
         let docElt = aDocument.documentElement;
         return docElt && docElt.getAttribute("disablefastfind") == "true";
       }
 
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -1302,9 +1302,12 @@
   </svg:svg>
 
 </vbox>
 # <iframe id="tab-view"> is dynamically appended as the 2nd child of #tab-view-deck.
 #     Introducing the iframe dynamically, as needed, was found to be better than
 #     starting with an empty iframe here in browser.xul from a Ts standpoint.
 </deck>
 
+<script type="application/javascript" src="chrome://browser/content/pocket/pktApi.js"/>
+<script type="application/javascript" src="chrome://browser/content/pocket/main.js"/>
+
 </window>
--- a/browser/components/customizableui/CustomizableWidgets.jsm
+++ b/browser/components/customizableui/CustomizableWidgets.jsm
@@ -1101,23 +1101,18 @@ if (Services.prefs.getBoolPref("browser.
     let pocketButton = {
       id: "pocket-button",
       defaultArea: CustomizableUI.AREA_NAVBAR,
       introducedInVersion: "pref",
       type: "view",
       viewId: "PanelUI-pocketView",
       label: label,
       tooltiptext: tooltiptext,
-      // Use forwarding functions here to avoid loading Pocket.jsm on startup:
-      onViewShowing: function() {
-        return Pocket.onPanelViewShowing.apply(this, arguments);
-      },
-      onViewHiding: function() {
-        return Pocket.onPanelViewHiding.apply(this, arguments);
-      },
+      onViewShowing: Pocket.onPanelViewShowing,
+      onViewHiding: Pocket.onPanelViewHiding,
 
       // If the user has the "classic" Pocket add-on installed, use that instead
       // and destroy the widget.
       conditionalDestroyPromise: new Promise(resolve => {
         AddonManager.getAddonByID("isreaditlater@ideashower.com", addon => {
           resolve(addon && addon.isActive);
         });
       }),
--- a/browser/components/customizableui/content/panelUI.js
+++ b/browser/components/customizableui/content/panelUI.js
@@ -1,16 +1,18 @@
 /* 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/. */
 
 XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
                                   "resource:///modules/CustomizableUI.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "ScrollbarSampler",
                                   "resource:///modules/ScrollbarSampler.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "Pocket",
+                                  "resource:///modules/Pocket.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Promise",
                                   "resource://gre/modules/Promise.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "ShortcutUtils",
                                   "resource://gre/modules/ShortcutUtils.jsm");
 
 /**
  * Maintains the state and dispatches events for the main menu panel.
  */
--- a/browser/components/pocket/Pocket.jsm
+++ b/browser/components/pocket/Pocket.jsm
@@ -61,16 +61,40 @@ let Pocket = {
     window.pktUI.pocketPanelDidShow();
   },
 
   onPanelViewHiding(event) {
     let window = event.target.ownerDocument.defaultView;
     window.pktUI.pocketPanelDidHide(event);
   },
 
+  // Called on tab/urlbar/location changes and after customization. Update
+  // anything that is tab specific.
+  onLocationChange(browser, locationURI) {
+    if (!locationURI) {
+      return;
+    }
+    let widget = CustomizableUI.getWidget("pocket-button");
+    for (let instance of widget.instances) {
+      let node = instance.node;
+      if (!node ||
+          node.ownerDocument != browser.ownerDocument) {
+        continue;
+      }
+      if (node) {
+        let win = browser.ownerDocument.defaultView;
+        node.disabled = win.pktApi.isUserLoggedIn() &&
+                        !locationURI.schemeIs("http") &&
+                        !locationURI.schemeIs("https") &&
+                        !(locationURI.schemeIs("about") &&
+                          locationURI.spec.toLowerCase().startsWith("about:reader?url="));
+      }
+    }
+  },
+
   _urlToSave: null,
   _titleToSave: null,
   savePage(browser, url, title) {
     let document = browser.ownerDocument;
     let pocketWidget = document.getElementById("pocket-button");
     let placement = CustomizableUI.getPlacementOfWidget("pocket-button");
     if (!placement)
       return;