OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 22 matching lines...) Expand all Loading... | |
33 explicit DeviceSettingsProvider(const NotifyObserversCallback& notify_cb); | 33 explicit DeviceSettingsProvider(const NotifyObserversCallback& notify_cb); |
34 virtual ~DeviceSettingsProvider(); | 34 virtual ~DeviceSettingsProvider(); |
35 | 35 |
36 // CrosSettingsProvider implementation. | 36 // CrosSettingsProvider implementation. |
37 virtual const base::Value* Get(const std::string& path) const OVERRIDE; | 37 virtual const base::Value* Get(const std::string& path) const OVERRIDE; |
38 virtual bool GetTrusted(const std::string& path, | 38 virtual bool GetTrusted(const std::string& path, |
39 const base::Closure& callback) OVERRIDE; | 39 const base::Closure& callback) OVERRIDE; |
40 virtual bool HandlesSetting(const std::string& path) const OVERRIDE; | 40 virtual bool HandlesSetting(const std::string& path) const OVERRIDE; |
41 virtual void Reload() OVERRIDE; | 41 virtual void Reload() OVERRIDE; |
42 | 42 |
43 protected: | |
44 // Constructor used by tests to mock the low level dependencies of this class. | |
45 DeviceSettingsProvider(const NotifyObserversCallback& notify_cb, | |
46 SignedSettingsHelper* signed_settings_helper, | |
47 OwnershipService::Status ownership_service); | |
Mattias Nissler (ping if slow)
2012/03/16 15:21:11
it seems like the name |ownership_service| is slig
pastarmovj
2012/03/21 15:23:27
Done.
| |
48 | |
49 // For test use only. | |
50 void set_ownership_status(OwnershipService::Status status) { | |
51 ownership_status_ = status; | |
52 } | |
53 | |
43 private: | 54 private: |
55 // Does the real intialization, shared by both constructors. | |
56 void Initialize(); | |
57 | |
44 // CrosSettingsProvider implementation: | 58 // CrosSettingsProvider implementation: |
45 virtual void DoSet(const std::string& path, | 59 virtual void DoSet(const std::string& path, |
46 const base::Value& value) OVERRIDE; | 60 const base::Value& value) OVERRIDE; |
47 | 61 |
48 // content::NotificationObserver implementation: | 62 // content::NotificationObserver implementation: |
49 virtual void Observe(int type, | 63 virtual void Observe(int type, |
50 const content::NotificationSource& source, | 64 const content::NotificationSource& source, |
51 const content::NotificationDetails& details) OVERRIDE; | 65 const content::NotificationDetails& details) OVERRIDE; |
52 | 66 |
53 const enterprise_management::PolicyData policy() const; | 67 const enterprise_management::PolicyData policy() const; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 void OnStorePolicyCompleted(SignedSettings::ReturnCode code); | 133 void OnStorePolicyCompleted(SignedSettings::ReturnCode code); |
120 | 134 |
121 // Callback of RetrievePolicyOp for ordinary policy [re]loads. | 135 // Callback of RetrievePolicyOp for ordinary policy [re]loads. |
122 void OnRetrievePolicyCompleted( | 136 void OnRetrievePolicyCompleted( |
123 SignedSettings::ReturnCode code, | 137 SignedSettings::ReturnCode code, |
124 const enterprise_management::PolicyFetchResponse& policy); | 138 const enterprise_management::PolicyFetchResponse& policy); |
125 | 139 |
126 // Pending callbacks that need to be invoked after settings verification. | 140 // Pending callbacks that need to be invoked after settings verification. |
127 std::vector<base::Closure> callbacks_; | 141 std::vector<base::Closure> callbacks_; |
128 | 142 |
143 SignedSettingsHelper* signed_settings_helper_; | |
129 OwnershipService::Status ownership_status_; | 144 OwnershipService::Status ownership_status_; |
130 mutable scoped_ptr<SignedSettingsMigrationHelper> migration_helper_; | 145 mutable scoped_ptr<SignedSettingsMigrationHelper> migration_helper_; |
131 | 146 |
132 content::NotificationRegistrar registrar_; | 147 content::NotificationRegistrar registrar_; |
133 | 148 |
134 // In order to guard against occasional failure to fetch a property | 149 // In order to guard against occasional failure to fetch a property |
135 // we allow for some number of retries. | 150 // we allow for some number of retries. |
136 int retries_left_; | 151 int retries_left_; |
137 | 152 |
138 enterprise_management::PolicyData policy_; | 153 enterprise_management::PolicyData policy_; |
139 bool trusted_; | 154 bool trusted_; |
140 | 155 |
141 PrefValueMap values_cache_; | 156 PrefValueMap values_cache_; |
142 | 157 |
143 // This is a queue for set requests, because those need to be sequential. | 158 // This is a queue for set requests, because those need to be sequential. |
144 typedef std::pair<std::string, base::Value*> PendingQueueElement; | 159 typedef std::pair<std::string, base::Value*> PendingQueueElement; |
145 std::vector<PendingQueueElement> pending_changes_; | 160 std::vector<PendingQueueElement> pending_changes_; |
146 | 161 |
162 friend class DeviceSettingsProviderTest; | |
163 FRIEND_TEST_ALL_PREFIXES(DeviceSettingsProviderTest, | |
164 InitializationTestUnowned); | |
147 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsProvider); | 165 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsProvider); |
148 }; | 166 }; |
149 | 167 |
150 } // namespace chromeos | 168 } // namespace chromeos |
151 | 169 |
152 #endif // CHROME_BROWSER_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_ | 170 #endif // CHROME_BROWSER_CHROMEOS_DEVICE_SETTINGS_PROVIDER_H_ |
OLD | NEW |