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-ui' implements the UI for the Settings page. | 7 * 'settings-ui' implements the UI for the Settings page. |
8 * | 8 * |
9 * Example: | 9 * Example: |
10 * | 10 * |
11 * <settings-ui prefs="{{prefs}}"></settings-ui> | 11 * <settings-ui prefs="{{prefs}}"></settings-ui> |
12 */ | 12 */ |
13 cr.exportPath('settings'); | 13 cr.exportPath('settings'); |
14 assert(!settings.defaultResourceLoaded, | 14 assert( |
15 'settings_ui.js run twice. You probably have an invalid import.'); | 15 !settings.defaultResourceLoaded, |
| 16 'settings_ui.js run twice. You probably have an invalid import.'); |
16 /** Global defined when the main Settings script runs. */ | 17 /** Global defined when the main Settings script runs. */ |
17 settings.defaultResourceLoaded = true; | 18 settings.defaultResourceLoaded = true; |
18 | 19 |
19 Polymer({ | 20 Polymer({ |
20 is: 'settings-ui', | 21 is: 'settings-ui', |
21 | 22 |
22 behaviors: [settings.RouteObserverBehavior], | 23 behaviors: [settings.RouteObserverBehavior], |
23 | 24 |
24 properties: { | 25 properties: { |
25 /** | 26 /** |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 92 |
92 CrPolicyStrings = { | 93 CrPolicyStrings = { |
93 controlledSettingExtension: | 94 controlledSettingExtension: |
94 loadTimeData.getString('controlledSettingExtension'), | 95 loadTimeData.getString('controlledSettingExtension'), |
95 controlledSettingPolicy: | 96 controlledSettingPolicy: |
96 loadTimeData.getString('controlledSettingPolicy'), | 97 loadTimeData.getString('controlledSettingPolicy'), |
97 controlledSettingRecommendedMatches: | 98 controlledSettingRecommendedMatches: |
98 loadTimeData.getString('controlledSettingRecommendedMatches'), | 99 loadTimeData.getString('controlledSettingRecommendedMatches'), |
99 controlledSettingRecommendedDiffers: | 100 controlledSettingRecommendedDiffers: |
100 loadTimeData.getString('controlledSettingRecommendedDiffers'), | 101 loadTimeData.getString('controlledSettingRecommendedDiffers'), |
101 // <if expr="chromeos"> | 102 // <if expr="chromeos"> |
102 controlledSettingShared: | 103 controlledSettingShared: |
103 loadTimeData.getString('controlledSettingShared'), | 104 loadTimeData.getString('controlledSettingShared'), |
104 controlledSettingOwner: loadTimeData.getString('controlledSettingOwner'), | 105 controlledSettingOwner: loadTimeData.getString('controlledSettingOwner'), |
105 // </if> | 106 // </if> |
106 }; | 107 }; |
107 | 108 |
108 // <if expr="chromeos"> | 109 // <if expr="chromeos"> |
109 CrOncStrings = { | 110 CrOncStrings = { |
110 OncTypeCellular: loadTimeData.getString('OncTypeCellular'), | 111 OncTypeCellular: loadTimeData.getString('OncTypeCellular'), |
111 OncTypeEthernet: loadTimeData.getString('OncTypeEthernet'), | 112 OncTypeEthernet: loadTimeData.getString('OncTypeEthernet'), |
112 OncTypeTether: loadTimeData.getString('OncTypeTether'), | 113 OncTypeTether: loadTimeData.getString('OncTypeTether'), |
113 OncTypeVPN: loadTimeData.getString('OncTypeVPN'), | 114 OncTypeVPN: loadTimeData.getString('OncTypeVPN'), |
114 OncTypeWiFi: loadTimeData.getString('OncTypeWiFi'), | 115 OncTypeWiFi: loadTimeData.getString('OncTypeWiFi'), |
115 OncTypeWiMAX: loadTimeData.getString('OncTypeWiMAX'), | 116 OncTypeWiMAX: loadTimeData.getString('OncTypeWiMAX'), |
116 networkListItemConnected: | 117 networkListItemConnected: |
117 loadTimeData.getString('networkListItemConnected'), | 118 loadTimeData.getString('networkListItemConnected'), |
118 networkListItemConnecting: | 119 networkListItemConnecting: |
119 loadTimeData.getString('networkListItemConnecting'), | 120 loadTimeData.getString('networkListItemConnecting'), |
120 networkListItemConnectingTo: | 121 networkListItemConnectingTo: |
121 loadTimeData.getString('networkListItemConnectingTo'), | 122 loadTimeData.getString('networkListItemConnectingTo'), |
122 networkListItemNotConnected: | 123 networkListItemNotConnected: |
123 loadTimeData.getString('networkListItemNotConnected'), | 124 loadTimeData.getString('networkListItemNotConnected'), |
124 vpnNameTemplate: loadTimeData.getString('vpnNameTemplate'), | 125 vpnNameTemplate: loadTimeData.getString('vpnNameTemplate'), |
125 }; | 126 }; |
126 // </if> | 127 // </if> |
127 | 128 |
128 if (loadTimeData.getBoolean('isGuest')) { | 129 if (loadTimeData.getBoolean('isGuest')) { |
129 this.pageVisibility_ = { | 130 this.pageVisibility_ = { |
130 passwordsAndForms: false, | 131 passwordsAndForms: false, |
131 people: false, | 132 people: false, |
132 onStartup: false, | 133 onStartup: false, |
133 reset: false, | 134 reset: false, |
134 // <if expr="not chromeos"> | 135 // <if expr="not chromeos"> |
135 appearance: false, | 136 appearance: false, |
136 defaultBrowser: false, | 137 defaultBrowser: false, |
137 advancedSettings: false, | 138 advancedSettings: false, |
138 // </if> | 139 // </if> |
139 // <if expr="chromeos"> | 140 // <if expr="chromeos"> |
140 appearance: { | 141 appearance: { |
141 setWallpaper: false, | 142 setWallpaper: false, |
142 setTheme: false, | 143 setTheme: false, |
143 homeButton: false, | 144 homeButton: false, |
144 bookmarksBar: false, | 145 bookmarksBar: false, |
145 pageZoom: false, | 146 pageZoom: false, |
146 }, | 147 }, |
147 advancedSettings: true, | 148 advancedSettings: true, |
148 privacy: { | 149 privacy: { |
149 searchPrediction: false, | 150 searchPrediction: false, |
150 networkPrediction: false, | 151 networkPrediction: false, |
151 }, | 152 }, |
152 downloads: { | 153 downloads: { |
153 googleDrive: false, | 154 googleDrive: false, |
154 }, | 155 }, |
155 // </if> | 156 // </if> |
156 }; | 157 }; |
157 } | 158 } |
158 | 159 |
159 this.showAndroidApps_ = loadTimeData.valueExists('androidAppsVisible') && | 160 this.showAndroidApps_ = loadTimeData.valueExists('androidAppsVisible') && |
160 loadTimeData.getBoolean('androidAppsVisible'); | 161 loadTimeData.getBoolean('androidAppsVisible'); |
161 | 162 |
162 this.addEventListener('show-container', function() { | 163 this.addEventListener('show-container', function() { |
163 this.$.container.style.visibility = 'visible'; | 164 this.$.container.style.visibility = 'visible'; |
164 }.bind(this)); | 165 }.bind(this)); |
165 | 166 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 211 |
211 /** @param {!settings.Route} route */ | 212 /** @param {!settings.Route} route */ |
212 currentRouteChanged: function(route) { | 213 currentRouteChanged: function(route) { |
213 var urlSearchQuery = settings.getQueryParameters().get('search') || ''; | 214 var urlSearchQuery = settings.getQueryParameters().get('search') || ''; |
214 if (urlSearchQuery == this.lastSearchQuery_) | 215 if (urlSearchQuery == this.lastSearchQuery_) |
215 return; | 216 return; |
216 | 217 |
217 this.lastSearchQuery_ = urlSearchQuery; | 218 this.lastSearchQuery_ = urlSearchQuery; |
218 | 219 |
219 var toolbar = /** @type {!CrToolbarElement} */ (this.$$('cr-toolbar')); | 220 var toolbar = /** @type {!CrToolbarElement} */ (this.$$('cr-toolbar')); |
220 var searchField = /** @type {CrToolbarSearchFieldElement} */ ( | 221 var searchField = |
221 toolbar.getSearchField()); | 222 /** @type {CrToolbarSearchFieldElement} */ (toolbar.getSearchField()); |
222 | 223 |
223 // If the search was initiated by directly entering a search URL, need to | 224 // If the search was initiated by directly entering a search URL, need to |
224 // sync the URL parameter to the textbox. | 225 // sync the URL parameter to the textbox. |
225 if (urlSearchQuery != searchField.getValue()) { | 226 if (urlSearchQuery != searchField.getValue()) { |
226 // Setting the search box value without triggering a 'search-changed' | 227 // Setting the search box value without triggering a 'search-changed' |
227 // event, to prevent an unnecessary duplicate entry in |window.history|. | 228 // event, to prevent an unnecessary duplicate entry in |window.history|. |
228 searchField.setValue(urlSearchQuery, true /* noEvent */); | 229 searchField.setValue(urlSearchQuery, true /* noEvent */); |
229 } | 230 } |
230 | 231 |
231 this.$.main.searchContents(urlSearchQuery); | 232 this.$.main.searchContents(urlSearchQuery); |
232 }, | 233 }, |
233 | 234 |
234 /** | 235 /** |
235 * @param {!CustomEvent} e | 236 * @param {!CustomEvent} e |
236 * @private | 237 * @private |
237 */ | 238 */ |
238 onRefreshPref_: function(e) { | 239 onRefreshPref_: function(e) { |
239 var prefName = /** @type {string} */(e.detail); | 240 var prefName = /** @type {string} */ (e.detail); |
240 return /** @type {SettingsPrefsElement} */(this.$.prefs).refresh(prefName); | 241 return /** @type {SettingsPrefsElement} */ (this.$.prefs).refresh(prefName); |
241 }, | 242 }, |
242 | 243 |
243 /** | 244 /** |
244 * Handles the 'search-changed' event fired from the toolbar. | 245 * Handles the 'search-changed' event fired from the toolbar. |
245 * @param {!Event} e | 246 * @param {!Event} e |
246 * @private | 247 * @private |
247 */ | 248 */ |
248 onSearchChanged_: function(e) { | 249 onSearchChanged_: function(e) { |
249 // Trim leading whitespace only, to prevent searching for empty string. This | 250 // Trim leading whitespace only, to prevent searching for empty string. This |
250 // still allows the user to search for 'foo bar', while taking a long pause | 251 // still allows the user to search for 'foo bar', while taking a long pause |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 this.$.container.setAttribute('tabindex', '-1'); | 283 this.$.container.setAttribute('tabindex', '-1'); |
283 this.$.container.focus(); | 284 this.$.container.focus(); |
284 | 285 |
285 listenOnce(this.$.container, ['blur', 'pointerdown'], function() { | 286 listenOnce(this.$.container, ['blur', 'pointerdown'], function() { |
286 this.$.container.removeAttribute('tabindex'); | 287 this.$.container.removeAttribute('tabindex'); |
287 }.bind(this)); | 288 }.bind(this)); |
288 }, | 289 }, |
289 | 290 |
290 /** @private */ | 291 /** @private */ |
291 directionDelegateChanged_: function() { | 292 directionDelegateChanged_: function() { |
292 this.$.drawer.align = this.directionDelegate.isRtl() ? | 293 this.$.drawer.align = this.directionDelegate.isRtl() ? 'right' : 'left'; |
293 'right' : 'left'; | |
294 }, | 294 }, |
295 }); | 295 }); |
OLD | NEW |