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

Side by Side Diff: chrome/browser/profiles/profile_attributes_entry.cc

Issue 2478173003: Lock profile before sign in when force sign in is enabled. (Closed)
Patch Set: fixup Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/browser_process.h"
5 #include "chrome/browser/profiles/profile_attributes_entry.h" 6 #include "chrome/browser/profiles/profile_attributes_entry.h"
6 #include "chrome/browser/profiles/profile_info_cache.h" 7 #include "chrome/browser/profiles/profile_info_cache.h"
8 #include "chrome/common/pref_names.h"
9 #include "components/prefs/pref_service.h"
10
11 namespace {
12 bool IsForceSigninEnabled() {
13 PrefService* prefs = g_browser_process->local_state();
14 return prefs && prefs->GetBoolean(prefs::kForceBrowserSignin);
15 }
16 } // namespace
7 17
8 ProfileAttributesEntry::ProfileAttributesEntry() 18 ProfileAttributesEntry::ProfileAttributesEntry()
9 : profile_info_cache_(nullptr), 19 : profile_info_cache_(nullptr), profile_path_(base::FilePath()) {}
10 profile_path_(base::FilePath()) {}
11 20
12 void ProfileAttributesEntry::Initialize( 21 void ProfileAttributesEntry::Initialize(
13 ProfileInfoCache* cache, const base::FilePath& path) { 22 ProfileInfoCache* cache, const base::FilePath& path) {
14 DCHECK(!profile_info_cache_); 23 DCHECK(!profile_info_cache_);
15 DCHECK(cache); 24 DCHECK(cache);
16 profile_info_cache_ = cache; 25 profile_info_cache_ = cache;
17 DCHECK(profile_path_.empty()); 26 DCHECK(profile_path_.empty());
18 DCHECK(!path.empty()); 27 DCHECK(!path.empty());
19 profile_path_ = path; 28 profile_path_ = path;
29 is_force_signin_enabled_ = IsForceSigninEnabled();
30 if (!IsAuthenticated() && is_force_signin_enabled_)
31 is_force_signin_profile_locked_ = true;
20 } 32 }
21 33
22 base::string16 ProfileAttributesEntry::GetName() const { 34 base::string16 ProfileAttributesEntry::GetName() const {
23 return profile_info_cache_->GetNameOfProfileAtIndex(profile_index()); 35 return profile_info_cache_->GetNameOfProfileAtIndex(profile_index());
24 } 36 }
25 37
26 base::string16 ProfileAttributesEntry::GetShortcutName() const { 38 base::string16 ProfileAttributesEntry::GetShortcutName() const {
27 return profile_info_cache_->GetShortcutNameOfProfileAtIndex(profile_index()); 39 return profile_info_cache_->GetShortcutNameOfProfileAtIndex(profile_index());
28 } 40 }
29 41
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 101
90 bool ProfileAttributesEntry::IsLegacySupervised() const { 102 bool ProfileAttributesEntry::IsLegacySupervised() const {
91 return profile_info_cache_->ProfileIsLegacySupervisedAtIndex(profile_index()); 103 return profile_info_cache_->ProfileIsLegacySupervisedAtIndex(profile_index());
92 } 104 }
93 105
94 bool ProfileAttributesEntry::IsOmitted() const { 106 bool ProfileAttributesEntry::IsOmitted() const {
95 return profile_info_cache_->IsOmittedProfileAtIndex(profile_index()); 107 return profile_info_cache_->IsOmittedProfileAtIndex(profile_index());
96 } 108 }
97 109
98 bool ProfileAttributesEntry::IsSigninRequired() const { 110 bool ProfileAttributesEntry::IsSigninRequired() const {
99 return profile_info_cache_->ProfileIsSigninRequiredAtIndex(profile_index()); 111 return (
anthonyvd 2016/11/04 21:31:02 nit: The parens aren't needed.
zmin 2016/11/04 22:11:53 Done.
112 profile_info_cache_->ProfileIsSigninRequiredAtIndex(profile_index()) ||
113 is_force_signin_profile_locked_);
100 } 114 }
101 115
102 std::string ProfileAttributesEntry::GetSupervisedUserId() const { 116 std::string ProfileAttributesEntry::GetSupervisedUserId() const {
103 return profile_info_cache_->GetSupervisedUserIdOfProfileAtIndex( 117 return profile_info_cache_->GetSupervisedUserIdOfProfileAtIndex(
104 profile_index()); 118 profile_index());
105 } 119 }
106 120
107 bool ProfileAttributesEntry::IsEphemeral() const { 121 bool ProfileAttributesEntry::IsEphemeral() const {
108 return profile_info_cache_->ProfileIsEphemeralAtIndex(profile_index()); 122 return profile_info_cache_->ProfileIsEphemeralAtIndex(profile_index());
109 } 123 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 profile_info_cache_->SetGAIAPictureOfProfileAtIndex(profile_index(), image); 230 profile_info_cache_->SetGAIAPictureOfProfileAtIndex(profile_index(), image);
217 } 231 }
218 232
219 void ProfileAttributesEntry::SetIsUsingGAIAPicture(bool value) { 233 void ProfileAttributesEntry::SetIsUsingGAIAPicture(bool value) {
220 profile_info_cache_->SetIsUsingGAIAPictureOfProfileAtIndex( 234 profile_info_cache_->SetIsUsingGAIAPictureOfProfileAtIndex(
221 profile_index(), value); 235 profile_index(), value);
222 } 236 }
223 237
224 void ProfileAttributesEntry::SetIsSigninRequired(bool value) { 238 void ProfileAttributesEntry::SetIsSigninRequired(bool value) {
225 profile_info_cache_->SetProfileSigninRequiredAtIndex(profile_index(), value); 239 profile_info_cache_->SetProfileSigninRequiredAtIndex(profile_index(), value);
240 LockForceSigninProfile(value);
241 }
242
243 void ProfileAttributesEntry::LockForceSigninProfile(bool is_lock) {
244 if (is_force_signin_enabled_)
245 is_force_signin_profile_locked_ = is_lock;
226 } 246 }
227 247
228 void ProfileAttributesEntry::SetIsEphemeral(bool value) { 248 void ProfileAttributesEntry::SetIsEphemeral(bool value) {
229 profile_info_cache_->SetProfileIsEphemeralAtIndex(profile_index(), value); 249 profile_info_cache_->SetProfileIsEphemeralAtIndex(profile_index(), value);
230 } 250 }
231 251
232 void ProfileAttributesEntry::SetIsUsingDefaultName(bool value) { 252 void ProfileAttributesEntry::SetIsUsingDefaultName(bool value) {
233 profile_info_cache_->SetProfileIsUsingDefaultNameAtIndex( 253 profile_info_cache_->SetProfileIsUsingDefaultNameAtIndex(
234 profile_index(), value); 254 profile_index(), value);
235 } 255 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 const std::string& gaia_id, const base::string16& user_name) { 291 const std::string& gaia_id, const base::string16& user_name) {
272 profile_info_cache_->SetAuthInfoOfProfileAtIndex( 292 profile_info_cache_->SetAuthInfoOfProfileAtIndex(
273 profile_index(), gaia_id, user_name); 293 profile_index(), gaia_id, user_name);
274 } 294 }
275 295
276 size_t ProfileAttributesEntry::profile_index() const { 296 size_t ProfileAttributesEntry::profile_index() const {
277 size_t index = profile_info_cache_->GetIndexOfProfileWithPath(profile_path_); 297 size_t index = profile_info_cache_->GetIndexOfProfileWithPath(profile_path_);
278 DCHECK(index < profile_info_cache_->GetNumberOfProfiles()); 298 DCHECK(index < profile_info_cache_->GetNumberOfProfiles());
279 return index; 299 return index;
280 } 300 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698