summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornoms@chromium.org <noms@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-06 16:48:08 +0000
committernoms@chromium.org <noms@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-06 16:48:08 +0000
commit901f82e959c77e4dde3e3416852ed7bbfcf01ec8 (patch)
tree0fc38e831923c976008e2fd63427d0bcbe587f31
parentf947f00dc113ffb74a8ca4339f513b30a0e6bf66 (diff)
downloadchromium_src-901f82e959c77e4dde3e3416852ed7bbfcf01ec8.zip
chromium_src-901f82e959c77e4dde3e3416852ed7bbfcf01ec8.tar.gz
chromium_src-901f82e959c77e4dde3e3416852ed7bbfcf01ec8.tar.bz2
Use a correct scale factor for Gaia avatar images
BUG=341607 TEST=Make sure that you have the --new-profile-management flag turned on, at least two profiles, and at least one of them signed in. Go to chrome://settings. All the users should display an avatar image in the Users section, including the signed in users, which will have their Gaia photo. Review URL: https://codereview.chromium.org/183893028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255367 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/options/browser_options_profile_list.js3
-rw-r--r--chrome/browser/resources/options/manage_profile_overlay.js2
-rw-r--r--chrome/browser/resources/options/managed_user_list.js3
-rw-r--r--chrome/browser/resources/options/profiles_icon_grid.js3
-rw-r--r--ui/webui/resources/js/util.js15
5 files changed, 19 insertions, 7 deletions
diff --git a/chrome/browser/resources/options/browser_options_profile_list.js b/chrome/browser/resources/options/browser_options_profile_list.js
index 7a60ca3..a51b5b7 100644
--- a/chrome/browser/resources/options/browser_options_profile_list.js
+++ b/chrome/browser/resources/options/browser_options_profile_list.js
@@ -54,7 +54,7 @@ cr.define('options.browser_options', function() {
var iconEl = this.ownerDocument.createElement('img');
iconEl.className = 'profile-img';
- iconEl.style.content = imageset(profileInfo.iconURL + '@scalefactorx');
+ iconEl.style.content = getProfileAvatarIcon(profileInfo.iconURL);
this.contentElement.appendChild(iconEl);
var nameEl = this.ownerDocument.createElement('div');
@@ -126,4 +126,3 @@ cr.define('options.browser_options', function() {
ProfileList: ProfileList
};
});
-
diff --git a/chrome/browser/resources/options/manage_profile_overlay.js b/chrome/browser/resources/options/manage_profile_overlay.js
index fd1b222..86e0ec3 100644
--- a/chrome/browser/resources/options/manage_profile_overlay.js
+++ b/chrome/browser/resources/options/manage_profile_overlay.js
@@ -485,7 +485,7 @@ cr.define('options', function() {
$('manage-profile-overlay-manage').hidden = true;
$('manage-profile-overlay-delete').hidden = false;
$('delete-profile-icon').style.content =
- imageset(profileInfo.iconURL + '@scalefactorx');
+ getProfileAvatarIcon(profileInfo.iconURL);
$('delete-profile-text').textContent =
loadTimeData.getStringF('deleteProfileMessage',
elide(profileInfo.name, /* maxLength */ 50));
diff --git a/chrome/browser/resources/options/managed_user_list.js b/chrome/browser/resources/options/managed_user_list.js
index 4af84c6..2d4ec61 100644
--- a/chrome/browser/resources/options/managed_user_list.js
+++ b/chrome/browser/resources/options/managed_user_list.js
@@ -62,8 +62,7 @@ cr.define('options.managedUserOptions', function() {
// Add the avatar.
var iconElement = this.ownerDocument.createElement('img');
iconElement.className = 'profile-img';
- iconElement.style.content =
- imageset(managedUser.iconURL + '@scalefactorx');
+ iconElement.style.content = getProfileAvatarIcon(managedUser.iconURL);
this.appendChild(iconElement);
// Add the profile name.
diff --git a/chrome/browser/resources/options/profiles_icon_grid.js b/chrome/browser/resources/options/profiles_icon_grid.js
index a35b23f..f8e7b61 100644
--- a/chrome/browser/resources/options/profiles_icon_grid.js
+++ b/chrome/browser/resources/options/profiles_icon_grid.js
@@ -37,7 +37,7 @@ cr.define('options', function() {
ListItem.prototype.decorate.call(this);
var imageEl = cr.doc.createElement('img');
imageEl.className = 'profile-icon';
- imageEl.style.content = imageset(this.iconURL_ + '@scalefactorx');
+ imageEl.style.content = getProfileAvatarIcon(this.iconURL_);
this.appendChild(imageEl);
this.className = 'profile-icon-grid-item';
@@ -65,4 +65,3 @@ cr.define('options', function() {
ProfilesIconGrid: ProfilesIconGrid
};
});
-
diff --git a/ui/webui/resources/js/util.js b/ui/webui/resources/js/util.js
index ebcf90c..56e2d2d 100644
--- a/ui/webui/resources/js/util.js
+++ b/ui/webui/resources/js/util.js
@@ -75,6 +75,21 @@ function url(s) {
}
/**
+ * Returns the URL of the image, or an image set of URLs for the profile avatar.
+ * Default avatars have resources available for multiple scalefactors, whereas
+ * the GAIA profile image only comes in one size.
+
+ * @param {string} url The path of the image.
+ * @return {string} The url, or an image set of URLs of the avatar image.
+ */
+function getProfileAvatarIcon(path) {
+ var chromeThemePath = 'chrome://theme';
+ var isDefaultAvatar =
+ (path.slice(0, chromeThemePath.length) == chromeThemePath);
+ return isDefaultAvatar ? imageset(path + '@scalefactorx'): url(path);
+}
+
+/**
* Generates a CSS -webkit-image-set for a chrome:// url.
* An entry in the image set is added for each of getSupportedScaleFactors().
* The scale-factor-specific url is generated by replacing the first instance of