Don't kill key events even when it's VKEY_UNKNOWN.
[chromium-blink-merge.git] / chromeos / network / managed_network_configuration_handler_impl.h
blob3580b6f64ded1553cd07b45eb5628e969c3f9a05
1 // Copyright 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.
5 #ifndef CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_IMPL_H_
6 #define CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_IMPL_H_
8 #include <map>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/linked_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "chromeos/chromeos_export.h"
16 #include "chromeos/network/managed_network_configuration_handler.h"
17 #include "chromeos/network/network_handler_callbacks.h"
18 #include "chromeos/network/network_profile_observer.h"
19 #include "chromeos/network/policy_applicator.h"
21 namespace base {
22 class DictionaryValue;
25 namespace chromeos {
27 class NetworkConfigurationHandler;
28 struct NetworkProfile;
29 class NetworkProfileHandler;
30 class NetworkStateHandler;
32 class CHROMEOS_EXPORT ManagedNetworkConfigurationHandlerImpl
33 : public ManagedNetworkConfigurationHandler,
34 public NetworkProfileObserver,
35 public PolicyApplicator::ConfigurationHandler {
36 public:
37 virtual ~ManagedNetworkConfigurationHandlerImpl();
39 // ManagedNetworkConfigurationHandler overrides
40 virtual void AddObserver(NetworkPolicyObserver* observer) OVERRIDE;
41 virtual void RemoveObserver(NetworkPolicyObserver* observer) OVERRIDE;
43 virtual void GetProperties(
44 const std::string& service_path,
45 const network_handler::DictionaryResultCallback& callback,
46 const network_handler::ErrorCallback& error_callback) OVERRIDE;
48 virtual void GetManagedProperties(
49 const std::string& userhash,
50 const std::string& service_path,
51 const network_handler::DictionaryResultCallback& callback,
52 const network_handler::ErrorCallback& error_callback) OVERRIDE;
54 virtual void SetProperties(
55 const std::string& service_path,
56 const base::DictionaryValue& user_settings,
57 const base::Closure& callback,
58 const network_handler::ErrorCallback& error_callback) const OVERRIDE;
60 virtual void CreateConfiguration(
61 const std::string& userhash,
62 const base::DictionaryValue& properties,
63 const network_handler::StringResultCallback& callback,
64 const network_handler::ErrorCallback& error_callback) const OVERRIDE;
66 virtual void RemoveConfiguration(
67 const std::string& service_path,
68 const base::Closure& callback,
69 const network_handler::ErrorCallback& error_callback) const OVERRIDE;
71 virtual void SetPolicy(
72 onc::ONCSource onc_source,
73 const std::string& userhash,
74 const base::ListValue& network_configs_onc,
75 const base::DictionaryValue& global_network_config) OVERRIDE;
77 virtual const base::DictionaryValue* FindPolicyByGUID(
78 const std::string userhash,
79 const std::string& guid,
80 onc::ONCSource* onc_source) const OVERRIDE;
82 virtual const base::DictionaryValue* GetGlobalConfigFromPolicy(
83 const std::string userhash) const OVERRIDE;
85 virtual const base::DictionaryValue* FindPolicyByGuidAndProfile(
86 const std::string& guid,
87 const std::string& profile_path) const OVERRIDE;
89 // NetworkProfileObserver overrides
90 virtual void OnProfileAdded(const NetworkProfile& profile) OVERRIDE;
91 virtual void OnProfileRemoved(const NetworkProfile& profile) OVERRIDE;
93 // PolicyApplicator::ConfigurationHandler overrides
94 virtual void CreateConfigurationFromPolicy(
95 const base::DictionaryValue& shill_properties) OVERRIDE;
97 virtual void UpdateExistingConfigurationWithPropertiesFromPolicy(
98 const base::DictionaryValue& existing_properties,
99 const base::DictionaryValue& new_properties) OVERRIDE;
101 virtual void OnPoliciesApplied() OVERRIDE;
103 private:
104 friend class ClientCertResolverTest;
105 friend class NetworkHandler;
106 friend class ManagedNetworkConfigurationHandlerTest;
108 struct Policies;
109 typedef std::map<std::string, linked_ptr<Policies> > UserToPoliciesMap;
111 ManagedNetworkConfigurationHandlerImpl();
113 void Init(NetworkStateHandler* network_state_handler,
114 NetworkProfileHandler* network_profile_handler,
115 NetworkConfigurationHandler* network_configuration_handler);
117 void GetManagedPropertiesCallback(
118 const network_handler::DictionaryResultCallback& callback,
119 const network_handler::ErrorCallback& error_callback,
120 const std::string& service_path,
121 const base::DictionaryValue& shill_properties);
123 void GetPropertiesCallback(
124 const network_handler::DictionaryResultCallback& callback,
125 const std::string& service_path,
126 const base::DictionaryValue& shill_properties);
128 const Policies* GetPoliciesForUser(const std::string& userhash) const;
129 const Policies* GetPoliciesForProfile(const NetworkProfile& profile) const;
131 void OnPolicyAppliedToNetwork(const std::string& service_path);
133 // Helper method to append "IPConfigs" property to |properties| by extracting
134 // them from the associated DeviceState.
135 void GetIPConfigs(const std::string& service_path,
136 base::DictionaryValue* properties);
138 // If present, the empty string maps to the device policy.
139 UserToPoliciesMap policies_by_user_;
141 // Local references to the associated handler instances.
142 NetworkStateHandler* network_state_handler_;
143 NetworkProfileHandler* network_profile_handler_;
144 NetworkConfigurationHandler* network_configuration_handler_;
146 ObserverList<NetworkPolicyObserver> observers_;
148 // For Shill client callbacks
149 base::WeakPtrFactory<ManagedNetworkConfigurationHandlerImpl>
150 weak_ptr_factory_;
152 DISALLOW_COPY_AND_ASSIGN(ManagedNetworkConfigurationHandlerImpl);
155 } // namespace chromeos
157 #endif // CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_IMPL_H_