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

Unified Diff: chrome/browser/chromeos/extensions/networking_private_api.h

Issue 11975015: This adds a private extension API to use for simple networking (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed self review nits Created 7 years, 11 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
Index: chrome/browser/chromeos/extensions/networking_private_api.h
diff --git a/chrome/browser/chromeos/extensions/networking_private_api.h b/chrome/browser/chromeos/extensions/networking_private_api.h
new file mode 100644
index 0000000000000000000000000000000000000000..f87acd5e7a1f7b15c3600cc6df7bb3a56e733e90
--- /dev/null
+++ b/chrome/browser/chromeos/extensions/networking_private_api.h
@@ -0,0 +1,135 @@
+// Copyright (c) 2013 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.
+
+// These classes implement the chrome.networkingPrivate JavaScript extension
+// API.
+
+#ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_NETWORKING_PRIVATE_API_H_
+#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_NETWORKING_PRIVATE_API_H_
+
+#include <string>
+
+#include "base/memory/ref_counted.h"
+#include "base/values.h"
+#include "chrome/browser/extensions/extension_function.h"
+#include "chrome/browser/profiles/profile_keyed_service.h"
+#include "chromeos/dbus/dbus_method_call_status.h"
+
+namespace chromeos {
+
+// Implements the chrome.networkingPrivate.getProperties method.
+class NetworkingGetPropertiesFunction : public AsyncExtensionFunction {
+ public:
+ NetworkingGetPropertiesFunction() {}
+ DECLARE_EXTENSION_FUNCTION_NAME("networkingPrivate.getProperties");
+
+ protected:
+ virtual ~NetworkingGetPropertiesFunction();
+
+ // AsyncExtensionFunction overrides.
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ void ResultCallback(DBusMethodCallStatus call_status,
+ const base::DictionaryValue& result);
+ DISALLOW_COPY_AND_ASSIGN(NetworkingGetPropertiesFunction);
+};
+
+// Implements the chrome.networkingPrivate.getVisibleNetworks method.
+class NetworkingGetVisibleNetworksFunction : public AsyncExtensionFunction {
+ public:
+ NetworkingGetVisibleNetworksFunction() {}
+ DECLARE_EXTENSION_FUNCTION_NAME("networkingPrivate.getVisibleNetworks");
+
+ protected:
+ virtual ~NetworkingGetVisibleNetworksFunction();
+
+ // AsyncExtensionFunction overrides.
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ class ResultList : public base::RefCounted<ResultList> {
+ public:
+ ResultList() : list(new base::ListValue), count(0) {}
+ scoped_ptr<base::ListValue> list;
+ int count;
+ };
+
+ class ScopedDecrementer {
+ public:
+ ScopedDecrementer(NetworkingGetVisibleNetworksFunction* parent,
+ scoped_refptr<ResultList> result_list);
+ ~ScopedDecrementer();
mazda 2013/01/16 22:08:52 nit: add an empty line.
Greg Spencer (Chromium) 2013/01/16 22:29:17 Done.
+ private:
+ NetworkingGetVisibleNetworksFunction* parent_;
+ scoped_refptr<ResultList> result_list_;
+ };
+
+ void ManagerPropertiesCallback(const std::string& network_type,
+ DBusMethodCallStatus call_status,
+ const base::DictionaryValue& result);
+ void ServicePropertiesCallback(const std::string& service_path,
+ const std::string& network_type,
+ scoped_refptr<ResultList> result_list,
+ DBusMethodCallStatus call_status,
+ const base::DictionaryValue& result);
+ DISALLOW_COPY_AND_ASSIGN(NetworkingGetVisibleNetworksFunction);
+};
+
+// Implements the chrome.networkingPrivate.requestConnect method.
+class NetworkingRequestConnectFunction : public AsyncExtensionFunction {
+ public:
+ NetworkingRequestConnectFunction() {}
+ DECLARE_EXTENSION_FUNCTION_NAME("networkingPrivate.requestConnect");
+
+ protected:
+ virtual ~NetworkingRequestConnectFunction();
+
+ // AsyncExtensionFunction overrides.
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ void ConnectSuccess();
+ void ConnectFailed(const std::string& errorName,
+ const std::string& errorMessage);
+ DISALLOW_COPY_AND_ASSIGN(NetworkingRequestConnectFunction);
+};
+
+// Implements the chrome.networkingPrivate.requestDisconnect method.
+class NetworkingRequestDisconnectFunction : public AsyncExtensionFunction {
+ public:
+ NetworkingRequestDisconnectFunction() {}
+ DECLARE_EXTENSION_FUNCTION_NAME("networkingPrivate.requestDisconnect");
+
+ protected:
+ virtual ~NetworkingRequestDisconnectFunction();
+
+ // AsyncExtensionFunction overrides.
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ void ConnectSuccess();
+ void ConnectFailed(const std::string& errorName,
+ const std::string& errorMessage);
+ DISALLOW_COPY_AND_ASSIGN(NetworkingRequestDisconnectFunction);
+};
+
+// Manages and registers the networkingPrivate API with the extension system.
+class NetworkingPrivateAPI : public ProfileKeyedService {
+ public:
+ explicit NetworkingPrivateAPI(Profile* profile);
+ virtual ~NetworkingPrivateAPI();
+
+ // ProfileKeyedService overrides.
+ virtual void Shutdown() OVERRIDE;
+
+ // Convenience function to return the NetworkingPrivateAPI for a Profile.
+ static NetworkingPrivateAPI* Get(Profile* profile);
+ private:
+ DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateAPI);
+};
+
+} // chromeos
mazda 2013/01/16 22:08:52 // namespace chromeos
Greg Spencer (Chromium) 2013/01/16 22:29:17 Done.
+
+#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_NETWORKING_PRIVATE_API_H_

Powered by Google App Engine
This is Rietveld 408576698