| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // <include src="assert.js"> | 5 // <include src="assert.js"> |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Alias for document.getElementById. Found elements must be HTMLElements. | 8 * Alias for document.getElementById. Found elements must be HTMLElements. |
| 9 * @param {string} id The ID of the element to find. | 9 * @param {string} id The ID of the element to find. |
| 10 * @return {HTMLElement} The found element or null if not found. | 10 * @return {HTMLElement} The found element or null if not found. |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 * itself. | 338 * itself. |
| 339 * @param {number=} opt_size Optional preferred size of the favicon. | 339 * @param {number=} opt_size Optional preferred size of the favicon. |
| 340 * @param {string=} opt_type Optional type of favicon to request. Valid values | 340 * @param {string=} opt_type Optional type of favicon to request. Valid values |
| 341 * are 'favicon' and 'touch-icon'. Default is 'favicon'. | 341 * are 'favicon' and 'touch-icon'. Default is 'favicon'. |
| 342 * @return {string} -webkit-image-set for the favicon. | 342 * @return {string} -webkit-image-set for the favicon. |
| 343 */ | 343 */ |
| 344 function getFaviconImageSet(url, opt_size, opt_type) { | 344 function getFaviconImageSet(url, opt_size, opt_type) { |
| 345 var size = opt_size || 16; | 345 var size = opt_size || 16; |
| 346 var type = opt_type || 'favicon'; | 346 var type = opt_type || 'favicon'; |
| 347 | 347 |
| 348 // Note: Literals 'iconurl' and 'origin' must match |kIconURLParameter| and | |
| 349 // |kOriginParameter| in components/favicon_base/favicon_url_parser.cc. | |
| 350 var urlType = FAVICON_URL_REGEX.test(url) ? 'iconurl' : 'origin'; | |
| 351 | |
| 352 return imageset( | 348 return imageset( |
| 353 'chrome://' + type + '/size/' + size + '@scalefactorx/' + | 349 'chrome://' + type + '/size/' + size + '@scalefactorx/' + |
| 354 urlType + '/' + url); | 350 // Note: Literal 'iconurl' must match |kIconURLParameter| in |
| 351 // components/favicon_base/favicon_url_parser.cc. |
| 352 (FAVICON_URL_REGEX.test(url) ? 'iconurl/' : '') + url); |
| 355 } | 353 } |
| 356 | 354 |
| 357 /** | 355 /** |
| 358 * Creates an element of a specified type with a specified class name. | 356 * Creates an element of a specified type with a specified class name. |
| 359 * @param {string} type The node type. | 357 * @param {string} type The node type. |
| 360 * @param {string} className The class name to use. | 358 * @param {string} className The class name to use. |
| 361 * @return {Element} The created element. | 359 * @return {Element} The created element. |
| 362 */ | 360 */ |
| 363 function createElementWithClassName(type, className) { | 361 function createElementWithClassName(type, className) { |
| 364 var elm = document.createElement(type); | 362 var elm = document.createElement(type); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 } | 462 } |
| 465 | 463 |
| 466 /** | 464 /** |
| 467 * Quote a string so it can be used in a regular expression. | 465 * Quote a string so it can be used in a regular expression. |
| 468 * @param {string} str The source string. | 466 * @param {string} str The source string. |
| 469 * @return {string} The escaped string. | 467 * @return {string} The escaped string. |
| 470 */ | 468 */ |
| 471 function quoteString(str) { | 469 function quoteString(str) { |
| 472 return str.replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g, '\\$1'); | 470 return str.replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g, '\\$1'); |
| 473 } | 471 } |
| OLD | NEW |