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

Side by Side Diff: ui/webui/resources/cr_elements/network/cr_network_select.js

Issue 2663293002: MD WebUI: Networking polish in OOBE and Settings (Closed)
Patch Set: Rebase Created 3 years, 10 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
« no previous file with comments | « ui/webui/resources/cr_elements/network/cr_network_select.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 Polymer element wrapping cr-network-list including the 6 * @fileoverview Polymer element wrapping cr-network-list including the
7 * networkingPrivate calls to populate it. 7 * networkingPrivate calls to populate it.
8 */ 8 */
9 9
10 Polymer({ 10 Polymer({
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 }, 45 },
46 46
47 /** 47 /**
48 * List of all network state data for all visible networks. 48 * List of all network state data for all visible networks.
49 * @private {!Array<!CrOnc.NetworkStateProperties>} 49 * @private {!Array<!CrOnc.NetworkStateProperties>}
50 */ 50 */
51 networkStateList_: { 51 networkStateList_: {
52 type: Array, 52 type: Array,
53 value: function() { 53 value: function() {
54 return []; 54 return [];
55 } 55 },
56 }, 56 },
57 57
58 }, 58 },
59 59
60 /** 60 /**
61 * Listener function for chrome.networkingPrivate.onNetworkListChanged event. 61 * Listener function for chrome.networkingPrivate.onNetworkListChanged event.
62 * @type {function(!Array<string>)} 62 * @type {function(!Array<string>)}
63 * @private 63 * @private
64 */ 64 */
65 networkListChangedListener_: function() {}, 65 networkListChangedListener_: function() {},
(...skipping 24 matching lines...) Expand all
90 detached: function() { 90 detached: function() {
91 chrome.networkingPrivate.onNetworkListChanged.removeListener( 91 chrome.networkingPrivate.onNetworkListChanged.removeListener(
92 this.networkListChangedListener_); 92 this.networkListChangedListener_);
93 chrome.networkingPrivate.onDeviceStateListChanged.removeListener( 93 chrome.networkingPrivate.onDeviceStateListChanged.removeListener(
94 this.deviceStateListChangedListener_); 94 this.deviceStateListChangedListener_);
95 }, 95 },
96 96
97 /** 97 /**
98 * Request the list of visible networks. May be called externally to force a 98 * Request the list of visible networks. May be called externally to force a
99 * refresh and list update (e.g. when the element is shown). 99 * refresh and list update (e.g. when the element is shown).
100 * @private
101 */ 100 */
102 refreshNetworks: function() { 101 refreshNetworks: function() {
103 var filter = { 102 var filter = {
104 networkType: chrome.networkingPrivate.NetworkType.ALL, 103 networkType: chrome.networkingPrivate.NetworkType.ALL,
105 visible: true, 104 visible: true,
106 configured: false 105 configured: false
107 }; 106 };
108 chrome.networkingPrivate.getNetworks( 107 chrome.networkingPrivate.getNetworks(
109 filter, this.getNetworksCallback_.bind(this)); 108 filter, this.getNetworksCallback_.bind(this));
110 }, 109 },
111 110
112 /** 111 /**
113 * @param {!Array<!CrOnc.NetworkStateProperties>} states 112 * @param {!Array<!CrOnc.NetworkStateProperties>} states
114 * @private 113 * @private
115 */ 114 */
116 getNetworksCallback_: function(states) { 115 getNetworksCallback_: function(states) {
117 this.networkStateList_ = states; 116 this.networkStateList_ = states;
117 var defaultState = (this.networkStateList_.length > 0 &&
118 this.networkStateList_[0].ConnectionState ==
119 CrOnc.ConnectionState.CONNECTED) ?
120 this.networkStateList_[0] :
121 null;
122 this.defaultNetworkChanged_(defaultState);
118 }, 123 },
119 124
120 /** 125 /**
121 * Event triggered when a cr-network-list-item is selected. 126 * Event triggered when a cr-network-list-item is selected.
122 * @param {!{target: HTMLElement, detail: !CrOnc.NetworkStateProperties}} e 127 * @param {!{target: HTMLElement, detail: !CrOnc.NetworkStateProperties}} e
123 * @private 128 * @private
124 */ 129 */
125 onNetworkListItemSelected_: function(e) { 130 onNetworkListItemSelected_: function(e) {
126 var state = e.detail; 131 var state = e.detail;
127 e.target.blur(); 132 e.target.blur();
128 133
129 if (!this.handleNetworkItemSelected) { 134 if (!this.handleNetworkItemSelected) {
130 this.fire('network-item-selected', state); 135 this.fire('network-item-selected', state);
131 return; 136 return;
132 } 137 }
133 138
134 if (state.ConnectionState != CrOnc.ConnectionState.NOT_CONNECTED) 139 if (state.ConnectionState != CrOnc.ConnectionState.NOT_CONNECTED)
135 return; 140 return;
136 141
137 chrome.networkingPrivate.startConnect(state.GUID, function() { 142 chrome.networkingPrivate.startConnect(state.GUID, function() {
138 var lastError = chrome.runtime.lastError; 143 var lastError = chrome.runtime.lastError;
139 if (lastError && lastError != 'connecting') 144 if (lastError && lastError != 'connecting')
140 console.error('networkingPrivate.startConnect error: ' + lastError); 145 console.error('networkingPrivate.startConnect error: ' + lastError);
141 }); 146 });
142 }, 147 },
148
149 /**
150 * Event triggered when a cr-network-list-item becomes connected.
151 * @param {!{target: HTMLElement, detail: !CrOnc.NetworkStateProperties}} e
152 * @private
153 */
154 onNetworkConnected_: function(e) {
155 this.defaultNetworkChanged_(e.detail);
156 },
157
158 /**
159 * @param {?CrOnc.NetworkStateProperties} state
160 * @private
161 */
162 defaultNetworkChanged_: function(state) {
163 this.fire('default-network-changed', state);
164 },
143 }); 165 });
OLDNEW
« no previous file with comments | « ui/webui/resources/cr_elements/network/cr_network_select.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698