diff --git a/browser/base/content/aboutaccounts/aboutaccounts.js b/browser/base/content/aboutaccounts/aboutaccounts.js index bf6fc6cf5157..641267462cf5 100644 --- a/browser/base/content/aboutaccounts/aboutaccounts.js +++ b/browser/base/content/aboutaccounts/aboutaccounts.js @@ -9,9 +9,17 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/FxAccounts.jsm"); +let fxAccountsCommon = {}; +Cu.import("resource://gre/modules/FxAccountsCommon.js", fxAccountsCommon); + const PREF_LAST_FXA_USER = "identity.fxaccounts.lastSignedInUserHash"; const PREF_SYNC_SHOW_CUSTOMIZATION = "services.sync.ui.showCustomizationDialog"; +const OBSERVER_TOPICS = [ + fxAccountsCommon.ONVERIFIED_NOTIFICATION, + fxAccountsCommon.ONLOGOUT_NOTIFICATION, +]; + function log(msg) { //dump("FXA: " + msg + "\n"); }; @@ -150,6 +158,11 @@ let wrapper = { xps.whenLoaded().then(() => { return fxAccounts.setSignedInUser(accountData); }).then(() => { + // If the user data is verified, we want it to immediately look like + // they are signed in without waiting for messages to bounce around. + if (accountData.verified) { + showManage(); + } this.injectData("message", { status: "login" }); // until we sort out a better UX, just leave the jelly page in place. // If the account email is not yet verified, it will tell the user to @@ -249,23 +262,36 @@ function openPrefs() { } function init() { - if (window.location.href.contains("action=signin")) { - show("remote"); - wrapper.init(fxAccounts.getAccountsSignInURI()); - } else if (window.location.href.contains("action=signup")) { - show("remote"); - wrapper.init(); - } else if (window.location.href.contains("action=reauth")) { - fxAccounts.promiseAccountsForceSigninURI().then(url => { - show("remote"); - wrapper.init(url); - }); - } else { - // Check if we have a local account - fxAccounts.getSignedInUser().then(user => { + fxAccounts.getSignedInUser().then(user => { + if (window.location.href.contains("action=signin")) { if (user) { - show("stage"); - show("manage"); + // asking to sign-in when already signed in just shows manage. + showManage(); + } else { + show("remote"); + wrapper.init(fxAccounts.getAccountsSignInURI()); + } + } else if (window.location.href.contains("action=signup")) { + if (user) { + // asking to sign-up when already signed in just shows manage. + showManage(); + } else { + show("remote"); + wrapper.init(); + } + } else if (window.location.href.contains("action=reauth")) { + // ideally we would only show this when we know the user is in a + // "must reauthenticate" state - but we don't. + // As the email address will be included in the URL returned from + // promiseAccountsForceSigninURI, just always show it. + fxAccounts.promiseAccountsForceSigninURI().then(url => { + show("remote"); + wrapper.init(url); + }); + } else { + // No action specified + if (user) { + showManage(); let sb = Services.strings.createBundle("chrome://browser/locale/syncSetup.properties"); document.title = sb.GetStringFromName("manage.pageTitle"); } else { @@ -274,8 +300,8 @@ function init() { // load the remote frame in the background wrapper.init(); } - }); - } + } + }); } function show(id) { @@ -285,7 +311,38 @@ function hide(id) { document.getElementById(id).style.display = 'none'; } +function showManage() { + show("stage"); + show("manage"); + hide("remote"); + hide("intro"); +} + document.addEventListener("DOMContentLoaded", function onload() { document.removeEventListener("DOMContentLoaded", onload, true); init(); }, true); + +function initObservers() { + function observe(subject, topic, data) { + log("about:accounts observed " + topic); + if (topic == fxAccountsCommon.ONLOGOUT_NOTIFICATION) { + // All about:account windows get changed to action=signin on logout. + window.location = "about:accounts?action=signin"; + return; + } + // must be onverified - just about:accounts is loaded. + window.location = "about:accounts"; + } + + for (let topic of OBSERVER_TOPICS) { + Services.obs.addObserver(observe, topic, false); + } + window.addEventListener("unload", function(event) { + log("about:accounts unloading") + for (let topic of OBSERVER_TOPICS) { + Services.obs.removeObserver(observe, topic); + } + }); +} +initObservers(); diff --git a/browser/base/content/browser-fxaccounts.js b/browser/base/content/browser-fxaccounts.js index dc26aae09c52..636bb9a2f1dd 100644 --- a/browser/base/content/browser-fxaccounts.js +++ b/browser/base/content/browser-fxaccounts.js @@ -24,6 +24,7 @@ let gFxAccounts = { // Do all this dance to lazy-load FxAccountsCommon. delete this.topics; return this.topics = [ + "weave:service:ready", "weave:service:sync:start", "weave:service:login:error", FxAccountsCommon.ONLOGIN_NOTIFICATION, diff --git a/browser/base/content/browser-social.js b/browser/base/content/browser-social.js index f7ab48a6b674..18941e916f17 100644 --- a/browser/base/content/browser-social.js +++ b/browser/base/content/browser-social.js @@ -901,7 +901,7 @@ SocialSidebar = { let popup = event.target; let providerMenuSeps = popup.getElementsByClassName("social-provider-menu"); if (providerMenuSeps[0].previousSibling.nodeName == "menuseparator") - SocialSidebar._populateProviderMenu(providerMenuSeps[0]); + SocialSidebar.populateProviderMenu(providerMenuSeps[0]); }, clearProviderMenus: function() { @@ -916,7 +916,7 @@ SocialSidebar = { } }, - _populateProviderMenu: function(providerMenuSep) { + populateProviderMenu: function(providerMenuSep) { let menu = providerMenuSep.parentNode; // selectable providers are inserted before the provider-menu seperator, // remove any menuitems in that area diff --git a/browser/base/content/browser.css b/browser/base/content/browser.css index 9383241abf80..0849ef76f54e 100644 --- a/browser/base/content/browser.css +++ b/browser/base/content/browser.css @@ -768,10 +768,6 @@ toolbarbutton[type="badged"] { -moz-binding: url("chrome://browser/content/urlbarBindings.xml#toolbarbutton-badged"); } -toolbarpaletteitem[place="palette"] > toolbarbutton[type="badged"] > .toolbarbutton-badge-container { - padding: 5px; -} - toolbarbutton[type="socialmark"] { -moz-binding: url("chrome://browser/content/socialmarks.xml#toolbarbutton-marks"); } @@ -779,11 +775,9 @@ toolbarbutton[type="socialmark"] { toolbarbutton[type="badged"] > .toolbarbutton-badge-container > .toolbarbutton-icon, toolbarbutton[type="socialmark"] > .toolbarbutton-icon { max-width: 16px; - max-height: 16px; } toolbarpaletteitem[place="palette"] > toolbarbutton[type="badged"] > .toolbarbutton-badge-container > .toolbarbutton-icon { max-width: 32px; - max-height: 32px; } panelview > .social-panel-frame { diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul index 5ea8be7bf3c8..2e945234fc77 100644 --- a/browser/base/content/browser.xul +++ b/browser/base/content/browser.xul @@ -1166,7 +1166,7 @@ #ifndef XP_UNIX - + diff --git a/browser/base/content/socialmarks.xml b/browser/base/content/socialmarks.xml index 351f26a04141..60baee9fd737 100644 --- a/browser/base/content/socialmarks.xml +++ b/browser/base/content/socialmarks.xml @@ -12,7 +12,9 @@