| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_POLICY_NETWORK_CONFIGURATION_UPDATER_H_ | |
| 6 #define CHROME_BROWSER_POLICY_NETWORK_CONFIGURATION_UPDATER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "chrome/browser/chromeos/cros/network_constants.h" | |
| 11 #include "chrome/browser/chromeos/cros/network_library.h" | |
| 12 #include "chrome/browser/chromeos/cros/network_ui_data.h" | |
| 13 #include "chrome/browser/policy/policy_service.h" | |
| 14 #include "chromeos/network/onc/onc_constants.h" | |
| 15 | |
| 16 namespace base { | |
| 17 class Value; | |
| 18 } | |
| 19 | |
| 20 namespace policy { | |
| 21 | |
| 22 class PolicyMap; | |
| 23 | |
| 24 // Keeps track of the network configuration policy settings and Shill's | |
| 25 // profiles. Requests the NetworkLibrary to apply the ONC of the network | |
| 26 // policies every time one of the relevant policies or Shill's profiles changes | |
| 27 // or OnUserPolicyInitialized() is called. If the user policy is available, | |
| 28 // always both the device and the user policy are applied. Otherwise only the | |
| 29 // device policy is applied. | |
| 30 class NetworkConfigurationUpdater | |
| 31 : public chromeos::NetworkLibrary::NetworkProfileObserver { | |
| 32 public: | |
| 33 NetworkConfigurationUpdater(PolicyService* policy_service, | |
| 34 chromeos::NetworkLibrary* network_library); | |
| 35 virtual ~NetworkConfigurationUpdater(); | |
| 36 | |
| 37 // NetworkProfileObserver overrides. | |
| 38 virtual void OnProfileListChanged() OVERRIDE; | |
| 39 | |
| 40 // Notifies this updater that the user policy is initialized. Before this | |
| 41 // function is called, the user policy is not applied. Afterwards, always both | |
| 42 // device and user policy are applied as described in the class comment. This | |
| 43 // function also triggers an immediate policy application of both device and | |
| 44 // user policy. | |
| 45 void OnUserPolicyInitialized(); | |
| 46 | |
| 47 // Web trust isn't given to certificates imported from ONC by default. Setting | |
| 48 // |allow_web_trust| to true allows giving Web trust to the certificates that | |
| 49 // request it. | |
| 50 void set_allow_web_trust(bool allow) { allow_web_trust_ = allow; } | |
| 51 | |
| 52 private: | |
| 53 // Callback that's called by |policy_service_| if the respective ONC policy | |
| 54 // changed. | |
| 55 void OnPolicyChanged(chromeos::onc::ONCSource onc_source, | |
| 56 const base::Value* previous, | |
| 57 const base::Value* current); | |
| 58 | |
| 59 // Retrieves the ONC policies from |policy_service_| and pushes the | |
| 60 // configurations to |network_library_|. Ensures that a device policy is | |
| 61 // always overwritten by a user policy. | |
| 62 void ApplyNetworkConfigurations(); | |
| 63 | |
| 64 // Push the policy stored at |policy_key| for |onc_source| to | |
| 65 // |network_library_|. | |
| 66 void ApplyNetworkConfiguration(const std::string& policy_key, | |
| 67 chromeos::onc::ONCSource onc_source); | |
| 68 | |
| 69 // Wraps the policy service we read network configuration from. | |
| 70 PolicyChangeRegistrar policy_change_registrar_; | |
| 71 | |
| 72 // Network library to write network configuration to. | |
| 73 chromeos::NetworkLibrary* network_library_; | |
| 74 | |
| 75 // Whether the user policy is already available. | |
| 76 bool user_policy_initialized_; | |
| 77 | |
| 78 // Whether Web trust is allowed or not. | |
| 79 bool allow_web_trust_; | |
| 80 | |
| 81 // The policy service storing the ONC policies. | |
| 82 PolicyService* policy_service_; | |
| 83 | |
| 84 DISALLOW_COPY_AND_ASSIGN(NetworkConfigurationUpdater); | |
| 85 }; | |
| 86 | |
| 87 } // namespace policy | |
| 88 | |
| 89 #endif // CHROME_BROWSER_POLICY_NETWORK_CONFIGURATION_UPDATER_H_ | |
| OLD | NEW |