Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/managed_mode/managed_user_shared_settings_update.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/values.h" | |
| 9 #include "chrome/browser/managed_mode/managed_user_shared_settings_service.h" | |
| 10 | |
| 11 ManagedUserSharedSettingsUpdate::ManagedUserSharedSettingsUpdate( | |
| 12 ManagedUserSharedSettingsService* service, | |
| 13 const std::string& mu_id, | |
| 14 const std::string& key, | |
| 15 scoped_ptr<base::Value> value, | |
| 16 const base::Callback<void(bool)>& success_callback) | |
| 17 : service_(service), | |
| 18 mu_id_(mu_id), | |
| 19 key_(key), | |
| 20 value_(value.Pass()), | |
| 21 callback_(success_callback) { | |
| 22 service->SetValueInternal(mu_id, key, *value_, false); | |
| 23 subscription_ = service->Subscribe( | |
| 24 base::Bind(&ManagedUserSharedSettingsUpdate::OnSettingChanged, | |
| 25 base::Unretained(this))); | |
| 26 } | |
| 27 | |
| 28 ManagedUserSharedSettingsUpdate::~ManagedUserSharedSettingsUpdate() {} | |
| 29 | |
| 30 void ManagedUserSharedSettingsUpdate::OnSettingChanged(const std::string& mu_id, | |
| 31 const std::string& key) { | |
| 32 if (mu_id != mu_id_) | |
| 33 return; | |
| 34 | |
| 35 if (key != key_) | |
| 36 return; | |
| 37 | |
| 38 const base::Value* value = service_->GetValue(mu_id, key); | |
| 39 callback_.Run(value->Equals(value_.get())); | |
|
Pam (message me for reviews)
2014/01/08 10:30:40
And also make sure acknowledged = true? Or what's
Bernhard Bauer
2014/01/08 11:42:04
Yes, I meant to DCHECK that in the service.
| |
| 40 } | |
| OLD | NEW |