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
3 // found in the LICENSE file.
5 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_update.h"
8 #include "base/values.h"
9 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.h"
11 SupervisedUserSharedSettingsUpdate::SupervisedUserSharedSettingsUpdate(
12 SupervisedUserSharedSettingsService
* service
,
13 const std::string
& su_id
,
14 const std::string
& key
,
15 scoped_ptr
<base::Value
> value
,
16 const base::Callback
<void(bool)>& success_callback
)
21 callback_(success_callback
) {
22 service
->SetValueInternal(su_id
, key
, *value_
, false);
23 subscription_
= service
->Subscribe(
24 base::Bind(&SupervisedUserSharedSettingsUpdate::OnSettingChanged
,
25 base::Unretained(this)));
28 SupervisedUserSharedSettingsUpdate::~SupervisedUserSharedSettingsUpdate() {}
30 void SupervisedUserSharedSettingsUpdate::OnSettingChanged(
31 const std::string
& su_id
, const std::string
& key
) {
38 const base::Value
* value
= service_
->GetValue(su_id
, key
);
39 callback_
.Run(value
->Equals(value_
.get()));