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

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: Fix compile. 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,
85 },
86
87 /**
88 * Whether to handle "item-selected" for network items.
89 * If this property is false, "network-item-selected" event is fired
90 * carrying CrOnc.NetworkStateProperties as event detail.
91 *
92 * @type {Function}
93 */
94 handleNetworkItemSelected: {
95 type: Boolean,
96 value: false,
97 },
65 }, 98 },
66 99
67 /** 100 /**
68 * Listener function for chrome.networkingPrivate.onNetworkListChanged event. 101 * Listener function for chrome.networkingPrivate.onNetworkListChanged event.
69 * @type {function(!Array<string>)} 102 * @type {function(!Array<string>)}
70 * @private 103 * @private
71 */ 104 */
72 networkListChangedListener_: function() {}, 105 networkListChangedListener_: function() {},
73 106
74 /** 107 /**
(...skipping 20 matching lines...) Expand all
95 128
96 /** @override */ 129 /** @override */
97 detached: function() { 130 detached: function() {
98 chrome.networkingPrivate.onNetworkListChanged.removeListener( 131 chrome.networkingPrivate.onNetworkListChanged.removeListener(
99 this.networkListChangedListener_); 132 this.networkListChangedListener_);
100 chrome.networkingPrivate.onDeviceStateListChanged.removeListener( 133 chrome.networkingPrivate.onDeviceStateListChanged.removeListener(
101 this.deviceStateListChangedListener_); 134 this.deviceStateListChangedListener_);
102 }, 135 },
103 136
104 /** 137 /**
105 * Polymer chnaged function. 138 * Polymer changed function.
106 * @private 139 * @private
107 */ 140 */
108 networkListOpenedChanged_: function() { 141 networkListOpenedChanged_: function() {
109 if (this.networkListOpened) 142 if (this.networkListOpened)
110 chrome.networkingPrivate.requestNetworkScan(); 143 chrome.networkingPrivate.requestNetworkScan();
111 }, 144 },
112 145
113 /** 146 /**
114 * Request the list of visible networks. 147 * Request the list of visible networks.
115 * @private 148 * @private
(...skipping 11 matching lines...) Expand all
127 /** 160 /**
128 * @param {!Array<!CrOnc.NetworkStateProperties>} states 161 * @param {!Array<!CrOnc.NetworkStateProperties>} states
129 * @private 162 * @private
130 */ 163 */
131 getNetworksCallback_: function(states) { 164 getNetworksCallback_: function(states) {
132 this.activeNetworkState = states[0] || null; 165 this.activeNetworkState = states[0] || null;
133 this.networkStateList = states; 166 this.networkStateList = states;
134 }, 167 },
135 168
136 /** 169 /**
137 * Event triggered when a cr-network-list-item is selected. 170 * Event triggered when a cr-network-list-network-item is selected.
138 * @param {!{detail: !CrOnc.NetworkStateProperties}} event 171 * @param {!{detail: !CrOnc.NetworkStateProperties}} event
139 * @private 172 * @private
140 */ 173 */
141 onNetworkListItemSelected_: function(event) { 174 onNetworkListItemSelected_: function(event) {
142 var state = event.detail; 175 var state = event.detail;
176
177 if (!this.handleNetworkItemSelected) {
178 this.fire("network-item-selected", state);
179 return;
180 }
181
143 if (state.ConnectionState != CrOnc.ConnectionState.NOT_CONNECTED) 182 if (state.ConnectionState != CrOnc.ConnectionState.NOT_CONNECTED)
144 return; 183 return;
184
145 chrome.networkingPrivate.startConnect(state.GUID, function() { 185 chrome.networkingPrivate.startConnect(state.GUID, function() {
146 var lastError = chrome.runtime.lastError; 186 var lastError = chrome.runtime.lastError;
147 if (lastError && lastError != 'connecting') 187 if (lastError && lastError != 'connecting')
148 console.error('networkingPrivate.startConnect error: ' + lastError); 188 console.error('networkingPrivate.startConnect error: ' + lastError);
149 }); 189 });
150 }, 190 },
151 }); 191 });
OLDNEW
« no previous file with comments | « ui/webui/resources/cr_elements/network/cr_network_select.html ('k') | ui/webui/resources/cr_elements_resources.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698