| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 cr.define('cr.icon', function() { | 5 cr.define('cr.icon', function() { |
| 6 /** | 6 /** |
| 7 * @return {!Array<number>} The scale factors supported by this platform for | 7 * @return {!Array<number>} The scale factors supported by this platform for |
| 8 * webui resources. | 8 * webui resources. |
| 9 */ | 9 */ |
| 10 function getSupportedScaleFactors() { | 10 function getSupportedScaleFactors() { |
| 11 var supportedScaleFactors = []; | 11 var supportedScaleFactors = []; |
| 12 if (!cr.isIOS) { |
| 13 // This matches the code in ResourceBundle::InitSharedInstance() that |
| 14 // supports SCALE_FACTOR_100P on all non-iOS platforms. |
| 15 supportedScaleFactors.push(1); |
| 16 } |
| 12 if (cr.isMac || cr.isChromeOS || cr.isWindows || cr.isLinux) { | 17 if (cr.isMac || cr.isChromeOS || cr.isWindows || cr.isLinux) { |
| 13 // All desktop platforms support zooming which also updates the | 18 // All desktop platforms support zooming which also updates the renderer's |
| 14 // renderer's device scale factors (a.k.a devicePixelRatio), and | 19 // device scale factors (a.k.a devicePixelRatio), and these platforms have |
| 15 // these platforms has high DPI assets for 2.0x. Use 1x and 2x in | 20 // high DPI assets for 2x. Let the renderer pick the closest image for |
| 16 // image-set on these platforms so that the renderer can pick the | 21 // the current device scale factor. |
| 17 // closest image for the current device scale factor. | |
| 18 supportedScaleFactors.push(1); | |
| 19 supportedScaleFactors.push(2); | 22 supportedScaleFactors.push(2); |
| 20 } else { | 23 } else { |
| 21 // For other platforms that use fixed device scale factor, use | 24 // For other platforms that use fixed device scale factor, use |
| 22 // the window's device pixel ratio. | 25 // the window's device pixel ratio. |
| 23 // TODO(oshima): Investigate if Android/iOS need to use image-set. | 26 // TODO(oshima): Investigate corresponding to |
| 27 // ResourceBundle::InitSharedInstance() more closely. |
| 24 supportedScaleFactors.push(window.devicePixelRatio); | 28 supportedScaleFactors.push(window.devicePixelRatio); |
| 25 } | 29 } |
| 26 return supportedScaleFactors; | 30 return supportedScaleFactors; |
| 27 } | 31 } |
| 28 | 32 |
| 29 /** | 33 /** |
| 30 * Returns the URL of the image, or an image set of URLs for the profile | 34 * Returns the URL of the image, or an image set of URLs for the profile |
| 31 * avatar. Default avatars have resources available for multiple scalefactors, | 35 * avatar. Default avatars have resources available for multiple scalefactors, |
| 32 * whereas the GAIA profile image only comes in one size. | 36 * whereas the GAIA profile image only comes in one size. |
| 33 * | 37 * |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // components/favicon_base/favicon_url_parser.cc. | 100 // components/favicon_base/favicon_url_parser.cc. |
| 97 (FAVICON_URL_REGEX.test(url) ? 'iconurl/' : '') + url); | 101 (FAVICON_URL_REGEX.test(url) ? 'iconurl/' : '') + url); |
| 98 } | 102 } |
| 99 | 103 |
| 100 return { | 104 return { |
| 101 getSupportedScaleFactors: getSupportedScaleFactors, | 105 getSupportedScaleFactors: getSupportedScaleFactors, |
| 102 getProfileAvatarIcon: getProfileAvatarIcon, | 106 getProfileAvatarIcon: getProfileAvatarIcon, |
| 103 getFaviconImageSet: getFaviconImageSet, | 107 getFaviconImageSet: getFaviconImageSet, |
| 104 }; | 108 }; |
| 105 }); | 109 }); |
| OLD | NEW |