Chromium Code Reviews| Index: ui/webui/resources/js/util.js |
| diff --git a/ui/webui/resources/js/util.js b/ui/webui/resources/js/util.js |
| index 3907c5215aa302660dd221706cfda9e6028ea6c0..b509fb1537d94c3f4cf14ead407e7cc4010d47fc 100644 |
| --- a/ui/webui/resources/js/util.js |
| +++ b/ui/webui/resources/js/util.js |
| @@ -346,6 +346,46 @@ function getFaviconImageSet(url, opt_size, opt_type) { |
| } |
| /** |
| + * Creates a CSS -webkit-image-set based on whether the url is secure. |
| + * @param {string} url The url for the icon. |
| + * @param {boolean} isUrlSecure True if the url is secure. |
| + * @return {string} -webkit-image-set for the icon. |
| + */ |
| +function getIconBasedOnUrlSecurity(url, isUrlSecure) { |
| + return isUrlSecure ? |
| + getLargeiconOrFallbackIconImageSet(url, 16) : |
| + getFaviconImageSet('', 16); |
|
pkotwicz
2015/10/15 15:44:26
This code confuses me.
Here is my understanding o
kolos1
2015/10/15 20:22:46
If the url is insecure, we show 'blank' icon.
If
pkotwicz
2015/10/15 21:10:55
Sorry for my misunderstanding. I think that we sho
kolos1
2015/10/16 14:19:26
Thanks for your advices.
Could you share your op
|
| +} |
| + |
| +/** |
| + * Creates a CSS -webkit-image-set for a large icon request. The service |
| + * chrome://large-icon/ return a fallback icon, if there is no available icon. |
| + * @param(string) path The url for the large icon. |
| + * @param {number=} opt_size Optional preferred size of the large icon. |
| + * @return {string} -webkit-image-set for the large icon. |
| + */ |
| +function getLargeiconOrFallbackIconImageSet(path, opt_size) { |
| + // Description of fallback icon's parameters can be found in |
| + // chrome/browser/ui/webui/fallback_icon_source.h. |
| + // The first parameter is ignored, since the size of icon should be defined in |
| + // the following way 'chrome://large-icon/size/...'. |
| + var fallback_icon_parameters = 'fallback/,777,FFF,0.625,0.4/'; |
| + var size = opt_size || 16; |
| + var supportedScaleFactors = getSupportedScaleFactors(); |
| + var result = ''; |
| + for (var i = 0; i < supportedScaleFactors.length; ++i) { |
| + var scaleFactor = supportedScaleFactors[i]; |
| + var scaledSize = Math.round(size * scaleFactor); |
| + var large_icon = 'chrome://large-icon/' + scaledSize + '/' + |
| + fallback_icon_parameters + path; |
| + result += url(large_icon) + ' ' + scaleFactor + 'x'; |
| + if (i != supportedScaleFactors.length - 1) |
| + result += ', '; |
| + } |
| + return '-webkit-image-set(' + result + ')'; |
| +} |
| + |
| +/** |
| * Creates a new URL for a favicon request for the current device pixel ratio. |
| * The URL must be updated when the user moves the browser to a screen with a |
| * different device pixel ratio. Use getFaviconImageSet() for the updating to |