OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/managed_mode/managed_user_settings_service.h" | 5 #include "chrome/browser/managed_mode/managed_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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 void ManagedUserSettingsService::Subscribe(const SettingsCallback& callback) { | 79 void ManagedUserSettingsService::Subscribe(const SettingsCallback& callback) { |
80 if (IsReady()) { | 80 if (IsReady()) { |
81 scoped_ptr<base::DictionaryValue> settings = GetSettings(); | 81 scoped_ptr<base::DictionaryValue> settings = GetSettings(); |
82 callback.Run(settings.get()); | 82 callback.Run(settings.get()); |
83 } | 83 } |
84 | 84 |
85 subscribers_.push_back(callback); | 85 subscribers_.push_back(callback); |
86 } | 86 } |
87 | 87 |
88 void ManagedUserSettingsService::Activate() { | 88 void ManagedUserSettingsService::SetActive(bool active) { |
89 active_ = true; | 89 active_ = active; |
90 InformSubscribers(); | 90 InformSubscribers(); |
91 } | 91 } |
92 | 92 |
93 bool ManagedUserSettingsService::IsReady() { | 93 bool ManagedUserSettingsService::IsReady() { |
94 return store_->IsInitializationComplete(); | 94 return store_->IsInitializationComplete(); |
95 } | 95 } |
96 | 96 |
97 void ManagedUserSettingsService::Clear() { | 97 void ManagedUserSettingsService::Clear() { |
98 store_->RemoveValue(kAtomicSettings); | 98 store_->RemoveValue(kAtomicSettings); |
99 store_->RemoveValue(kSplitSettings); | 99 store_->RemoveValue(kSplitSettings); |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 void ManagedUserSettingsService::InformSubscribers() { | 374 void ManagedUserSettingsService::InformSubscribers() { |
375 if (!IsReady()) | 375 if (!IsReady()) |
376 return; | 376 return; |
377 | 377 |
378 scoped_ptr<base::DictionaryValue> settings = GetSettings(); | 378 scoped_ptr<base::DictionaryValue> settings = GetSettings(); |
379 for (std::vector<SettingsCallback>::iterator it = subscribers_.begin(); | 379 for (std::vector<SettingsCallback>::iterator it = subscribers_.begin(); |
380 it != subscribers_.end(); ++it) { | 380 it != subscribers_.end(); ++it) { |
381 it->Run(settings.get()); | 381 it->Run(settings.get()); |
382 } | 382 } |
383 } | 383 } |
OLD | NEW |