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

Side by Side Diff: chrome/browser/resources/chromeos/network/network_config.js

Issue 260083007: Replace chrome://network implementation with networkConfig API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 'use strict';
6
7 // This object provides a similar API to chrome.networkingPrivate. It simulates
8 // the extension callback model by storing callbacks in a member object and
9 // invoking them when the corresponding method is called by Chrome in response
10 // to a chrome.send call.
11
12 var networkConfig = {
13 // ONC types
14 Type: {
15 All: 'All',
16 Cellular: 'Cellular',
17 Ethernet: 'Ethernet',
18 VPN: 'VPN',
19 WiFi: 'WiFi'
20 },
21
22 // ONC Service properties
23 Service: {
24 Address: 'Address',
25 Cellular: {
26 NetworkTechnology: 'Cellular.NetworkTechnology',
27 ActivationState: 'Cellular.ActivationState',
28 RoamingState: 'Cellular.RoamingState',
29 OutOfCredits: 'Cellular.OutOfCredits'
30 },
31 Connectable: 'Connectable',
32 ConnectionState: 'ConnectionState',
33 EAP: {
34 EAP: 'EAP.EAP'
michaelpg 2014/04/29 19:51:00 indent off
stevenjb 2014/05/01 01:45:14 Done.
35 },
36 ErrorState: 'ErrorState',
37 GUID: 'GUID',
38 Name: 'Name',
39 OncSource: 'onc_source',
40 Profile: 'Profile',
41 WiFi: {
42 Security: 'WiFi.Security',
43 SignalStrength: 'WiFi.SignalStrength'
44 },
45 ServicePath: 'ServicePath',
46 Type: 'Type'
47 },
48
49 // Callback storage. Callbacks will be responded to in the order in which
50 // they were called, so we store these as a FIFO.
51 callbacks: {
52 getVisibleNetworks: [],
53 getFavoriteNetworks: []
54 },
55
56
57 /**
58 * Implement networkingPrivate.getVisibleNetworks
59 *
60 * @param {string} type The type of networks to return
61 */
62 getVisibleNetworks: function(type, callback) {
63 networkConfig.callbacks.getVisibleNetworks.push(callback);
64 chrome.send('networkConfig.getVisibleNetworks', [type]);
65 },
66
67 /**
68 * Callback for networkingPrivate.getVisibleNetworks
69 *
70 * @param {string} data The visible networks as a JSON string
71 */
72 getVisibleNetworksCallback: function(data) {
73 if (networkConfig.callbacks.getVisibleNetworks.length) {
74 networkConfig.callbacks.getVisibleNetworks.shift()(data);
75 }
76 },
77
78 /**
79 * Implement networkingPrivate.getFavoriteNetworks
80 *
81 * @param {string} type The type of networks to return
82 */
83 getFavoriteNetworks: function(type, callback) {
84 networkConfig.callbacks.getFavoriteNetworks.push(callback);
85 chrome.send('networkConfig.getFavoriteNetworks', [type]);
86 },
87
88 /**
89 * Callback for networkingPrivate.getFavoriteNetworks
90 *
91 * @param {string} data The favorite networks as a JSON string
92 */
93 getFavoriteNetworksCallback: function(data) {
94 if (networkConfig.callbacks.getFavoriteNetworks.length) {
95 networkConfig.callbacks.getFavoriteNetworks.shift()(data);
96 }
97 }
98 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698