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 82a4e50328d9af214dfc00c0ea84eed786be8a7f..12d91ba9a5998f08aca95ce8086b891dd854e96f 100644 |
| --- a/ui/webui/resources/js/util.js |
| +++ b/ui/webui/resources/js/util.js |
| @@ -325,8 +325,17 @@ function appendParam(url, key, value) { |
| } |
| /** |
| + * A regular expression for identifying favicon URLs. |
| + * @const {!RegExp} |
| + * TODO(dpapad): Move all favicon related methods to a new favicon_util.js file |
| + * and make this RegExp private. |
| + */ |
| +var FAVICON_URL_REGEX = /\.ico$/; |
|
Dan Beam
2016/04/27 02:18:31
nit: /i
dpapad
2016/04/27 17:21:47
Are you suggesting modifying the regex to /ico$/?
dpapad
2016/04/27 17:24:25
On second thought, you probably meant adding /i at
Dan Beam
2016/04/27 18:46:56
yes, that ^
|
| + |
| +/** |
| * Creates a CSS -webkit-image-set for a favicon request. |
| - * @param {string} url The url for the favicon. |
| + * @param {string} url Either the URL of the original page or of the favicon |
| + * itself. |
| * @param {number=} opt_size Optional preferred size of the favicon. |
| * @param {string=} opt_type Optional type of favicon to request. Valid values |
| * are 'favicon' and 'touch-icon'. Default is 'favicon'. |
| @@ -335,8 +344,14 @@ function appendParam(url, key, value) { |
| function getFaviconImageSet(url, opt_size, opt_type) { |
| var size = opt_size || 16; |
| var type = opt_type || 'favicon'; |
| + |
| + // Note: Literals 'iconurl' and 'origin' must match |kIconURLParameter| and |
| + // |kOriginParameter| in components/favicon_base/favicon_url_parser.cc. |
| + var urlType = FAVICON_URL_REGEX.test(url) ? 'iconurl' : 'origin'; |
| + |
| return imageset( |
| - 'chrome://' + type + '/size/' + size + '@scalefactorx/' + url); |
| + 'chrome://' + type + '/size/' + size + '@scalefactorx/' + |
| + urlType + '/' + url); |
| } |
| /** |