| 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 Behavior common to Site Settings classes. | 6 * @fileoverview Behavior common to Site Settings classes. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 /** @polymerBehavior */ | 9 /** @polymerBehavior */ |
| 10 var SiteSettingsBehaviorImpl = { | 10 var SiteSettingsBehaviorImpl = { |
| 11 properties: { | 11 properties: { |
| 12 /** | 12 /** |
| 13 * The ID of the category this element is displaying data for. | 13 * The string ID of the category this element is displaying data for. |
| 14 * See site_settings/constants.js for possible values. | 14 * See site_settings/constants.js for possible values. |
| 15 */ | 15 */ |
| 16 category: Number, | 16 category: String, |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * The browser proxy used to retrieve and change information about site | 19 * The browser proxy used to retrieve and change information about site |
| 20 * settings categories and the sites within. | 20 * settings categories and the sites within. |
| 21 * @type {settings.SiteSettingsPrefsBrowserProxyImpl} | 21 * @type {settings.SiteSettingsPrefsBrowserProxyImpl} |
| 22 */ | 22 */ |
| 23 browserProxy: Object, | 23 browserProxy: Object, |
| 24 }, | 24 }, |
| 25 | 25 |
| 26 created: function() { | 26 created: function() { |
| 27 this.browserProxy = | 27 this.browserProxy = |
| 28 settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); | 28 settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); |
| 29 }, | 29 }, |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * Re-sets the category permission for a given origin. | 32 * Re-sets the category permission for a given origin. |
| 33 * @param {string} primaryPattern The primary pattern to reset the permission | 33 * @param {string} primaryPattern The primary pattern to reset the permission |
| 34 * for. | 34 * for. |
| 35 * @param {string} secondaryPattern The secondary pattern to reset the | 35 * @param {string} secondaryPattern The secondary pattern to reset the |
| 36 * permission for. | 36 * permission for. |
| 37 * @param {number} category The category permission to change. | 37 * @param {string} category The category permission to change. |
| 38 * @protected | 38 * @protected |
| 39 */ | 39 */ |
| 40 resetCategoryPermissionForOrigin: function( | 40 resetCategoryPermissionForOrigin: function( |
| 41 primaryPattern, secondaryPattern, category) { | 41 primaryPattern, secondaryPattern, category) { |
| 42 this.browserProxy.resetCategoryPermissionForOrigin( | 42 this.browserProxy.resetCategoryPermissionForOrigin( |
| 43 primaryPattern, secondaryPattern, category); | 43 primaryPattern, secondaryPattern, category); |
| 44 }, | 44 }, |
| 45 | 45 |
| 46 /** | 46 /** |
| 47 * Sets the category permission for a given origin. | 47 * Sets the category permission for a given origin. |
| 48 * @param {string} primaryPattern The primary pattern to change the permission | 48 * @param {string} primaryPattern The primary pattern to change the permission |
| 49 * for. | 49 * for. |
| 50 * @param {string} secondaryPattern The secondary pattern to change the | 50 * @param {string} secondaryPattern The secondary pattern to change the |
| 51 * permission for. | 51 * permission for. |
| 52 * @param {number} category The category permission to change. | 52 * @param {string} category The category permission to change. |
| 53 * @param {string} value What value to set the permission to. | 53 * @param {string} value What value to set the permission to. |
| 54 * @protected | 54 * @protected |
| 55 */ | 55 */ |
| 56 setCategoryPermissionForOrigin: function( | 56 setCategoryPermissionForOrigin: function( |
| 57 primaryPattern, secondaryPattern, category, value) { | 57 primaryPattern, secondaryPattern, category, value) { |
| 58 this.browserProxy.setCategoryPermissionForOrigin( | 58 this.browserProxy.setCategoryPermissionForOrigin( |
| 59 primaryPattern, secondaryPattern, category, value); | 59 primaryPattern, secondaryPattern, category, value); |
| 60 }, | 60 }, |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * A utility function to lookup a category name from its enum. | 63 * A utility function to lookup a category name from its enum. Note: The |
| 64 * @param {number} category The category ID to look up. | 64 * category name is visible to the user as part of the URL. |
| 65 * @param {string} category The category ID to look up. |
| 65 * @return {string} The category found or blank string if not found. | 66 * @return {string} The category found or blank string if not found. |
| 66 * @protected | 67 * @protected |
| 67 */ | 68 */ |
| 68 computeCategoryTextId: function(category) { | 69 computeCategoryTextId: function(category) { |
| 69 switch (category) { | 70 switch (category) { |
| 71 case settings.ContentSettingsTypes.AUTOMATIC_DOWNLOADS: |
| 72 return 'automatic-downloads'; |
| 73 case settings.ContentSettingsTypes.BACKGROUND_SYNC: |
| 74 return 'background-sync'; |
| 70 case settings.ContentSettingsTypes.CAMERA: | 75 case settings.ContentSettingsTypes.CAMERA: |
| 71 return 'camera'; | 76 return 'camera'; |
| 72 case settings.ContentSettingsTypes.COOKIES: | 77 case settings.ContentSettingsTypes.COOKIES: |
| 73 return 'cookies'; | 78 return 'cookies'; |
| 74 case settings.ContentSettingsTypes.GEOLOCATION: | 79 case settings.ContentSettingsTypes.GEOLOCATION: |
| 75 return 'location'; | 80 return 'location'; |
| 76 case settings.ContentSettingsTypes.IMAGES: | 81 case settings.ContentSettingsTypes.IMAGES: |
| 77 return 'images'; | 82 return 'images'; |
| 78 case settings.ContentSettingsTypes.JAVASCRIPT: | 83 case settings.ContentSettingsTypes.JAVASCRIPT: |
| 79 return 'javascript'; | 84 return 'javascript'; |
| 85 case settings.ContentSettingsTypes.KEYGEN: |
| 86 return 'keygen'; |
| 80 case settings.ContentSettingsTypes.MIC: | 87 case settings.ContentSettingsTypes.MIC: |
| 81 return 'microphone'; | 88 return 'microphone'; |
| 82 case settings.ContentSettingsTypes.NOTIFICATIONS: | 89 case settings.ContentSettingsTypes.NOTIFICATIONS: |
| 83 return 'notifications'; | 90 return 'notifications'; |
| 91 case settings.ContentSettingsTypes.PLUGINS: |
| 92 return 'plugins'; |
| 84 case settings.ContentSettingsTypes.POPUPS: | 93 case settings.ContentSettingsTypes.POPUPS: |
| 85 return 'popups'; | 94 return 'popups'; |
| 95 case settings.ContentSettingsTypes.UNSANDBOXED_PLUGINS: |
| 96 return 'unsandboxed-plugins'; |
| 86 default: | 97 default: |
| 87 return ''; | 98 return ''; |
| 88 } | 99 } |
| 89 }, | 100 }, |
| 90 | 101 |
| 91 /** | 102 /** |
| 92 * A utility function to compute the icon to use for the category, both for | 103 * A utility function to compute the icon to use for the category, both for |
| 93 * the overall category as well as the individual permission in the details | 104 * the overall category as well as the individual permission in the details |
| 94 * for a site. | 105 * for a site. |
| 95 * @param {number} category The category to show the icon for. | 106 * @param {string} category The category to show the icon for. |
| 96 * @return {string} The id of the icon for the given category. | 107 * @return {string} The id of the icon for the given category. |
| 97 * @protected | 108 * @protected |
| 98 */ | 109 */ |
| 99 computeIconForContentCategory: function(category) { | 110 computeIconForContentCategory: function(category) { |
| 111 // TODO(finnur): Get missing image assets from designer. |
| 100 switch (category) { | 112 switch (category) { |
| 113 case settings.ContentSettingsTypes.AUTOMATIC_DOWNLOADS: |
| 114 return ''; |
| 115 case settings.ContentSettingsTypes.BACKGROUND_SYNC: |
| 116 return ''; |
| 101 case settings.ContentSettingsTypes.CAMERA: | 117 case settings.ContentSettingsTypes.CAMERA: |
| 102 return 'settings:videocam'; | 118 return 'settings:videocam'; |
| 103 case settings.ContentSettingsTypes.COOKIES: | 119 case settings.ContentSettingsTypes.COOKIES: |
| 104 return 'settings:cookie'; | 120 return 'settings:cookie'; |
| 105 case settings.ContentSettingsTypes.FULLSCREEN: | 121 case settings.ContentSettingsTypes.FULLSCREEN: |
| 106 return 'cr:fullscreen'; | 122 return 'cr:fullscreen'; |
| 107 case settings.ContentSettingsTypes.GEOLOCATION: | 123 case settings.ContentSettingsTypes.GEOLOCATION: |
| 108 return 'settings:location-on'; | 124 return 'settings:location-on'; |
| 109 case settings.ContentSettingsTypes.IMAGES: | 125 case settings.ContentSettingsTypes.IMAGES: |
| 110 return 'settings:photo'; | 126 return 'settings:photo'; |
| 111 case settings.ContentSettingsTypes.JAVASCRIPT: | 127 case settings.ContentSettingsTypes.JAVASCRIPT: |
| 112 return 'settings:input'; | 128 return 'settings:input'; |
| 129 case settings.ContentSettingsTypes.KEYGEN: |
| 130 return ''; |
| 113 case settings.ContentSettingsTypes.MIC: | 131 case settings.ContentSettingsTypes.MIC: |
| 114 return 'settings:mic'; | 132 return 'settings:mic'; |
| 115 case settings.ContentSettingsTypes.NOTIFICATIONS: | 133 case settings.ContentSettingsTypes.NOTIFICATIONS: |
| 116 return 'settings:notifications'; | 134 return 'settings:notifications'; |
| 135 case settings.ContentSettingsTypes.PLUGINS: |
| 136 return ''; |
| 117 case settings.ContentSettingsTypes.POPUPS: | 137 case settings.ContentSettingsTypes.POPUPS: |
| 118 return 'settings:open-in-new'; | 138 return 'settings:open-in-new'; |
| 139 case settings.ContentSettingsTypes.UNSANDBOXED_PLUGINS: |
| 140 return ''; |
| 119 default: | 141 default: |
| 120 assertNotReached('Invalid category: ' + category); | 142 assertNotReached('Invalid category: ' + category); |
| 121 return ''; | 143 return ''; |
| 122 } | 144 } |
| 123 }, | 145 }, |
| 124 | 146 |
| 125 /** | 147 /** |
| 126 * A utility function to compute the title of the category, both for | 148 * A utility function to compute the title of the category, both for |
| 127 * the overall category as well as the individual permission in the details | 149 * the overall category as well as the individual permission in the details |
| 128 * for a site. | 150 * for a site. |
| 129 * @param {number} category The category to show the title for. | 151 * @param {string} category The category to show the title for. |
| 130 * @return {string} The title for the given category. | 152 * @return {string} The title for the given category. |
| 131 * @protected | 153 * @protected |
| 132 */ | 154 */ |
| 133 computeTitleForContentCategory: function(category) { | 155 computeTitleForContentCategory: function(category) { |
| 134 switch (category) { | 156 switch (category) { |
| 157 case settings.ContentSettingsTypes.AUTOMATIC_DOWNLOADS: |
| 158 return loadTimeData.getString('siteSettingsAutomaticDownloads'); |
| 159 case settings.ContentSettingsTypes.BACKGROUND_SYNC: |
| 160 return loadTimeData.getString('siteSettingsBackgroundSync'); |
| 135 case settings.ContentSettingsTypes.CAMERA: | 161 case settings.ContentSettingsTypes.CAMERA: |
| 136 return loadTimeData.getString('siteSettingsCamera'); | 162 return loadTimeData.getString('siteSettingsCamera'); |
| 137 case settings.ContentSettingsTypes.COOKIES: | 163 case settings.ContentSettingsTypes.COOKIES: |
| 138 return loadTimeData.getString('siteSettingsCookies'); | 164 return loadTimeData.getString('siteSettingsCookies'); |
| 139 case settings.ContentSettingsTypes.FULLSCREEN: | 165 case settings.ContentSettingsTypes.FULLSCREEN: |
| 140 return loadTimeData.getString('siteSettingsFullscreen'); | 166 return loadTimeData.getString('siteSettingsFullscreen'); |
| 141 case settings.ContentSettingsTypes.GEOLOCATION: | 167 case settings.ContentSettingsTypes.GEOLOCATION: |
| 142 return loadTimeData.getString('siteSettingsLocation'); | 168 return loadTimeData.getString('siteSettingsLocation'); |
| 143 case settings.ContentSettingsTypes.IMAGES: | 169 case settings.ContentSettingsTypes.IMAGES: |
| 144 return loadTimeData.getString('siteSettingsImages'); | 170 return loadTimeData.getString('siteSettingsImages'); |
| 145 case settings.ContentSettingsTypes.JAVASCRIPT: | 171 case settings.ContentSettingsTypes.JAVASCRIPT: |
| 146 return loadTimeData.getString('siteSettingsJavascript'); | 172 return loadTimeData.getString('siteSettingsJavascript'); |
| 173 case settings.ContentSettingsTypes.KEYGEN: |
| 174 return loadTimeData.getString('siteSettingsKeygen'); |
| 147 case settings.ContentSettingsTypes.MIC: | 175 case settings.ContentSettingsTypes.MIC: |
| 148 return loadTimeData.getString('siteSettingsMic'); | 176 return loadTimeData.getString('siteSettingsMic'); |
| 149 case settings.ContentSettingsTypes.NOTIFICATIONS: | 177 case settings.ContentSettingsTypes.NOTIFICATIONS: |
| 150 return loadTimeData.getString('siteSettingsNotifications'); | 178 return loadTimeData.getString('siteSettingsNotifications'); |
| 179 case settings.ContentSettingsTypes.PLUGINS: |
| 180 return loadTimeData.getString('siteSettingsPlugins'); |
| 151 case settings.ContentSettingsTypes.POPUPS: | 181 case settings.ContentSettingsTypes.POPUPS: |
| 152 return loadTimeData.getString('siteSettingsPopups'); | 182 return loadTimeData.getString('siteSettingsPopups'); |
| 183 case settings.ContentSettingsTypes.UNSANDBOXED_PLUGINS: |
| 184 return loadTimeData.getString('siteSettingsUnsandboxedPlugins'); |
| 153 default: | 185 default: |
| 154 assertNotReached('Invalid category: ' + category); | 186 assertNotReached('Invalid category: ' + category); |
| 155 return ''; | 187 return ''; |
| 156 } | 188 } |
| 157 }, | 189 }, |
| 158 | 190 |
| 159 /** | 191 /** |
| 160 * A utility function to compute the description for the category. | 192 * A utility function to compute the description for the category. |
| 161 * @param {number} category The category to show the description for. | 193 * @param {string} category The category to show the description for. |
| 162 * @param {boolean} categoryEnabled The state of the global toggle. | 194 * @param {boolean} categoryEnabled The state of the global toggle. |
| 163 * @param {boolean} showRecommendation Whether to show the '(recommended)' | 195 * @param {boolean} showRecommendation Whether to show the '(recommended)' |
| 164 * label prefix. | 196 * label prefix. |
| 165 * @return {string} The category description. | 197 * @return {string} The category description. |
| 166 * @protected | 198 * @protected |
| 167 */ | 199 */ |
| 168 computeCategoryDesc: function(category, categoryEnabled, showRecommendation) { | 200 computeCategoryDesc: function(category, categoryEnabled, showRecommendation) { |
| 169 switch (category) { | 201 switch (category) { |
| 170 case settings.ContentSettingsTypes.JAVASCRIPT: | 202 case settings.ContentSettingsTypes.JAVASCRIPT: |
| 171 // "Allowed (recommended)" vs "Blocked". | 203 // "Allowed (recommended)" vs "Blocked". |
| (...skipping 12 matching lines...) Expand all Loading... |
| 184 loadTimeData.getString('siteSettingsBlockedRecommended') : | 216 loadTimeData.getString('siteSettingsBlockedRecommended') : |
| 185 loadTimeData.getString('siteSettingsBlocked'); | 217 loadTimeData.getString('siteSettingsBlocked'); |
| 186 case settings.ContentSettingsTypes.NOTIFICATIONS: | 218 case settings.ContentSettingsTypes.NOTIFICATIONS: |
| 187 // "Ask before sending (recommended)" vs "Blocked". | 219 // "Ask before sending (recommended)" vs "Blocked". |
| 188 if (!categoryEnabled) { | 220 if (!categoryEnabled) { |
| 189 return loadTimeData.getString('siteSettingsBlocked'); | 221 return loadTimeData.getString('siteSettingsBlocked'); |
| 190 } | 222 } |
| 191 return showRecommendation ? | 223 return showRecommendation ? |
| 192 loadTimeData.getString('siteSettingsAskBeforeSendingRecommended') : | 224 loadTimeData.getString('siteSettingsAskBeforeSendingRecommended') : |
| 193 loadTimeData.getString('siteSettingsAskBeforeSending'); | 225 loadTimeData.getString('siteSettingsAskBeforeSending'); |
| 226 case settings.ContentSettingsTypes.CAMERA: |
| 194 case settings.ContentSettingsTypes.GEOLOCATION: | 227 case settings.ContentSettingsTypes.GEOLOCATION: |
| 195 case settings.ContentSettingsTypes.CAMERA: | |
| 196 case settings.ContentSettingsTypes.MIC: | 228 case settings.ContentSettingsTypes.MIC: |
| 197 // "Ask before accessing (recommended)" vs "Blocked". | 229 // "Ask before accessing (recommended)" vs "Blocked". |
| 198 if (!categoryEnabled) { | 230 if (!categoryEnabled) { |
| 199 return loadTimeData.getString('siteSettingsBlocked'); | 231 return loadTimeData.getString('siteSettingsBlocked'); |
| 200 } | 232 } |
| 201 return showRecommendation ? | 233 return showRecommendation ? |
| 202 loadTimeData.getString( | 234 loadTimeData.getString( |
| 203 'siteSettingsAskBeforeAccessingRecommended') : | 235 'siteSettingsAskBeforeAccessingRecommended') : |
| 204 loadTimeData.getString('siteSettingsAskBeforeAccessing'); | 236 loadTimeData.getString('siteSettingsAskBeforeAccessing'); |
| 205 case settings.ContentSettingsTypes.COOKIES: | 237 case settings.ContentSettingsTypes.COOKIES: |
| 206 // "Allow sites to save and read cookie data" vs "Blocked". | 238 // "Allow sites to save and read cookie data" vs "Blocked". |
| 207 if (!categoryEnabled) { | 239 if (!categoryEnabled) { |
| 208 return loadTimeData.getString('siteSettingsBlocked'); | 240 return loadTimeData.getString('siteSettingsBlocked'); |
| 209 } | 241 } |
| 210 return showRecommendation ? | 242 return showRecommendation ? |
| 211 loadTimeData.getString('siteSettingsCookiesAllowedRecommended') : | 243 loadTimeData.getString('siteSettingsCookiesAllowedRecommended') : |
| 212 loadTimeData.getString('siteSettingsCookiesAllowed'); | 244 loadTimeData.getString('siteSettingsCookiesAllowed'); |
| 213 case settings.ContentSettingsTypes.IMAGES: | 245 case settings.ContentSettingsTypes.IMAGES: |
| 214 if (!categoryEnabled) { | 246 if (!categoryEnabled) { |
| 215 return loadTimeData.getString('siteSettingsDontShowImages'); | 247 return loadTimeData.getString('siteSettingsDontShowImages'); |
| 216 } | 248 } |
| 217 return showRecommendation ? | 249 return showRecommendation ? |
| 218 loadTimeData.getString('siteSettingsShowAllRecommended') : | 250 loadTimeData.getString('siteSettingsShowAllRecommended') : |
| 219 loadTimeData.getString('siteSettingsShowAll'); | 251 loadTimeData.getString('siteSettingsShowAll'); |
| 252 case settings.ContentSettingsTypes.PLUGINS: |
| 253 // "Detect and run important content (recommended)" vs "Let me choose". |
| 254 if (!categoryEnabled) { |
| 255 return loadTimeData.getString('siteSettingsLetMeChoose'); |
| 256 } |
| 257 return showRecommendation ? |
| 258 loadTimeData.getString( |
| 259 'siteSettingsDetectAndRunImportantRecommended') : |
| 260 loadTimeData.getString('siteSettingsDetectAndRunImportant'); |
| 261 case settings.ContentSettingsTypes.BACKGROUND_SYNC: |
| 262 // "Allow sites to finish sending and receiving data" vs "Do not allow". |
| 263 if (!categoryEnabled) { |
| 264 return loadTimeData.getString('siteSettingsBackgroundSyncBlocked'); |
| 265 } |
| 266 return showRecommendation ? |
| 267 loadTimeData.getString( |
| 268 'siteSettingsAllowRecentlyClosedSitesRecommended') : |
| 269 loadTimeData.getString('siteSettingsAllowRecentlyClosedSites'); |
| 270 case settings.ContentSettingsTypes.KEYGEN: |
| 271 // "Allow sites to use keygen" vs "Do not allow". |
| 272 if (categoryEnabled) { |
| 273 return loadTimeData.getString('siteSettingsKeygenAllow'); |
| 274 } |
| 275 return showRecommendation ? |
| 276 loadTimeData.getString('siteSettingsKeygenBlockRecommended') : |
| 277 loadTimeData.getString('siteSettingsKeygenBlock'); |
| 278 case settings.ContentSettingsTypes.AUTOMATIC_DOWNLOADS: |
| 279 // "Ask when a site wants to auto-download multiple" vs "Do not allow". |
| 280 if (!categoryEnabled) { |
| 281 return loadTimeData.getString('siteSettingsAutoDownloadBlock'); |
| 282 } |
| 283 return showRecommendation ? |
| 284 loadTimeData.getString('siteSettingsAutoDownloadAskRecommended') : |
| 285 loadTimeData.getString('siteSettingsAutoDownloadAsk'); |
| 286 case settings.ContentSettingsTypes.UNSANDBOXED_PLUGINS: |
| 287 // "Ask when a plugin accesses your computer" vs "Do not allow". |
| 288 if (!categoryEnabled) { |
| 289 return loadTimeData.getString('siteSettingsUnsandboxedPluginsBlock'); |
| 290 } |
| 291 return showRecommendation ? |
| 292 loadTimeData.getString( |
| 293 'siteSettingsUnsandboxedPluginsAskRecommended') : |
| 294 loadTimeData.getString('siteSettingsUnsandboxedPluginsAsk'); |
| 220 default: | 295 default: |
| 221 assertNotReached(); | 296 assertNotReached(); |
| 222 return ''; | 297 return ''; |
| 223 } | 298 } |
| 224 }, | 299 }, |
| 225 | 300 |
| 226 /** | 301 /** |
| 227 * Ensures the URL has a scheme (assumes http if omitted). | 302 * Ensures the URL has a scheme (assumes http if omitted). |
| 228 * @param {string} url The URL with or without a scheme. | 303 * @param {string} url The URL with or without a scheme. |
| 229 * @return {string} The URL with a scheme, or an empty string. | 304 * @return {string} The URL with a scheme, or an empty string. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 245 return url.slice(0, -4); | 320 return url.slice(0, -4); |
| 246 } | 321 } |
| 247 if (urlWithScheme.startsWith('http://') && | 322 if (urlWithScheme.startsWith('http://') && |
| 248 urlWithScheme.endsWith(':80')) { | 323 urlWithScheme.endsWith(':80')) { |
| 249 return url.slice(0, -3); | 324 return url.slice(0, -3); |
| 250 } | 325 } |
| 251 return url; | 326 return url; |
| 252 }, | 327 }, |
| 253 | 328 |
| 254 /** | 329 /** |
| 330 * Adds the wildcard prefix to a pattern string. |
| 331 * @param {string} pattern The pattern to add the wildcard to. |
| 332 * @return {string} The resulting pattern. |
| 333 * @private |
| 334 */ |
| 335 addPatternWildcard_: function(pattern) { |
| 336 if (pattern.startsWith('http://')) |
| 337 return pattern.replace('http://', 'http://[*.]'); |
| 338 else if (pattern.startsWith('https://')) |
| 339 return pattern.replace('https://', 'https://[*.]'); |
| 340 else |
| 341 return '[*.]' + pattern; |
| 342 }, |
| 343 |
| 344 /** |
| 345 * Removes the wildcard prefix from a pattern string. |
| 346 * @param {string} pattern The pattern to remove the wildcard from. |
| 347 * @return {string} The resulting pattern. |
| 348 * @private |
| 349 */ |
| 350 removePatternWildcard_: function(pattern) { |
| 351 if (pattern.startsWith('http://[*.]')) |
| 352 return pattern.replace('http://[*.]', 'http://'); |
| 353 else if (pattern.startsWith('https://[*.]')) |
| 354 return pattern.replace('https://[*.]', 'https://'); |
| 355 else if (pattern.startsWith('[*.]')) |
| 356 return pattern.substring(4, pattern.length); |
| 357 return pattern; |
| 358 }, |
| 359 |
| 360 /** |
| 255 * Returns the icon to use for a given site. | 361 * Returns the icon to use for a given site. |
| 256 * @param {SiteException} site The url of the site to fetch the icon for. | 362 * @param {SiteException} site The url of the site to fetch the icon for. |
| 257 * @return {string} The background-image style with the favicon. | 363 * @return {string} The background-image style with the favicon. |
| 258 * @private | 364 * @private |
| 259 */ | 365 */ |
| 260 computeSiteIcon: function(site) { | 366 computeSiteIcon: function(site) { |
| 261 var url = this.ensureUrlHasScheme(site.originForDisplay); | 367 var url = this.ensureUrlHasScheme(site.originForDisplay); |
| 262 return 'background-image: ' + cr.icon.getFaviconImageSet(url); | 368 return 'background-image: ' + cr.icon.getFaviconImageSet(url); |
| 263 }, | 369 }, |
| 264 }; | 370 }; |
| 265 | 371 |
| 266 /** @polymerBehavior */ | 372 /** @polymerBehavior */ |
| 267 var SiteSettingsBehavior = [SiteSettingsBehaviorImpl]; | 373 var SiteSettingsBehavior = [SiteSettingsBehaviorImpl]; |
| OLD | NEW |