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/legacy/supervised_user_shared_settings_
update.h" | 5 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_
update.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/values.h" | 10 #include "base/values.h" |
9 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_
service.h" | 11 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_
service.h" |
10 | 12 |
11 SupervisedUserSharedSettingsUpdate::SupervisedUserSharedSettingsUpdate( | 13 SupervisedUserSharedSettingsUpdate::SupervisedUserSharedSettingsUpdate( |
12 SupervisedUserSharedSettingsService* service, | 14 SupervisedUserSharedSettingsService* service, |
13 const std::string& su_id, | 15 const std::string& su_id, |
14 const std::string& key, | 16 const std::string& key, |
15 scoped_ptr<base::Value> value, | 17 scoped_ptr<base::Value> value, |
16 const base::Callback<void(bool)>& success_callback) | 18 const base::Callback<void(bool)>& success_callback) |
17 : service_(service), | 19 : service_(service), |
18 su_id_(su_id), | 20 su_id_(su_id), |
19 key_(key), | 21 key_(key), |
20 value_(value.Pass()), | 22 value_(std::move(value)), |
21 callback_(success_callback) { | 23 callback_(success_callback) { |
22 service->SetValueInternal(su_id, key, *value_, false); | 24 service->SetValueInternal(su_id, key, *value_, false); |
23 subscription_ = service->Subscribe( | 25 subscription_ = service->Subscribe( |
24 base::Bind(&SupervisedUserSharedSettingsUpdate::OnSettingChanged, | 26 base::Bind(&SupervisedUserSharedSettingsUpdate::OnSettingChanged, |
25 base::Unretained(this))); | 27 base::Unretained(this))); |
26 } | 28 } |
27 | 29 |
28 SupervisedUserSharedSettingsUpdate::~SupervisedUserSharedSettingsUpdate() {} | 30 SupervisedUserSharedSettingsUpdate::~SupervisedUserSharedSettingsUpdate() {} |
29 | 31 |
30 void SupervisedUserSharedSettingsUpdate::OnSettingChanged( | 32 void SupervisedUserSharedSettingsUpdate::OnSettingChanged( |
31 const std::string& su_id, const std::string& key) { | 33 const std::string& su_id, const std::string& key) { |
32 if (su_id != su_id_) | 34 if (su_id != su_id_) |
33 return; | 35 return; |
34 | 36 |
35 if (key != key_) | 37 if (key != key_) |
36 return; | 38 return; |
37 | 39 |
38 const base::Value* value = service_->GetValue(su_id, key); | 40 const base::Value* value = service_->GetValue(su_id, key); |
39 callback_.Run(value->Equals(value_.get())); | 41 callback_.Run(value->Equals(value_.get())); |
40 } | 42 } |
OLD | NEW |