Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 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_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/callback.h" | |
| 14 #include "base/hash_tables.h" | |
| 15 #include "chrome/browser/chromeos/cros_settings_provider.h" | |
| 16 #include "chrome/browser/chromeos/login/signed_settings_helper.h" | |
| 17 #include "chrome/browser/chromeos/signed_settings_migration_helper.h" | |
| 18 #include "chrome/browser/policy/proto/device_management_backend.pb.h" | |
| 19 #include "content/public/browser/notification_registrar.h" | |
| 20 | |
| 21 namespace em = enterprise_management; | |
| 22 | |
| 23 class PrefService; | |
| 24 | |
| 25 namespace base { | |
| 26 class ListValue; | |
| 27 } | |
| 28 | |
| 29 namespace chromeos { | |
| 30 | |
| 31 class OwnershipService; | |
| 32 | |
| 33 // CrosSettingsProvider implementation that works with SignedSettings. | |
| 34 class DeviceSettingsProvider : public CrosSettingsProvider, | |
| 35 public content::NotificationObserver { | |
| 36 public: | |
| 37 DeviceSettingsProvider(); | |
| 38 virtual ~DeviceSettingsProvider(); | |
| 39 | |
| 40 // CrosSettingsProvider implementation. | |
| 41 virtual const base::Value* Get(const std::string& path) const OVERRIDE; | |
| 42 virtual bool GetTrusted(const std::string& path, | |
| 43 const base::Closure& callback) OVERRIDE; | |
| 44 virtual bool HandlesSetting(const std::string& path) const OVERRIDE; | |
| 45 virtual void Reload() OVERRIDE; | |
| 46 | |
| 47 private: | |
| 48 // CrosSettingsProvider implementation: | |
| 49 virtual void DoSet(const std::string& path, | |
| 50 const base::Value& value) OVERRIDE; | |
| 51 | |
| 52 // content::NotificationObserver implementation: | |
| 53 virtual void Observe(int type, | |
| 54 const content::NotificationSource& source, | |
| 55 const content::NotificationDetails& details) OVERRIDE; | |
| 56 | |
| 57 const em::PolicyData get_policy() const; | |
|
Mattias Nissler (ping if slow)
2011/12/02 12:13:37
if this is a true accessor, it should be called po
pastarmovj
2011/12/02 14:43:38
It is - renamed.
| |
| 58 | |
| 59 void RetrieveCachedData(); | |
|
Mattias Nissler (ping if slow)
2011/12/02 12:13:37
missing a comment on what it does.
pastarmovj
2011/12/02 14:43:38
Done.
| |
| 60 | |
| 61 void SetInPolicy(const std::string& prop, const base::Value& value); | |
|
Mattias Nissler (ping if slow)
2011/12/02 12:13:37
same here: where does the data actually end up?
pastarmovj
2011/12/02 14:43:38
Done.
| |
| 62 | |
| 63 // Finalizes stores to the policy file if the cache is dirt | |
|
Mattias Nissler (ping if slow)
2011/12/02 12:13:37
y.
pastarmovj
2011/12/02 14:43:38
e.
| |
| 64 void FinishSetInPolicy(const std::string& prop, | |
| 65 const base::Value* value, | |
| 66 SignedSettings::ReturnCode code, | |
| 67 const em::PolicyFetchResponse& policy); | |
| 68 | |
| 69 // Parses the policy cache and fills the cache of base::Value objects. | |
| 70 void UpdateValuesCache(); | |
| 71 | |
| 72 // Applies the metrics policy and if not set migrates the legacy file. | |
| 73 void ApplyMetricsSetting(bool use_file, bool new_value) const; | |
| 74 | |
| 75 // Applies the data roaming policy. | |
| 76 void ApplyRoamingSetting(bool new_value) const; | |
| 77 | |
| 78 // Applies any changes of the policies that are not handled by the respective | |
| 79 // subsystms. | |
| 80 void ApplySideEffects() const; | |
| 81 | |
| 82 // Called right before boolean property is changed. | |
| 83 void OnBooleanPropertyChange(const std::string& path, bool new_value); | |
| 84 | |
| 85 // Checks if the current cache value can be trusted for being representative | |
| 86 // for the disk cache. | |
| 87 bool RequestTrustedEntity(); | |
| 88 | |
| 89 // Called right after signed value was checked. | |
| 90 void OnPropertyRetrieve(const std::string& path, | |
| 91 const base::Value* value, | |
| 92 bool use_default_value); | |
| 93 | |
| 94 // Callback of StorePolicyOp for ordinary policy stores. | |
| 95 void OnStorePolicyCompleted(SignedSettings::ReturnCode code); | |
| 96 | |
| 97 // Callback of RetrievePolicyOp for ordinary policy [re]loads. | |
| 98 void OnRetrievePolicyCompleted(SignedSettings::ReturnCode code, | |
| 99 const em::PolicyFetchResponse& policy); | |
| 100 | |
| 101 // Pending callbacks that need to be invoked after settings verification. | |
| 102 std::vector<base::Closure> callbacks_; | |
| 103 | |
| 104 OwnershipService::Status ownership_status_; | |
| 105 mutable scoped_ptr<SignedSettingsMigrationHelper> migration_helper_; | |
| 106 | |
| 107 content::NotificationRegistrar registrar_; | |
| 108 | |
| 109 // In order to guard against occasional failure to fetch a property | |
| 110 // we allow for some number of retries. | |
| 111 int retries_left_; | |
| 112 | |
| 113 em::PolicyData policy_; | |
| 114 bool trusted_; | |
| 115 | |
| 116 PrefValueMap values_cache_; | |
| 117 | |
| 118 friend class SignedSettingsHelper; | |
| 119 | |
| 120 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsProvider); | |
| 121 }; | |
| 122 | |
| 123 } // namespace chromeos | |
| 124 | |
| 125 #endif // CHROME_BROWSER_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_ | |
| OLD | NEW |