OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 | 6 * @fileoverview |
7 * 'settings-site-list' shows a list of Allowed and Blocked sites for a given | 7 * 'settings-site-list' shows a list of Allowed and Blocked sites for a given |
8 * category. | 8 * category. |
9 */ | 9 */ |
10 Polymer({ | 10 Polymer({ |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 } | 263 } |
264 | 264 |
265 sites.push(exceptionList[i]); | 265 sites.push(exceptionList[i]); |
266 } | 266 } |
267 return sites; | 267 return sites; |
268 }, | 268 }, |
269 | 269 |
270 /** | 270 /** |
271 * Converts a string origin/pattern to a URL. | 271 * Converts a string origin/pattern to a URL. |
272 * @param {string} originOrPattern The origin/pattern to convert to URL. | 272 * @param {string} originOrPattern The origin/pattern to convert to URL. |
273 * @return {!URL} The URL to return (or null if origin is not a valid URL). | 273 * @return {URL} The URL to return (or null if origin is not a valid URL). |
274 * @private | 274 * @private |
275 */ | 275 */ |
276 toUrl_: function(originOrPattern) { | 276 toUrl_: function(originOrPattern) { |
277 if (originOrPattern.length == 0) | 277 if (originOrPattern.length == 0) |
278 return null; | 278 return null; |
279 // TODO(finnur): Hmm, it would probably be better to ensure scheme on the | 279 // TODO(finnur): Hmm, it would probably be better to ensure scheme on the |
280 // JS/C++ boundary. | 280 // JS/C++ boundary. |
281 return new URL( | 281 return new URL( |
282 this.ensureUrlHasScheme(originOrPattern.replace('[*.]', ''))); | 282 this.ensureUrlHasScheme(originOrPattern.replace('[*.]', ''))); |
283 }, | 283 }, |
284 | 284 |
285 /** | 285 /** |
286 * Converts an unordered site list to an ordered array, sorted by site name | 286 * Converts an unordered site list to an ordered array, sorted by site name |
287 * then protocol and de-duped (by origin). | 287 * then protocol and de-duped (by origin). |
288 * @param {!Array<SiteException>} sites A list of sites to sort and de-dup. | 288 * @param {!Array<SiteException>} sites A list of sites to sort and de-dup. |
| 289 * @return {!Array<SiteException>} Sorted and de-duped list. |
289 * @private | 290 * @private |
290 */ | 291 */ |
291 toSiteArray_: function(sites) { | 292 toSiteArray_: function(sites) { |
292 var self = this; | 293 var self = this; |
293 sites.sort(function(a, b) { | 294 sites.sort(function(a, b) { |
294 var url1 = self.toUrl_(a.origin); | 295 var url1 = self.toUrl_(a.origin); |
295 var url2 = self.toUrl_(b.origin); | 296 var url2 = self.toUrl_(b.origin); |
296 var comparison = url1.host.localeCompare(url2.host); | 297 var comparison = url1.host.localeCompare(url2.host); |
297 if (comparison == 0) { | 298 if (comparison == 0) { |
298 comparison = url1.protocol.localeCompare(url2.protocol); | 299 comparison = url1.protocol.localeCompare(url2.protocol); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 * Returns the icon to use for a given site. | 448 * Returns the icon to use for a given site. |
448 * @param {string} url The url of the site to fetch the icon for. | 449 * @param {string} url The url of the site to fetch the icon for. |
449 * @private | 450 * @private |
450 */ | 451 */ |
451 computeSiteIcon_: function(url) { | 452 computeSiteIcon_: function(url) { |
452 // TODO(finnur): For now, we're returning a placeholder image for each site | 453 // TODO(finnur): For now, we're returning a placeholder image for each site |
453 // but the actual favicon for each site will need to be returned. | 454 // but the actual favicon for each site will need to be returned. |
454 return 'communication:message'; | 455 return 'communication:message'; |
455 }, | 456 }, |
456 }); | 457 }); |
OLD | NEW |