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

Side by Side Diff: ios/web/webui/resources/web_ui_favicons.js

Issue 2583963002: Remove WebUI favicon support on iOS (Closed)
Patch Set: Remove web_ui_favicons.js from BUILD.gn Created 4 years 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 unified diff | Download patch
« no previous file with comments | « ios/web/webui/resources/web_ui_bundle.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This file adheres to closure-compiler conventions in order to enable
6 // compilation with ADVANCED_OPTIMIZATIONS. In particular, members that are to
7 // be accessed externally should be specified in this['style'] as opposed to
8 // this.style because member identifiers are minified by default.
9 // See http://goo.gl/FwOgy
10
11 goog.require('__crWeb.webUIBase');
12
13 goog.provide('__crWeb.webUIFavicons');
14
15 /**
16 * Sends message requesting favicon at the URL from imageSet for el. Sets
17 * favicon-url attribute on el to the favicon URL.
18 * @param {Element} el The DOM element to request the favicon for.
19 * @param {string} imageSet The CSS -webkit-image-set.
20 */
21 window['chrome']['requestFavicon'] = function(el, imageSet) {
22 var cssUrls = imageSet.match(/url\([^\)]+\) \dx/g);
23 // TODO(jyquinn): Review match above (crbug.com/528080).
24 if (!cssUrls) {
25 return;
26 }
27 // Extract url from CSS -webkit-image-set.
28 var faviconUrl = '';
29 for (var i = 0; i < cssUrls.length; ++i) {
30 var scaleFactorExp = /(\d)x$/;
31 var scaleFactor = window.devicePixelRatio;
32 if (parseInt(scaleFactorExp.exec(cssUrls[i])[1], 10) === scaleFactor) {
33 var urlExp = /url\(\"(.+)\"\)/;
34 faviconUrl = urlExp.exec(cssUrls[i])[1];
35 break;
36 }
37 }
38 el.setAttribute('favicon-url', url(faviconUrl));
39 chrome.send('webui.requestFavicon', [faviconUrl]);
40 };
41
42 /**
43 * Called to set elements with favicon-url attribute equal to faviconUrl to
44 * provided dataUrl.
45 * @param {string} faviconUrl Favicon URL used to locate favicon element
46 * via the favicon-url attribute.
47 * @param {string} dataUrl The data URL to assign to the favicon element's
48 * backgroundImage.
49 */
50 window['chrome']['setFaviconBackground'] = function(faviconUrl, dataUrl) {
51 var selector = "[favicon-url='" + url(faviconUrl) + "']";
52 var elements = document.querySelectorAll(selector);
53 for (var i = 0; i < elements.length; ++i) {
54 elements[i].style.backgroundImage = url(dataUrl);
55 }
56 };
OLDNEW
« no previous file with comments | « ios/web/webui/resources/web_ui_bundle.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698