OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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 // These classes implement the chrome.networkingPrivate JavaScript extension |
| 6 // API. |
| 7 |
| 8 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_NETWORKING_PRIVATE_API_H_ |
| 9 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_NETWORKING_PRIVATE_API_H_ |
| 10 |
| 11 #include <string> |
| 12 |
| 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/values.h" |
| 15 #include "chrome/browser/extensions/extension_function.h" |
| 16 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 17 #include "chromeos/dbus/dbus_method_call_status.h" |
| 18 |
| 19 // Implements the chrome.networkingPrivate.getProperties method. |
| 20 class NetworkingPrivateGetPropertiesFunction : public AsyncExtensionFunction { |
| 21 public: |
| 22 NetworkingPrivateGetPropertiesFunction() {} |
| 23 DECLARE_EXTENSION_FUNCTION("networkingPrivate.getProperties", |
| 24 NETWORKINGPRIVATE_GETPROPERTIES); |
| 25 |
| 26 protected: |
| 27 virtual ~NetworkingPrivateGetPropertiesFunction(); |
| 28 |
| 29 // AsyncExtensionFunction overrides. |
| 30 virtual bool RunImpl() OVERRIDE; |
| 31 |
| 32 private: |
| 33 void ResultCallback(chromeos::DBusMethodCallStatus call_status, |
| 34 const base::DictionaryValue& result); |
| 35 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetPropertiesFunction); |
| 36 }; |
| 37 |
| 38 // Implements the chrome.networkingPrivate.getVisibleNetworks method. |
| 39 class NetworkingPrivateGetVisibleNetworksFunction |
| 40 : public AsyncExtensionFunction { |
| 41 public: |
| 42 NetworkingPrivateGetVisibleNetworksFunction() {} |
| 43 DECLARE_EXTENSION_FUNCTION("networkingPrivate.getVisibleNetworks", |
| 44 NETWORKINGPRIVATE_GETVISIBLENETWORKS); |
| 45 |
| 46 protected: |
| 47 virtual ~NetworkingPrivateGetVisibleNetworksFunction(); |
| 48 |
| 49 // AsyncExtensionFunction overrides. |
| 50 virtual bool RunImpl() OVERRIDE; |
| 51 |
| 52 private: |
| 53 class ResultList; |
| 54 |
| 55 // Receives the result of a call to GetProperties on the Shill Manager API. |
| 56 void ManagerPropertiesCallback(const std::string& network_type, |
| 57 chromeos::DBusMethodCallStatus call_status, |
| 58 const base::DictionaryValue& result); |
| 59 |
| 60 // Receives the result of a call to GetProperties on the Shill Service API. |
| 61 void ServicePropertiesCallback(const std::string& service_path, |
| 62 const std::string& network_type, |
| 63 scoped_refptr<ResultList> result_list, |
| 64 chromeos::DBusMethodCallStatus call_status, |
| 65 const base::DictionaryValue& result); |
| 66 // Gets called when all the results are in. |
| 67 void SendResultCallback(scoped_ptr<base::ListValue> result_list); |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetVisibleNetworksFunction); |
| 70 }; |
| 71 |
| 72 // Implements the chrome.networkingPrivate.startConnect method. |
| 73 class NetworkingPrivateStartConnectFunction : public AsyncExtensionFunction { |
| 74 public: |
| 75 NetworkingPrivateStartConnectFunction() {} |
| 76 DECLARE_EXTENSION_FUNCTION("networkingPrivate.startConnect", |
| 77 NETWORKINGPRIVATE_STARTCONNECT); |
| 78 |
| 79 protected: |
| 80 virtual ~NetworkingPrivateStartConnectFunction(); |
| 81 |
| 82 // AsyncExtensionFunction overrides. |
| 83 virtual bool RunImpl() OVERRIDE; |
| 84 |
| 85 private: |
| 86 // Called when the request to connect succeeds. Doesn't mean that the connect |
| 87 // itself succeeded, just that the request did. |
| 88 void ConnectionStartSuccess(); |
| 89 |
| 90 void ConnectionStartFailed(const std::string& errorName, |
| 91 const std::string& errorMessage); |
| 92 |
| 93 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateStartConnectFunction); |
| 94 }; |
| 95 |
| 96 // Implements the chrome.networkingPrivate.startDisconnect method. |
| 97 class NetworkingPrivateStartDisconnectFunction |
| 98 : public AsyncExtensionFunction { |
| 99 public: |
| 100 NetworkingPrivateStartDisconnectFunction() {} |
| 101 DECLARE_EXTENSION_FUNCTION("networkingPrivate.startDisconnect", |
| 102 NETWORKINGPRIVATE_STARTDISCONNECT); |
| 103 |
| 104 protected: |
| 105 virtual ~NetworkingPrivateStartDisconnectFunction(); |
| 106 |
| 107 // AsyncExtensionFunction overrides. |
| 108 virtual bool RunImpl() OVERRIDE; |
| 109 |
| 110 private: |
| 111 // Called when the request to disconnect succeeds. Doesn't mean that the |
| 112 // disconnect itself succeeded, just that the request did. |
| 113 void DisconnectionStartSuccess(); |
| 114 |
| 115 void DisconnectionStartFailed(const std::string& errorName, |
| 116 const std::string& errorMessage); |
| 117 |
| 118 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateStartDisconnectFunction); |
| 119 }; |
| 120 |
| 121 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_NETWORKING_PRIVATE_API_H_ |
OLD | NEW |