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

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

Issue 2069323002: Add support for custom entries in <cr_network_select/>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@604119--Implement-Chrome-OS-out-of-box-flow-in-Material-Design--ImplementNetworkSelectionScreen
Patch Set: Split cr-network-list into two dom-repeat objects/. Removed list_item_base. 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 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 /** 49 /**
50 * If true, show the active network state. 50 * If true, show the active network state.
51 */ 51 */
52 showActive: { 52 showActive: {
53 type: Boolean, 53 type: Boolean,
54 value: false 54 value: false
55 }, 55 },
56 56
57 /** 57 /**
58 * List of all network state data for all visible networks. 58 * List of all network state data for all visible networks.
59 * See <cr-network-list-network-item/> for details.
60 *
59 * @type {!Array<!CrOnc.NetworkStateProperties>} 61 * @type {!Array<!CrOnc.NetworkStateProperties>}
60 */ 62 */
61 networkStateList: { 63 networkStateList: {
62 type: Array, 64 type: Array,
63 value: function() { return []; } 65 value: function() { return []; }
64 } 66 },
67
68 /**
69 * List of custom items to display at the end of networks list.
70 * See <cr-network-list-custom-item/> for details.
71 *
72 * @type {!Array<Object>}
73 */
74 customItems: {
75 type: Array,
76 value: function() { return []; },
77 },
78
79 /**
80 * Show all buttons in list items.
81 */
82 showButtons: {
83 type: Boolean,
84 value: false,
stevenjb 2016/06/24 22:33:08 nit: This could default to true, then we don't hav
85 },
86
87 /**
88 * If this event name is defined, "selected" event for network list item
89 * will trigger this event instead of <cr-network-select/> internal
90 * handler.
91 *
92 * @type {Function}
93 */
94 itemSelectedEventOverride: {
stevenjb 2016/06/24 22:33:08 I think this should just be a boolean, e.g. 'handl
stevenjb 2016/06/27 20:09:45 How about this?
Alexander Alekseev 2016/06/28 06:51:16 Done.
95 type: Object,
96 value: null,
97 },
98
99 /**
100 * This event is fired on each NetworkStateProperties object when it has
101 * state 'Connected'.
102 *
103 * @type {String}
104 */
105 networkConnectedEvent: {
106 type: String,
107 value: null,
108 },
65 }, 109 },
66 110
67 /** 111 /**
68 * Listener function for chrome.networkingPrivate.onNetworkListChanged event. 112 * Listener function for chrome.networkingPrivate.onNetworkListChanged event.
69 * @type {function(!Array<string>)} 113 * @type {function(!Array<string>)}
70 * @private 114 * @private
71 */ 115 */
72 networkListChangedListener_: function() {}, 116 networkListChangedListener_: function() {},
73 117
74 /** 118 /**
(...skipping 20 matching lines...) Expand all
95 139
96 /** @override */ 140 /** @override */
97 detached: function() { 141 detached: function() {
98 chrome.networkingPrivate.onNetworkListChanged.removeListener( 142 chrome.networkingPrivate.onNetworkListChanged.removeListener(
99 this.networkListChangedListener_); 143 this.networkListChangedListener_);
100 chrome.networkingPrivate.onDeviceStateListChanged.removeListener( 144 chrome.networkingPrivate.onDeviceStateListChanged.removeListener(
101 this.deviceStateListChangedListener_); 145 this.deviceStateListChangedListener_);
102 }, 146 },
103 147
104 /** 148 /**
105 * Polymer chnaged function. 149 * Polymer changed function.
106 * @private 150 * @private
107 */ 151 */
108 networkListOpenedChanged_: function() { 152 networkListOpenedChanged_: function() {
109 if (this.networkListOpened) 153 if (this.networkListOpened)
110 chrome.networkingPrivate.requestNetworkScan(); 154 chrome.networkingPrivate.requestNetworkScan();
111 }, 155 },
112 156
113 /** 157 /**
114 * Request the list of visible networks. 158 * Request the list of visible networks.
115 * @private 159 * @private
(...skipping 11 matching lines...) Expand all
127 /** 171 /**
128 * @param {!Array<!CrOnc.NetworkStateProperties>} states 172 * @param {!Array<!CrOnc.NetworkStateProperties>} states
129 * @private 173 * @private
130 */ 174 */
131 getNetworksCallback_: function(states) { 175 getNetworksCallback_: function(states) {
132 this.activeNetworkState = states[0] || null; 176 this.activeNetworkState = states[0] || null;
133 this.networkStateList = states; 177 this.networkStateList = states;
134 }, 178 },
135 179
136 /** 180 /**
137 * Event triggered when a cr-network-list-item is selected. 181 * Event triggered when a cr-network-list-network-item is selected.
138 * @param {!{detail: !CrOnc.NetworkStateProperties}} event 182 * @param {!{detail: !CrOnc.NetworkStateProperties}} event
139 * @private 183 * @private
140 */ 184 */
141 onNetworkListItemSelected_: function(event) { 185 onNetworkListItemSelected_: function(event) {
142 var state = event.detail; 186 var state = event.detail;
187
188 if (this.itemSelectedEventOverride) {
189 this.fire(this.itemSelectedEventOverride, state);
190 return;
191 }
192
143 if (state.ConnectionState != CrOnc.ConnectionState.NOT_CONNECTED) 193 if (state.ConnectionState != CrOnc.ConnectionState.NOT_CONNECTED)
144 return; 194 return;
195
145 chrome.networkingPrivate.startConnect(state.GUID, function() { 196 chrome.networkingPrivate.startConnect(state.GUID, function() {
146 var lastError = chrome.runtime.lastError; 197 var lastError = chrome.runtime.lastError;
147 if (lastError && lastError != 'connecting') 198 if (lastError && lastError != 'connecting')
148 console.error('networkingPrivate.startConnect error: ' + lastError); 199 console.error('networkingPrivate.startConnect error: ' + lastError);
149 }); 200 });
150 }, 201 },
151 }); 202 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698