OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
gauravsh
2013/02/26 21:25:03
NIT: 2013
pneubeck (no reviews)
2013/02/27 09:49:25
Done.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_NET_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_NET_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/callback.h" | |
13 #include "base/gtest_prod_util.h" | |
14 #include "chromeos/chromeos_export.h" | |
15 #include "chromeos/network/network_handler_callbacks.h" | |
16 | |
17 namespace base { | |
18 class DictionaryValue; | |
19 } | |
20 | |
21 namespace chromeos { | |
22 | |
23 // The ManagedNetworkConfigurationHandler class is used to create and configure | |
24 // networks in ChromeOS using ONC. | |
25 // | |
26 // Its interface exposes only ONC and should decouple users from Shill. | |
27 // Internally it translates ONC to Shill dictionaries and calls through to the | |
28 // NetworkConfigurationHandler. | |
29 // | |
30 // For accessing lists of visible networks, and other state information, see the | |
31 // class NetworkStateHandler. | |
32 // | |
33 // This is a singleton and it's lifetime is managed by by the Chrome startup | |
gauravsh
2013/02/26 21:25:03
NIT: s/it's/its/, s/by by/by/
pneubeck (no reviews)
2013/02/27 09:49:25
Done.
| |
34 // code. | |
35 // | |
36 // Network configurations are referred to by Shill's service path. These | |
37 // identifiers should at most be used to also access network state using the | |
38 // NetworkStateHandler, but dependencies to Shill should be avoided. In the | |
39 // future, we may switch to other identifiers. | |
40 // | |
41 // Note on callbacks: Because all the functions here are meant to be | |
42 // asynchronous, they all take a |callback| of some type, and an | |
43 // |error_callback|. When the operation succeeds, |callback| will be called, and | |
44 // when it doesn't, |error_callback| will be called with information about the | |
45 // error, including a symbolic name for the error and often some error message | |
46 // that is suitable for logging. None of the error message text is meant for | |
47 // user consumption. | |
48 // | |
49 // TODO(pneubeck): Enforce network policies. | |
50 | |
51 class ManagedNetworkConfigurationHandler { | |
52 public: | |
53 // Initializes the singleton. | |
54 static void Initialize(); | |
55 | |
56 // Returns if the singleton is initialized. | |
57 static bool IsInitialized(); | |
58 | |
59 // Destroys the singleton. | |
60 static void Shutdown(); | |
61 | |
62 // Initialize() must be called before this. | |
63 static ManagedNetworkConfigurationHandler* Get(); | |
64 | |
65 // Provides the properties of the network with |service_path| to |callback|. | |
66 void GetProperties( | |
67 const std::string& service_path, | |
68 const network_handler::DictionaryResultCallback& callback, | |
69 const network_handler::ErrorCallback& error_callback) const; | |
70 | |
71 // Sets the user's settings of an already configured network with | |
72 // |service_path|. A network can be initially configured by calling | |
73 // CreateConfiguration or if it is managed by a policy. The given properties | |
74 // will be merged with the existing settings, and it won't clear any existing | |
75 // properties. | |
76 void SetProperties( | |
77 const std::string& service_path, | |
78 const base::DictionaryValue& properties, | |
79 const base::Closure& callback, | |
80 const network_handler::ErrorCallback& error_callback) const; | |
81 | |
82 // Initiates a connection with network that has |service_path|. |callback| is | |
83 // called if the connection request was successfully handled. That doesn't | |
84 // mean that the connection was successfully established. | |
85 void Connect(const std::string& service_path, | |
86 const base::Closure& callback, | |
87 const network_handler::ErrorCallback& error_callback) const; | |
88 | |
89 // Initiates a disconnect with the network at |service_path|. |callback| is | |
90 // called if the diconnect request was successfully handled. That doesn't mean | |
91 // that the network is already diconnected. | |
92 void Disconnect(const std::string& service_path, | |
93 const base::Closure& callback, | |
94 const network_handler::ErrorCallback& error_callback) const; | |
95 | |
96 | |
stevenjb
2013/02/26 17:31:24
nit: one blank line
pneubeck (no reviews)
2013/02/27 09:49:25
Done.
| |
97 // Initially configures an unconfigured network with the given user settings | |
98 // and returns the new identifier to |callback| if successful. Fails if the | |
99 // network was already configured by a call to this function or because of a | |
100 // policy. | |
101 void CreateConfiguration( | |
102 const base::DictionaryValue& properties, | |
103 const network_handler::StringResultCallback& callback, | |
104 const network_handler::ErrorCallback& error_callback) const; | |
105 | |
106 // Removes the user's configuration from the network with |service_path|. The | |
107 // network may still show up in the visible networks after this, but no user | |
108 // configuration will remain. If it was managed, it will still be configured. | |
109 void RemoveConfiguration( | |
110 const std::string& service_path, | |
111 const base::Closure& callback, | |
112 const network_handler::ErrorCallback& error_callback) const; | |
113 | |
114 private: | |
115 ManagedNetworkConfigurationHandler(); | |
116 ~ManagedNetworkConfigurationHandler(); | |
117 | |
118 DISALLOW_COPY_AND_ASSIGN(ManagedNetworkConfigurationHandler); | |
119 }; | |
120 | |
121 } // namespace chromeos | |
122 | |
123 #endif // CHROME_BROWSER_CHROMEOS_NET_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_ | |
OLD | NEW |