Bug 1353571 part 1 - Remove pref identity.fxaccounts.profile_image.enabled. r?markh draft
authorEdouard Oger <eoger@fastmail.com>
Fri, 07 Apr 2017 15:57:43 -0400
changeset 572163 67b61b648996540c08fb45d6ca29eb7a33600ac0
parent 572162 b25ad0674afd563e888dc07981baa626e8d794db
child 572164 f9fe9ef116ec7f42ab950fa2c0b9ca4d23d46d1e
push id57011
push userbmo:eoger@fastmail.com
push dateWed, 03 May 2017 21:00:43 +0000
reviewersmarkh
bugs1353571
milestone55.0a1
Bug 1353571 part 1 - Remove pref identity.fxaccounts.profile_image.enabled. r?markh MozReview-Commit-ID: 4iy2S1kYUEh
browser/app/profile/firefox.js
browser/base/content/browser-fxaccounts.js
browser/components/preferences/in-content-old/sync.js
browser/components/preferences/in-content-old/sync.xul
browser/components/preferences/in-content/sync.js
browser/components/preferences/in-content/sync.xul
browser/themes/shared/customizableui/panelUI.inc.css
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1379,19 +1379,16 @@ pref("identity.fxaccounts.settings.uri",
 pref("identity.fxaccounts.settings.devices.uri", "https://accounts.firefox.com/settings/clients?service=sync&context=fx_desktop_v3");
 
 // The remote URL of the FxA Profile Server
 pref("identity.fxaccounts.remote.profile.uri", "https://profile.accounts.firefox.com/v1");
 
 // The remote URL of the FxA OAuth Server
 pref("identity.fxaccounts.remote.oauth.uri", "https://oauth.accounts.firefox.com/v1");
 
-// Whether we display profile images in the UI or not.
-pref("identity.fxaccounts.profile_image.enabled", true);
-
 // Token server used by the FxA Sync identity.
 pref("identity.sync.tokenserver.uri", "https://token.services.mozilla.com/1.0/sync/1.5");
 
 // URLs for promo links to mobile browsers. Note that consumers are expected to
 // append a value for utm_campaign.
 pref("identity.mobilepromo.android", "https://www.mozilla.org/firefox/android/?utm_source=firefox-browser&utm_medium=firefox-browser&utm_campaign=");
 pref("identity.mobilepromo.ios", "https://www.mozilla.org/firefox/ios/?utm_source=firefox-browser&utm_medium=firefox-browser&utm_campaign=");
 
--- a/browser/base/content/browser-fxaccounts.js
+++ b/browser/base/content/browser-fxaccounts.js
@@ -149,18 +149,16 @@ var gFxAccounts = {
 
   handleEvent(event) {
     this._inCustomizationMode = event.type == "customizationstarting";
     this.updateUI();
   },
 
   // Note that updateUI() returns a Promise that's only used by tests.
   updateUI() {
-    let profileInfoEnabled = Services.prefs.getBoolPref("identity.fxaccounts.profile_image.enabled", false);
-
     this.panelUIFooter.hidden = false;
 
     // Make sure the button is disabled in customization mode.
     if (this._inCustomizationMode) {
       this.panelUIStatus.setAttribute("disabled", "true");
       this.panelUILabel.setAttribute("disabled", "true");
       this.panelUIAvatar.setAttribute("disabled", "true");
       this.panelUIIcon.setAttribute("disabled", "true");
@@ -182,17 +180,16 @@ var gFxAccounts = {
       if (window.closed) {
         return;
       }
 
       // Reset the button to its original state.
       this.panelUILabel.setAttribute("label", defaultLabel);
       this.panelUIStatus.setAttribute("tooltiptext", defaultTooltiptext);
       this.panelUIFooter.removeAttribute("fxastatus");
-      this.panelUIFooter.removeAttribute("fxaprofileimage");
       this.panelUIAvatar.style.removeProperty("list-style-image");
       let showErrorBadge = false;
       if (userData) {
         // At this point we consider the user as logged-in (but still can be in an error state)
         if (this.loginFailed) {
           let tooltipDescription = this.strings.formatStringFromName("reconnectDescription", [userData.email], 1);
           this.panelUIFooter.setAttribute("fxastatus", "error");
           this.panelUILabel.setAttribute("label", errorLabel);
@@ -204,57 +201,50 @@ var gFxAccounts = {
           this.panelUIFooter.setAttribute("unverified", "true");
           this.panelUILabel.setAttribute("label", unverifiedLabel);
           this.panelUIStatus.setAttribute("tooltiptext", tooltipDescription);
           showErrorBadge = true;
         } else {
           this.panelUIFooter.setAttribute("fxastatus", "signedin");
           this.panelUILabel.setAttribute("label", userData.email);
         }
-        if (profileInfoEnabled) {
-          this.panelUIFooter.setAttribute("fxaprofileimage", "enabled");
-        }
       }
       if (showErrorBadge) {
         PanelUI.showBadgeOnlyNotification("fxa-needs-authentication");
       } else {
         PanelUI.removeNotification("fxa-needs-authentication");
       }
     }
 
     let updateWithProfile = (profile) => {
-      if (profileInfoEnabled) {
-        if (profile.displayName) {
-          this.panelUILabel.setAttribute("label", profile.displayName);
-        }
-        if (profile.avatar) {
-          this.panelUIFooter.setAttribute("fxaprofileimage", "set");
-          let bgImage = "url(\"" + profile.avatar + "\")";
-          this.panelUIAvatar.style.listStyleImage = bgImage;
+      if (profile.displayName) {
+        this.panelUILabel.setAttribute("label", profile.displayName);
+      }
+      if (profile.avatar) {
+        let bgImage = "url(\"" + profile.avatar + "\")";
+        this.panelUIAvatar.style.listStyleImage = bgImage;
 
-          let img = new Image();
-          img.onerror = () => {
-            // Clear the image if it has trouble loading. Since this callback is asynchronous
-            // we check to make sure the image is still the same before we clear it.
-            if (this.panelUIAvatar.style.listStyleImage === bgImage) {
-              this.panelUIFooter.removeAttribute("fxaprofileimage");
-              this.panelUIAvatar.style.removeProperty("list-style-image");
-            }
-          };
-          img.src = profile.avatar;
-        }
+        let img = new Image();
+        img.onerror = () => {
+          // Clear the image if it has trouble loading. Since this callback is asynchronous
+          // we check to make sure the image is still the same before we clear it.
+          if (this.panelUIAvatar.style.listStyleImage === bgImage) {
+            this.panelUIAvatar.style.removeProperty("list-style-image");
+          }
+        };
+        img.src = profile.avatar;
       }
     }
 
     return fxAccounts.getSignedInUser().then(userData => {
       // userData may be null here when the user is not signed-in, but that's expected
       updateWithUserData(userData);
       // unverified users cause us to spew log errors fetching an OAuth token
       // to fetch the profile, so don't even try in that case.
-      if (!userData || !userData.verified || !profileInfoEnabled) {
+      if (!userData || !userData.verified) {
         return null; // don't even try to grab the profile.
       }
       if (this._cachedProfile) {
         return this._cachedProfile;
       }
       return fxAccounts.getSignedInUserProfile().catch(err => {
         // Not fetching the profile is sad but the FxA logs will already have noise.
         return null;
--- a/browser/components/preferences/in-content-old/sync.js
+++ b/browser/components/preferences/in-content-old/sync.js
@@ -124,18 +124,16 @@ var gSyncPane = {
     document.getElementById("tosPP-small-ToS").setAttribute("href", Weave.Svc.Prefs.get("fxa.termsURL"));
     document.getElementById("tosPP-small-PP").setAttribute("href", Weave.Svc.Prefs.get("fxa.privacyURL"));
 
     fxAccounts.promiseAccountsManageURI(this._getEntryPoint()).then(accountsManageURI => {
       document.getElementById("verifiedManage").setAttribute("href", accountsManageURI);
     });
 
     this.updateWeavePrefs();
-
-    this._initProfileImageUI();
   },
 
   _toggleComputerNameControls(editMode) {
     let textbox = document.getElementById("fxaSyncComputerName");
     textbox.disabled = !editMode;
     document.getElementById("fxaChangeDeviceName").hidden = editMode;
     document.getElementById("fxaCancelChangeDeviceName").hidden = !editMode;
     document.getElementById("fxaSaveChangeDeviceName").hidden = !editMode;
@@ -220,36 +218,26 @@ var gSyncPane = {
       if (e.keyCode == KeyEvent.DOM_VK_RETURN) {
         document.getElementById("fxaSaveChangeDeviceName").click();
       } else if (e.keyCode == KeyEvent.DOM_VK_ESCAPE) {
         document.getElementById("fxaCancelChangeDeviceName").click();
       }
     });
   },
 
-  _initProfileImageUI() {
-    try {
-      if (Services.prefs.getBoolPref("identity.fxaccounts.profile_image.enabled")) {
-        document.getElementById("fxaProfileImage").hidden = false;
-      }
-    } catch (e) { }
-  },
-
   updateWeavePrefs() {
     let service = Components.classes["@mozilla.org/weave/service;1"]
                   .getService(Components.interfaces.nsISupports)
                   .wrappedJSObject;
 
     let displayNameLabel = document.getElementById("fxaDisplayName");
     let fxaEmailAddress1Label = document.getElementById("fxaEmailAddress1");
     fxaEmailAddress1Label.hidden = false;
     displayNameLabel.hidden = true;
 
-    let profileInfoEnabled = Services.prefs.getBoolPref("identity.fxaccounts.profile_image.enabled", false);
-
     // determine the fxa status...
     this._showLoadPage(service);
 
     fxAccounts.getSignedInUser().then(data => {
       if (!data) {
         this.page = FXA_PAGE_LOGGED_OUT;
         return false;
       }
@@ -295,17 +283,17 @@ var gSyncPane = {
       return data.verified;
     }).then(isVerified => {
       if (isVerified) {
         return fxAccounts.getSignedInUserProfile();
       }
       return null;
     }).then(data => {
       let fxaLoginStatus = document.getElementById("fxaLoginStatus");
-      if (data && profileInfoEnabled) {
+      if (data) {
         if (data.displayName) {
           fxaLoginStatus.setAttribute("hasName", true);
           displayNameLabel.hidden = false;
           displayNameLabel.textContent = data.displayName;
         } else {
           fxaLoginStatus.removeAttribute("hasName");
         }
         if (data.avatar) {
--- a/browser/components/preferences/in-content-old/sync.xul
+++ b/browser/components/preferences/in-content-old/sync.xul
@@ -83,17 +83,17 @@
           <caption><label>&syncBrand.fxAccount.label;</label></caption>
           <deck id="fxaLoginStatus">
 
             <!-- logged in and verified and all is good -->
             <hbox id="fxaLoginVerified" class="fxaAccountBox">
               <vbox align="center" pack="center">
                 <image id="fxaProfileImage" class="actionable"
                     role="button"
-                    onclick="gSyncPane.openChangeProfileImage(event);" hidden="true"
+                    onclick="gSyncPane.openChangeProfileImage(event);"
                     onkeypress="gSyncPane.openChangeProfileImage(event);"
                     tooltiptext="&profilePicture.tooltip;"/>
               </vbox>
               <vbox flex="1" pack="center">
                 <label id="fxaDisplayName" hidden="true"/>
                 <label id="fxaEmailAddress1"/>
                 <hbox class="fxaAccountBoxButtons">
                   <button id="fxaUnlinkButton" label="&disconnect.label;" accesskey="&disconnect.accesskey;"/>
--- a/browser/components/preferences/in-content/sync.js
+++ b/browser/components/preferences/in-content/sync.js
@@ -124,18 +124,16 @@ var gSyncPane = {
     document.getElementById("tosPP-small-ToS").setAttribute("href", Weave.Svc.Prefs.get("fxa.termsURL"));
     document.getElementById("tosPP-small-PP").setAttribute("href", Weave.Svc.Prefs.get("fxa.privacyURL"));
 
     fxAccounts.promiseAccountsManageURI(this._getEntryPoint()).then(accountsManageURI => {
       document.getElementById("verifiedManage").setAttribute("href", accountsManageURI);
     });
 
     this.updateWeavePrefs();
-
-    this._initProfileImageUI();
   },
 
   _toggleComputerNameControls(editMode) {
     let textbox = document.getElementById("fxaSyncComputerName");
     textbox.disabled = !editMode;
     document.getElementById("fxaChangeDeviceName").hidden = editMode;
     document.getElementById("fxaCancelChangeDeviceName").hidden = !editMode;
     document.getElementById("fxaSaveChangeDeviceName").hidden = !editMode;
@@ -220,36 +218,26 @@ var gSyncPane = {
       if (e.keyCode == KeyEvent.DOM_VK_RETURN) {
         document.getElementById("fxaSaveChangeDeviceName").click();
       } else if (e.keyCode == KeyEvent.DOM_VK_ESCAPE) {
         document.getElementById("fxaCancelChangeDeviceName").click();
       }
     });
   },
 
-  _initProfileImageUI() {
-    try {
-      if (Services.prefs.getBoolPref("identity.fxaccounts.profile_image.enabled")) {
-        document.getElementById("fxaProfileImage").hidden = false;
-      }
-    } catch (e) { }
-  },
-
   updateWeavePrefs() {
     let service = Components.classes["@mozilla.org/weave/service;1"]
                   .getService(Components.interfaces.nsISupports)
                   .wrappedJSObject;
 
     let displayNameLabel = document.getElementById("fxaDisplayName");
     let fxaEmailAddress1Label = document.getElementById("fxaEmailAddress1");
     fxaEmailAddress1Label.hidden = false;
     displayNameLabel.hidden = true;
 
-    let profileInfoEnabled = Services.prefs.getBoolPref("identity.fxaccounts.profile_image.enabled", false);
-
     // determine the fxa status...
     this._showLoadPage(service);
 
     fxAccounts.getSignedInUser().then(data => {
       if (!data) {
         this.page = FXA_PAGE_LOGGED_OUT;
         return false;
       }
@@ -295,17 +283,17 @@ var gSyncPane = {
       return data.verified;
     }).then(isVerified => {
       if (isVerified) {
         return fxAccounts.getSignedInUserProfile();
       }
       return null;
     }).then(data => {
       let fxaLoginStatus = document.getElementById("fxaLoginStatus");
-      if (data && profileInfoEnabled) {
+      if (data) {
         if (data.displayName) {
           fxaLoginStatus.setAttribute("hasName", true);
           displayNameLabel.hidden = false;
           displayNameLabel.textContent = data.displayName;
         } else {
           fxaLoginStatus.removeAttribute("hasName");
         }
         if (data.avatar) {
--- a/browser/components/preferences/in-content/sync.xul
+++ b/browser/components/preferences/in-content/sync.xul
@@ -82,17 +82,17 @@
           <caption><label>&syncBrand.fxAccount.label;</label></caption>
           <deck id="fxaLoginStatus">
 
             <!-- logged in and verified and all is good -->
             <hbox id="fxaLoginVerified" class="fxaAccountBox">
               <vbox align="center" pack="center">
                 <image id="fxaProfileImage" class="actionable"
                     role="button"
-                    onclick="gSyncPane.openChangeProfileImage(event);" hidden="true"
+                    onclick="gSyncPane.openChangeProfileImage(event);"
                     onkeypress="gSyncPane.openChangeProfileImage(event);"
                     tooltiptext="&profilePicture.tooltip;"/>
               </vbox>
               <vbox flex="1" pack="center">
                 <label id="fxaDisplayName" hidden="true"/>
                 <label id="fxaEmailAddress1"/>
                 <hbox class="fxaAccountBoxButtons">
                   <button id="fxaUnlinkButton" label="&disconnect3.label;" accesskey="&disconnect3.accesskey;"/>
--- a/browser/themes/shared/customizableui/panelUI.inc.css
+++ b/browser/themes/shared/customizableui/panelUI.inc.css
@@ -566,18 +566,17 @@ toolbarpaletteitem[place="palette"] > to
   margin: 0;
 }
 
 #main-window[customizing] #PanelUI-footer-fxa {
   display: none;
 }
 
 #PanelUI-footer-fxa:not([fxastatus="signedin"]) > toolbarseparator,
-#PanelUI-footer-fxa:not([fxastatus="signedin"]) > #PanelUI-fxa-icon,
-#PanelUI-footer-fxa:not([fxaprofileimage]) > #PanelUI-fxa-status > #PanelUI-fxa-avatar {
+#PanelUI-footer-fxa:not([fxastatus="signedin"]) > #PanelUI-fxa-icon {
   display: none;
 }
 
 #PanelUI-footer-fxa[fxastatus="error"] > #PanelUI-fxa-status::after {
   content: url(chrome://browser/skin/warning.svg);
   filter: drop-shadow(0 1px 0 hsla(206,50%,10%,.15));
   width: 47px;
   padding-top: 1px;
@@ -720,18 +719,17 @@ toolbarpaletteitem[place="palette"] > to
 #PanelUI-fxa-label,
 #PanelUI-footer-addons > toolbarbutton,
 #PanelUI-customize {
   flex: 1;
   padding-inline-start: 15px;
   border-inline-start-style: none;
 }
 
-#PanelUI-footer-fxa[fxaprofileimage="set"] > #PanelUI-fxa-status > #PanelUI-fxa-label,
-#PanelUI-footer-fxa[fxaprofileimage="enabled"]:not([fxastatus="error"]) > #PanelUI-fxa-status > #PanelUI-fxa-label {
+#PanelUI-footer-fxa[fxastatus="signedin"] > #PanelUI-fxa-status > #PanelUI-fxa-label {
   padding-inline-start: 0px;
 }
 
 /* descend from #PanelUI-footer to add specificity, or else the
    padding-inline-start will be overridden */
 #PanelUI-footer > .PanelUI-notification-menu-item {
   width: calc(@menuPanelWidth@ + 30px);
   padding-inline-start: 15px;
@@ -882,21 +880,17 @@ toolbarpaletteitem[place="palette"] > to
 #PanelUI-footer-addons > toolbarbutton,
 #PanelUI-customize,
 #PanelUI-help,
 #PanelUI-quit {
   -moz-image-region: rect(0, 16px, 16px, 0);
 }
 
 #PanelUI-footer-fxa[fxastatus="signedin"] > #PanelUI-fxa-status > #PanelUI-fxa-label > .toolbarbutton-icon,
-#PanelUI-footer-fxa[fxastatus="error"][fxaprofileimage="set"] > #PanelUI-fxa-status > #PanelUI-fxa-label > .toolbarbutton-icon {
-  display: none;
-}
-
-#PanelUI-footer-fxa[fxastatus="error"]:not([fxaprofileimage="set"]) > #PanelUI-fxa-status > #PanelUI-fxa-avatar {
+#PanelUI-footer-fxa:not([fxastatus="signedin"]) > #PanelUI-fxa-status > #PanelUI-fxa-avatar {
   display: none;
 }
 
 #PanelUI-fxa-status[disabled],
 #PanelUI-fxa-icon[disabled] {
   pointer-events: none;
 }
 
@@ -909,17 +903,17 @@ toolbarpaletteitem[place="palette"] > to
   background-size: contain;
   align-self: center;
   margin: 0px 7px;
   padding: 0px;
   border: 0px none;
   margin-inline-end: 0;
 }
 
-#PanelUI-footer-fxa[fxaprofileimage="enabled"] > #PanelUI-fxa-status > #PanelUI-fxa-avatar {
+#PanelUI-footer-fxa > #PanelUI-fxa-status > #PanelUI-fxa-avatar {
   list-style-image: url(chrome://browser/skin/fxa/default-avatar.svg);
 }
 
 #PanelUI-customize:hover,
 #PanelUI-help:not([disabled]):hover,
 #PanelUI-quit:not([disabled]):hover {
   -moz-image-region: rect(0, 32px, 16px, 16px);
 }