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