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

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

Issue 460233004: Fixed misuse of GetProfileByUser in MultiProfileUserController. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with master Created 6 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/prefs/pref_change_registrar.h" 9 #include "base/prefs/pref_change_registrar.h"
10 #include "base/prefs/pref_registry_simple.h" 10 #include "base/prefs/pref_registry_simple.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 false, 86 false,
87 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 87 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
88 } 88 }
89 89
90 // static 90 // static
91 MultiProfileUserController::UserAllowedInSessionReason 91 MultiProfileUserController::UserAllowedInSessionReason
92 MultiProfileUserController::GetPrimaryUserPolicy() { 92 MultiProfileUserController::GetPrimaryUserPolicy() {
93 UserManager* user_manager = UserManager::Get(); 93 UserManager* user_manager = UserManager::Get();
94 CHECK(user_manager); 94 CHECK(user_manager);
95 95
96 const user_manager::User* primary_user = user_manager->GetPrimaryUser(); 96 const user_manager::User* user = user_manager->GetPrimaryUser();
97 if (!primary_user) 97 if (!user)
98 return ALLOWED; 98 return ALLOWED;
99 Profile* primary_user_profile =
100 ProfileHelper::Get()->GetProfileByUserUnsafe(primary_user);
101
102 std::string primary_user_email = primary_user->email();
103 99
104 // Don't allow any secondary profiles if the primary profile is tainted. 100 // Don't allow any secondary profiles if the primary profile is tainted.
105 if (policy::PolicyCertServiceFactory::UsedPolicyCertificates( 101 if (policy::PolicyCertServiceFactory::UsedPolicyCertificates(user->email())) {
106 primary_user_email)) {
107 // Check directly in local_state before checking if the primary user has 102 // Check directly in local_state before checking if the primary user has
108 // a PolicyCertService. His profile may have been tainted previously though 103 // a PolicyCertService. His profile may have been tainted previously though
109 // he didn't get a PolicyCertService created for this session. 104 // he didn't get a PolicyCertService created for this session.
110 return NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED; 105 return NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED;
111 } 106 }
112 107
113 // If the primary profile already has policy certificates installed but hasn't 108 Profile* profile = ProfileHelper::Get()->GetProfileByUser(user);
114 // used them yet then it can become tainted at any time during this session; 109 if (!profile)
115 // disable secondary profiles in this case too. 110 return ALLOWED;
111
112 // If the primary profile already has policy certificates installed but
113 // hasn't used them yet then it can become tainted at any time during this
114 // session disable secondary profiles in this case too.
116 policy::PolicyCertService* service = 115 policy::PolicyCertService* service =
117 primary_user_profile ? policy::PolicyCertServiceFactory::GetForProfile( 116 policy::PolicyCertServiceFactory::GetForProfile(profile);
118 primary_user_profile)
119 : NULL;
120 if (service && service->has_policy_certificates()) 117 if (service && service->has_policy_certificates())
121 return NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED; 118 return NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED;
122 119
123 // No user is allowed if the primary user policy forbids it. 120 // No user is allowed if the primary user policy forbids it.
124 const std::string primary_user_behavior = 121 const std::string behavior = profile->GetPrefs()->GetString(
125 primary_user_profile->GetPrefs()->GetString( 122 prefs::kMultiProfileUserBehavior);
126 prefs::kMultiProfileUserBehavior); 123 if (behavior == kBehaviorNotAllowed)
127 if (primary_user_behavior == kBehaviorNotAllowed)
128 return NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS; 124 return NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS;
129 125
130 return ALLOWED; 126 return ALLOWED;
131 } 127 }
132 128
133 bool MultiProfileUserController::IsUserAllowedInSession( 129 bool MultiProfileUserController::IsUserAllowedInSession(
134 const std::string& user_email, 130 const std::string& user_email,
135 MultiProfileUserController::UserAllowedInSessionReason* reason) const { 131 MultiProfileUserController::UserAllowedInSessionReason* reason) const {
136 UserManager* user_manager = UserManager::Get(); 132 UserManager* user_manager = UserManager::Get();
137 CHECK(user_manager); 133 CHECK(user_manager);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } else { 236 } else {
241 const std::string behavior = 237 const std::string behavior =
242 prefs->GetString(prefs::kMultiProfileUserBehavior); 238 prefs->GetString(prefs::kMultiProfileUserBehavior);
243 SetCachedValue(user_email, behavior); 239 SetCachedValue(user_email, behavior);
244 } 240 }
245 241
246 CheckSessionUsers(); 242 CheckSessionUsers();
247 } 243 }
248 244
249 } // namespace chromeos 245 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698