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

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 },
17 }, 20 },
18 21
22 /**
23 * GUID of the user-selected network. It is remembered after user taps on
24 * network entry. After we receive event "connected" on this network,
25 * OOBE will proceed.
26 */
27 networkLastSelectedGuid_: '',
28
29 /**
30 * Sets proper focus.
31 */
19 focus: function() { 32 focus: function() {
20 this.$.welcomeNextButton.focus(); 33 this.$.welcomeNextButton.focus();
21 }, 34 },
22 35
36 /**
37 * Handles "visible" event.
38 * @private
39 */
23 onAnimationFinish_: function() { 40 onAnimationFinish_: function() {
24 this.focus(); 41 this.focus();
25 }, 42 },
26 43
44 /**
45 * Handle "Next" button for "Welcome" screen.
46 *
47 * @private
48 */
27 onWelcomeNextButtonClicked_: function() { 49 onWelcomeNextButtonClicked_: function() {
50 this.$.networkSelect.maxHeight = 280;
51 this.$.networkSelect.showActive = false;
52 var self = this;
53 this.$.networkSelect.customItems = [
54 {
55 customItemName: 'proxySettingsMenuName',
56 polymerIcon: 'oobe-welcome:add',
57 customData: {
58 onTap: function() { self.OpenProxySettingsDialog_(); },
59 },
60 },
61 {
62 customItemName: 'addWiFiNetworkMenuName',
63 polymerIcon: 'oobe-welcome:add',
64 customData: {
65 onTap: function() { self.OpenAddWiFiNetworkDialog_(); },
66 },
67 },
68 {
69 customItemName: 'addMobileNetworkMenuName',
70 polymerIcon: 'oobe-welcome:add',
71 customData: {
72 onTap: function() { self.OpenAddWiFiNetworkDialog_(); },
73 },
74 },
75 ];
76 this.$.networkSection.hidden = false;
77 this.$.welcomeSection.hidden = true;
78 },
79
80 /**
81 * Handle Networwork Setup screen "Proxy settings" button.
82 *
83 * @private
84 */
85 OpenProxySettingsDialog_: function(item) {
86 chrome.send('launchProxySettingsDialog');
87 },
88
89 /**
90 * Handle Networwork Setup screen "Add WiFi network" button.
91 *
92 * @private
93 */
94 OpenAddWiFiNetworkDialog_: function(item) {
95 chrome.send('launchAddWiFiNetworkDialog');
96 },
97
98 /**
99 * Handle Networwork Setup screen "Add cellular network" button.
100 *
101 * @private
102 */
103 OpenAddMobileNetworkDialog_: function(item) {
104 chrome.send('launchAddMobileNetworkDialog');
105 },
106
107 /**
108 * This is called when network setup is done.
109 *
110 * @private
111 */
112 onSelectedNetworkConnected_: function() {
28 $('oobe-connect').hidden = false; 113 $('oobe-connect').hidden = false;
29 $('oobe-welcome-md').hidden = true; 114 $('oobe-welcome-md').hidden = true;
30 } 115 },
116
117 /**
118 * This gets called when a network enters the 'Connected' state.
119 *
120 * @param {!{detail: !CrOnc.NetworkStateProperties}} event
121 * @private
122 */
123 onNetworkConnected_: function(event) {
124 var state = event.detail;
125 if (state.GUID != this.networkLastSelectedGuid_)
126 return;
127
128 this.onSelectedNetworkConnected_();
129 },
130
131 /**
132 * This is called when user taps on network entry in networks list.
133 *
134 * @param {!{detail: !CrOnc.NetworkStateProperties}} event
135 * @private
136 */
137 onNetworkListNetworkItemSelected_: function(event) {
138 var state = event.detail;
139 // If user has not previously made a selection and selected network
140 // is already connected, just continue to the next screen.
141 if (this.networkLastSelectedGuid_ == '' &&
142 state.ConnectionState == CrOnc.ConnectionState.CONNECTED) {
143 this.onSelectedNetworkConnected_();
144 }
145
146 // If user has previously selected another network, there
147 // is pending connection attempt. So even if new selection is currently
148 // connected, it may get disconnected at any time.
149 // So just send one more connection request to cancel current attempts.
150 this.networkLastSelectedGuid_ = state.GUID;
151
152 var self = this;
153 var networkStateCopy = Object.assign({}, state);
154
155 chrome.networkingPrivate.startConnect(state.GUID, function() {
156 var lastError = chrome.runtime.lastError;
157 if (!lastError)
158 return;
159
160 if (lastError.message == 'connected') {
161 self.onNetworkConnected_({'detail': networkStateCopy});
162 return;
163 }
164
165 if (lastError.message != 'connecting')
166 console.error('networkingPrivate.startConnect error: ' + lastError);
167 });
168 },
169
170 /**
171 * @param {!Event} event
172 */
173 onNetworkListCustomItemSelected_: function(e) {
174 var itemState = e.detail;
175 itemState.customData.onTap();
176 },
31 }); 177 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698