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 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 enableSiteSettings_: { | 31 enableSiteSettings_: { |
32 type: Boolean, | 32 type: Boolean, |
33 value: function() { | 33 value: function() { |
34 return loadTimeData.getBoolean('enableSiteSettings'); | 34 return loadTimeData.getBoolean('enableSiteSettings'); |
35 }, | 35 }, |
36 }, | 36 }, |
37 | 37 |
38 /** @private */ | 38 /** @private */ |
39 isGuest_: { | 39 isGuest_: { |
40 type: Boolean, | 40 type: Boolean, |
41 value: function() { return loadTimeData.getBoolean('isGuest'); } | 41 value: function() { |
| 42 return loadTimeData.getBoolean('isGuest'); |
| 43 } |
42 }, | 44 }, |
43 | 45 |
44 /** @private */ | 46 /** @private */ |
45 enableSafeBrowsingSubresourceFilter_: { | 47 enableSafeBrowsingSubresourceFilter_: { |
46 type: Boolean, | 48 type: Boolean, |
47 value: function() { | 49 value: function() { |
48 return loadTimeData.getBoolean('enableSafeBrowsingSubresourceFilter'); | 50 return loadTimeData.getBoolean('enableSafeBrowsingSubresourceFilter'); |
49 } | 51 } |
50 }, | 52 }, |
51 | 53 |
(...skipping 11 matching lines...) Expand all Loading... |
63 */ | 65 */ |
64 focusConfigChanged_: function(newConfig, oldConfig) { | 66 focusConfigChanged_: function(newConfig, oldConfig) { |
65 // focusConfig is set only once on the parent, so this observer should only | 67 // focusConfig is set only once on the parent, so this observer should only |
66 // fire once. | 68 // fire once. |
67 assert(!oldConfig); | 69 assert(!oldConfig); |
68 | 70 |
69 // Populate the |focusConfig| map of the parent <settings-animated-pages> | 71 // Populate the |focusConfig| map of the parent <settings-animated-pages> |
70 // element, with additional entries that correspond to subpage trigger | 72 // element, with additional entries that correspond to subpage trigger |
71 // elements residing in this element's Shadow DOM. | 73 // elements residing in this element's Shadow DOM. |
72 var R = settings.Route; | 74 var R = settings.Route; |
73 [ | 75 [[R.SITE_SETTINGS_COOKIES, 'cookies'], |
74 [R.SITE_SETTINGS_COOKIES, 'cookies'], | 76 [R.SITE_SETTINGS_LOCATION, 'location'], [R.SITE_SETTINGS_CAMERA, 'camera'], |
75 [R.SITE_SETTINGS_LOCATION, 'location'], | 77 [R.SITE_SETTINGS_MICROPHONE, 'microphone'], |
76 [R.SITE_SETTINGS_CAMERA, 'camera'], | 78 [R.SITE_SETTINGS_NOTIFICATIONS, 'notifications'], |
77 [R.SITE_SETTINGS_MICROPHONE, 'microphone'], | 79 [R.SITE_SETTINGS_JAVASCRIPT, 'javascript'], |
78 [R.SITE_SETTINGS_NOTIFICATIONS, 'notifications'], | 80 [R.SITE_SETTINGS_FLASH, 'flash'], [R.SITE_SETTINGS_IMAGES, 'images'], |
79 [R.SITE_SETTINGS_JAVASCRIPT,'javascript'], | 81 [R.SITE_SETTINGS_POPUPS, 'popups'], |
80 [R.SITE_SETTINGS_FLASH,'flash'], | 82 [R.SITE_SETTINGS_BACKGROUND_SYNC, 'background-sync'], |
81 [R.SITE_SETTINGS_IMAGES,'images'], | 83 [R.SITE_SETTINGS_AUTOMATIC_DOWNLOADS, 'automatic-downloads'], |
82 [R.SITE_SETTINGS_POPUPS,'popups'], | 84 [R.SITE_SETTINGS_UNSANDBOXED_PLUGINS, 'unsandboxed-plugins'], |
83 [R.SITE_SETTINGS_BACKGROUND_SYNC,'background-sync'], | 85 [R.SITE_SETTINGS_HANDLERS, 'protocol-handlers'], |
84 [R.SITE_SETTINGS_AUTOMATIC_DOWNLOADS,'automatic-downloads'], | 86 [R.SITE_SETTINGS_MIDI_DEVICES, 'midi-devices'], |
85 [R.SITE_SETTINGS_UNSANDBOXED_PLUGINS,'unsandboxed-plugins'], | 87 [R.SITE_SETTINGS_ADS, 'ads'], [R.SITE_SETTINGS_ZOOM_LEVELS, 'zoom-levels'], |
86 [R.SITE_SETTINGS_HANDLERS,'protocol-handlers'], | 88 [R.SITE_SETTINGS_USB_DEVICES, 'usb-devices'], |
87 [R.SITE_SETTINGS_MIDI_DEVICES,'midi-devices'], | 89 [R.SITE_SETTINGS_PDF_DOCUMENTS, 'pdf-documents'], |
88 [R.SITE_SETTINGS_ADS,'ads'], | 90 [R.SITE_SETTINGS_PROTECTED_CONTENT, 'protected-content'], |
89 [R.SITE_SETTINGS_ZOOM_LEVELS,'zoom-levels'], | |
90 [R.SITE_SETTINGS_USB_DEVICES,'usb-devices'], | |
91 [R.SITE_SETTINGS_PDF_DOCUMENTS,'pdf-documents'], | |
92 [R.SITE_SETTINGS_PROTECTED_CONTENT,'protected-content'], | |
93 ].forEach(function(pair) { | 91 ].forEach(function(pair) { |
94 var route = pair[0]; | 92 var route = pair[0]; |
95 var id = pair[1]; | 93 var id = pair[1]; |
96 this.focusConfig.set( | 94 this.focusConfig.set(route.path, '* /deep/ #' + id + ' .subpage-arrow'); |
97 route.path, '* /deep/ #' + id + ' .subpage-arrow'); | |
98 }.bind(this)); | 95 }.bind(this)); |
99 }, | 96 }, |
100 | 97 |
101 /** @override */ | 98 /** @override */ |
102 ready: function() { | 99 ready: function() { |
103 this.ContentSettingsTypes = settings.ContentSettingsTypes; | 100 this.ContentSettingsTypes = settings.ContentSettingsTypes; |
104 this.ALL_SITES = settings.ALL_SITES; | 101 this.ALL_SITES = settings.ALL_SITES; |
105 | 102 |
106 var keys = Object.keys(settings.ContentSettingsTypes); | 103 var keys = Object.keys(settings.ContentSettingsTypes); |
107 for (var i = 0; i < keys.length; ++i) { | 104 for (var i = 0; i < keys.length; ++i) { |
108 var key = settings.ContentSettingsTypes[keys[i]]; | 105 var key = settings.ContentSettingsTypes[keys[i]]; |
109 // Default labels are not applicable to USB and ZOOM. | 106 // Default labels are not applicable to USB and ZOOM. |
110 if (key == settings.ContentSettingsTypes.USB_DEVICES || | 107 if (key == settings.ContentSettingsTypes.USB_DEVICES || |
111 key == settings.ContentSettingsTypes.ZOOM_LEVELS) | 108 key == settings.ContentSettingsTypes.ZOOM_LEVELS) |
112 continue; | 109 continue; |
113 // Some values are not available (and will DCHECK) in guest mode. | 110 // Some values are not available (and will DCHECK) in guest mode. |
114 if (this.isGuest_ && | 111 if (this.isGuest_ && |
115 key == settings.ContentSettingsTypes.PROTOCOL_HANDLERS) { | 112 key == settings.ContentSettingsTypes.PROTOCOL_HANDLERS) { |
116 continue; | 113 continue; |
117 } | 114 } |
118 this.updateDefaultValueLabel_(key); | 115 this.updateDefaultValueLabel_(key); |
119 } | 116 } |
120 | 117 |
121 this.addWebUIListener( | 118 this.addWebUIListener( |
122 'contentSettingCategoryChanged', | 119 'contentSettingCategoryChanged', |
123 this.updateDefaultValueLabel_.bind(this)); | 120 this.updateDefaultValueLabel_.bind(this)); |
124 this.addWebUIListener( | 121 this.addWebUIListener( |
125 'setHandlersEnabled', | 122 'setHandlersEnabled', this.updateHandlersEnabled_.bind(this)); |
126 this.updateHandlersEnabled_.bind(this)); | |
127 this.browserProxy.observeProtocolHandlersEnabledState(); | 123 this.browserProxy.observeProtocolHandlersEnabledState(); |
128 }, | 124 }, |
129 | 125 |
130 /** | 126 /** |
131 * @param {string} setting Value from settings.PermissionValues. | 127 * @param {string} setting Value from settings.PermissionValues. |
132 * @param {string} enabled Non-block label ('feature X not allowed'). | 128 * @param {string} enabled Non-block label ('feature X not allowed'). |
133 * @param {string} disabled Block label (likely just, 'Blocked'). | 129 * @param {string} disabled Block label (likely just, 'Blocked'). |
134 * @param {?string} other Tristate value (maybe, 'session only'). | 130 * @param {?string} other Tristate value (maybe, 'session only'). |
135 * @private | 131 * @private |
136 */ | 132 */ |
137 defaultSettingLabel_: function(setting, enabled, disabled, other) { | 133 defaultSettingLabel_: function(setting, enabled, disabled, other) { |
138 if (setting == settings.PermissionValues.BLOCK) | 134 if (setting == settings.PermissionValues.BLOCK) |
139 return disabled; | 135 return disabled; |
140 if (setting == settings.PermissionValues.ALLOW) | 136 if (setting == settings.PermissionValues.ALLOW) |
141 return enabled; | 137 return enabled; |
142 if (other) | 138 if (other) |
143 return other; | 139 return other; |
144 return enabled; | 140 return enabled; |
145 }, | 141 }, |
146 | 142 |
147 /** | 143 /** |
148 * @param {string} category The category to update. | 144 * @param {string} category The category to update. |
149 * @private | 145 * @private |
150 */ | 146 */ |
151 updateDefaultValueLabel_: function(category) { | 147 updateDefaultValueLabel_: function(category) { |
152 this.browserProxy.getDefaultValueForContentType( | 148 this.browserProxy.getDefaultValueForContentType(category).then( |
153 category).then(function(defaultValue) { | 149 function(defaultValue) { |
154 this.set( | 150 this.set( |
155 'default_.' + Polymer.CaseMap.dashToCamelCase(category), | 151 'default_.' + Polymer.CaseMap.dashToCamelCase(category), |
156 defaultValue.setting); | 152 defaultValue.setting); |
157 }.bind(this)); | 153 }.bind(this)); |
158 }, | 154 }, |
159 | 155 |
160 /** | 156 /** |
161 * The protocol handlers have a separate enabled/disabled notifier. | 157 * The protocol handlers have a separate enabled/disabled notifier. |
162 * @param {boolean} enabled | 158 * @param {boolean} enabled |
163 * @private | 159 * @private |
164 */ | 160 */ |
165 updateHandlersEnabled_: function(enabled) { | 161 updateHandlersEnabled_: function(enabled) { |
166 var category = settings.ContentSettingsTypes.PROTOCOL_HANDLERS; | 162 var category = settings.ContentSettingsTypes.PROTOCOL_HANDLERS; |
167 this.set( | 163 this.set( |
168 'default_.' + Polymer.CaseMap.dashToCamelCase(category), | 164 'default_.' + Polymer.CaseMap.dashToCamelCase(category), |
169 enabled ? | 165 enabled ? settings.PermissionValues.ALLOW : |
170 settings.PermissionValues.ALLOW : | 166 settings.PermissionValues.BLOCK); |
171 settings.PermissionValues.BLOCK); | |
172 }, | 167 }, |
173 | 168 |
174 /** | 169 /** |
175 * Navigate to the route specified in the event dataset. | 170 * Navigate to the route specified in the event dataset. |
176 * @param {!Event} event The tap event. | 171 * @param {!Event} event The tap event. |
177 * @private | 172 * @private |
178 */ | 173 */ |
179 onTapNavigate_: function(event) { | 174 onTapNavigate_: function(event) { |
180 var dataSet = /** @type {{route: string}} */(event.currentTarget.dataset); | 175 var dataSet = /** @type {{route: string}} */ (event.currentTarget.dataset); |
181 settings.navigateTo(settings.Route[dataSet.route]); | 176 settings.navigateTo(settings.Route[dataSet.route]); |
182 }, | 177 }, |
183 }); | 178 }); |
OLD | NEW |