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 #ifndef CHROME_BROWSER_SUPERVISED_USER_LEGACY_SUPERVISED_USER_PREF_MAPPING_SERVICE_H_
6 #define CHROME_BROWSER_SUPERVISED_USER_LEGACY_SUPERVISED_USER_PREF_MAPPING_SERVICE_H_
8 #include "base/callback.h"
9 #include "base/callback_list.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/prefs/pref_change_registrar.h"
13 #include "chrome/browser/supervised_user/supervised_users.h"
14 #include "components/keyed_service/core/keyed_service.h"
17 class SupervisedUserSharedSettingsService
;
19 // SupervisedUserPrefMappingService maps shared supervised user settings to user
20 // preferences. When a shared supervised user setting is updated via sync, the
21 // corresponding local user preference is set to this new value.
22 class SupervisedUserPrefMappingService
: public KeyedService
{
24 typedef base::CallbackList
<void(const std::string
&, const std::string
&)>
27 SupervisedUserPrefMappingService(
29 SupervisedUserSharedSettingsService
* shared_settings
);
30 ~SupervisedUserPrefMappingService() override
;
32 // KeyedService implementation:
33 void Shutdown() override
;
37 // Updates the supervised user shared setting when the avatar has changed.
38 void OnAvatarChanged();
40 // Called when a supervised user shared setting was changed by receiving new
41 // sync data. Updates the corresponding user pref.
42 void OnSharedSettingChanged(const std::string
& su_id
, const std::string
& key
);
45 // Returns the current chrome avatar index that is stored as a supervised user
46 // shared setting, or -1 if no avatar index is stored.
47 int GetChromeAvatarIndex();
50 SupervisedUserSharedSettingsService
* shared_settings_
;
51 scoped_ptr
<CallbackList::Subscription
> subscription_
;
52 std::string supervised_user_id_
;
53 PrefChangeRegistrar pref_change_registrar_
;
54 base::WeakPtrFactory
<SupervisedUserPrefMappingService
> weak_ptr_factory_
;
56 DISALLOW_COPY_AND_ASSIGN(SupervisedUserPrefMappingService
);
59 #endif // CHROME_BROWSER_SUPERVISED_USER_LEGACY_SUPERVISED_USER_PREF_MAPPING_SERVICE_H_