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

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

Issue 2712883005: Sign out profile when local_state file has been changed. (Closed)
Patch Set: fixup Created 3 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
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"
6 #include "chrome/browser/profiles/profile_attributes_entry.h" 5 #include "chrome/browser/profiles/profile_attributes_entry.h"
7 #include "chrome/browser/profiles/profile_info_cache.h" 6 #include "chrome/browser/profiles/profile_info_cache.h"
8 #include "chrome/common/pref_names.h" 7 #include "chrome/browser/signin/signin_util.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
17 8
18 ProfileAttributesEntry::ProfileAttributesEntry() 9 ProfileAttributesEntry::ProfileAttributesEntry()
19 : profile_info_cache_(nullptr), profile_path_(base::FilePath()) {} 10 : profile_info_cache_(nullptr), profile_path_(base::FilePath()) {}
20 11
21 void ProfileAttributesEntry::Initialize( 12 void ProfileAttributesEntry::Initialize(
22 ProfileInfoCache* cache, const base::FilePath& path) { 13 ProfileInfoCache* cache, const base::FilePath& path) {
23 DCHECK(!profile_info_cache_); 14 DCHECK(!profile_info_cache_);
24 DCHECK(cache); 15 DCHECK(cache);
25 profile_info_cache_ = cache; 16 profile_info_cache_ = cache;
26 DCHECK(profile_path_.empty()); 17 DCHECK(profile_path_.empty());
27 DCHECK(!path.empty()); 18 DCHECK(!path.empty());
28 profile_path_ = path; 19 profile_path_ = path;
29 is_force_signin_enabled_ = IsForceSigninEnabled(); 20 is_force_signin_enabled_ = signin_util::IsForceSigninEnabled();
30 if (!IsAuthenticated() && is_force_signin_enabled_) 21 if (!IsAuthenticated() && is_force_signin_enabled_)
31 is_force_signin_profile_locked_ = true; 22 is_force_signin_profile_locked_ = true;
32 } 23 }
33 24
34 base::string16 ProfileAttributesEntry::GetName() const { 25 base::string16 ProfileAttributesEntry::GetName() const {
35 return profile_info_cache_->GetNameOfProfileAtIndex(profile_index()); 26 return profile_info_cache_->GetNameOfProfileAtIndex(profile_index());
36 } 27 }
37 28
38 base::string16 ProfileAttributesEntry::GetShortcutName() const { 29 base::string16 ProfileAttributesEntry::GetShortcutName() const {
39 return profile_info_cache_->GetShortcutNameOfProfileAtIndex(profile_index()); 30 return profile_info_cache_->GetShortcutNameOfProfileAtIndex(profile_index());
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 226 }
236 227
237 void ProfileAttributesEntry::SetIsSigninRequired(bool value) { 228 void ProfileAttributesEntry::SetIsSigninRequired(bool value) {
238 profile_info_cache_->SetProfileSigninRequiredAtIndex(profile_index(), value); 229 profile_info_cache_->SetProfileSigninRequiredAtIndex(profile_index(), value);
239 if (is_force_signin_enabled_) 230 if (is_force_signin_enabled_)
240 LockForceSigninProfile(value); 231 LockForceSigninProfile(value);
241 } 232 }
242 233
243 void ProfileAttributesEntry::LockForceSigninProfile(bool is_lock) { 234 void ProfileAttributesEntry::LockForceSigninProfile(bool is_lock) {
244 DCHECK(is_force_signin_enabled_); 235 DCHECK(is_force_signin_enabled_);
236 if (is_force_signin_profile_locked_ == is_lock)
237 return;
245 is_force_signin_profile_locked_ = is_lock; 238 is_force_signin_profile_locked_ = is_lock;
239 profile_info_cache_->NotifyIsSigninRequiredChanged(profile_path_);
246 } 240 }
247 241
248 void ProfileAttributesEntry::SetIsEphemeral(bool value) { 242 void ProfileAttributesEntry::SetIsEphemeral(bool value) {
249 profile_info_cache_->SetProfileIsEphemeralAtIndex(profile_index(), value); 243 profile_info_cache_->SetProfileIsEphemeralAtIndex(profile_index(), value);
250 } 244 }
251 245
252 void ProfileAttributesEntry::SetIsUsingDefaultName(bool value) { 246 void ProfileAttributesEntry::SetIsUsingDefaultName(bool value) {
253 profile_info_cache_->SetProfileIsUsingDefaultNameAtIndex( 247 profile_info_cache_->SetProfileIsUsingDefaultNameAtIndex(
254 profile_index(), value); 248 profile_index(), value);
255 } 249 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 const std::string& gaia_id, const base::string16& user_name) { 285 const std::string& gaia_id, const base::string16& user_name) {
292 profile_info_cache_->SetAuthInfoOfProfileAtIndex( 286 profile_info_cache_->SetAuthInfoOfProfileAtIndex(
293 profile_index(), gaia_id, user_name); 287 profile_index(), gaia_id, user_name);
294 } 288 }
295 289
296 size_t ProfileAttributesEntry::profile_index() const { 290 size_t ProfileAttributesEntry::profile_index() const {
297 size_t index = profile_info_cache_->GetIndexOfProfileWithPath(profile_path_); 291 size_t index = profile_info_cache_->GetIndexOfProfileWithPath(profile_path_);
298 DCHECK(index < profile_info_cache_->GetNumberOfProfiles()); 292 DCHECK(index < profile_info_cache_->GetNumberOfProfiles());
299 return index; 293 return index;
300 } 294 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698