Bug 1367921 - add 'sign in to sync' action to send tab/page/link to device if sync is not configured, r?eoger draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 24 Aug 2017 16:04:23 +0100
changeset 652794 bf5ec464e416e07965db6670ceeda7446813bd42
parent 652622 2306e153fba9ca55726ffcce889eaca7a479c29f
child 728182 3a258813da9b5de0e72b565a3697508f27f4e90a
push id76154
push usergijskruitbosch@gmail.com
push dateFri, 25 Aug 2017 08:01:39 +0000
reviewerseoger
bugs1367921
milestone57.0a1
Bug 1367921 - add 'sign in to sync' action to send tab/page/link to device if sync is not configured, r?eoger MozReview-Commit-ID: 5zOAJh1ZltG
browser/base/content/browser-sync.js
browser/base/content/test/sync/browser_contextmenu_sendpage.js
browser/base/content/test/urlbar/browser_page_action_menu.js
browser/locales/en-US/chrome/browser/accounts.properties
browser/themes/shared/urlbar-searchbar.inc.css
--- a/browser/base/content/browser-sync.js
+++ b/browser/base/content/browser-sync.js
@@ -388,16 +388,31 @@ var gSync = {
 
   _appendSendTabUnconfigured(fragment, createDeviceNodeFn) {
     const notConnected = this.fxaStrings.GetStringFromName("sendTabToDevice.unconfigured.status");
     const learnMore = this.fxaStrings.GetStringFromName("sendTabToDevice.unconfigured");
     this._appendSendTabInfoItems(fragment, createDeviceNodeFn, notConnected, learnMore, () => {
       this.openSendToDevicePromo();
       BrowserPageActions.panelNode.hidePopup();
     });
+
+    // Now add a 'sign in to sync' item above the 'learn more' item.
+    const signInToSync = this.fxaStrings.GetStringFromName("sendTabToDevice.signintosync");
+    let signInItem = createDeviceNodeFn(null, signInToSync, null);
+    signInItem.classList.add("sync-menuitem");
+    signInItem.setAttribute("label", signInToSync);
+    // Show an icon if opened in the page action panel:
+    if (signInItem.classList.contains("subviewbutton")) {
+      signInItem.classList.add("subviewbutton-iconic", "signintosync");
+    }
+    signInItem.addEventListener("command", () => {
+      this.openPrefs("sendtab");
+      BrowserPageActions.panelNode.hidePopup();
+    });
+    fragment.insertBefore(signInItem, fragment.lastChild);
   },
 
   _appendSendTabInfoItems(fragment, createDeviceNodeFn, statusLabel, actionLabel, actionCommand) {
     const status = createDeviceNodeFn(null, statusLabel, null);
     status.setAttribute("label", statusLabel);
     status.setAttribute("disabled", true);
     status.classList.add("sync-menuitem");
     fragment.appendChild(status);
--- a/browser/base/content/test/sync/browser_contextmenu_sendpage.js
+++ b/browser/base/content/test/sync/browser_contextmenu_sendpage.js
@@ -121,16 +121,17 @@ add_task(async function test_page_contex
                                       state: UIState.STATUS_NOT_CONFIGURED, isSendableURI: true });
 
   await openContentContextMenu("#moztext", "context-sendpagetodevice");
   is(document.getElementById("context-sendpagetodevice").hidden, false, "Send tab to device is shown");
   is(document.getElementById("context-sendpagetodevice").disabled, false, "Send tab to device is enabled");
   checkPopup([
     { label: "Not Connected to Sync", disabled: true },
     "----",
+    { label: "Sign in to Sync..." },
     { label: "Learn About Sending Tabs..." }
   ]);
 
   await hideContentContextMenu();
 
   sandbox.restore();
 });
 
--- a/browser/base/content/test/urlbar/browser_page_action_menu.js
+++ b/browser/base/content/test/urlbar/browser_page_action_menu.js
@@ -303,16 +303,21 @@ add_task(async function sendToDevice_not
         attrs: {
           label: "Not Connected to Sync",
         },
         disabled: true
       },
       null,
       {
         attrs: {
+          label: "Sign in to Sync..."
+        },
+      },
+      {
+        attrs: {
           label: "Learn About Sending Tabs..."
         },
       }
     ];
     checkSendToDeviceItems(expectedItems);
 
     // Done, hide the panel.
     let hiddenPromise = promisePageActionPanelHidden();
--- a/browser/locales/en-US/chrome/browser/accounts.properties
+++ b/browser/locales/en-US/chrome/browser/accounts.properties
@@ -40,16 +40,21 @@ deviceDisconnectedNotification.body = Th
 sendToAllDevices.menuitem = Send to All Devices
 
 # LOCALIZATION NOTE (sendTabToDevice.unconfigured, sendTabToDevice.unconfigured.status)
 # Displayed in the Send Tabs context menu when right clicking a tab, a page or a link
 # and the Sync account is unconfigured. Redirects to a marketing page.
 sendTabToDevice.unconfigured.status = Not Connected to Sync
 sendTabToDevice.unconfigured = Learn About Sending Tabs…
 
+# LOCALIZATION NOTE (sendTabToDevice.signintosync)
+# Displayed in the Send Tabs context menu and the page action panel when sync is not
+# configured. Allows users to immediately sign into sync via the preferences.
+sendTabToDevice.signintosync = Sign in to Sync…
+
 # LOCALIZATION NOTE (sendTabToDevice.singledevice, sendTabToDevice.singledevice.status)
 # Displayed in the Send Tabs context menu when right clicking a tab, a page or a link
 # and the Sync account has only 1 device. Redirects to a marketing page.
 sendTabToDevice.singledevice.status = No Devices Connected
 sendTabToDevice.singledevice = Learn About Sending Tabs…
 
 # LOCALIZATION NOTE (sendTabToDevice.verify, sendTabToDevice.verify.status)
 # Displayed in the Send Tabs context menu when right clicking a tab, a page or a link
--- a/browser/themes/shared/urlbar-searchbar.inc.css
+++ b/browser/themes/shared/urlbar-searchbar.inc.css
@@ -99,16 +99,17 @@
 .pageAction-sendToDevice-device[clientType=mobile] {
   list-style-image: url("chrome://browser/skin/device-mobile.svg");
 }
 
 .pageAction-sendToDevice-device[clientType=desktop] {
   list-style-image: url("chrome://browser/skin/device-desktop.svg");
 }
 
+.pageAction-sendToDevice-device.signintosync,
 #pageAction-panel-sendToDevice-fxa,
 #pageAction-urlbar-sendToDevice-fxa {
   list-style-image: url("chrome://browser/skin/sync.svg");
 }
 
 /* URL bar and page action buttons */
 
 #page-action-buttons {