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 namespace chromeos { | |
20 | |
21 // Implements the chrome.networkingPrivate.getProperties method. | |
22 class NetworkingGetPropertiesFunction : public AsyncExtensionFunction { | |
23 public: | |
24 NetworkingGetPropertiesFunction() {} | |
25 DECLARE_EXTENSION_FUNCTION_NAME("networkingPrivate.getProperties"); | |
26 | |
27 protected: | |
28 virtual ~NetworkingGetPropertiesFunction(); | |
29 | |
30 // AsyncExtensionFunction overrides. | |
31 virtual bool RunImpl() OVERRIDE; | |
32 | |
33 private: | |
34 void ResultCallback(DBusMethodCallStatus call_status, | |
35 const base::DictionaryValue& result); | |
36 DISALLOW_COPY_AND_ASSIGN(NetworkingGetPropertiesFunction); | |
37 }; | |
38 | |
39 // Implements the chrome.networkingPrivate.getVisibleNetworks method. | |
40 class NetworkingGetVisibleNetworksFunction : public AsyncExtensionFunction { | |
41 public: | |
42 NetworkingGetVisibleNetworksFunction() {} | |
43 DECLARE_EXTENSION_FUNCTION_NAME("networkingPrivate.getVisibleNetworks"); | |
44 | |
45 protected: | |
46 virtual ~NetworkingGetVisibleNetworksFunction(); | |
47 | |
48 // AsyncExtensionFunction overrides. | |
49 virtual bool RunImpl() OVERRIDE; | |
50 | |
51 private: | |
52 class ResultList : public base::RefCounted<ResultList> { | |
53 public: | |
54 ResultList() : list(new base::ListValue), count(0) {} | |
55 scoped_ptr<base::ListValue> list; | |
56 int count; | |
57 }; | |
58 | |
59 class ScopedDecrementer { | |
60 public: | |
61 ScopedDecrementer(NetworkingGetVisibleNetworksFunction* parent, | |
62 scoped_refptr<ResultList> result_list); | |
63 ~ScopedDecrementer(); | |
mazda
2013/01/16 22:08:52
nit: add an empty line.
Greg Spencer (Chromium)
2013/01/16 22:29:17
Done.
| |
64 private: | |
65 NetworkingGetVisibleNetworksFunction* parent_; | |
66 scoped_refptr<ResultList> result_list_; | |
67 }; | |
68 | |
69 void ManagerPropertiesCallback(const std::string& network_type, | |
70 DBusMethodCallStatus call_status, | |
71 const base::DictionaryValue& result); | |
72 void ServicePropertiesCallback(const std::string& service_path, | |
73 const std::string& network_type, | |
74 scoped_refptr<ResultList> result_list, | |
75 DBusMethodCallStatus call_status, | |
76 const base::DictionaryValue& result); | |
77 DISALLOW_COPY_AND_ASSIGN(NetworkingGetVisibleNetworksFunction); | |
78 }; | |
79 | |
80 // Implements the chrome.networkingPrivate.requestConnect method. | |
81 class NetworkingRequestConnectFunction : public AsyncExtensionFunction { | |
82 public: | |
83 NetworkingRequestConnectFunction() {} | |
84 DECLARE_EXTENSION_FUNCTION_NAME("networkingPrivate.requestConnect"); | |
85 | |
86 protected: | |
87 virtual ~NetworkingRequestConnectFunction(); | |
88 | |
89 // AsyncExtensionFunction overrides. | |
90 virtual bool RunImpl() OVERRIDE; | |
91 | |
92 private: | |
93 void ConnectSuccess(); | |
94 void ConnectFailed(const std::string& errorName, | |
95 const std::string& errorMessage); | |
96 DISALLOW_COPY_AND_ASSIGN(NetworkingRequestConnectFunction); | |
97 }; | |
98 | |
99 // Implements the chrome.networkingPrivate.requestDisconnect method. | |
100 class NetworkingRequestDisconnectFunction : public AsyncExtensionFunction { | |
101 public: | |
102 NetworkingRequestDisconnectFunction() {} | |
103 DECLARE_EXTENSION_FUNCTION_NAME("networkingPrivate.requestDisconnect"); | |
104 | |
105 protected: | |
106 virtual ~NetworkingRequestDisconnectFunction(); | |
107 | |
108 // AsyncExtensionFunction overrides. | |
109 virtual bool RunImpl() OVERRIDE; | |
110 | |
111 private: | |
112 void ConnectSuccess(); | |
113 void ConnectFailed(const std::string& errorName, | |
114 const std::string& errorMessage); | |
115 DISALLOW_COPY_AND_ASSIGN(NetworkingRequestDisconnectFunction); | |
116 }; | |
117 | |
118 // Manages and registers the networkingPrivate API with the extension system. | |
119 class NetworkingPrivateAPI : public ProfileKeyedService { | |
120 public: | |
121 explicit NetworkingPrivateAPI(Profile* profile); | |
122 virtual ~NetworkingPrivateAPI(); | |
123 | |
124 // ProfileKeyedService overrides. | |
125 virtual void Shutdown() OVERRIDE; | |
126 | |
127 // Convenience function to return the NetworkingPrivateAPI for a Profile. | |
128 static NetworkingPrivateAPI* Get(Profile* profile); | |
129 private: | |
130 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateAPI); | |
131 }; | |
132 | |
133 } // chromeos | |
mazda
2013/01/16 22:08:52
// namespace chromeos
Greg Spencer (Chromium)
2013/01/16 22:29:17
Done.
| |
134 | |
135 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_NETWORKING_PRIVATE_API_H_ | |
OLD | NEW |