Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: ui/webui/resources/js/util.js

Issue 183893028: Use a correct scale factor for Gaia avatar images (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: only return an imageset for an actual image set Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/options/profiles_icon_grid.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 <include src="assert.js"> 5 <include src="assert.js">
6 6
7 /** 7 /**
8 * The global object. 8 * The global object.
9 * @type {!Object} 9 * @type {!Object}
10 * @const 10 * @const
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // WebKit has a bug when it comes to URLs that end with \ 68 // WebKit has a bug when it comes to URLs that end with \
69 // https://bugs.webkit.org/show_bug.cgi?id=28885 69 // https://bugs.webkit.org/show_bug.cgi?id=28885
70 if (/\\\\$/.test(s2)) { 70 if (/\\\\$/.test(s2)) {
71 // Add a space to work around the WebKit bug. 71 // Add a space to work around the WebKit bug.
72 s2 += ' '; 72 s2 += ' ';
73 } 73 }
74 return 'url("' + s2 + '")'; 74 return 'url("' + s2 + '")';
75 } 75 }
76 76
77 /** 77 /**
78 * Returns the URL of the image, or an image set of URLs for the profile avatar.
79 * Default avatars have resources available for multiple scalefactors, whereas
80 * the GAIA profile image only comes in one size.
81
82 * @param {string} url The path of the image.
83 * @return {string} The url, or an image set of URLs of the avatar image.
84 */
85 function getProfileAvatarIcon(path) {
86 var chromeThemePath = 'chrome://theme';
87 var isDefaultAvatar =
88 (path.slice(0, chromeThemePath.length) == chromeThemePath);
89 return isDefaultAvatar ? imageset(path + '@scalefactorx'): url(path);
90 }
91
92 /**
78 * Generates a CSS -webkit-image-set for a chrome:// url. 93 * Generates a CSS -webkit-image-set for a chrome:// url.
79 * An entry in the image set is added for each of getSupportedScaleFactors(). 94 * An entry in the image set is added for each of getSupportedScaleFactors().
80 * The scale-factor-specific url is generated by replacing the first instance of 95 * The scale-factor-specific url is generated by replacing the first instance of
81 * 'scalefactor' in |path| with the numeric scale factor. 96 * 'scalefactor' in |path| with the numeric scale factor.
82 * @param {string} path The URL to generate an image set for. 97 * @param {string} path The URL to generate an image set for.
83 * 'scalefactor' should be a substring of |path|. 98 * 'scalefactor' should be a substring of |path|.
84 * @return {string} The CSS -webkit-image-set. 99 * @return {string} The CSS -webkit-image-set.
85 */ 100 */
86 function imageset(path) { 101 function imageset(path) {
87 var supportedScaleFactors = getSupportedScaleFactors(); 102 var supportedScaleFactors = getSupportedScaleFactors();
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 * @param {number} maxLength The maximum length allowed for the string. 417 * @param {number} maxLength The maximum length allowed for the string.
403 * @return {string} The original string if its length does not exceed 418 * @return {string} The original string if its length does not exceed
404 * |maxLength|. Otherwise the first |maxLength| - 1 characters with '...' 419 * |maxLength|. Otherwise the first |maxLength| - 1 characters with '...'
405 * appended. 420 * appended.
406 */ 421 */
407 function elide(original, maxLength) { 422 function elide(original, maxLength) {
408 if (original.length <= maxLength) 423 if (original.length <= maxLength)
409 return original; 424 return original;
410 return original.substring(0, maxLength - 1) + '\u2026'; 425 return original.substring(0, maxLength - 1) + '\u2026';
411 } 426 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/profiles_icon_grid.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698