OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * 'category-default-setting' is the polymer element for showing a certain | 7 * 'category-default-setting' is the polymer element for showing a certain |
8 * category under Site Settings. | 8 * category under Site Settings. |
9 */ | 9 */ |
10 Polymer({ | 10 Polymer({ |
11 is: 'category-default-setting', | 11 is: 'category-default-setting', |
12 | 12 |
13 behaviors: [SiteSettingsBehavior, WebUIListenerBehavior], | 13 behaviors: [SiteSettingsBehavior, WebUIListenerBehavior], |
14 | 14 |
15 properties: { | 15 properties: { |
16 /** | |
17 * The second line (secondary) text to be shown next to the toggle. | |
18 */ | |
19 optionDescription: String, | |
20 | |
21 /* Labels for the toggle on/off positions. */ | |
22 toggleOffLabel: String, | |
23 toggleOnLabel: String, | |
stevenjb
2017/03/31 23:28:15
Maybe move these above optionDescription and menti
dschuyler
2017/04/01 00:09:38
I didn't do exactly that. I've sorted the public a
| |
24 | |
25 /** | |
26 * The second line (secondary) text to be shown next to the toggle. | |
27 */ | |
28 subOptionLabel: String, | |
29 | |
30 /** | |
31 * The second line (secondary) text to be shown next to the toggle. | |
stevenjb
2017/03/31 23:28:15
All three of these have the same comment.
dschuyler
2017/04/01 00:09:38
Whoops, thanks!
| |
32 */ | |
33 subOptionDescription: String, | |
34 | |
16 /** @private {chrome.settingsPrivate.PrefObject} */ | 35 /** @private {chrome.settingsPrivate.PrefObject} */ |
17 controlParams_: { | 36 controlParams_: { |
18 type: Object, | 37 type: Object, |
19 value: function() { | 38 value: function() { |
20 return /** @type {chrome.settingsPrivate.PrefObject} */({}); | 39 return /** @type {chrome.settingsPrivate.PrefObject} */({}); |
21 }, | 40 }, |
22 }, | 41 }, |
23 | 42 |
24 /** @private {!DefaultContentSetting} */ | 43 /** @private {!DefaultContentSetting} */ |
25 priorDefaultContentSetting_: { | 44 priorDefaultContentSetting_: { |
26 type: Object, | 45 type: Object, |
27 value: function() { | 46 value: function() { |
28 return /** @type {DefaultContentSetting} */({}); | 47 return /** @type {DefaultContentSetting} */({}); |
29 }, | 48 }, |
30 }, | 49 }, |
31 | 50 |
32 /** | 51 /** |
33 * The description to be shown next to the slider. | 52 * The label to be shown next to the toggle. This will be either |
53 * toggleOffLabel or toggleOnLabel. | |
34 * @private | 54 * @private |
35 */ | 55 */ |
36 sliderDescription_: String, | 56 optionLabel_: String, |
37 | 57 |
38 /** | 58 /** |
39 * Cookies and Flash settings have a sub-control that is used to mimic a | 59 * Cookies and Flash settings have a sub-control that is used to mimic a |
40 * tri-state value. | 60 * tri-state value. |
41 * @private {chrome.settingsPrivate.PrefObject} | 61 * @private {chrome.settingsPrivate.PrefObject} |
42 */ | 62 */ |
43 subControlParams_: { | 63 subControlParams_: { |
44 type: Object, | 64 type: Object, |
45 value: function() { | 65 value: function() { |
46 return /** @type {chrome.settingsPrivate.PrefObject} */({}); | 66 return /** @type {chrome.settingsPrivate.PrefObject} */({}); |
47 }, | 67 }, |
48 }, | 68 }, |
49 | |
50 /* Labels for the toggle on/off positions. */ | |
51 toggleOffLabel: String, | |
52 toggleOnLabel: String, | |
53 | |
54 subOptionLabel: String, | |
55 subOptionSecondary: { | |
56 type: String, | |
57 value: null, // Needs default value so binding fires upon initialization. | |
58 }, | |
59 }, | 69 }, |
60 | 70 |
61 observers: [ | 71 observers: [ |
62 'onCategoryChanged_(category)', | 72 'onCategoryChanged_(category)', |
63 'onChangePermissionControl_(category, controlParams_.value, ' + | 73 'onChangePermissionControl_(category, controlParams_.value, ' + |
64 'subControlParams_.value)', | 74 'subControlParams_.value)', |
65 ], | 75 ], |
66 | 76 |
67 ready: function() { | 77 ready: function() { |
68 this.addWebUIListener('contentSettingCategoryChanged', | 78 this.addWebUIListener('contentSettingCategoryChanged', |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 /** | 196 /** |
187 * Handles changes to the category pref and the |category| member variable. | 197 * Handles changes to the category pref and the |category| member variable. |
188 * @private | 198 * @private |
189 */ | 199 */ |
190 onCategoryChanged_: function() { | 200 onCategoryChanged_: function() { |
191 this.browserProxy | 201 this.browserProxy |
192 .getDefaultValueForContentType( | 202 .getDefaultValueForContentType( |
193 this.category).then(function(defaultValue) { | 203 this.category).then(function(defaultValue) { |
194 this.updateControlParams_(defaultValue); | 204 this.updateControlParams_(defaultValue); |
195 | 205 |
196 // Flash only shows ALLOW or BLOCK descriptions on the slider. | 206 // Flash only shows ALLOW or BLOCK descriptions on the toggle. |
197 var setting = defaultValue.setting; | 207 var setting = defaultValue.setting; |
198 if (this.category == settings.ContentSettingsTypes.PLUGINS && | 208 if (this.category == settings.ContentSettingsTypes.PLUGINS && |
199 setting == settings.PermissionValues.IMPORTANT_CONTENT) { | 209 setting == settings.PermissionValues.IMPORTANT_CONTENT) { |
200 setting = settings.PermissionValues.ALLOW; | 210 setting = settings.PermissionValues.ALLOW; |
201 } else if ( | 211 } else if ( |
202 this.category == settings.ContentSettingsTypes.COOKIES && | 212 this.category == settings.ContentSettingsTypes.COOKIES && |
203 setting == settings.PermissionValues.SESSION_ONLY) { | 213 setting == settings.PermissionValues.SESSION_ONLY) { |
204 setting = settings.PermissionValues.ALLOW; | 214 setting = settings.PermissionValues.ALLOW; |
205 } | 215 } |
206 var categoryEnabled = setting != settings.PermissionValues.BLOCK; | 216 var categoryEnabled = setting != settings.PermissionValues.BLOCK; |
207 this.sliderDescription_ = | 217 this.optionLabel_ = |
208 categoryEnabled ? this.toggleOnLabel : this.toggleOffLabel; | 218 categoryEnabled ? this.toggleOnLabel : this.toggleOffLabel; |
209 }.bind(this)); | 219 }.bind(this)); |
210 }, | 220 }, |
211 | 221 |
212 /** | 222 /** |
213 * @return {boolean} | 223 * @return {boolean} |
214 * @private | 224 * @private |
215 */ | 225 */ |
216 isToggleDisabled_: function() { | 226 isToggleDisabled_: function() { |
217 return this.category == settings.ContentSettingsTypes.POPUPS && | 227 return this.category == settings.ContentSettingsTypes.POPUPS && |
218 loadTimeData.getBoolean('isGuest'); | 228 loadTimeData.getBoolean('isGuest'); |
219 }, | 229 }, |
220 | |
221 /** | |
222 * Returns classname to indicate secondary label exists. | |
223 * @param {boolean} subOptionLabel | |
224 * @return {string} | |
225 * @private | |
226 */ | |
227 subOptionClass_: function(subOptionLabel) { | |
228 return subOptionLabel ? 'two-line' : ''; | |
229 } | |
230 }); | 230 }); |
OLD | NEW |