OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |