OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_ | 5 #ifndef CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_ |
6 #define CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_ | 6 #define CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "chromeos/chromeos_export.h" | 15 #include "chromeos/chromeos_export.h" |
16 #include "chromeos/network/network_handler_callbacks.h" | 16 #include "chromeos/network/network_handler_callbacks.h" |
17 #include "chromeos/network/onc/onc_constants.h" | 17 #include "chromeos/network/onc/onc_constants.h" |
18 | 18 |
19 namespace base { | 19 namespace base { |
20 class DictionaryValue; | 20 class DictionaryValue; |
21 class ListValue; | 21 class ListValue; |
22 } | 22 } |
23 | 23 |
24 namespace chromeos { | 24 namespace chromeos { |
25 | 25 |
| 26 class NetworkUIData; |
| 27 |
26 // The ManagedNetworkConfigurationHandler class is used to create and configure | 28 // The ManagedNetworkConfigurationHandler class is used to create and configure |
27 // networks in ChromeOS using ONC and takes care of network policies. | 29 // networks in ChromeOS using ONC and takes care of network policies. |
28 // | 30 // |
29 // Its interface exposes only ONC and should decouple users from Shill. | 31 // Its interface exposes only ONC and should decouple users from Shill. |
30 // Internally it translates ONC to Shill dictionaries and calls through to the | 32 // Internally it translates ONC to Shill dictionaries and calls through to the |
31 // NetworkConfigurationHandler. | 33 // NetworkConfigurationHandler. |
32 // | 34 // |
33 // For accessing lists of visible networks, and other state information, see the | 35 // For accessing lists of visible networks, and other state information, see the |
34 // class NetworkStateHandler. | 36 // class NetworkStateHandler. |
35 // | 37 // |
(...skipping 21 matching lines...) Expand all Loading... |
57 | 59 |
58 // Returns if the singleton is initialized. | 60 // Returns if the singleton is initialized. |
59 static bool IsInitialized(); | 61 static bool IsInitialized(); |
60 | 62 |
61 // Destroys the singleton. | 63 // Destroys the singleton. |
62 static void Shutdown(); | 64 static void Shutdown(); |
63 | 65 |
64 // Initialize() must be called before this. | 66 // Initialize() must be called before this. |
65 static ManagedNetworkConfigurationHandler* Get(); | 67 static ManagedNetworkConfigurationHandler* Get(); |
66 | 68 |
| 69 // Returns the NetworkUIData parsed from the UIData property of |
| 70 // |shill_dictionary|. If parsing fails or the field doesn't exist, returns |
| 71 // NULL. |
| 72 static scoped_ptr<NetworkUIData> GetUIData( |
| 73 const base::DictionaryValue& shill_dictionary); |
| 74 |
67 // Provides the properties of the network with |service_path| to |callback|. | 75 // Provides the properties of the network with |service_path| to |callback|. |
68 void GetProperties( | 76 void GetProperties( |
69 const std::string& service_path, | 77 const std::string& service_path, |
70 const network_handler::DictionaryResultCallback& callback, | 78 const network_handler::DictionaryResultCallback& callback, |
71 const network_handler::ErrorCallback& error_callback) const; | 79 const network_handler::ErrorCallback& error_callback) const; |
72 | 80 |
73 // Provides the managed properties of the network with |service_path| to | 81 // Provides the managed properties of the network with |service_path| to |
74 // |callback|. | 82 // |callback|. |
75 void GetManagedProperties( | 83 void GetManagedProperties( |
76 const std::string& service_path, | 84 const std::string& service_path, |
77 const network_handler::DictionaryResultCallback& callback, | 85 const network_handler::DictionaryResultCallback& callback, |
78 const network_handler::ErrorCallback& error_callback); | 86 const network_handler::ErrorCallback& error_callback); |
79 | 87 |
80 // Sets the user's settings of an already configured network with | 88 // Sets the user's settings of an already configured network with |
81 // |service_path|. A network can be initially configured by calling | 89 // |service_path|. A network can be initially configured by calling |
82 // CreateConfiguration or if it is managed by a policy. The given properties | 90 // CreateConfiguration or if it is managed by a policy. The given properties |
83 // will be merged with the existing settings, and it won't clear any existing | 91 // will be merged with the existing settings, and it won't clear any existing |
84 // properties. | 92 // properties. |
85 void SetProperties( | 93 void SetProperties( |
86 const std::string& service_path, | 94 const std::string& service_path, |
87 const base::DictionaryValue& user_settings, | 95 const base::DictionaryValue& user_settings, |
88 const base::Closure& callback, | 96 const base::Closure& callback, |
89 const network_handler::ErrorCallback& error_callback) const; | 97 const network_handler::ErrorCallback& error_callback) const; |
90 | 98 |
91 // Initiates a connection with network that has |service_path|. |callback| is | |
92 // called if the connection request was successfully handled. That doesn't | |
93 // mean that the connection was successfully established. | |
94 void Connect(const std::string& service_path, | |
95 const base::Closure& callback, | |
96 const network_handler::ErrorCallback& error_callback) const; | |
97 | |
98 // Initiates a disconnect with the network at |service_path|. |callback| is | |
99 // called if the diconnect request was successfully handled. That doesn't mean | |
100 // that the network is already diconnected. | |
101 void Disconnect(const std::string& service_path, | |
102 const base::Closure& callback, | |
103 const network_handler::ErrorCallback& error_callback) const; | |
104 | |
105 // Initially configures an unconfigured network with the given user settings | 99 // Initially configures an unconfigured network with the given user settings |
106 // and returns the new identifier to |callback| if successful. Fails if the | 100 // and returns the new identifier to |callback| if successful. Fails if the |
107 // network was already configured by a call to this function or because of a | 101 // network was already configured by a call to this function or because of a |
108 // policy. | 102 // policy. |
109 void CreateConfiguration( | 103 void CreateConfiguration( |
110 const base::DictionaryValue& properties, | 104 const base::DictionaryValue& properties, |
111 const network_handler::StringResultCallback& callback, | 105 const network_handler::StringResultCallback& callback, |
112 const network_handler::ErrorCallback& error_callback) const; | 106 const network_handler::ErrorCallback& error_callback) const; |
113 | 107 |
114 // Removes the user's configuration from the network with |service_path|. The | 108 // Removes the user's configuration from the network with |service_path|. The |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 145 |
152 // For Shill client callbacks | 146 // For Shill client callbacks |
153 base::WeakPtrFactory<ManagedNetworkConfigurationHandler> weak_ptr_factory_; | 147 base::WeakPtrFactory<ManagedNetworkConfigurationHandler> weak_ptr_factory_; |
154 | 148 |
155 DISALLOW_COPY_AND_ASSIGN(ManagedNetworkConfigurationHandler); | 149 DISALLOW_COPY_AND_ASSIGN(ManagedNetworkConfigurationHandler); |
156 }; | 150 }; |
157 | 151 |
158 } // namespace chromeos | 152 } // namespace chromeos |
159 | 153 |
160 #endif // CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_ | 154 #endif // CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_ |
OLD | NEW |