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 Polymer element for displaying material design OOBE. | 6 * @fileoverview Polymer element for displaying material design OOBE. |
7 */ | 7 */ |
8 | 8 |
9 Polymer({ | 9 Polymer({ |
10 is: 'oobe-welcome-md', | 10 is: 'oobe-welcome-md', |
(...skipping 27 matching lines...) Expand all Loading... | |
38 /** | 38 /** |
39 * List of keyboards for keyboard selector dropdown. | 39 * List of keyboards for keyboard selector dropdown. |
40 * @type {!Array<OobeTypes.IMEDsc>} | 40 * @type {!Array<OobeTypes.IMEDsc>} |
41 */ | 41 */ |
42 keyboards: { | 42 keyboards: { |
43 type: Array, | 43 type: Array, |
44 observer: "onKeyboardsChanged_", | 44 observer: "onKeyboardsChanged_", |
45 }, | 45 }, |
46 | 46 |
47 /** | 47 /** |
48 * Flag that shows Welcome screen. | |
49 */ | |
50 welcomeScreenShown: { | |
51 type: Boolean, | |
52 value: true, | |
53 }, | |
54 | |
55 /** | |
56 * Flag that shows Language Selection screen. | |
57 */ | |
58 languageSelectionScreenShown: { | |
59 type: Boolean, | |
60 value: false, | |
61 }, | |
62 | |
63 /** | |
64 * Flag that shows Accessibility Options screen. | |
65 */ | |
66 accessibilityOptionsScreenShown: { | |
67 type: Boolean, | |
68 value: false, | |
69 }, | |
70 | |
71 /** | |
72 * Flag that shows Timezone Selection screen. | |
73 */ | |
74 timezoneScreenShown: { | |
75 type: Boolean, | |
76 value: false, | |
77 }, | |
78 | |
79 /** | |
80 * Flag that shows Network Selection screen. | |
81 */ | |
82 networkSelectionScreenShown: { | |
83 type: Boolean, | |
84 value: false, | |
85 observer: 'networkSelectionScreenShownChanged_', | |
86 }, | |
87 | |
88 /** | |
89 * Flag that enables MD-OOBE. | 48 * Flag that enables MD-OOBE. |
90 */ | 49 */ |
91 enabled: { | 50 enabled: { |
92 type: Boolean, | 51 type: Boolean, |
93 value: false, | 52 value: false, |
94 }, | 53 }, |
95 | 54 |
96 /** | 55 /** |
97 * Accessibility options status. | 56 * Accessibility options status. |
98 * @type {!OobeTypes.A11yStatuses} | 57 * @type {!OobeTypes.A11yStatuses} |
(...skipping 22 matching lines...) Expand all Loading... | |
121 /** | 80 /** |
122 * True when connected to a network. | 81 * True when connected to a network. |
123 * @private | 82 * @private |
124 */ | 83 */ |
125 isConnected_: { | 84 isConnected_: { |
126 type: Boolean, | 85 type: Boolean, |
127 value: false, | 86 value: false, |
128 }, | 87 }, |
129 }, | 88 }, |
130 | 89 |
90 /** | |
91 * GUID of the user-selected network. It is remembered after user taps on | |
92 * network entry. After we receive event "connected" on this network, | |
93 * OOBE will proceed. | |
94 */ | |
95 networkLastSelectedGuid_: '', | |
96 | |
131 /** @override */ | 97 /** @override */ |
132 ready: function() { | 98 ready: function() { |
133 CrOncStrings = { | 99 CrOncStrings = { |
134 OncTypeCellular: loadTimeData.getString('OncTypeCellular'), | 100 OncTypeCellular: loadTimeData.getString('OncTypeCellular'), |
135 OncTypeEthernet: loadTimeData.getString('OncTypeEthernet'), | 101 OncTypeEthernet: loadTimeData.getString('OncTypeEthernet'), |
136 OncTypeVPN: loadTimeData.getString('OncTypeVPN'), | 102 OncTypeVPN: loadTimeData.getString('OncTypeVPN'), |
137 OncTypeWiFi: loadTimeData.getString('OncTypeWiFi'), | 103 OncTypeWiFi: loadTimeData.getString('OncTypeWiFi'), |
138 OncTypeWiMAX: loadTimeData.getString('OncTypeWiMAX'), | 104 OncTypeWiMAX: loadTimeData.getString('OncTypeWiMAX'), |
139 networkDisabled: loadTimeData.getString('networkDisabled'), | 105 networkDisabled: loadTimeData.getString('networkDisabled'), |
140 networkListItemConnected: | 106 networkListItemConnected: |
141 loadTimeData.getString('networkListItemConnected'), | 107 loadTimeData.getString('networkListItemConnected'), |
142 networkListItemConnecting: | 108 networkListItemConnecting: |
143 loadTimeData.getString('networkListItemConnecting'), | 109 loadTimeData.getString('networkListItemConnecting'), |
144 networkListItemConnectingTo: | 110 networkListItemConnectingTo: |
145 loadTimeData.getString('networkListItemConnectingTo'), | 111 loadTimeData.getString('networkListItemConnectingTo'), |
146 networkListItemNotConnected: | 112 networkListItemNotConnected: |
147 loadTimeData.getString('networkListItemNotConnected'), | 113 loadTimeData.getString('networkListItemNotConnected'), |
148 vpnNameTemplate: loadTimeData.getString('vpnNameTemplate'), | 114 vpnNameTemplate: loadTimeData.getString('vpnNameTemplate'), |
149 | 115 |
150 // Additional strings for custom items. | 116 // Additional strings for custom items. |
151 addMobileNetworkMenuName: | 117 addMobileNetworkMenuName: |
152 loadTimeData.getString('addMobileNetworkMenuName'), | 118 loadTimeData.getString('addMobileNetworkMenuName'), |
153 addWiFiNetworkMenuName: loadTimeData.getString('addWiFiNetworkMenuName'), | 119 addWiFiNetworkMenuName: loadTimeData.getString('addWiFiNetworkMenuName'), |
154 proxySettingsMenuName: loadTimeData.getString('proxySettingsMenuName'), | 120 proxySettingsMenuName: loadTimeData.getString('proxySettingsMenuName'), |
155 }; | 121 }; |
156 }, | 122 }, |
157 | 123 |
158 /** | 124 /** |
159 * Hides all screens to help switching from one screen to another. | 125 * Hides all screens to help switching from one screen to another. |
126 * @private | |
160 */ | 127 */ |
161 hideAllScreens_: function() { | 128 hideAllScreens_: function() { |
162 this.welcomeScreenShown = false; | 129 this.$.welcomeScreen.hidden = true; |
163 this.networkSelectionScreenShown = false; | |
164 this.languageSelectionScreenShown = false; | |
165 this.accessibilityOptionsScreenShown = false; | |
166 this.timezoneScreenShown = false; | |
167 }, | |
168 | 130 |
169 /** | 131 var screens = Polymer.dom(this.root).querySelectorAll('oobe-dialog') |
170 * GUID of the user-selected network. It is remembered after user taps on | 132 for (var i = 0; i < screens.length; ++i) { |
171 * network entry. After we receive event "connected" on this network, | 133 screens[i].hidden = true; |
172 * OOBE will proceed. | |
173 */ | |
174 networkLastSelectedGuid_: '', | |
175 | |
176 /** | |
177 * Sets proper focus. | |
178 */ | |
179 focus: function() { | |
180 this.$.welcomeNextButton.focus(); | |
181 }, | |
182 | |
183 /** @private */ | |
184 networkSelectionScreenShownChanged_: function() { | |
185 if (this.networkSelectionScreenShown) { | |
186 // After #networkSelect is stamped, trigger a refresh so that the list | |
187 // will be updated with the currently visible networks and sized | |
188 // appropriately. | |
189 this.async(function() { | |
190 this.$.networkSelect.refreshNetworks(); | |
191 }.bind(this)); | |
192 } | 134 } |
193 }, | 135 }, |
194 | 136 |
195 /** | 137 /** |
138 * Shows given screen. | |
139 * @param id String Screen ID. | |
140 * @private | |
141 */ | |
142 showScreen_: function(id) { | |
143 this.hideAllScreens_(); | |
144 | |
145 var screen = this.$[id]; | |
stevenjb
2017/02/14 01:21:32
nit: assert(screen) may help other devs in the fut
Alexander Alekseev
2017/02/14 11:59:27
Done.
| |
146 screen.hidden = false; | |
147 screen.show(); | |
148 }, | |
149 | |
150 /** | |
151 * Returns active screen object. | |
152 * @private | |
153 */ | |
154 getActiveScreen_: function() { | |
155 var screens = Polymer.dom(this.root).querySelectorAll('oobe-dialog') | |
156 for (var i = 0; i < screens.length; ++i) { | |
157 if (!screens[i].hidden) | |
158 return screens[i]; | |
159 } | |
160 return this.$.welcomeScreen; | |
161 }, | |
162 | |
163 focus: function() { | |
164 this.getActiveScreen_().focus(); | |
165 }, | |
166 | |
167 /** @private */ | |
168 onNetworkSelectionScreenShown_: function() { | |
169 // After #networkSelect is stamped, trigger a refresh so that the list | |
170 // will be updated with the currently visible networks and sized | |
171 // appropriately. | |
172 this.async(function() { | |
173 this.$.networkSelect.refreshNetworks(); | |
174 }.bind(this)); | |
175 }, | |
176 | |
177 /** | |
196 * Handles "visible" event. | 178 * Handles "visible" event. |
197 * @private | 179 * @private |
198 */ | 180 */ |
199 onAnimationFinish_: function() { | 181 onAnimationFinish_: function() { |
200 this.focus(); | 182 this.focus(); |
201 }, | 183 }, |
202 | 184 |
203 /** | 185 /** |
204 * Returns custom items for network selector. | 186 * Returns custom items for network selector. |
187 * @private | |
205 */ | 188 */ |
206 _getNetworkCustomItems: function() { | 189 getNetworkCustomItems_: function() { |
207 var self = this; | 190 var self = this; |
208 return [ | 191 return [ |
209 { | 192 { |
210 customItemName: 'proxySettingsMenuName', | 193 customItemName: 'proxySettingsMenuName', |
211 polymerIcon: 'oobe-welcome-20:add-proxy', | 194 polymerIcon: 'oobe-welcome-20:add-proxy', |
212 customData: { | 195 customData: { |
213 onTap: function() { self.OpenProxySettingsDialog_(); }, | 196 onTap: function() { self.OpenProxySettingsDialog_(); }, |
214 }, | 197 }, |
215 }, | 198 }, |
216 { | 199 { |
(...skipping 20 matching lines...) Expand all Loading... | |
237 isTimezoneButtonVisible_: function(highlightStrength) { | 220 isTimezoneButtonVisible_: function(highlightStrength) { |
238 return highlightStrength === 'strong'; | 221 return highlightStrength === 'strong'; |
239 }, | 222 }, |
240 | 223 |
241 /** | 224 /** |
242 * Handle "Next" button for "Welcome" screen. | 225 * Handle "Next" button for "Welcome" screen. |
243 * | 226 * |
244 * @private | 227 * @private |
245 */ | 228 */ |
246 onWelcomeNextButtonClicked_: function() { | 229 onWelcomeNextButtonClicked_: function() { |
247 this.hideAllScreens_(); | 230 this.showScreen_('networkSelectionScreen'); |
248 this.networkSelectionScreenShown = true; | |
249 }, | 231 }, |
250 | 232 |
251 /** | 233 /** |
252 * Handle "Language" button for "Welcome" screen. | 234 * Handle "Language" button for "Welcome" screen. |
253 * | 235 * |
254 * @private | 236 * @private |
255 */ | 237 */ |
256 onWelcomeSelectLanguageButtonClicked_: function() { | 238 onWelcomeSelectLanguageButtonClicked_: function() { |
257 this.hideAllScreens_(); | 239 this.showScreen_('languageScreen'); |
258 this.languageSelectionScreenShown = true; | |
259 }, | 240 }, |
260 | 241 |
261 /** | 242 /** |
262 * Handle "Accessibility" button for "Welcome" screen. | 243 * Handle "Accessibility" button for "Welcome" screen. |
263 * | 244 * |
264 * @private | 245 * @private |
265 */ | 246 */ |
266 onWelcomeAccessibilityButtonClicked_: function() { | 247 onWelcomeAccessibilityButtonClicked_: function() { |
267 this.hideAllScreens_(); | 248 this.showScreen_('accessibilityScreen'); |
268 this.accessibilityOptionsScreenShown = true; | |
269 }, | 249 }, |
270 | 250 |
271 /** | 251 /** |
272 * Handle "Timezone" button for "Welcome" screen. | 252 * Handle "Timezone" button for "Welcome" screen. |
273 * | 253 * |
274 * @private | 254 * @private |
275 */ | 255 */ |
276 onWelcomeTimezoneButtonClicked_: function() { | 256 onWelcomeTimezoneButtonClicked_: function() { |
277 this.hideAllScreens_(); | 257 this.showScreen_('timezoneScreen'); |
278 this.timezoneScreenShown = true; | |
279 }, | 258 }, |
280 | 259 |
281 /** | 260 /** |
282 * Handle Networwork Setup screen "Proxy settings" button. | 261 * Handle Networwork Setup screen "Proxy settings" button. |
283 * | 262 * |
284 * @private | 263 * @private |
285 */ | 264 */ |
286 OpenProxySettingsDialog_: function(item) { | 265 OpenProxySettingsDialog_: function(item) { |
287 chrome.send('launchProxySettingsDialog'); | 266 chrome.send('launchProxySettingsDialog'); |
288 }, | 267 }, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 itemState.customData.onTap(); | 359 itemState.customData.onTap(); |
381 }, | 360 }, |
382 | 361 |
383 /** | 362 /** |
384 * Handle "<- Back" button on network selection screen. | 363 * Handle "<- Back" button on network selection screen. |
385 * | 364 * |
386 * @private | 365 * @private |
387 */ | 366 */ |
388 onNetworkSelectionBackButtonPressed_: function() { | 367 onNetworkSelectionBackButtonPressed_: function() { |
389 this.networkLastSelectedGuid_ = ''; | 368 this.networkLastSelectedGuid_ = ''; |
390 this.hideAllScreens_(); | 369 this.showScreen_('welcomeScreen'); |
391 this.welcomeScreenShown = true; | |
392 }, | 370 }, |
393 | 371 |
394 /** | 372 /** |
395 * Handle language selection. | 373 * Handle language selection. |
396 * | 374 * |
397 * @param {!{detail: {!OobeTypes.LanguageDsc}}} event | 375 * @param {!{detail: {!OobeTypes.LanguageDsc}}} event |
398 * @private | 376 * @private |
399 */ | 377 */ |
400 onLanguageSelected_: function(event) { | 378 onLanguageSelected_: function(event) { |
401 var item = event.detail; | 379 var item = event.detail; |
(...skipping 22 matching lines...) Expand all Loading... | |
424 onKeyboardsChanged_: function() { | 402 onKeyboardsChanged_: function() { |
425 this.currentKeyboard = Oobe.getSelectedTitle(this.keyboards); | 403 this.currentKeyboard = Oobe.getSelectedTitle(this.keyboards); |
426 }, | 404 }, |
427 | 405 |
428 /** | 406 /** |
429 * Handle "OK" button for "LanguageSelection" screen. | 407 * Handle "OK" button for "LanguageSelection" screen. |
430 * | 408 * |
431 * @private | 409 * @private |
432 */ | 410 */ |
433 closeLanguageSection_: function() { | 411 closeLanguageSection_: function() { |
434 this.hideAllScreens_(); | 412 this.showScreen_('welcomeScreen'); |
435 this.welcomeScreenShown = true; | |
436 }, | 413 }, |
437 | 414 |
438 /** ******************** Accessibility section ******************* */ | 415 /** ******************** Accessibility section ******************* */ |
439 | 416 |
440 /** | 417 /** |
441 * Handle "OK" button for "Accessibility Options" screen. | 418 * Handle "OK" button for "Accessibility Options" screen. |
442 * | 419 * |
443 * @private | 420 * @private |
444 */ | 421 */ |
445 closeAccessibilitySection_: function() { | 422 closeAccessibilitySection_: function() { |
446 this.hideAllScreens_(); | 423 this.showScreen_('welcomeScreen'); |
447 this.welcomeScreenShown = true; | |
448 }, | 424 }, |
449 | 425 |
450 /** | 426 /** |
451 * Handle all accessibility buttons. | 427 * Handle all accessibility buttons. |
452 * Note that each <oobe-a11y-option> has chromeMessage attribute | 428 * Note that each <oobe-a11y-option> has chromeMessage attribute |
453 * containing Chromium callback name. | 429 * containing Chromium callback name. |
454 * | 430 * |
455 * @private | 431 * @private |
456 * @param {!Event} event | 432 * @param {!Event} event |
457 */ | 433 */ |
458 onA11yOptionChanged_: function(event) { | 434 onA11yOptionChanged_: function(event) { |
459 chrome.send( | 435 chrome.send( |
460 event.currentTarget.chromeMessage, [event.currentTarget.checked]); | 436 event.currentTarget.chromeMessage, [event.currentTarget.checked]); |
461 }, | 437 }, |
462 | 438 |
463 /** ******************** Timezone section ******************* */ | 439 /** ******************** Timezone section ******************* */ |
464 | 440 |
465 /** | 441 /** |
466 * Handle "OK" button for "Timezone Selection" screen. | 442 * Handle "OK" button for "Timezone Selection" screen. |
467 * | 443 * |
468 * @private | 444 * @private |
469 */ | 445 */ |
470 closeTimezoneSection_: function() { | 446 closeTimezoneSection_: function() { |
471 this.hideAllScreens_(); | 447 this.showScreen_('welcomeScreen'); |
472 this.welcomeScreenShown = true; | |
473 }, | 448 }, |
474 | 449 |
475 /** | 450 /** |
476 * Handle timezone selection. | 451 * Handle timezone selection. |
477 * | 452 * |
478 * @param {!{detail: {!OobeTypes.Timezone}}} event | 453 * @param {!{detail: {!OobeTypes.Timezone}}} event |
479 * @private | 454 * @private |
480 */ | 455 */ |
481 onTimezoneSelected_: function(event) { | 456 onTimezoneSelected_: function(event) { |
482 var item = event.detail; | 457 var item = event.detail; |
483 if (!item) | 458 if (!item) |
484 return; | 459 return; |
485 | 460 |
486 this.screen.onTimezoneSelected_(item.value); | 461 this.screen.onTimezoneSelected_(item.value); |
487 }, | 462 }, |
488 | 463 |
489 /** | 464 /** |
490 * This function formats message for labels. | 465 * This function formats message for labels. |
491 * @param String label i18n string ID. | 466 * @param String label i18n string ID. |
492 * @param String parameter i18n string parameter. | 467 * @param String parameter i18n string parameter. |
493 * @private | 468 * @private |
494 */ | 469 */ |
495 formatMessage_: function(label, parameter) { | 470 formatMessage_: function(label, parameter) { |
496 return loadTimeData.getStringF(label, parameter); | 471 return loadTimeData.getStringF(label, parameter); |
497 }, | 472 }, |
498 }); | 473 }); |
OLD | NEW |