Bug 957436 - [Australis] Show doorhanger for first fxa-based sync r=markh
authorTim Taubert <ttaubert@mozilla.com>
Sat, 25 Jan 2014 16:19:07 +0100
changeset 165172 45f1ee0a3a1c375856474b5848a1ca11de27f24a
parent 165171 f8148a7a0260ea5bc66cc0cbb606bac84b68ca10
child 165173 1a635b8dc7fa59e7dec63a20230d6c4f6e827d44
push id4573
push userttaubert@mozilla.com
push dateSat, 25 Jan 2014 15:46:10 +0000
treeherderfx-team@45f1ee0a3a1c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarkh
bugs957436
milestone29.0a1
Bug 957436 - [Australis] Show doorhanger for first fxa-based sync r=markh
browser/base/content/browser-fxaccounts.js
browser/base/content/browser.js
browser/base/content/browser.xul
browser/locales/en-US/chrome/browser/browser.dtd
browser/themes/linux/browser.css
browser/themes/osx/browser.css
browser/themes/windows/browser.css
new file mode 100644
--- /dev/null
+++ b/browser/base/content/browser-fxaccounts.js
@@ -0,0 +1,45 @@
+# 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.defineLazyGetter(this, "FxAccountsCommon", function () {
+  return Cu.import("resource://gre/modules/FxAccountsCommon.js", {});
+});
+
+let gFxAccounts = {
+
+  get topics() {
+    delete this.topics;
+    return this.topics = [
+      FxAccountsCommon.ONVERIFIED_NOTIFICATION
+    ];
+  },
+
+  init: function () {
+    for (let topic of this.topics) {
+      Services.obs.addObserver(this, topic, false);
+    }
+  },
+
+  uninit: function () {
+    for (let topic of this.topics) {
+      Services.obs.removeObserver(this, topic);
+    }
+  },
+
+  observe: function (subject, topic) {
+    this.showDoorhanger();
+  },
+
+  showDoorhanger: function () {
+    let panel = document.getElementById("sync-popup");
+    let anchor = document.getElementById("PanelUI-menu-button");
+
+    let iconAnchor =
+      document.getAnonymousElementByAttribute(anchor, "class",
+                                              "toolbarbutton-icon");
+
+    panel.hidden = false;
+    panel.openPopup(iconAnchor || anchor, "bottomcenter topright");
+  }
+};
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -181,16 +181,18 @@ let gInitialPages = [
 #ifdef MOZ_DATA_REPORTING
 #include browser-data-submission-info-bar.js
 #endif
 
 #ifdef MOZ_SERVICES_SYNC
 #include browser-syncui.js
 #endif
 
+#include browser-fxaccounts.js
+
 XPCOMUtils.defineLazyGetter(this, "Win7Features", function () {
 #ifdef XP_WIN
   // Bug 666808 - AeroPeek support for e10s
   if (gMultiProcessBrowser)
     return null;
 
   const WINTASKBAR_CONTRACTID = "@mozilla.org/windows-taskbar;1";
   if (WINTASKBAR_CONTRACTID in Cc &&
@@ -1132,16 +1134,17 @@ var gBrowserInit = {
     if (window.fullScreen)
       onFullScreen();
     if (document.mozFullScreen)
       onMozEnteredDomFullscreen();
 
 #ifdef MOZ_SERVICES_SYNC
     // initialize the sync UI
     gSyncUI.init();
+    gFxAccounts.init();
 #endif
 
 #ifdef MOZ_DATA_REPORTING
     gDataNotificationInfoBar.init();
 #endif
 
     gBrowserThumbnails.init();
 
@@ -1236,16 +1239,20 @@ var gBrowserInit = {
     CombinedBackForward.uninit();
 
     gGestureSupport.init(false);
 
     gHistorySwipeAnimation.uninit();
 
     FullScreen.cleanup();
 
+#ifdef MOZ_SERVICES_SYNC
+    gFxAccounts.uninit();
+#endif
+
     Services.obs.removeObserver(gPluginHandler.pluginCrashed, "plugin-crashed");
 
     try {
       gBrowser.removeProgressListener(window.XULBrowserWindow);
       gBrowser.removeTabsProgressListener(window.TabsProgressListener);
     } catch (ex) {
     }
 
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -377,16 +377,28 @@
         <button class="ctrlTab-preview" flex="1"/>
         <button class="ctrlTab-preview" flex="1"/>
       </hbox>
       <hbox pack="center">
         <button id="ctrlTab-showAll" class="ctrlTab-preview" noicon="true"/>
       </hbox>
     </panel>
 
+    <!-- Sync Panel -->
+    <panel id="sync-popup" type="arrow" hidden="true" noautofocus="true"
+           level="top" onclick="this.hidePopup();">
+      <hbox id="sync-popup-outer">
+        <image id="sync-popup-icon"/>
+        <vbox id="sync-popup-inner">
+          <description id="sync-popup-desc-syncing" value="&syncPanel.descriptionSyncing;"/>
+          <description id="sync-popup-desc-prefs">&syncPanel.descriptionPrefs;</description>
+        </vbox>
+      </hbox>
+    </panel>
+
     <!-- Bookmarks and history tooltip -->
     <tooltip id="bhTooltip"/>
 
     <tooltip id="tabbrowser-tab-tooltip" onpopupshowing="gBrowser.createTooltip(event);"/>
 
     <tooltip id="back-button-tooltip">
       <label class="tooltip-label" value="&backButton.tooltip;"/>
 #ifdef XP_MACOSX
--- a/browser/locales/en-US/chrome/browser/browser.dtd
+++ b/browser/locales/en-US/chrome/browser/browser.dtd
@@ -91,16 +91,19 @@ These should match what Safari and other
 <!ENTITY exitFullScreenCmd.label "Exit Full Screen">
 <!ENTITY exitFullScreenCmd.accesskey "F">
 <!ENTITY fullScreenCmd.label "Full Screen">
 <!ENTITY fullScreenCmd.accesskey "F">
 <!ENTITY fullScreenCmd.macCommandKey "f">
 <!ENTITY showAllTabsCmd.label "Show All Tabs">
 <!ENTITY showAllTabsCmd.accesskey "A">
 
+<!ENTITY syncPanel.descriptionSyncing "&brandShortName; is now syncing.">
+<!ENTITY syncPanel.descriptionPrefs "You can manage Sync from your browser's Preferences.">
+
 <!ENTITY fullScreenMinimize.tooltip "Minimize">
 <!ENTITY fullScreenRestore.tooltip "Restore">
 <!ENTITY fullScreenClose.tooltip "Close">
 <!ENTITY fullScreenAutohide.label "Hide Toolbars">
 <!ENTITY fullScreenAutohide.accesskey "H">
 <!ENTITY fullScreenExit.label "Exit Full Screen Mode">
 <!ENTITY fullScreenExit.accesskey "F">
 <!ENTITY fullscreenAllowButton.label "Allow">
--- a/browser/themes/linux/browser.css
+++ b/browser/themes/linux/browser.css
@@ -1676,16 +1676,36 @@ toolbarbutton.chevron > .toolbarbutton-i
 
 #ctrlTab-showAll {
   -moz-appearance: button;
   color: ButtonText;
   padding: 0 3px;
   margin-top: 10px;
 }
 
+/* Sync Panel */
+
+#sync-popup {
+  padding: 10px;
+}
+
+#sync-popup-icon {
+  width: 32px;
+  background: url("chrome://browser/content/abouthome/sync.png") center center no-repeat;
+}
+
+#sync-popup-inner {
+  width: 0;
+  padding-left: 10px;
+}
+
+#sync-popup-desc-prefs {
+  margin: 0;
+}
+
 /* Status panel */
 
 .statuspanel-label {
   margin: 0;
   padding: 2px 4px;
   background: linear-gradient(#fff, #ddd);
   border: 1px none #ccc;
   border-top-style: solid;
--- a/browser/themes/osx/browser.css
+++ b/browser/themes/osx/browser.css
@@ -3583,16 +3583,43 @@ toolbarbutton.chevron > .toolbarbutton-m
 .ctrlTab-preview:not(#ctrlTab-showAll):focus > * > .ctrlTab-preview-inner {
   margin: -10px -10px 0;
 }
 
 #ctrlTab-showAll {
   margin-top: .5em;
 }
 
+/* Sync Panel */
+
+#sync-popup {
+  padding: 10px;
+}
+
+#sync-popup-icon {
+  width: 32px;
+  background: url("chrome://browser/content/abouthome/sync.png") center center no-repeat;
+}
+
+@media (min-resolution: 2dppx) {
+  #sync-popup-icon {
+    background: url("chrome://browser/content/abouthome/sync@2x.png") center center no-repeat;
+    background-size: 32px 32px;
+  }
+}
+
+#sync-popup-inner {
+  width: 0;
+  padding-left: 10px;
+}
+
+#sync-popup-desc-prefs {
+  margin: 0;
+}
+
 /* Status panel */
 
 .statuspanel-label {
   margin: 0;
   padding: 2px 4px;
   background: linear-gradient(#fff, #ddd);
   border: 1px none #ccc;
   border-top-style: solid;
--- a/browser/themes/windows/browser.css
+++ b/browser/themes/windows/browser.css
@@ -2135,16 +2135,36 @@ toolbarbutton.bookmark-item[dragover="tr
 .ctrlTab-preview:not(#ctrlTab-showAll):focus > * > .ctrlTab-preview-inner {
   margin: -10px -10px 0;
 }
 
 #ctrlTab-showAll {
   margin-top: .5em;
 }
 
+/* Sync Panel */
+
+#sync-popup {
+  padding: 10px;
+}
+
+#sync-popup-icon {
+  width: 32px;
+  background: url("chrome://browser/content/abouthome/sync.png") center center no-repeat;
+}
+
+#sync-popup-inner {
+  width: 0;
+  padding-left: 10px;
+}
+
+#sync-popup-desc-prefs {
+  margin: 0;
+}
+
 /* Status panel */
 
 .statuspanel-label {
   margin: 0;
   padding: 2px 4px;
   background: linear-gradient(#fff, #ddd);
   border: 1px none #ccc;
   border-top-style: solid;