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 | 6 * @fileoverview |
| 7 * 'settings-site-settings-page' is the settings page containing privacy and | 7 * 'settings-site-settings-page' is the settings page containing privacy and |
| 8 * security site settings. | 8 * security site settings. |
| 9 */ | 9 */ |
| 10 | |
|
tommycli
2017/01/27 00:36:52
nit: this was on purpose i assume?
dschuyler
2017/01/27 22:29:17
Acknowledged.
| |
| 10 Polymer({ | 11 Polymer({ |
| 11 is: 'settings-site-settings-page', | 12 is: 'settings-site-settings-page', |
| 12 | 13 |
| 13 behaviors: [SiteSettingsBehavior, WebUIListenerBehavior], | 14 behaviors: [SiteSettingsBehavior, WebUIListenerBehavior], |
| 14 | 15 |
| 15 properties: { | 16 properties: { |
| 16 /** | 17 /** |
| 17 * An object to bind default value labels to (so they are not in the |this| | 18 * An object to bind default value labels to (so they are not in the |this| |
|
tommycli
2017/01/27 00:36:52
Update comment to reflect that fact that they now
dschuyler
2017/01/27 22:29:17
Done.
| |
| 18 * scope). The keys of this object are the values of the | 19 * scope). The keys of this object are the values of the |
| 19 * settings.ContentSettingsTypes enum. | 20 * settings.ContentSettingsTypes enum. |
| 20 * @private | 21 * @private |
| 21 */ | 22 */ |
| 22 default_: { | 23 default_: { |
| 23 type: Object, | 24 type: Object, |
| 24 value: function() { | 25 value: function() { |
| 25 return {}; | 26 return {}; |
| 26 }, | 27 }, |
| 27 }, | 28 }, |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 53 this.addWebUIListener( | 54 this.addWebUIListener( |
| 54 'contentSettingCategoryChanged', | 55 'contentSettingCategoryChanged', |
| 55 this.updateDefaultValueLabel_.bind(this)); | 56 this.updateDefaultValueLabel_.bind(this)); |
| 56 this.addWebUIListener( | 57 this.addWebUIListener( |
| 57 'setHandlersEnabled', | 58 'setHandlersEnabled', |
| 58 this.updateHandlersEnabled_.bind(this)); | 59 this.updateHandlersEnabled_.bind(this)); |
| 59 this.browserProxy.observeProtocolHandlersEnabledState(); | 60 this.browserProxy.observeProtocolHandlersEnabledState(); |
| 60 }, | 61 }, |
| 61 | 62 |
| 62 /** | 63 /** |
| 64 * @param {string} setting Value from settings.PermissionValues. | |
| 65 * @param {string} allow Non-block label ('feature X not allowed'). | |
| 66 * @param {string} block Block label (likely just, 'Blocked'). | |
| 67 * @param {?string} other Tristate value (maybe, 'session only'). | |
| 68 * @private | |
| 69 */ | |
| 70 defaultSettingLabel_: function(setting, allow, block, other) { | |
|
tommycli
2017/01/27 00:36:52
ALLOW and BLOCK have special meanings in content s
dschuyler
2017/01/27 22:29:17
I left of the String suffix since iirc, type decor
| |
| 71 if (setting == settings.PermissionValues.BLOCK) | |
| 72 return block; | |
| 73 if (other === undefined || setting == settings.PermissionValues.ALLOW) | |
| 74 return allow; | |
| 75 return other; | |
|
tommycli
2017/01/27 00:36:52
A nitpick, but the (other === undefined || setting
dschuyler
2017/01/27 22:29:17
I left out the blank line because the whole group
| |
| 76 }, | |
| 77 | |
| 78 /** | |
| 63 * @param {string} category The category to update. | 79 * @param {string} category The category to update. |
| 64 * @private | 80 * @private |
| 65 */ | 81 */ |
| 66 updateDefaultValueLabel_: function(category) { | 82 updateDefaultValueLabel_: function(category) { |
| 67 this.browserProxy.getDefaultValueForContentType( | 83 this.browserProxy.getDefaultValueForContentType( |
| 68 category).then(function(defaultValue) { | 84 category).then(function(defaultValue) { |
| 69 this.set( | 85 this.set( |
| 70 'default_.' + Polymer.CaseMap.dashToCamelCase(category), | 86 'default_.' + Polymer.CaseMap.dashToCamelCase(category), |
| 71 this.computeCategoryDesc( | 87 defaultValue.setting); |
| 72 category, | |
| 73 defaultValue.setting, | |
| 74 /*showRecommendation=*/false)); | |
| 75 }.bind(this)); | 88 }.bind(this)); |
| 76 }, | 89 }, |
| 77 | 90 |
| 78 /** | 91 /** |
| 79 * The protocol handlers have a separate enabled/disabled notifier. | 92 * The protocol handlers have a separate enabled/disabled notifier. |
| 80 * @param {boolean} enabled | 93 * @param {boolean} enabled |
| 81 * @private | 94 * @private |
| 82 */ | 95 */ |
| 83 updateHandlersEnabled_: function(enabled) { | 96 updateHandlersEnabled_: function(enabled) { |
| 84 var category = settings.ContentSettingsTypes.PROTOCOL_HANDLERS; | 97 var category = settings.ContentSettingsTypes.PROTOCOL_HANDLERS; |
| 85 this.set( | 98 this.set( |
| 86 'default_.' + Polymer.CaseMap.dashToCamelCase(category), | 99 'default_.' + Polymer.CaseMap.dashToCamelCase(category), |
| 87 this.computeCategoryDesc( | 100 enabled ? |
| 88 category, | 101 settings.PermissionValues.ALLOW : |
| 89 enabled ? | 102 settings.PermissionValues.BLOCK); |
| 90 settings.PermissionValues.ALLOW : | |
| 91 settings.PermissionValues.BLOCK, | |
| 92 /*showRecommendation=*/false)); | |
| 93 }, | 103 }, |
| 94 | 104 |
| 95 /** | 105 /** |
| 96 * Navigate to the route specified in the event dataset. | 106 * Navigate to the route specified in the event dataset. |
| 97 * @param {!Event} event The tap event. | 107 * @param {!Event} event The tap event. |
| 98 * @private | 108 * @private |
| 99 */ | 109 */ |
| 100 onTapNavigate_: function(event) { | 110 onTapNavigate_: function(event) { |
| 101 var dataSet = /** @type {{route: string}} */(event.currentTarget.dataset); | 111 var dataSet = /** @type {{route: string}} */(event.currentTarget.dataset); |
| 102 settings.navigateTo(settings.Route[dataSet.route]); | 112 settings.navigateTo(settings.Route[dataSet.route]); |
| 103 }, | 113 }, |
| 104 }); | 114 }); |
| OLD | NEW |