Chromium Code Reviews| Index: chrome/browser/resources/chromeos/network/network_config.js |
| diff --git a/chrome/browser/resources/chromeos/network/network_config.js b/chrome/browser/resources/chromeos/network/network_config.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0fd2bc79641927c29103eaf393df9b34a3d88519 |
| --- /dev/null |
| +++ b/chrome/browser/resources/chromeos/network/network_config.js |
| @@ -0,0 +1,98 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +'use strict'; |
| + |
| +// This object provides a similar API to chrome.networkingPrivate. It simulates |
| +// the extension callback model by storing callbacks in a member object and |
| +// invoking them when the corresponding method is called by Chrome in response |
| +// to a chrome.send call. |
| + |
| +var networkConfig = { |
| + // ONC types |
| + Type: { |
| + All: 'All', |
| + Cellular: 'Cellular', |
| + Ethernet: 'Ethernet', |
| + VPN: 'VPN', |
| + WiFi: 'WiFi' |
| + }, |
| + |
| + // ONC Service properties |
| + Service: { |
| + Address: 'Address', |
| + Cellular: { |
| + NetworkTechnology: 'Cellular.NetworkTechnology', |
| + ActivationState: 'Cellular.ActivationState', |
| + RoamingState: 'Cellular.RoamingState', |
| + OutOfCredits: 'Cellular.OutOfCredits' |
| + }, |
| + Connectable: 'Connectable', |
| + ConnectionState: 'ConnectionState', |
| + EAP: { |
| + EAP: 'EAP.EAP' |
|
michaelpg
2014/04/29 19:51:00
indent off
stevenjb
2014/05/01 01:45:14
Done.
|
| + }, |
| + ErrorState: 'ErrorState', |
| + GUID: 'GUID', |
| + Name: 'Name', |
| + OncSource: 'onc_source', |
| + Profile: 'Profile', |
| + WiFi: { |
| + Security: 'WiFi.Security', |
| + SignalStrength: 'WiFi.SignalStrength' |
| + }, |
| + ServicePath: 'ServicePath', |
| + Type: 'Type' |
| + }, |
| + |
| + // Callback storage. Callbacks will be responded to in the order in which |
| + // they were called, so we store these as a FIFO. |
| + callbacks: { |
| + getVisibleNetworks: [], |
| + getFavoriteNetworks: [] |
| + }, |
| + |
| + |
| + /** |
| + * Implement networkingPrivate.getVisibleNetworks |
| + * |
| + * @param {string} type The type of networks to return |
| + */ |
| + getVisibleNetworks: function(type, callback) { |
| + networkConfig.callbacks.getVisibleNetworks.push(callback); |
| + chrome.send('networkConfig.getVisibleNetworks', [type]); |
| + }, |
| + |
| + /** |
| + * Callback for networkingPrivate.getVisibleNetworks |
| + * |
| + * @param {string} data The visible networks as a JSON string |
| + */ |
| + getVisibleNetworksCallback: function(data) { |
| + if (networkConfig.callbacks.getVisibleNetworks.length) { |
| + networkConfig.callbacks.getVisibleNetworks.shift()(data); |
| + } |
| + }, |
| + |
| + /** |
| + * Implement networkingPrivate.getFavoriteNetworks |
| + * |
| + * @param {string} type The type of networks to return |
| + */ |
| + getFavoriteNetworks: function(type, callback) { |
| + networkConfig.callbacks.getFavoriteNetworks.push(callback); |
| + chrome.send('networkConfig.getFavoriteNetworks', [type]); |
| + }, |
| + |
| + /** |
| + * Callback for networkingPrivate.getFavoriteNetworks |
| + * |
| + * @param {string} data The favorite networks as a JSON string |
| + */ |
| + getFavoriteNetworksCallback: function(data) { |
| + if (networkConfig.callbacks.getFavoriteNetworks.length) { |
| + networkConfig.callbacks.getFavoriteNetworks.shift()(data); |
| + } |
| + } |
| +}; |