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

Side by Side Diff: chrome/browser/resources/md_downloads/crisper.js

Issue 1947533002: Material WebUI: create shared icon file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase fix Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/md_downloads/toolbar.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 /** 5 /**
6 * @fileoverview Assertion support. 6 * @fileoverview Assertion support.
7 */ 7 */
8 8
9 /** 9 /**
10 * Verify |condition| is truthy and return |condition| if so. 10 * Verify |condition| is truthy and return |condition| if so.
(...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 */ 1461 */
1462 function appendParam(url, key, value) { 1462 function appendParam(url, key, value) {
1463 var param = encodeURIComponent(key) + '=' + encodeURIComponent(value); 1463 var param = encodeURIComponent(key) + '=' + encodeURIComponent(value);
1464 1464
1465 if (url.indexOf('?') == -1) 1465 if (url.indexOf('?') == -1)
1466 return url + '?' + param; 1466 return url + '?' + param;
1467 return url + '&' + param; 1467 return url + '&' + param;
1468 } 1468 }
1469 1469
1470 /** 1470 /**
1471 * A regular expression for identifying favicon URLs.
1472 * @const {!RegExp}
1473 * TODO(dpapad): Move all favicon related methods to a new favicon_util.js file
1474 * and make this RegExp private.
1475 */
1476 var FAVICON_URL_REGEX = /\.ico$/i;
1477
1478 /**
1471 * Creates a CSS -webkit-image-set for a favicon request. 1479 * Creates a CSS -webkit-image-set for a favicon request.
1472 * @param {string} url The url for the favicon. 1480 * @param {string} url Either the URL of the original page or of the favicon
1481 * itself.
1473 * @param {number=} opt_size Optional preferred size of the favicon. 1482 * @param {number=} opt_size Optional preferred size of the favicon.
1474 * @param {string=} opt_type Optional type of favicon to request. Valid values 1483 * @param {string=} opt_type Optional type of favicon to request. Valid values
1475 * are 'favicon' and 'touch-icon'. Default is 'favicon'. 1484 * are 'favicon' and 'touch-icon'. Default is 'favicon'.
1476 * @return {string} -webkit-image-set for the favicon. 1485 * @return {string} -webkit-image-set for the favicon.
1477 */ 1486 */
1478 function getFaviconImageSet(url, opt_size, opt_type) { 1487 function getFaviconImageSet(url, opt_size, opt_type) {
1479 var size = opt_size || 16; 1488 var size = opt_size || 16;
1480 var type = opt_type || 'favicon'; 1489 var type = opt_type || 'favicon';
1490
1481 return imageset( 1491 return imageset(
1482 'chrome://' + type + '/size/' + size + '@scalefactorx/' + url); 1492 'chrome://' + type + '/size/' + size + '@scalefactorx/' +
1493 // Note: Literal 'iconurl' must match |kIconURLParameter| in
1494 // components/favicon_base/favicon_url_parser.cc.
1495 (FAVICON_URL_REGEX.test(url) ? 'iconurl/' : '') + url);
1483 } 1496 }
1484 1497
1485 /** 1498 /**
1486 * Creates a new URL for a favicon request for the current device pixel ratio.
1487 * The URL must be updated when the user moves the browser to a screen with a
1488 * different device pixel ratio. Use getFaviconImageSet() for the updating to
1489 * occur automatically.
1490 * @param {string} url The url for the favicon.
1491 * @param {number=} opt_size Optional preferred size of the favicon.
1492 * @param {string=} opt_type Optional type of favicon to request. Valid values
1493 * are 'favicon' and 'touch-icon'. Default is 'favicon'.
1494 * @return {string} Updated URL for the favicon.
1495 */
1496 function getFaviconUrlForCurrentDevicePixelRatio(url, opt_size, opt_type) {
1497 var size = opt_size || 16;
1498 var type = opt_type || 'favicon';
1499 return 'chrome://' + type + '/size/' + size + '@' +
1500 window.devicePixelRatio + 'x/' + url;
1501 }
1502
1503 /**
1504 * Creates an element of a specified type with a specified class name. 1499 * Creates an element of a specified type with a specified class name.
1505 * @param {string} type The node type. 1500 * @param {string} type The node type.
1506 * @param {string} className The class name to use. 1501 * @param {string} className The class name to use.
1507 * @return {Element} The created element. 1502 * @return {Element} The created element.
1508 */ 1503 */
1509 function createElementWithClassName(type, className) { 1504 function createElementWithClassName(type, className) {
1510 var elm = document.createElement(type); 1505 var elm = document.createElement(type);
1511 elm.className = className; 1506 elm.className = className;
1512 return elm; 1507 return elm;
1513 } 1508 }
(...skipping 9862 matching lines...) Expand 10 before | Expand all | Expand 10 after
11376 Manager.get().updateItem_(index, data); 11371 Manager.get().updateItem_(index, data);
11377 }; 11372 };
11378 11373
11379 return {Manager: Manager}; 11374 return {Manager: Manager};
11380 }); 11375 });
11381 // Copyright 2015 The Chromium Authors. All rights reserved. 11376 // Copyright 2015 The Chromium Authors. All rights reserved.
11382 // Use of this source code is governed by a BSD-style license that can be 11377 // Use of this source code is governed by a BSD-style license that can be
11383 // found in the LICENSE file. 11378 // found in the LICENSE file.
11384 11379
11385 window.addEventListener('load', downloads.Manager.onLoad); 11380 window.addEventListener('load', downloads.Manager.onLoad);
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/md_downloads/toolbar.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698