| 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/chromeos/login/users/multi_profile_user_controller.h" | 5 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
| 6 | 6 |
| 7 #include <memory> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller_dele
gate.h" | 10 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller_dele
gate.h" |
| 10 #include "chrome/browser/chromeos/policy/policy_cert_service.h" | 11 #include "chrome/browser/chromeos/policy/policy_cert_service.h" |
| 11 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" | 12 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" |
| 12 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 13 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 15 #include "components/prefs/pref_change_registrar.h" | 16 #include "components/prefs/pref_change_registrar.h" |
| 16 #include "components/prefs/pref_registry_simple.h" | 17 #include "components/prefs/pref_registry_simple.h" |
| 17 #include "components/prefs/pref_service.h" | 18 #include "components/prefs/pref_service.h" |
| 18 #include "components/prefs/scoped_user_pref_update.h" | 19 #include "components/prefs/scoped_user_pref_update.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 return SetUserAllowedReason( | 155 return SetUserAllowedReason( |
| 155 reason, | 156 reason, |
| 156 behavior == kBehaviorUnrestricted ? ALLOWED : NOT_ALLOWED_POLICY_FORBIDS); | 157 behavior == kBehaviorUnrestricted ? ALLOWED : NOT_ALLOWED_POLICY_FORBIDS); |
| 157 } | 158 } |
| 158 | 159 |
| 159 void MultiProfileUserController::StartObserving(Profile* user_profile) { | 160 void MultiProfileUserController::StartObserving(Profile* user_profile) { |
| 160 // Profile name could be empty during tests. | 161 // Profile name could be empty during tests. |
| 161 if (user_profile->GetProfileUserName().empty()) | 162 if (user_profile->GetProfileUserName().empty()) |
| 162 return; | 163 return; |
| 163 | 164 |
| 164 scoped_ptr<PrefChangeRegistrar> registrar(new PrefChangeRegistrar); | 165 std::unique_ptr<PrefChangeRegistrar> registrar(new PrefChangeRegistrar); |
| 165 registrar->Init(user_profile->GetPrefs()); | 166 registrar->Init(user_profile->GetPrefs()); |
| 166 registrar->Add( | 167 registrar->Add( |
| 167 prefs::kMultiProfileUserBehavior, | 168 prefs::kMultiProfileUserBehavior, |
| 168 base::Bind(&MultiProfileUserController::OnUserPrefChanged, | 169 base::Bind(&MultiProfileUserController::OnUserPrefChanged, |
| 169 base::Unretained(this), | 170 base::Unretained(this), |
| 170 user_profile)); | 171 user_profile)); |
| 171 pref_watchers_.push_back(registrar.release()); | 172 pref_watchers_.push_back(registrar.release()); |
| 172 | 173 |
| 173 OnUserPrefChanged(user_profile); | 174 OnUserPrefChanged(user_profile); |
| 174 } | 175 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 } else { | 232 } else { |
| 232 const std::string behavior = | 233 const std::string behavior = |
| 233 prefs->GetString(prefs::kMultiProfileUserBehavior); | 234 prefs->GetString(prefs::kMultiProfileUserBehavior); |
| 234 SetCachedValue(user_email, behavior); | 235 SetCachedValue(user_email, behavior); |
| 235 } | 236 } |
| 236 | 237 |
| 237 CheckSessionUsers(); | 238 CheckSessionUsers(); |
| 238 } | 239 } |
| 239 | 240 |
| 240 } // namespace chromeos | 241 } // namespace chromeos |
| OLD | NEW |