Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: chrome/browser/resources/chromeos/login/oobe_welcome.js

Issue 2067153002: ChromeOS: Implement Network Selection screen of material design OOBE. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update after review. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 /**
6 * @fileoverview Polymer element for displaying material design OOBE.
7 */
8
5 Polymer({ 9 Polymer({
6 is: 'oobe-welcome-md', 10 is: 'oobe-welcome-md',
7 11
8 properties: { 12 properties: {
9 disabled: { 13 /**
10 type: Boolean, 14 * Currently selected system language.
11 value: false, 15 */
12 },
13 currentLanguage: { 16 currentLanguage: {
14 type: String, 17 type: String,
15 value: 'English (US)', 18 value: 'English (US)',
16 }, 19 },
stevenjb 2016/07/11 16:37:23 nit: blank line
Alexander Alekseev 2016/07/12 04:12:14 Done.
20 /**
21 * Flag that switches Welcome screen to Network Selection screen.
22 */
23 networkSelectionScreenShown: {
24 type: Boolean,
25 value: false,
26 },
17 }, 27 },
18 28
29 /**
30 * GUID of the user-selected network. It is remembered after user taps on
31 * network entry. After we receive event "connected" on this network,
32 * OOBE will proceed.
33 */
34 networkLastSelectedGuid_: '',
35
36 /**
37 * Sets proper focus.
38 */
19 focus: function() { 39 focus: function() {
20 this.$.welcomeNextButton.focus(); 40 this.$.welcomeNextButton.focus();
21 }, 41 },
22 42
43 /**
44 * Handles "visible" event.
45 * @private
46 */
23 onAnimationFinish_: function() { 47 onAnimationFinish_: function() {
24 this.focus(); 48 this.focus();
25 }, 49 },
26 50
51 /**
52 * Returns custom items for network selector.
53 */
54 _getNetworkCustomItems: function() {
55 var self = this;
56 return [
57 {
58 customItemName: 'proxySettingsMenuName',
59 polymerIcon: 'oobe-welcome:add',
60 customData: {
61 onTap: function() { self.OpenProxySettingsDialog_(); },
62 },
63 },
64 {
65 customItemName: 'addWiFiNetworkMenuName',
66 polymerIcon: 'oobe-welcome:add',
67 customData: {
68 onTap: function() { self.OpenAddWiFiNetworkDialog_(); },
69 },
70 },
71 {
72 customItemName: 'addMobileNetworkMenuName',
73 polymerIcon: 'oobe-welcome:add',
74 customData: {
75 onTap: function() { self.OpenAddWiFiNetworkDialog_(); },
76 },
77 },
78 ];
79 },
80
81 /**
82 * Handle "Next" button for "Welcome" screen.
83 *
84 * @private
85 */
27 onWelcomeNextButtonClicked_: function() { 86 onWelcomeNextButtonClicked_: function() {
87 this.networkSelectionScreenShown = true;
88 },
89
90 /**
91 * Handle Networwork Setup screen "Proxy settings" button.
92 *
93 * @private
94 */
95 OpenProxySettingsDialog_: function(item) {
96 chrome.send('launchProxySettingsDialog');
97 },
98
99 /**
100 * Handle Networwork Setup screen "Add WiFi network" button.
101 *
102 * @private
103 */
104 OpenAddWiFiNetworkDialog_: function(item) {
105 chrome.send('launchAddWiFiNetworkDialog');
106 },
107
108 /**
109 * Handle Networwork Setup screen "Add cellular network" button.
110 *
111 * @private
112 */
113 OpenAddMobileNetworkDialog_: function(item) {
114 chrome.send('launchAddMobileNetworkDialog');
115 },
116
117 /**
118 * This is called when network setup is done.
119 *
120 * @private
121 */
122 onSelectedNetworkConnected_: function() {
28 $('oobe-connect').hidden = false; 123 $('oobe-connect').hidden = false;
29 $('oobe-welcome-md').hidden = true; 124 $('oobe-welcome-md').hidden = true;
30 } 125 },
126
127 /**
128 * This gets called when a network enters the 'Connected' state.
129 *
130 * @param {!{detail: !CrOnc.NetworkStateProperties}} event
131 * @private
132 */
133 onNetworkConnected_: function(event) {
134 var state = event.detail;
135 if (state.GUID != this.networkLastSelectedGuid_)
136 return;
137
138 this.onSelectedNetworkConnected_();
139 },
140
141 /**
142 * This is called when user taps on network entry in networks list.
143 *
144 * @param {!{detail: !CrOnc.NetworkStateProperties}} event
145 * @private
146 */
147 onNetworkListNetworkItemSelected_: function(event) {
148 var state = event.detail;
149 // If user has not previously made a selection and selected network
150 // is already connected, just continue to the next screen.
151 if (this.networkLastSelectedGuid_ == '' &&
152 state.ConnectionState == CrOnc.ConnectionState.CONNECTED) {
153 this.onSelectedNetworkConnected_();
154 }
155
156 // If user has previously selected another network, there
157 // is pending connection attempt. So even if new selection is currently
158 // connected, it may get disconnected at any time.
159 // So just send one more connection request to cancel current attempts.
160 this.networkLastSelectedGuid_ = state.GUID;
161
162 var self = this;
163 var networkStateCopy = Object.assign({}, state);
164
165 chrome.networkingPrivate.startConnect(state.GUID, function() {
166 var lastError = chrome.runtime.lastError;
167 if (!lastError)
168 return;
169
170 if (lastError.message == 'connected') {
171 self.onNetworkConnected_({'detail': networkStateCopy});
172 return;
173 }
174
175 if (lastError.message != 'connecting')
176 console.error('networkingPrivate.startConnect error: ' + lastError);
177 });
178 },
179
180 /**
181 * @param {!Event} event
182 */
183 onNetworkListCustomItemSelected_: function(e) {
184 var itemState = e.detail;
185 itemState.customData.onTap();
186 },
31 }); 187 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698