OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/supervised_user/supervised_user_settings_service.h" | 5 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/prefs/json_pref_store.h" | 10 #include "base/prefs/json_pref_store.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 path, sequenced_task_runner, scoped_ptr<PrefFilter>()); | 64 path, sequenced_task_runner, scoped_ptr<PrefFilter>()); |
65 Init(store); | 65 Init(store); |
66 if (load_synchronously) | 66 if (load_synchronously) |
67 store_->ReadPrefs(); | 67 store_->ReadPrefs(); |
68 else | 68 else |
69 store_->ReadPrefsAsync(NULL); | 69 store_->ReadPrefsAsync(NULL); |
70 } | 70 } |
71 | 71 |
72 void SupervisedUserSettingsService::Init( | 72 void SupervisedUserSettingsService::Init( |
73 scoped_refptr<PersistentPrefStore> store) { | 73 scoped_refptr<PersistentPrefStore> store) { |
74 DCHECK(!store_); | 74 DCHECK(!store_.get()); |
75 store_ = store; | 75 store_ = store; |
76 store_->AddObserver(this); | 76 store_->AddObserver(this); |
77 } | 77 } |
78 | 78 |
79 void SupervisedUserSettingsService::Subscribe( | 79 void SupervisedUserSettingsService::Subscribe( |
80 const SettingsCallback& callback) { | 80 const SettingsCallback& callback) { |
81 if (IsReady()) { | 81 if (IsReady()) { |
82 scoped_ptr<base::DictionaryValue> settings = GetSettings(); | 82 scoped_ptr<base::DictionaryValue> settings = GetSettings(); |
83 callback.Run(settings.get()); | 83 callback.Run(settings.get()); |
84 } | 84 } |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 void SupervisedUserSettingsService::InformSubscribers() { | 377 void SupervisedUserSettingsService::InformSubscribers() { |
378 if (!IsReady()) | 378 if (!IsReady()) |
379 return; | 379 return; |
380 | 380 |
381 scoped_ptr<base::DictionaryValue> settings = GetSettings(); | 381 scoped_ptr<base::DictionaryValue> settings = GetSettings(); |
382 for (std::vector<SettingsCallback>::iterator it = subscribers_.begin(); | 382 for (std::vector<SettingsCallback>::iterator it = subscribers_.begin(); |
383 it != subscribers_.end(); ++it) { | 383 it != subscribers_.end(); ++it) { |
384 it->Run(settings.get()); | 384 it->Run(settings.get()); |
385 } | 385 } |
386 } | 386 } |
OLD | NEW |