OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/multi_profile_user_controller.h" | 5 #include "chrome/browser/chromeos/login/multi_profile_user_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
9 #include "base/prefs/pref_change_registrar.h" | 10 #include "base/prefs/pref_change_registrar.h" |
10 #include "base/prefs/pref_registry_simple.h" | 11 #include "base/prefs/pref_registry_simple.h" |
11 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
12 #include "base/prefs/scoped_user_pref_update.h" | 13 #include "base/prefs/scoped_user_pref_update.h" |
13 #include "chrome/browser/chromeos/login/multi_profile_user_controller_delegate.h
" | 14 #include "chrome/browser/chromeos/login/multi_profile_user_controller_delegate.h
" |
14 #include "chrome/browser/chromeos/login/user.h" | 15 #include "chrome/browser/chromeos/login/user.h" |
15 #include "chrome/browser/chromeos/login/user_manager.h" | 16 #include "chrome/browser/chromeos/login/user_manager.h" |
16 #include "chrome/browser/chromeos/policy/policy_cert_service.h" | 17 #include "chrome/browser/chromeos/policy/policy_cert_service.h" |
17 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" | 18 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" |
18 #include "chrome/browser/prefs/pref_service_syncable.h" | 19 #include "chrome/browser/prefs/pref_service_syncable.h" |
19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 22 #include "chromeos/chromeos_switches.h" |
21 #include "google_apis/gaia/gaia_auth_util.h" | 23 #include "google_apis/gaia/gaia_auth_util.h" |
22 | 24 |
23 namespace chromeos { | 25 namespace chromeos { |
24 | 26 |
25 namespace { | 27 namespace { |
26 | 28 |
27 std::string SanitizeBehaviorValue(const std::string& value) { | 29 std::string SanitizeBehaviorValue(const std::string& value) { |
28 if (value == MultiProfileUserController::kBehaviorUnrestricted || | 30 if (value == MultiProfileUserController::kBehaviorUnrestricted || |
29 value == MultiProfileUserController::kBehaviorPrimaryOnly || | 31 value == MultiProfileUserController::kBehaviorPrimaryOnly || |
30 value == MultiProfileUserController::kBehaviorNotAllowed) { | 32 value == MultiProfileUserController::kBehaviorNotAllowed) { |
(...skipping 21 matching lines...) Expand all Loading... |
52 | 54 |
53 // static | 55 // static |
54 void MultiProfileUserController::RegisterPrefs( | 56 void MultiProfileUserController::RegisterPrefs( |
55 PrefRegistrySimple* registry) { | 57 PrefRegistrySimple* registry) { |
56 registry->RegisterDictionaryPref(prefs::kCachedMultiProfileUserBehavior); | 58 registry->RegisterDictionaryPref(prefs::kCachedMultiProfileUserBehavior); |
57 } | 59 } |
58 | 60 |
59 // static | 61 // static |
60 void MultiProfileUserController::RegisterProfilePrefs( | 62 void MultiProfileUserController::RegisterProfilePrefs( |
61 user_prefs::PrefRegistrySyncable* registry) { | 63 user_prefs::PrefRegistrySyncable* registry) { |
| 64 // Use "disabled" default if there is no user manager or no logged in user. |
| 65 // This is true for signin profile (where the value does not matter) or |
| 66 // for the primary user's profile. This essentially disables multiprofile |
| 67 // unless the primary user has a policy to say otherwise. |
| 68 const bool use_disable_default = |
| 69 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 70 switches::kForceMultiProfileInTests) && |
| 71 (!UserManager::IsInitialized() || |
| 72 UserManager::Get()->GetLoggedInUsers().size() == 1); |
62 registry->RegisterStringPref( | 73 registry->RegisterStringPref( |
63 prefs::kMultiProfileUserBehavior, | 74 prefs::kMultiProfileUserBehavior, |
64 kBehaviorUnrestricted, | 75 use_disable_default ? kBehaviorNotAllowed : kBehaviorUnrestricted, |
65 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 76 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
66 } | 77 } |
67 | 78 |
68 MultiProfileUserController::UserAllowedInSessionResult | 79 MultiProfileUserController::UserAllowedInSessionResult |
69 MultiProfileUserController::IsUserAllowedInSession( | 80 MultiProfileUserController::IsUserAllowedInSession( |
70 const std::string& user_email) const { | 81 const std::string& user_email) const { |
71 UserManager* user_manager = UserManager::Get(); | 82 UserManager* user_manager = UserManager::Get(); |
72 CHECK(user_manager); | 83 CHECK(user_manager); |
73 | 84 |
74 const User* primary_user = user_manager->GetPrimaryUser(); | 85 const User* primary_user = user_manager->GetPrimaryUser(); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 } else { | 207 } else { |
197 const std::string behavior = | 208 const std::string behavior = |
198 prefs->GetString(prefs::kMultiProfileUserBehavior); | 209 prefs->GetString(prefs::kMultiProfileUserBehavior); |
199 SetCachedValue(user_email, behavior); | 210 SetCachedValue(user_email, behavior); |
200 } | 211 } |
201 | 212 |
202 CheckSessionUsers(); | 213 CheckSessionUsers(); |
203 } | 214 } |
204 | 215 |
205 } // namespace chromeos | 216 } // namespace chromeos |
OLD | NEW |