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

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

Issue 585653002: After locking a profile and showing the User Manager, make Guest the active profile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 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 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/profiles/profiles_state.h" 5 #include "chrome/browser/profiles/profiles_state.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/prefs/pref_registry_simple.h" 8 #include "base/prefs/pref_registry_simple.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 DCHECK(profile); 149 DCHECK(profile);
150 GAIAInfoUpdateServiceFactory::GetInstance()->GetForProfile(profile)->Update(); 150 GAIAInfoUpdateServiceFactory::GetInstance()->GetForProfile(profile)->Update();
151 } 151 }
152 152
153 SigninErrorController* GetSigninErrorController(Profile* profile) { 153 SigninErrorController* GetSigninErrorController(Profile* profile) {
154 ProfileOAuth2TokenService* token_service = 154 ProfileOAuth2TokenService* token_service =
155 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); 155 ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
156 return token_service ? token_service->signin_error_controller() : NULL; 156 return token_service ? token_service->signin_error_controller() : NULL;
157 } 157 }
158 158
159 void SetActiveProfileToGuestIfLocked() {
160 Profile* active_profile = ProfileManager::GetLastUsedProfile();
161 DCHECK(active_profile);
162
163 ProfileManager* profile_manager = g_browser_process->profile_manager();
164 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
Alexei Svitkine (slow) 2014/09/19 15:33:36 Nit: Const ref or ptr, please.
noms (inactive) 2014/09/22 15:39:45 Done.
165 size_t index = cache.GetIndexOfProfileWithPath(active_profile->GetPath());
166 if (!cache.ProfileIsSigninRequiredAtIndex(index))
167 return;
168
169 // The guest profile must have been loaded already.
170 Profile* guest_profile = profile_manager->GetProfile(
171 ProfileManager::GetGuestProfilePath());
172 CHECK(guest_profile);
173
174 PrefService* local_state = g_browser_process->local_state();
175 DCHECK(local_state);
176 local_state->SetString(prefs::kProfileLastUsed,
177 guest_profile->GetPath().BaseName().MaybeAsASCII());
178 }
179
159 } // namespace profiles 180 } // namespace profiles
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698