| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 local_settings_->RemoveWithoutPathExpansion(key, NULL); | 156 local_settings_->RemoveWithoutPathExpansion(key, NULL); |
| 157 | 157 |
| 158 InformSubscribers(); | 158 InformSubscribers(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 // static | 161 // static |
| 162 SyncData SupervisedUserSettingsService::CreateSyncDataForSetting( | 162 SyncData SupervisedUserSettingsService::CreateSyncDataForSetting( |
| 163 const std::string& name, | 163 const std::string& name, |
| 164 const base::Value& value) { | 164 const base::Value& value) { |
| 165 std::string json_value; | 165 std::string json_value; |
| 166 base::JSONWriter::Write(&value, &json_value); | 166 base::JSONWriter::Write(value, &json_value); |
| 167 ::sync_pb::EntitySpecifics specifics; | 167 ::sync_pb::EntitySpecifics specifics; |
| 168 specifics.mutable_managed_user_setting()->set_name(name); | 168 specifics.mutable_managed_user_setting()->set_name(name); |
| 169 specifics.mutable_managed_user_setting()->set_value(json_value); | 169 specifics.mutable_managed_user_setting()->set_value(json_value); |
| 170 return SyncData::CreateLocalData(name, name, specifics); | 170 return SyncData::CreateLocalData(name, name, specifics); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void SupervisedUserSettingsService::Shutdown() { | 173 void SupervisedUserSettingsService::Shutdown() { |
| 174 store_->RemoveObserver(this); | 174 store_->RemoveObserver(this); |
| 175 } | 175 } |
| 176 | 176 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 } | 400 } |
| 401 | 401 |
| 402 void SupervisedUserSettingsService::InformSubscribers() { | 402 void SupervisedUserSettingsService::InformSubscribers() { |
| 403 if (!IsReady()) | 403 if (!IsReady()) |
| 404 return; | 404 return; |
| 405 | 405 |
| 406 scoped_ptr<base::DictionaryValue> settings = GetSettings(); | 406 scoped_ptr<base::DictionaryValue> settings = GetSettings(); |
| 407 for (const auto& callback : subscribers_) | 407 for (const auto& callback : subscribers_) |
| 408 callback.Run(settings.get()); | 408 callback.Run(settings.get()); |
| 409 } | 409 } |
| OLD | NEW |