OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/browser/prefs/pref_value_store.h" | 5 #include "chrome/browser/prefs/pref_value_store.h" |
6 | 6 |
7 #include "chrome/browser/browser_thread.h" | 7 #include "chrome/browser/browser_thread.h" |
8 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 8 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
9 #include "chrome/browser/prefs/pref_notifier.h" | 9 #include "chrome/browser/prefs/pref_notifier.h" |
10 #include "chrome/common/notification_service.h" | 10 #include "chrome/common/notification_service.h" |
11 | 11 |
12 PrefValueStore::PrefStoreKeeper::PrefStoreKeeper() | 12 PrefValueStore::PrefStoreKeeper::PrefStoreKeeper() |
13 : pref_value_store_(NULL), | 13 : pref_value_store_(NULL), |
14 type_(PrefValueStore::INVALID_STORE) { | 14 type_(PrefValueStore::INVALID_STORE) { |
15 } | 15 } |
16 | 16 |
17 PrefValueStore::PrefStoreKeeper::~PrefStoreKeeper() { | 17 PrefValueStore::PrefStoreKeeper::~PrefStoreKeeper() { |
18 if (pref_store_.get()) | 18 if (pref_store_.get()) |
19 pref_store_->RemoveObserver(this); | 19 pref_store_->RemoveObserver(this); |
20 } | 20 } |
21 | 21 |
22 void PrefValueStore::PrefStoreKeeper::Initialize( | 22 void PrefValueStore::PrefStoreKeeper::Initialize( |
23 PrefValueStore* store, | 23 PrefValueStore* store, |
24 PrefStore* pref_store, | 24 scoped_refptr<PrefStore> pref_store, |
25 PrefValueStore::PrefStoreType type) { | 25 PrefValueStore::PrefStoreType type) { |
26 if (pref_store_.get()) | 26 if (pref_store_.get()) |
27 pref_store_->RemoveObserver(this); | 27 pref_store_->RemoveObserver(this); |
28 type_ = type; | 28 type_ = type; |
29 pref_value_store_ = store; | 29 pref_value_store_ = store; |
30 pref_store_.reset(pref_store); | 30 pref_store_ = pref_store; |
31 if (pref_store_.get()) | 31 if (pref_store_.get()) |
32 pref_store_->AddObserver(this); | 32 pref_store_->AddObserver(this); |
33 } | 33 } |
34 | 34 |
35 void PrefValueStore::PrefStoreKeeper::OnPrefValueChanged( | 35 void PrefValueStore::PrefStoreKeeper::OnPrefValueChanged( |
36 const std::string& key) { | 36 const std::string& key) { |
37 pref_value_store_->OnPrefValueChanged(type_, key); | 37 pref_value_store_->OnPrefValueChanged(type_, key); |
38 } | 38 } |
39 | 39 |
40 void PrefValueStore::PrefStoreKeeper::OnInitializationCompleted() { | 40 void PrefValueStore::PrefStoreKeeper::OnInitializationCompleted() { |
41 pref_value_store_->OnInitializationCompleted(type_); | 41 pref_value_store_->OnInitializationCompleted(type_); |
42 } | 42 } |
43 | 43 |
44 PrefValueStore::PrefValueStore(PrefStore* managed_platform_prefs, | 44 PrefValueStore::PrefValueStore(scoped_refptr<PrefStore> managed_platform_prefs, |
45 PrefStore* device_management_prefs, | 45 scoped_refptr<PrefStore> device_management_prefs, |
46 PrefStore* extension_prefs, | 46 scoped_refptr<PrefStore> extension_prefs, |
47 PrefStore* command_line_prefs, | 47 scoped_refptr<PrefStore> command_line_prefs, |
48 PrefStore* user_prefs, | 48 scoped_refptr<PrefStore> user_prefs, |
49 PrefStore* recommended_prefs, | 49 scoped_refptr<PrefStore> recommended_prefs, |
50 PrefStore* default_prefs, | 50 scoped_refptr<PrefStore> default_prefs, |
51 PrefNotifier* pref_notifier, | 51 PrefNotifier* pref_notifier, |
52 Profile* profile) | 52 Profile* profile) |
53 : pref_notifier_(pref_notifier), | 53 : pref_notifier_(pref_notifier), |
54 profile_(profile) { | 54 profile_(profile) { |
55 InitPrefStore(MANAGED_PLATFORM_STORE, managed_platform_prefs); | 55 InitPrefStore(MANAGED_PLATFORM_STORE, managed_platform_prefs); |
56 InitPrefStore(DEVICE_MANAGEMENT_STORE, device_management_prefs); | 56 InitPrefStore(DEVICE_MANAGEMENT_STORE, device_management_prefs); |
57 InitPrefStore(EXTENSION_STORE, extension_prefs); | 57 InitPrefStore(EXTENSION_STORE, extension_prefs); |
58 InitPrefStore(COMMAND_LINE_STORE, command_line_prefs); | 58 InitPrefStore(COMMAND_LINE_STORE, command_line_prefs); |
59 InitPrefStore(USER_STORE, user_prefs); | 59 InitPrefStore(USER_STORE, user_prefs); |
60 InitPrefStore(RECOMMENDED_STORE, recommended_prefs); | 60 InitPrefStore(RECOMMENDED_STORE, recommended_prefs); |
61 InitPrefStore(DEFAULT_STORE, default_prefs); | 61 InitPrefStore(DEFAULT_STORE, default_prefs); |
62 | 62 |
63 // TODO(mnissler): Remove after policy refresh cleanup. | 63 // TODO(mnissler): Remove after policy refresh cleanup. |
64 registrar_.Add(this, | 64 registrar_.Add(this, |
65 NotificationType(NotificationType::POLICY_CHANGED), | 65 NotificationType(NotificationType::POLICY_CHANGED), |
66 NotificationService::AllSources()); | 66 NotificationService::AllSources()); |
67 | 67 |
68 CheckInitializationCompleted(); | 68 CheckInitializationCompleted(); |
69 } | 69 } |
70 | 70 |
71 PrefValueStore::~PrefValueStore() {} | 71 PrefValueStore::~PrefValueStore() {} |
72 | 72 |
| 73 PrefValueStore* PrefValueStore::Derive(scoped_refptr<PrefStore> extension_prefs, |
| 74 scoped_refptr<PrefStore> user_prefs, |
| 75 PrefNotifier* pref_notifier) { |
| 76 return new PrefValueStore(GetPrefStore(MANAGED_PLATFORM_STORE), |
| 77 GetPrefStore(DEVICE_MANAGEMENT_STORE), |
| 78 extension_prefs, |
| 79 GetPrefStore(COMMAND_LINE_STORE), |
| 80 user_prefs, |
| 81 GetPrefStore(RECOMMENDED_STORE), |
| 82 GetPrefStore(DEFAULT_STORE), |
| 83 pref_notifier, |
| 84 profile_); |
| 85 } |
| 86 |
73 bool PrefValueStore::GetValue(const std::string& name, | 87 bool PrefValueStore::GetValue(const std::string& name, |
| 88 Value::ValueType type, |
74 Value** out_value) const { | 89 Value** out_value) const { |
| 90 *out_value = NULL; |
75 // Check the |PrefStore|s in order of their priority from highest to lowest | 91 // Check the |PrefStore|s in order of their priority from highest to lowest |
76 // to find the value of the preference described by the given preference name. | 92 // to find the value of the preference described by the given preference name. |
77 for (size_t i = 0; i <= PREF_STORE_TYPE_MAX; ++i) { | 93 for (size_t i = 0; i <= PREF_STORE_TYPE_MAX; ++i) { |
78 if (GetValueFromStore(name.c_str(), static_cast<PrefStoreType>(i), | 94 if (GetValueFromStore(name.c_str(), static_cast<PrefStoreType>(i), |
79 out_value)) | 95 out_value)) { |
| 96 if (!(*out_value)->IsType(type)) { |
| 97 LOG(WARNING) << "Expected type for " << name << " is " << type |
| 98 << " but got " << (*out_value)->GetType() |
| 99 << " in store " << i; |
| 100 continue; |
| 101 } |
80 return true; | 102 return true; |
| 103 } |
81 } | 104 } |
82 return false; | 105 return false; |
83 } | 106 } |
84 | 107 |
85 void PrefValueStore::RegisterPreferenceType(const std::string& name, | |
86 Value::ValueType type) { | |
87 pref_types_[name] = type; | |
88 } | |
89 | |
90 Value::ValueType PrefValueStore::GetRegisteredType( | |
91 const std::string& name) const { | |
92 PrefTypeMap::const_iterator found = pref_types_.find(name); | |
93 if (found == pref_types_.end()) | |
94 return Value::TYPE_NULL; | |
95 return found->second; | |
96 } | |
97 | |
98 bool PrefValueStore::HasPrefPath(const char* path) const { | |
99 Value* tmp_value = NULL; | |
100 const std::string name(path); | |
101 bool rv = GetValue(name, &tmp_value); | |
102 // Merely registering a pref doesn't count as "having" it: we require a | |
103 // non-default value set. | |
104 return rv && !PrefValueFromDefaultStore(path); | |
105 } | |
106 | |
107 void PrefValueStore::NotifyPrefChanged( | 108 void PrefValueStore::NotifyPrefChanged( |
108 const char* path, | 109 const char* path, |
109 PrefValueStore::PrefStoreType new_store) { | 110 PrefValueStore::PrefStoreType new_store) { |
110 DCHECK(new_store != INVALID_STORE); | 111 DCHECK(new_store != INVALID_STORE); |
111 | 112 |
112 // If this pref is not registered, just discard the notification. | |
113 if (!pref_types_.count(path)) | |
114 return; | |
115 | |
116 bool changed = true; | 113 bool changed = true; |
117 // Replying that the pref has changed in case the new store is invalid may | 114 // Replying that the pref has changed in case the new store is invalid may |
118 // cause problems, but it's the safer choice. | 115 // cause problems, but it's the safer choice. |
119 if (new_store != INVALID_STORE) { | 116 if (new_store != INVALID_STORE) { |
120 PrefStoreType controller = ControllingPrefStoreForPref(path); | 117 PrefStoreType controller = ControllingPrefStoreForPref(path); |
121 DCHECK(controller != INVALID_STORE); | 118 DCHECK(controller != INVALID_STORE); |
122 // If the pref is controlled by a higher-priority store, its effective value | 119 // If the pref is controlled by a higher-priority store, its effective value |
123 // cannot have changed. | 120 // cannot have changed. |
124 if (controller != INVALID_STORE && | 121 if (controller != INVALID_STORE && |
125 controller < new_store) { | 122 controller < new_store) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 bool PrefValueStore::PrefValueFromDefaultStore(const char* name) const { | 155 bool PrefValueStore::PrefValueFromDefaultStore(const char* name) const { |
159 return ControllingPrefStoreForPref(name) == DEFAULT_STORE; | 156 return ControllingPrefStoreForPref(name) == DEFAULT_STORE; |
160 } | 157 } |
161 | 158 |
162 bool PrefValueStore::PrefValueUserModifiable(const char* name) const { | 159 bool PrefValueStore::PrefValueUserModifiable(const char* name) const { |
163 PrefStoreType effective_store = ControllingPrefStoreForPref(name); | 160 PrefStoreType effective_store = ControllingPrefStoreForPref(name); |
164 return effective_store >= USER_STORE || | 161 return effective_store >= USER_STORE || |
165 effective_store == INVALID_STORE; | 162 effective_store == INVALID_STORE; |
166 } | 163 } |
167 | 164 |
168 // Returns true if the actual value is a valid type for the expected type when | |
169 // found in the given store. | |
170 bool PrefValueStore::IsValidType(Value::ValueType expected, | |
171 Value::ValueType actual, | |
172 PrefValueStore::PrefStoreType store) { | |
173 if (expected == actual) | |
174 return true; | |
175 | |
176 // Dictionaries and lists are allowed to hold TYPE_NULL values too, but only | |
177 // in the default pref store. | |
178 if (store == DEFAULT_STORE && | |
179 actual == Value::TYPE_NULL && | |
180 (expected == Value::TYPE_DICTIONARY || expected == Value::TYPE_LIST)) { | |
181 return true; | |
182 } | |
183 return false; | |
184 } | |
185 | |
186 bool PrefValueStore::PrefValueInStore( | 165 bool PrefValueStore::PrefValueInStore( |
187 const char* name, | 166 const char* name, |
188 PrefValueStore::PrefStoreType store) const { | 167 PrefValueStore::PrefStoreType store) const { |
189 // Declare a temp Value* and call GetValueFromStore, | 168 // Declare a temp Value* and call GetValueFromStore, |
190 // ignoring the output value. | 169 // ignoring the output value. |
191 Value* tmp_value = NULL; | 170 Value* tmp_value = NULL; |
192 return GetValueFromStore(name, store, &tmp_value); | 171 return GetValueFromStore(name, store, &tmp_value); |
193 } | 172 } |
194 | 173 |
195 bool PrefValueStore::PrefValueInStoreRange( | 174 bool PrefValueStore::PrefValueInStoreRange( |
(...skipping 20 matching lines...) Expand all Loading... |
216 return static_cast<PrefStoreType>(i); | 195 return static_cast<PrefStoreType>(i); |
217 } | 196 } |
218 return INVALID_STORE; | 197 return INVALID_STORE; |
219 } | 198 } |
220 | 199 |
221 bool PrefValueStore::GetValueFromStore(const char* name, | 200 bool PrefValueStore::GetValueFromStore(const char* name, |
222 PrefValueStore::PrefStoreType store_type, | 201 PrefValueStore::PrefStoreType store_type, |
223 Value** out_value) const { | 202 Value** out_value) const { |
224 // Only return true if we find a value and it is the correct type, so stale | 203 // Only return true if we find a value and it is the correct type, so stale |
225 // values with the incorrect type will be ignored. | 204 // values with the incorrect type will be ignored. |
226 const PrefStore* store = GetPrefStore(static_cast<PrefStoreType>(store_type)); | 205 scoped_refptr<PrefStore> store = |
| 206 GetPrefStore(static_cast<PrefStoreType>(store_type)); |
227 if (store) { | 207 if (store) { |
228 switch (store->GetValue(name, out_value)) { | 208 switch (store->GetValue(name, out_value)) { |
229 case PrefStore::READ_USE_DEFAULT: | 209 case PrefStore::READ_USE_DEFAULT: |
230 store = GetPrefStore(DEFAULT_STORE); | 210 store = GetPrefStore(DEFAULT_STORE); |
231 if (!store || store->GetValue(name, out_value) != PrefStore::READ_OK) { | 211 if (!store || store->GetValue(name, out_value) != PrefStore::READ_OK) { |
232 *out_value = NULL; | 212 *out_value = NULL; |
233 return false; | 213 return false; |
234 } | 214 } |
235 // Fall through... | 215 // Fall through... |
236 case PrefStore::READ_OK: | 216 case PrefStore::READ_OK: |
237 if (IsValidType(GetRegisteredType(name), | 217 return true; |
238 (*out_value)->GetType(), | |
239 store_type)) { | |
240 return true; | |
241 } | |
242 break; | |
243 case PrefStore::READ_NO_VALUE: | 218 case PrefStore::READ_NO_VALUE: |
244 break; | 219 break; |
245 } | 220 } |
246 } | 221 } |
247 | 222 |
248 // No valid value found for the given preference name: set the return false. | 223 // No valid value found for the given preference name: set the return false. |
249 *out_value = NULL; | 224 *out_value = NULL; |
250 return false; | 225 return false; |
251 } | 226 } |
252 | 227 |
253 void PrefValueStore::RefreshPolicyPrefsOnFileThread( | 228 void PrefValueStore::RefreshPolicyPrefsOnFileThread( |
254 BrowserThread::ID calling_thread_id, | 229 BrowserThread::ID calling_thread_id, |
255 policy::ConfigurationPolicyPrefStore* new_managed_platform_pref_store, | 230 scoped_refptr<policy::ConfigurationPolicyPrefStore> |
256 policy::ConfigurationPolicyPrefStore* new_device_management_pref_store, | 231 new_managed_platform_pref_store, |
257 policy::ConfigurationPolicyPrefStore* new_recommended_pref_store) { | 232 scoped_refptr<policy::ConfigurationPolicyPrefStore> |
| 233 new_device_management_pref_store, |
| 234 scoped_refptr<policy::ConfigurationPolicyPrefStore> |
| 235 new_recommended_pref_store) { |
258 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 236 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
259 scoped_ptr<policy::ConfigurationPolicyPrefStore> managed_platform_pref_store( | |
260 new_managed_platform_pref_store); | |
261 scoped_ptr<policy::ConfigurationPolicyPrefStore> device_management_pref_store( | |
262 new_device_management_pref_store); | |
263 scoped_ptr<policy::ConfigurationPolicyPrefStore> recommended_pref_store( | |
264 new_recommended_pref_store); | |
265 | 237 |
266 BrowserThread::PostTask( | 238 BrowserThread::PostTask( |
267 calling_thread_id, FROM_HERE, | 239 calling_thread_id, FROM_HERE, |
268 NewRunnableMethod(this, | 240 NewRunnableMethod(this, |
269 &PrefValueStore::RefreshPolicyPrefsCompletion, | 241 &PrefValueStore::RefreshPolicyPrefsCompletion, |
270 managed_platform_pref_store.release(), | 242 new_managed_platform_pref_store, |
271 device_management_pref_store.release(), | 243 new_device_management_pref_store, |
272 recommended_pref_store.release())); | 244 new_recommended_pref_store)); |
273 } | 245 } |
274 | 246 |
275 void PrefValueStore::RefreshPolicyPrefs() { | 247 void PrefValueStore::RefreshPolicyPrefs() { |
276 using policy::ConfigurationPolicyPrefStore; | 248 using policy::ConfigurationPolicyPrefStore; |
277 // Because loading of policy information must happen on the FILE | 249 // Because loading of policy information must happen on the FILE |
278 // thread, it's not possible to just replace the contents of the | 250 // thread, it's not possible to just replace the contents of the |
279 // managed and recommended stores in place due to possible | 251 // managed and recommended stores in place due to possible |
280 // concurrent access from the UI thread. Instead, new stores are | 252 // concurrent access from the UI thread. Instead, new stores are |
281 // created and the refreshed policy read into them. The new stores | 253 // created and the refreshed policy read into them. The new stores |
282 // are swapped with the old from a Task on the UI thread after the | 254 // are swapped with the old from a Task on the UI thread after the |
283 // load is complete. | 255 // load is complete. |
284 ConfigurationPolicyPrefStore* new_managed_platform_pref_store( | 256 scoped_refptr<ConfigurationPolicyPrefStore> new_managed_platform_pref_store( |
285 ConfigurationPolicyPrefStore::CreateManagedPlatformPolicyPrefStore()); | 257 ConfigurationPolicyPrefStore::CreateManagedPlatformPolicyPrefStore()); |
286 ConfigurationPolicyPrefStore* new_device_management_pref_store( | 258 scoped_refptr<ConfigurationPolicyPrefStore> new_device_management_pref_store( |
287 ConfigurationPolicyPrefStore::CreateDeviceManagementPolicyPrefStore( | 259 ConfigurationPolicyPrefStore::CreateDeviceManagementPolicyPrefStore( |
288 profile_)); | 260 profile_)); |
289 ConfigurationPolicyPrefStore* new_recommended_pref_store( | 261 scoped_refptr<ConfigurationPolicyPrefStore> new_recommended_pref_store( |
290 ConfigurationPolicyPrefStore::CreateRecommendedPolicyPrefStore()); | 262 ConfigurationPolicyPrefStore::CreateRecommendedPolicyPrefStore()); |
291 BrowserThread::ID current_thread_id; | 263 BrowserThread::ID current_thread_id; |
292 CHECK(BrowserThread::GetCurrentThreadIdentifier(¤t_thread_id)); | 264 CHECK(BrowserThread::GetCurrentThreadIdentifier(¤t_thread_id)); |
293 BrowserThread::PostTask( | 265 BrowserThread::PostTask( |
294 BrowserThread::FILE, FROM_HERE, | 266 BrowserThread::FILE, FROM_HERE, |
295 NewRunnableMethod(this, | 267 NewRunnableMethod(this, |
296 &PrefValueStore::RefreshPolicyPrefsOnFileThread, | 268 &PrefValueStore::RefreshPolicyPrefsOnFileThread, |
297 current_thread_id, | 269 current_thread_id, |
298 new_managed_platform_pref_store, | 270 new_managed_platform_pref_store, |
299 new_device_management_pref_store, | 271 new_device_management_pref_store, |
300 new_recommended_pref_store)); | 272 new_recommended_pref_store)); |
301 } | 273 } |
302 | 274 |
303 void PrefValueStore::RefreshPolicyPrefsCompletion( | 275 void PrefValueStore::RefreshPolicyPrefsCompletion( |
304 policy::ConfigurationPolicyPrefStore* new_managed_platform_pref_store, | 276 scoped_refptr<policy::ConfigurationPolicyPrefStore> |
305 policy::ConfigurationPolicyPrefStore* new_device_management_pref_store, | 277 new_managed_platform_pref_store, |
306 policy::ConfigurationPolicyPrefStore* new_recommended_pref_store) { | 278 scoped_refptr<policy::ConfigurationPolicyPrefStore> |
| 279 new_device_management_pref_store, |
| 280 scoped_refptr<policy::ConfigurationPolicyPrefStore> |
| 281 new_recommended_pref_store) { |
307 // Determine the paths of all the changed preferences values in the three | 282 // Determine the paths of all the changed preferences values in the three |
308 // policy-related stores (managed platform, device management and | 283 // policy-related stores (managed platform, device management and |
309 // recommended). | 284 // recommended). |
310 DictionaryValue* managed_platform_prefs_before( | 285 DictionaryValue* managed_platform_prefs_before( |
311 static_cast<policy::ConfigurationPolicyPrefStore*>( | 286 static_cast<policy::ConfigurationPolicyPrefStore*>( |
312 GetPrefStore(MANAGED_PLATFORM_STORE))->prefs()); | 287 GetPrefStore(MANAGED_PLATFORM_STORE).get())->prefs()); |
313 DictionaryValue* managed_platform_prefs_after( | 288 DictionaryValue* managed_platform_prefs_after( |
314 new_managed_platform_pref_store->prefs()); | 289 new_managed_platform_pref_store->prefs()); |
315 DictionaryValue* device_management_prefs_before( | 290 DictionaryValue* device_management_prefs_before( |
316 static_cast<policy::ConfigurationPolicyPrefStore*>( | 291 static_cast<policy::ConfigurationPolicyPrefStore*>( |
317 GetPrefStore(DEVICE_MANAGEMENT_STORE))->prefs()); | 292 GetPrefStore(DEVICE_MANAGEMENT_STORE).get())->prefs()); |
318 DictionaryValue* device_management_prefs_after( | 293 DictionaryValue* device_management_prefs_after( |
319 new_device_management_pref_store->prefs()); | 294 new_device_management_pref_store->prefs()); |
320 DictionaryValue* recommended_prefs_before( | 295 DictionaryValue* recommended_prefs_before( |
321 static_cast<policy::ConfigurationPolicyPrefStore*>( | 296 static_cast<policy::ConfigurationPolicyPrefStore*>( |
322 GetPrefStore(RECOMMENDED_STORE))->prefs()); | 297 GetPrefStore(RECOMMENDED_STORE).get())->prefs()); |
323 DictionaryValue* recommended_prefs_after(new_recommended_pref_store->prefs()); | 298 DictionaryValue* recommended_prefs_after(new_recommended_pref_store->prefs()); |
324 | 299 |
325 std::vector<std::string> changed_managed_platform_paths; | 300 std::vector<std::string> changed_managed_platform_paths; |
326 managed_platform_prefs_before->GetDifferingPaths( | 301 managed_platform_prefs_before->GetDifferingPaths( |
327 managed_platform_prefs_after, | 302 managed_platform_prefs_after, |
328 &changed_managed_platform_paths); | 303 &changed_managed_platform_paths); |
329 | 304 |
330 std::vector<std::string> changed_device_management_paths; | 305 std::vector<std::string> changed_device_management_paths; |
331 device_management_prefs_before->GetDifferingPaths( | 306 device_management_prefs_before->GetDifferingPaths( |
332 device_management_prefs_after, | 307 device_management_prefs_after, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 const std::string& key) { | 365 const std::string& key) { |
391 NotifyPrefChanged(key.c_str(), type); | 366 NotifyPrefChanged(key.c_str(), type); |
392 } | 367 } |
393 | 368 |
394 void PrefValueStore::OnInitializationCompleted( | 369 void PrefValueStore::OnInitializationCompleted( |
395 PrefValueStore::PrefStoreType type) { | 370 PrefValueStore::PrefStoreType type) { |
396 CheckInitializationCompleted(); | 371 CheckInitializationCompleted(); |
397 } | 372 } |
398 | 373 |
399 void PrefValueStore::InitPrefStore(PrefValueStore::PrefStoreType type, | 374 void PrefValueStore::InitPrefStore(PrefValueStore::PrefStoreType type, |
400 PrefStore* pref_store) { | 375 scoped_refptr<PrefStore> pref_store) { |
401 pref_stores_[type].Initialize(this, pref_store, type); | 376 pref_stores_[type].Initialize(this, pref_store, type); |
402 } | 377 } |
403 | 378 |
404 void PrefValueStore::CheckInitializationCompleted() { | 379 void PrefValueStore::CheckInitializationCompleted() { |
405 for (size_t i = 0; i <= PREF_STORE_TYPE_MAX; ++i) { | 380 for (size_t i = 0; i <= PREF_STORE_TYPE_MAX; ++i) { |
406 PrefStore* store = GetPrefStore(static_cast<PrefStoreType>(i)); | 381 scoped_refptr<PrefStore> store = |
| 382 GetPrefStore(static_cast<PrefStoreType>(i)); |
407 if (store && !store->IsInitializationComplete()) | 383 if (store && !store->IsInitializationComplete()) |
408 return; | 384 return; |
409 } | 385 } |
410 pref_notifier_->OnInitializationCompleted(); | 386 pref_notifier_->OnInitializationCompleted(); |
411 } | 387 } |
OLD | NEW |