Bug 1158960 - Reader view is broken in e10s mode. r=Gijs a=dolske
authorJared Wein <jwein@mozilla.com>
Mon, 27 Apr 2015 18:29:18 -0400
changeset 260434 92c7576dce37
parent 260433 20872d739a18
child 260435 8c8f410e61e8
push id782
push userjdolske@mozilla.com
push date2015-05-09 00:18 +0000
treeherdermozilla-release@067c9c7a5e75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, dolske
bugs1158960
milestone38.0
Bug 1158960 - Reader view is broken in e10s mode. r=Gijs a=dolske
browser/modules/ReaderParent.jsm
toolkit/components/reader/AboutReader.jsm
--- a/browser/modules/ReaderParent.jsm
+++ b/browser/modules/ReaderParent.jsm
@@ -24,16 +24,17 @@ let ReaderParent = {
   _readerModeInfoPanelOpen: false,
 
   MESSAGES: [
     "Reader:AddToList",
     "Reader:AddToPocket",
     "Reader:ArticleGet",
     "Reader:FaviconRequest",
     "Reader:ListStatusRequest",
+    "Reader:PocketEnabledGet",
     "Reader:RemoveFromList",
     "Reader:Share",
     "Reader:SystemUIVisibility",
     "Reader:UpdateReaderButton",
     "Reader:SetIntPref",
     "Reader:SetCharPref",
   ],
 
@@ -85,16 +86,23 @@ let ReaderParent = {
         this._getArticle(message.data.url, message.target).then((article) => {
           // Make sure the target browser is still alive before trying to send data back.
           if (message.target.messageManager) {
             message.target.messageManager.sendAsyncMessage("Reader:ArticleData", { article: article });
           }
         });
         break;
 
+      case "Reader:PocketEnabledGet": {
+        let pocketPlacement = CustomizableUI.getPlacementOfWidget("pocket-button");
+        let isPocketEnabled = pocketPlacement && pocketPlacement.area;
+        message.target.messageManager.sendAsyncMessage("Reader:PocketEnabledData", { enabled: !!isPocketEnabled});
+        break;
+      }
+
       case "Reader:FaviconRequest": {
         if (message.target.messageManager) {
           let faviconUrl = PlacesUtils.promiseFaviconLinkUrl(message.data.url);
           faviconUrl.then(function onResolution(favicon) {
             message.target.messageManager.sendAsyncMessage("Reader:FaviconReturn", {
               url: message.data.url,
               faviconUrl: favicon.path.replace(/^favicon:/, "")
             })
--- a/toolkit/components/reader/AboutReader.jsm
+++ b/toolkit/components/reader/AboutReader.jsm
@@ -7,20 +7,16 @@
 let Ci = Components.interfaces, Cc = Components.classes, Cu = Components.utils;
 
 this.EXPORTED_SYMBOLS = [ "AboutReader" ];
 
 Cu.import("resource://gre/modules/ReaderMode.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
-const gIsFirefoxDesktop = Services.appinfo.ID == "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
-if (gIsFirefoxDesktop) {
-  XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI", "resource:///modules/CustomizableUI.jsm");
-}
 XPCOMUtils.defineLazyModuleGetter(this, "Rect", "resource://gre/modules/Geometry.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Task", "resource://gre/modules/Task.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "UITelemetry", "resource://gre/modules/UITelemetry.jsm");
 
 const READINGLIST_COMMAND_ID = "readingListSidebar";
 
 let gStrings = Services.strings.createBundle("chrome://global/locale/aboutReader.properties");
 
@@ -82,23 +78,19 @@ let AboutReader = function(mm, win, arti
       this._setupButton("remove-button", this._onReaderToggle.bind(this, "footer"),
         "aboutReader.footer.deleteThisArticle", "aboutReader.footer.deleteThisArticle");
       this._doc.getElementById("reader-footer").setAttribute('readinglist-enabled', "true");
     }
   } catch (e) {
     // Pref doesn't exist.
   }
 
+  const gIsFirefoxDesktop = Services.appinfo.ID == "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
   if (gIsFirefoxDesktop) {
-    let pocketPlacement = CustomizableUI.getPlacementOfWidget("pocket-button");
-    if (pocketPlacement && pocketPlacement.area) {
-      this._setupButton("pocket-button", this._onPocketToggle.bind(this, "button"));
-    } else {
-      this._doc.getElementById("pocket-button").hidden = true;
-    }
+    this._setupPocketButton();
   } else {
     this._doc.getElementById("pocket-button").hidden = true;
   }
 
   let colorSchemeValues = JSON.parse(Services.prefs.getCharPref("reader.color_scheme.values"));
   let colorSchemeOptions = colorSchemeValues.map((value) => {
     return { name: gStrings.GetStringFromName("aboutReader.colorScheme." + value),
              value: value,
@@ -616,16 +608,34 @@ AboutReader.prototype = {
   _toggleToolbarVisibility: function Reader_toggleToolbarVisibility() {
     this._setToolbarVisibility(!this._getToolbarVisibility());
   },
 
   _setSystemUIVisibility: function Reader_setSystemUIVisibility(visible) {
     this._mm.sendAsyncMessage("Reader:SystemUIVisibility", { visible: visible });
   },
 
+  _setupPocketButton: Task.async(function* () {
+    let pocketEnabledPromise = new Promise((resolve, reject) => {
+      let listener = (message) => {
+        this._mm.removeMessageListener("Reader:PocketEnabledData", listener);
+        resolve(message.data.enabled);
+      };
+      this._mm.addMessageListener("Reader:PocketEnabledData", listener);
+      this._mm.sendAsyncMessage("Reader:PocketEnabledGet");
+    });
+
+    let isPocketEnabled = yield pocketEnabledPromise;
+    if (isPocketEnabled) {
+      this._setupButton("pocket-button", this._onPocketToggle.bind(this, "button"));
+    } else {
+      this._doc.getElementById("pocket-button").hidden = true;
+    }
+  }),
+
   _loadArticle: Task.async(function* () {
     let url = this._getOriginalUrl();
     this._showProgressDelayed();
 
     let article;
     if (this._articlePromise) {
       article = yield this._articlePromise;
     } else {