| 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 = { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 /** | 179 /** |
| 180 * A utility function to compute the description for the category. | 180 * A utility function to compute the description for the category. |
| 181 * @param {string} category The category to show the description for. | 181 * @param {string} category The category to show the description for. |
| 182 * @param {string} setting The string value of the setting. | 182 * @param {string} setting The string value of the setting. |
| 183 * @param {boolean} showRecommendation Whether to show the '(recommended)' | 183 * @param {boolean} showRecommendation Whether to show the '(recommended)' |
| 184 * label prefix. | 184 * label prefix. |
| 185 * @return {string} The category description. | 185 * @return {string} The category description. |
| 186 * @protected | 186 * @protected |
| 187 */ | 187 */ |
| 188 computeCategoryDesc: function(category, setting, showRecommendation) { | 188 computeCategoryDesc: function(category, setting, showRecommendation) { |
| 189 var categoryEnabled = this.computeIsSettingEnabled(category, setting); | 189 var categoryEnabled = this.computeIsSettingEnabled(setting); |
| 190 switch (category) { | 190 switch (category) { |
| 191 case settings.ContentSettingsTypes.JAVASCRIPT: | 191 case settings.ContentSettingsTypes.JAVASCRIPT: |
| 192 // "Allowed (recommended)" vs "Blocked". | 192 // "Allowed (recommended)" vs "Blocked". |
| 193 if (!categoryEnabled) { | 193 if (!categoryEnabled) { |
| 194 return loadTimeData.getString('siteSettingsBlocked'); | 194 return loadTimeData.getString('siteSettingsBlocked'); |
| 195 } | 195 } |
| 196 return showRecommendation ? | 196 return showRecommendation ? |
| 197 loadTimeData.getString('siteSettingsAllowedRecommended') : | 197 loadTimeData.getString('siteSettingsAllowedRecommended') : |
| 198 loadTimeData.getString('siteSettingsAllowed'); | 198 loadTimeData.getString('siteSettingsAllowed'); |
| 199 case settings.ContentSettingsTypes.POPUPS: | 199 case settings.ContentSettingsTypes.POPUPS: |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 * @return {string} The background-image style with the favicon. | 390 * @return {string} The background-image style with the favicon. |
| 391 * @private | 391 * @private |
| 392 */ | 392 */ |
| 393 computeSiteIcon: function(site) { | 393 computeSiteIcon: function(site) { |
| 394 var url = this.ensureUrlHasScheme(site); | 394 var url = this.ensureUrlHasScheme(site); |
| 395 return 'background-image: ' + cr.icon.getFavicon(url); | 395 return 'background-image: ' + cr.icon.getFavicon(url); |
| 396 }, | 396 }, |
| 397 | 397 |
| 398 /** | 398 /** |
| 399 * Returns true if the passed content setting is considered 'enabled'. | 399 * Returns true if the passed content setting is considered 'enabled'. |
| 400 * @param {string} category | |
| 401 * @param {string} setting | 400 * @param {string} setting |
| 402 * @return {boolean} | 401 * @return {boolean} |
| 403 * @private | 402 * @private |
| 404 */ | 403 */ |
| 405 computeIsSettingEnabled: function(category, setting) { | 404 computeIsSettingEnabled: function(setting) { |
| 406 // FullScreen is Allow vs. Ask. | 405 return setting != settings.PermissionValues.BLOCK; |
| 407 return category == settings.ContentSettingsTypes.FULLSCREEN ? | |
| 408 setting != settings.PermissionValues.ASK : | |
| 409 setting != settings.PermissionValues.BLOCK; | |
| 410 }, | 406 }, |
| 411 | 407 |
| 412 /** | 408 /** |
| 413 * Converts a string origin/pattern to a URL. | 409 * Converts a string origin/pattern to a URL. |
| 414 * @param {string} originOrPattern The origin/pattern to convert to URL. | 410 * @param {string} originOrPattern The origin/pattern to convert to URL. |
| 415 * @return {URL} The URL to return (or null if origin is not a valid URL). | 411 * @return {URL} The URL to return (or null if origin is not a valid URL). |
| 416 * @private | 412 * @private |
| 417 */ | 413 */ |
| 418 toUrl: function(originOrPattern) { | 414 toUrl: function(originOrPattern) { |
| 419 if (originOrPattern.length == 0) | 415 if (originOrPattern.length == 0) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 incognito: exception.incognito, | 451 incognito: exception.incognito, |
| 456 setting: exception.setting, | 452 setting: exception.setting, |
| 457 source: exception.source, | 453 source: exception.source, |
| 458 }; | 454 }; |
| 459 }, | 455 }, |
| 460 | 456 |
| 461 }; | 457 }; |
| 462 | 458 |
| 463 /** @polymerBehavior */ | 459 /** @polymerBehavior */ |
| 464 var SiteSettingsBehavior = [SiteSettingsBehaviorImpl]; | 460 var SiteSettingsBehavior = [SiteSettingsBehaviorImpl]; |
| OLD | NEW |