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

Side by Side Diff: chromeos/network/managed_network_configuration_handler.h

Issue 12676017: Adding policy support to the new network configuration stack. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed remaining comments of Steven. Created 7 years, 8 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
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 <string> 9 #include <string>
9 #include <vector>
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 "chromeos/chromeos_export.h" 15 #include "chromeos/chromeos_export.h"
15 #include "chromeos/network/network_handler_callbacks.h" 16 #include "chromeos/network/network_handler_callbacks.h"
17 #include "chromeos/network/onc/onc_constants.h"
16 18
17 namespace base { 19 namespace base {
18 class DictionaryValue; 20 class DictionaryValue;
19 } 21 }
20 22
21 namespace chromeos { 23 namespace chromeos {
22 24
23 // The ManagedNetworkConfigurationHandler class is used to create and configure 25 // The ManagedNetworkConfigurationHandler class is used to create and configure
24 // networks in ChromeOS using ONC. 26 // networks in ChromeOS using ONC.
25 // 27 //
(...skipping 16 matching lines...) Expand all
42 // |error_callback|. When the operation succeeds, |callback| will be called, and 44 // |error_callback|. When the operation succeeds, |callback| will be called, and
43 // when it doesn't, |error_callback| will be called with information about the 45 // when it doesn't, |error_callback| will be called with information about the
44 // error, including a symbolic name for the error and often some error message 46 // error, including a symbolic name for the error and often some error message
45 // that is suitable for logging. None of the error message text is meant for 47 // that is suitable for logging. None of the error message text is meant for
46 // user consumption. 48 // user consumption.
47 // 49 //
48 // TODO(pneubeck): Enforce network policies. 50 // TODO(pneubeck): Enforce network policies.
49 51
50 class CHROMEOS_EXPORT ManagedNetworkConfigurationHandler { 52 class CHROMEOS_EXPORT ManagedNetworkConfigurationHandler {
51 public: 53 public:
54 typedef std::map<std::string, const base::DictionaryValue*> PolicyMap;
55
52 // Initializes the singleton. 56 // Initializes the singleton.
53 static void Initialize(); 57 static void Initialize();
54 58
55 // Returns if the singleton is initialized. 59 // Returns if the singleton is initialized.
56 static bool IsInitialized(); 60 static bool IsInitialized();
57 61
58 // Destroys the singleton. 62 // Destroys the singleton.
59 static void Shutdown(); 63 static void Shutdown();
60 64
61 // Initialize() must be called before this. 65 // Initialize() must be called before this.
62 static ManagedNetworkConfigurationHandler* Get(); 66 static ManagedNetworkConfigurationHandler* Get();
63 67
64 // Provides the properties of the network with |service_path| to |callback|. 68 // Provides the properties of the network with |service_path| to |callback|.
65 void GetProperties( 69 void GetProperties(
66 const std::string& service_path, 70 const std::string& service_path,
67 const network_handler::DictionaryResultCallback& callback, 71 const network_handler::DictionaryResultCallback& callback,
68 const network_handler::ErrorCallback& error_callback) const; 72 const network_handler::ErrorCallback& error_callback) const;
69 73
74 // Provides the managed properties of the network with |service_path| to
75 // |callback|.
76 void GetManagedProperties(
77 const std::string& service_path,
78 const network_handler::DictionaryResultCallback& callback,
79 const network_handler::ErrorCallback& error_callback);
80
70 // Sets the user's settings of an already configured network with 81 // Sets the user's settings of an already configured network with
71 // |service_path|. A network can be initially configured by calling 82 // |service_path|. A network can be initially configured by calling
72 // CreateConfiguration or if it is managed by a policy. The given properties 83 // CreateConfiguration or if it is managed by a policy. The given properties
73 // will be merged with the existing settings, and it won't clear any existing 84 // will be merged with the existing settings, and it won't clear any existing
74 // properties. 85 // properties.
75 void SetProperties( 86 void SetProperties(
76 const std::string& service_path, 87 const std::string& service_path,
77 const base::DictionaryValue& properties, 88 const base::DictionaryValue& user_settings,
78 const base::Closure& callback, 89 const base::Closure& callback,
79 const network_handler::ErrorCallback& error_callback) const; 90 const network_handler::ErrorCallback& error_callback) const;
80 91
81 // Initiates a connection with network that has |service_path|. |callback| is 92 // Initiates a connection with network that has |service_path|. |callback| is
82 // called if the connection request was successfully handled. That doesn't 93 // called if the connection request was successfully handled. That doesn't
83 // mean that the connection was successfully established. 94 // mean that the connection was successfully established.
84 void Connect(const std::string& service_path, 95 void Connect(const std::string& service_path,
85 const base::Closure& callback, 96 const base::Closure& callback,
86 const network_handler::ErrorCallback& error_callback) const; 97 const network_handler::ErrorCallback& error_callback) const;
87 98
(...skipping 14 matching lines...) Expand all
102 const network_handler::ErrorCallback& error_callback) const; 113 const network_handler::ErrorCallback& error_callback) const;
103 114
104 // Removes the user's configuration from the network with |service_path|. The 115 // Removes the user's configuration from the network with |service_path|. The
105 // network may still show up in the visible networks after this, but no user 116 // network may still show up in the visible networks after this, but no user
106 // configuration will remain. If it was managed, it will still be configured. 117 // configuration will remain. If it was managed, it will still be configured.
107 void RemoveConfiguration( 118 void RemoveConfiguration(
108 const std::string& service_path, 119 const std::string& service_path,
109 const base::Closure& callback, 120 const base::Closure& callback,
110 const network_handler::ErrorCallback& error_callback) const; 121 const network_handler::ErrorCallback& error_callback) const;
111 122
123 // Only to be called by NetworkConfigurationUpdater or from tests.
124 // Sets |toplevel_onc| as the current policy of |onc_source|. The network
125 // configurations of the policy will be applied (not necessarily immediately)
126 // to Shill's profiles and enforced in future configurations until the policy
127 // associated with |onc_source| is changed again with this function.
128 void SetPolicy(onc::ONCSource onc_source,
129 const base::DictionaryValue& toplevel_onc);
130
112 private: 131 private:
132 class PolicyApplicator;
133
113 ManagedNetworkConfigurationHandler(); 134 ManagedNetworkConfigurationHandler();
114 ~ManagedNetworkConfigurationHandler(); 135 ~ManagedNetworkConfigurationHandler();
115 136
137 void GetManagedPropertiesCallback(
138 const network_handler::DictionaryResultCallback& callback,
139 const network_handler::ErrorCallback& error_callback,
140 const std::string& service_path,
141 const base::DictionaryValue& shill_properties);
142
143 const PolicyMap* GetPoliciesForProfile(const std::string& profile) const;
144
145 // The entries of these maps are owned by this class and are explicitly
146 // deleted where necessary.
147 PolicyMap user_policies_by_guid_;
148 PolicyMap device_policies_by_guid_;
149 bool user_policies_initialized_;
150 bool device_policies_initialized_;
151
152 // For Shill client callbacks
153 base::WeakPtrFactory<ManagedNetworkConfigurationHandler> weak_ptr_factory_;
154
116 DISALLOW_COPY_AND_ASSIGN(ManagedNetworkConfigurationHandler); 155 DISALLOW_COPY_AND_ASSIGN(ManagedNetworkConfigurationHandler);
117 }; 156 };
118 157
119 } // namespace chromeos 158 } // namespace chromeos
120 159
121 #endif // CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_ 160 #endif // CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698