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

Side by Side 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: Review changes 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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;
53
54 void ManagerPropertiesCallback(const std::string& network_type,
55 DBusMethodCallStatus call_status,
56 const base::DictionaryValue& result);
57
58 void ServicePropertiesCallback(const std::string& service_path,
59 const std::string& network_type,
60 scoped_refptr<ResultList> result_list,
61 DBusMethodCallStatus call_status,
62 const base::DictionaryValue& result);
63
64 DISALLOW_COPY_AND_ASSIGN(NetworkingGetVisibleNetworksFunction);
65 };
66
67 // Implements the chrome.networkingPrivate.requestConnect method.
68 class NetworkingRequestConnectFunction : public AsyncExtensionFunction {
69 public:
70 NetworkingRequestConnectFunction() {}
71 DECLARE_EXTENSION_FUNCTION_NAME("networkingPrivate.requestConnect");
72
73 protected:
74 virtual ~NetworkingRequestConnectFunction();
75
76 // AsyncExtensionFunction overrides.
77 virtual bool RunImpl() OVERRIDE;
78
79 private:
80 // Called when the request to connect succeeds. Doesn't mean that the connect
81 // itself succeeded, just that the request did.
82 void ConnectRequestSuccess();
83
84 void ConnectRequestFailed(const std::string& errorName,
85 const std::string& errorMessage);
86
87 DISALLOW_COPY_AND_ASSIGN(NetworkingRequestConnectFunction);
88 };
89
90 // Implements the chrome.networkingPrivate.requestDisconnect method.
91 class NetworkingRequestDisconnectFunction : public AsyncExtensionFunction {
92 public:
93 NetworkingRequestDisconnectFunction() {}
94 DECLARE_EXTENSION_FUNCTION_NAME("networkingPrivate.requestDisconnect");
95
96 protected:
97 virtual ~NetworkingRequestDisconnectFunction();
98
99 // AsyncExtensionFunction overrides.
100 virtual bool RunImpl() OVERRIDE;
101
102 private:
103 // Called when the request to disconnect succeeds. Doesn't mean that the
104 // disconnect itself succeeded, just that the request did.
105 void DisconnectRequestSuccess();
106
107 void DisconnectRequestFailed(const std::string& errorName,
108 const std::string& errorMessage);
109
110 DISALLOW_COPY_AND_ASSIGN(NetworkingRequestDisconnectFunction);
111 };
112
113 // Manages and registers the networkingPrivate API with the extension system.
114 class NetworkingPrivateAPI : public ProfileKeyedService {
115 public:
116 explicit NetworkingPrivateAPI(Profile* profile);
117 virtual ~NetworkingPrivateAPI();
118
119 // ProfileKeyedService overrides.
120 virtual void Shutdown() OVERRIDE;
121
122 // Convenience function to return the NetworkingPrivateAPI for a Profile.
123 static NetworkingPrivateAPI* Get(Profile* profile);
124
125 private:
126 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateAPI);
127 };
128
129 } // namespace chromeos
130
131 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_NETWORKING_PRIVATE_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698