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..4ee893c58ef50966e9a6b22c833c1d93a89df6ad |
--- /dev/null |
+++ b/chrome/browser/chromeos/extensions/networking_private_api.h |
@@ -0,0 +1,131 @@ |
+// 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; |
+ |
+ 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: |
+ // Called when the request to connect succeeds. Doesn't mean that the connect |
+ // itself succeeded, just that the request did. |
+ void ConnectRequestSuccess(); |
+ |
+ void ConnectRequestFailed(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: |
+ // Called when the request to disconnect succeeds. Doesn't mean that the |
+ // disconnect itself succeeded, just that the request did. |
+ void DisconnectRequestSuccess(); |
+ |
+ void DisconnectRequestFailed(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); |
+}; |
+ |
+} // namespace chromeos |
+ |
+#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_NETWORKING_PRIVATE_API_H_ |