Commit 901f82e9 authored by noms@chromium.org's avatar noms@chromium.org

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
parent f947f00d
......@@ -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
};
});
......@@ -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));
......
......@@ -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.
......
......@@ -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
};
});
......@@ -74,6 +74,21 @@ function url(s) {
return 'url("' + s2 + '")';
}
/**
* 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().
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment