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/managed_mode/supervised_user_pref_mapping_service.h" | 5 #include "chrome/browser/managed_mode/supervised_user_pref_mapping_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/managed_mode/managed_user_constants.h" | 10 #include "chrome/browser/managed_mode/managed_user_constants.h" |
11 #include "chrome/browser/managed_mode/managed_user_shared_settings_service.h" | 11 #include "chrome/browser/managed_mode/managed_user_shared_settings_service.h" |
12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
13 | 13 |
14 const int kNoAvatar = -1; | 14 const int kNoAvatar = -1; |
15 | 15 |
16 SupervisedUserPrefMappingService::SupervisedUserPrefMappingService( | 16 SupervisedUserPrefMappingService::SupervisedUserPrefMappingService( |
17 PrefService* prefs, | 17 PrefService* prefs, |
18 ManagedUserSharedSettingsService* shared_settings) | 18 ManagedUserSharedSettingsService* shared_settings) |
19 : prefs_(prefs), | 19 : prefs_(prefs), |
20 shared_settings_(shared_settings), | 20 shared_settings_(shared_settings), |
21 managed_user_id_(prefs->GetString(prefs::kManagedUserId)), | 21 managed_user_id_(prefs->GetString(prefs::kSupervisedUserId)), |
22 weak_ptr_factory_(this) {} | 22 weak_ptr_factory_(this) {} |
23 | 23 |
24 SupervisedUserPrefMappingService::~SupervisedUserPrefMappingService() {} | 24 SupervisedUserPrefMappingService::~SupervisedUserPrefMappingService() {} |
25 | 25 |
26 void SupervisedUserPrefMappingService::Init() { | 26 void SupervisedUserPrefMappingService::Init() { |
27 subscription_ = shared_settings_->Subscribe( | 27 subscription_ = shared_settings_->Subscribe( |
28 base::Bind(&SupervisedUserPrefMappingService::OnSharedSettingChanged, | 28 base::Bind(&SupervisedUserPrefMappingService::OnSharedSettingChanged, |
29 weak_ptr_factory_.GetWeakPtr())); | 29 weak_ptr_factory_.GetWeakPtr())); |
30 | 30 |
31 pref_change_registrar_.Init(prefs_); | 31 pref_change_registrar_.Init(prefs_); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 const base::Value* value = shared_settings_->GetValue( | 79 const base::Value* value = shared_settings_->GetValue( |
80 managed_user_id_, managed_users::kChromeAvatarIndex); | 80 managed_user_id_, managed_users::kChromeAvatarIndex); |
81 if (!value) | 81 if (!value) |
82 return kNoAvatar; | 82 return kNoAvatar; |
83 | 83 |
84 int current_avatar_index; | 84 int current_avatar_index; |
85 bool success = value->GetAsInteger(¤t_avatar_index); | 85 bool success = value->GetAsInteger(¤t_avatar_index); |
86 DCHECK(success); | 86 DCHECK(success); |
87 return current_avatar_index; | 87 return current_avatar_index; |
88 } | 88 } |
OLD | NEW |