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

Unified Diff: ui/webui/resources/js/util.js

Issue 1914073005: Make getFaviconImageSet work with all expected URL types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: case insensitive Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/webui/webui_resource_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f65e6504554762f34de38c32c4645aa790f59028 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$/i;
+
+/**
* 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);
}
/**
« no previous file with comments | « chrome/test/data/webui/webui_resource_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698