Bug 1536895 - Disable send tab on Fxa avatar menu for unsupported pages, r=gijs, a=pascalc
authorVijay Budhram <vbudhram@mozilla.com>
Thu, 21 Mar 2019 21:14:34 +0000
changeset 525847 0b05c9bed71b2c90b490dca27c38623236e90691
parent 525846 cfb2d7610755e1d487cea0e0fec537c8e36e639a
child 525848 f83ea1d76d6e4a785c84bad975659e24c40f5c85
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgijs, pascalc
bugs1536895
milestone67.0
Bug 1536895 - Disable send tab on Fxa avatar menu for unsupported pages, r=gijs, a=pascalc Differential Revision: https://phabricator.services.mozilla.com//D24430
browser/base/content/browser-sync.js
--- a/browser/base/content/browser-sync.js
+++ b/browser/base/content/browser-sync.js
@@ -285,16 +285,18 @@ var gSync = {
       return;
     }
 
     if (!gFxaToolbarAccessed) {
       Services.prefs.setBoolPref("identity.fxaccounts.toolbar.accessed", true);
       document.documentElement.removeAttribute("fxa_avatar_badged");
     }
 
+    this.enableSendTabIfValidTab();
+
     const anchor = document.getElementById("fxa-toolbar-menu-button");
     if (anchor.getAttribute("open") == "true") {
       PanelUI.hide();
     } else {
       PanelUI.showSubView(viewId, anchor, aEvent);
     }
   },
 
@@ -340,16 +342,28 @@ var gSync = {
       document.getElementById("fxa-menu-email").value = state.email;
 
       let defaultPanelTitle = this.fxaStrings.GetStringFromName("account.title");
       document.getElementById("PanelUI-fxa").setAttribute("title", state.displayName ? state.displayName : defaultPanelTitle);
     }
     mainWindowEl.setAttribute("fxastatus", stateValue);
   },
 
+  enableSendTabIfValidTab() {
+    // All tabs selected must be sendable for the Send Tab button to be enabled
+    // on the FxA menu.
+    let canSendAllURIs = gBrowser.selectedTabs.every(t => this.isSendableURI(t.linkedBrowser.currentURI.spec));
+
+    if (canSendAllURIs) {
+      document.getElementById("PanelUI-fxa-menu-sendtab-button").removeAttribute("disabled");
+    } else {
+      document.getElementById("PanelUI-fxa-menu-sendtab-button").setAttribute("disabled", true);
+    }
+  },
+
   updatePanelPopup(state) {
     let defaultLabel = this.appMenuStatus.getAttribute("defaultlabel");
     // The localization string is for the signed in text, but it's the default text as well
     let defaultTooltiptext = this.appMenuStatus.getAttribute("signedinTooltiptext");
 
     const status = state.status;
     // Reset the status bar to its original state.
     this.appMenuLabel.setAttribute("label", defaultLabel);