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