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

Unified Diff: chrome/browser/resources/chromeos/network/network_config.js

Issue 890663003: Use chrome.networkingPrivate in chrome://network (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + feedback Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/browser_resources.grd ('k') | chrome/browser/resources/chromeos/network_ui/network_ui.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
deleted file mode 100644
index 29ac7a7c1cc33fa8f0d4a2e9819b66a470b4db80..0000000000000000000000000000000000000000
--- a/chrome/browser/resources/chromeos/network/network_config.js
+++ /dev/null
@@ -1,147 +0,0 @@
-// 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';
-
-/**
- * @fileoverview 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 = {
- /**
- * Return the property associated with a key (which may reference a
- * sub-object).
- *
- * @param {Object} properties The object containing the network properties.
- * @param {string} key The ONC key for the property. May refer to a nested
- * propety, e.g. 'WiFi.Security'.
- * @return {*} The value associated with the property.
- */
- getValueFromProperties: function(properties, key) {
- if (!key) {
- console.error('Empty key');
- return undefined;
- }
- var dot = key.indexOf('.');
- if (dot > 0) {
- var key1 = key.substring(0, dot);
- var key2 = key.substring(dot + 1);
- var subobject = properties[key1];
- if (subobject)
- return this.getValueFromProperties(subobject, key2);
- }
- return properties[key];
- },
-
- /**
- * Generate a unique id for 'callback' and store it for future retrieval.
- *
- * @param {function} callback The associated callback.
- * @return {integer} The id of the callback.
- * @private
- */
- callbackId: 1,
- callbackMap: {},
- storeCallback_: function(callback) {
- var id = this.callbackId++;
- this.callbackMap[id] = callback;
- return id;
- },
-
- /**
- * Retrieve the callback associated with |id| and remove it from the map.
- *
- * @param {integer} id The id of the callback.
- * @return {function} The associated callback.
- * @private
- */
- retrieveCallback_: function(id) {
- var callback = this.callbackMap[id];
- delete this.callbackMap[id];
- return callback;
- },
-
- /**
- * Callback invoked by Chrome.
- *
- * @param {Array} args A list of arguments passed to the callback. The first
- * entry must be the callbackId passed to chrome.send.
- */
- chromeCallbackSuccess: function(args) {
- var callbackId = args.shift();
- var callback = this.retrieveCallback_(callbackId);
- this.lastError = '';
- if (callback)
- callback.apply(null, args);
- else
- console.error('Callback not found for id: ' + callbackId);
- },
-
- /**
- * Error Callback invoked by Chrome. Sets lastError and logs to the console.
- *
- * @param {Args} args A list of arguments. The first entry must be the
- * callbackId passed to chrome.send.
- */
- lastError: '',
- chromeCallbackError: function(args) {
- var callbackId = args.shift();
- this.lastError = args.shift();
- console.error('Callback error: "' + this.lastError);
- // We still invoke the callback, but with null args. The callback should
- // check this.lastError and handle that.
- var callback = this.retrieveCallback_(callbackId);
- if (callback)
- callback.apply(null, null);
- },
-
- /**
- * Implement networkingPrivate.getProperties. See networking_private.json.
- *
- * @param {string} guid The guid identifying the network.
- * @param {function()} callback The callback to call on completion.
- */
- getProperties: function(guid, callback) {
- var callbackId = this.storeCallback_(callback);
- chrome.send('networkConfig.getProperties', [callbackId, guid]);
- },
-
- /**
- * Implement networkingPrivate.getManagedProperties. See
- * networking_private.json.
- *
- * @param {string} guid The guid identifying the network.
- * @param {function()} callback The callback to call on completion.
- */
- getManagedProperties: function(guid, callback) {
- var callbackId = this.storeCallback_(callback);
- chrome.send('networkConfig.getManagedProperties', [callbackId, guid]);
- },
-
- /**
- * Implement networkingPrivate.getNetworks. See networking_private.json.
- *
- * @param {string} guid The guid identifying the network.
- * @param {function()} callback The callback to call on completion.
- */
- getNetworks: function(filter, callback) {
- var callbackId = this.storeCallback_(callback);
- chrome.send('networkConfig.getNetworks', [callbackId, filter]);
- },
-
- /**
- * Debugging method to get raw Shill properties
- *
- * @param {string} guid The guid identifying the network.
- * @param {function()} callback The callback to call on completion.
- */
- getShillProperties: function(guid, callback) {
- var callbackId = this.storeCallback_(callback);
- chrome.send('networkConfig.getShillProperties', [callbackId, guid]);
- },
-
-};
« no previous file with comments | « chrome/browser/browser_resources.grd ('k') | chrome/browser/resources/chromeos/network_ui/network_ui.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698