Chromium Code Reviews| OLD | NEW |
|---|---|
| 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(); | |
|
Roger Tawa OOO till Jul 10th
2016/11/08 15:16:11
Do you really need to save IsForceSigninEnabled()
zmin
2016/11/08 18:39:07
force_signin flag will be checked every time the S
| |
| 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 Loading... | |
| 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 profile_info_cache_->ProfileIsSigninRequiredAtIndex(profile_index()) || |
| 112 is_force_signin_profile_locked_; | |
| 100 } | 113 } |
| 101 | 114 |
| 102 std::string ProfileAttributesEntry::GetSupervisedUserId() const { | 115 std::string ProfileAttributesEntry::GetSupervisedUserId() const { |
| 103 return profile_info_cache_->GetSupervisedUserIdOfProfileAtIndex( | 116 return profile_info_cache_->GetSupervisedUserIdOfProfileAtIndex( |
| 104 profile_index()); | 117 profile_index()); |
| 105 } | 118 } |
| 106 | 119 |
| 107 bool ProfileAttributesEntry::IsEphemeral() const { | 120 bool ProfileAttributesEntry::IsEphemeral() const { |
| 108 return profile_info_cache_->ProfileIsEphemeralAtIndex(profile_index()); | 121 return profile_info_cache_->ProfileIsEphemeralAtIndex(profile_index()); |
| 109 } | 122 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 profile_info_cache_->SetGAIAPictureOfProfileAtIndex(profile_index(), image); | 229 profile_info_cache_->SetGAIAPictureOfProfileAtIndex(profile_index(), image); |
| 217 } | 230 } |
| 218 | 231 |
| 219 void ProfileAttributesEntry::SetIsUsingGAIAPicture(bool value) { | 232 void ProfileAttributesEntry::SetIsUsingGAIAPicture(bool value) { |
| 220 profile_info_cache_->SetIsUsingGAIAPictureOfProfileAtIndex( | 233 profile_info_cache_->SetIsUsingGAIAPictureOfProfileAtIndex( |
| 221 profile_index(), value); | 234 profile_index(), value); |
| 222 } | 235 } |
| 223 | 236 |
| 224 void ProfileAttributesEntry::SetIsSigninRequired(bool value) { | 237 void ProfileAttributesEntry::SetIsSigninRequired(bool value) { |
| 225 profile_info_cache_->SetProfileSigninRequiredAtIndex(profile_index(), value); | 238 profile_info_cache_->SetProfileSigninRequiredAtIndex(profile_index(), value); |
| 239 LockForceSigninProfile(value); | |
| 240 } | |
| 241 | |
| 242 void ProfileAttributesEntry::LockForceSigninProfile(bool is_lock) { | |
| 243 if (is_force_signin_enabled_) | |
|
Roger Tawa OOO till Jul 10th
2016/11/08 15:16:11
Should this be a DCHECK instead of if statement?
zmin
2016/11/08 18:39:07
SetIsSigninRequired() will call LockForceSigninPro
| |
| 244 is_force_signin_profile_locked_ = is_lock; | |
| 226 } | 245 } |
| 227 | 246 |
| 228 void ProfileAttributesEntry::SetIsEphemeral(bool value) { | 247 void ProfileAttributesEntry::SetIsEphemeral(bool value) { |
| 229 profile_info_cache_->SetProfileIsEphemeralAtIndex(profile_index(), value); | 248 profile_info_cache_->SetProfileIsEphemeralAtIndex(profile_index(), value); |
| 230 } | 249 } |
| 231 | 250 |
| 232 void ProfileAttributesEntry::SetIsUsingDefaultName(bool value) { | 251 void ProfileAttributesEntry::SetIsUsingDefaultName(bool value) { |
| 233 profile_info_cache_->SetProfileIsUsingDefaultNameAtIndex( | 252 profile_info_cache_->SetProfileIsUsingDefaultNameAtIndex( |
| 234 profile_index(), value); | 253 profile_index(), value); |
| 235 } | 254 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 const std::string& gaia_id, const base::string16& user_name) { | 290 const std::string& gaia_id, const base::string16& user_name) { |
| 272 profile_info_cache_->SetAuthInfoOfProfileAtIndex( | 291 profile_info_cache_->SetAuthInfoOfProfileAtIndex( |
| 273 profile_index(), gaia_id, user_name); | 292 profile_index(), gaia_id, user_name); |
| 274 } | 293 } |
| 275 | 294 |
| 276 size_t ProfileAttributesEntry::profile_index() const { | 295 size_t ProfileAttributesEntry::profile_index() const { |
| 277 size_t index = profile_info_cache_->GetIndexOfProfileWithPath(profile_path_); | 296 size_t index = profile_info_cache_->GetIndexOfProfileWithPath(profile_path_); |
| 278 DCHECK(index < profile_info_cache_->GetNumberOfProfiles()); | 297 DCHECK(index < profile_info_cache_->GetNumberOfProfiles()); |
| 279 return index; | 298 return index; |
| 280 } | 299 } |
| OLD | NEW |