Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: chrome/browser/chromeos/login/multi_profile_user_controller.cc

Issue 146193005: Reland 251352 "cros: Enable multiprofile for everyone." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix browser_tests compile and remove unneeded header Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
9 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
10 #include "base/prefs/pref_change_registrar.h" 9 #include "base/prefs/pref_change_registrar.h"
11 #include "base/prefs/pref_registry_simple.h" 10 #include "base/prefs/pref_registry_simple.h"
12 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
13 #include "base/prefs/scoped_user_pref_update.h" 12 #include "base/prefs/scoped_user_pref_update.h"
14 #include "chrome/browser/chromeos/login/multi_profile_user_controller_delegate.h " 13 #include "chrome/browser/chromeos/login/multi_profile_user_controller_delegate.h "
15 #include "chrome/browser/chromeos/login/user.h" 14 #include "chrome/browser/chromeos/login/user.h"
16 #include "chrome/browser/chromeos/login/user_manager.h" 15 #include "chrome/browser/chromeos/login/user_manager.h"
17 #include "chrome/browser/chromeos/policy/policy_cert_service.h" 16 #include "chrome/browser/chromeos/policy/policy_cert_service.h"
18 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" 17 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
19 #include "chrome/browser/prefs/pref_service_syncable.h" 18 #include "chrome/browser/prefs/pref_service_syncable.h"
20 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
22 #include "chromeos/chromeos_switches.h"
23 #include "google_apis/gaia/gaia_auth_util.h" 21 #include "google_apis/gaia/gaia_auth_util.h"
24 22
25 namespace chromeos { 23 namespace chromeos {
26 24
27 namespace { 25 namespace {
28 26
29 std::string SanitizeBehaviorValue(const std::string& value) { 27 std::string SanitizeBehaviorValue(const std::string& value) {
30 if (value == MultiProfileUserController::kBehaviorUnrestricted || 28 if (value == MultiProfileUserController::kBehaviorUnrestricted ||
31 value == MultiProfileUserController::kBehaviorPrimaryOnly || 29 value == MultiProfileUserController::kBehaviorPrimaryOnly ||
32 value == MultiProfileUserController::kBehaviorNotAllowed) { 30 value == MultiProfileUserController::kBehaviorNotAllowed) {
(...skipping 21 matching lines...) Expand all
54 52
55 // static 53 // static
56 void MultiProfileUserController::RegisterPrefs( 54 void MultiProfileUserController::RegisterPrefs(
57 PrefRegistrySimple* registry) { 55 PrefRegistrySimple* registry) {
58 registry->RegisterDictionaryPref(prefs::kCachedMultiProfileUserBehavior); 56 registry->RegisterDictionaryPref(prefs::kCachedMultiProfileUserBehavior);
59 } 57 }
60 58
61 // static 59 // static
62 void MultiProfileUserController::RegisterProfilePrefs( 60 void MultiProfileUserController::RegisterProfilePrefs(
63 user_prefs::PrefRegistrySyncable* registry) { 61 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);
73 registry->RegisterStringPref( 62 registry->RegisterStringPref(
74 prefs::kMultiProfileUserBehavior, 63 prefs::kMultiProfileUserBehavior,
75 use_disable_default ? kBehaviorNotAllowed : kBehaviorUnrestricted, 64 kBehaviorUnrestricted,
76 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 65 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
77 } 66 }
78 67
79 MultiProfileUserController::UserAllowedInSessionResult 68 MultiProfileUserController::UserAllowedInSessionResult
80 MultiProfileUserController::IsUserAllowedInSession( 69 MultiProfileUserController::IsUserAllowedInSession(
81 const std::string& user_email) const { 70 const std::string& user_email) const {
82 UserManager* user_manager = UserManager::Get(); 71 UserManager* user_manager = UserManager::Get();
83 CHECK(user_manager); 72 CHECK(user_manager);
84 73
85 const User* primary_user = user_manager->GetPrimaryUser(); 74 const User* primary_user = user_manager->GetPrimaryUser();
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } else { 196 } else {
208 const std::string behavior = 197 const std::string behavior =
209 prefs->GetString(prefs::kMultiProfileUserBehavior); 198 prefs->GetString(prefs::kMultiProfileUserBehavior);
210 SetCachedValue(user_email, behavior); 199 SetCachedValue(user_email, behavior);
211 } 200 }
212 201
213 CheckSessionUsers(); 202 CheckSessionUsers();
214 } 203 }
215 204
216 } // namespace chromeos 205 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698