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

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

Issue 885493005: Setting Guest last-active for the User Manager doesn't create the Guest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the test not the code Created 5 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 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 GAIAInfoUpdateServiceFactory::GetInstance()->GetForProfile(profile); 164 GAIAInfoUpdateServiceFactory::GetInstance()->GetForProfile(profile);
165 // The service may be null, for example during unit tests. 165 // The service may be null, for example during unit tests.
166 if (service) 166 if (service)
167 service->Update(); 167 service->Update();
168 } 168 }
169 169
170 SigninErrorController* GetSigninErrorController(Profile* profile) { 170 SigninErrorController* GetSigninErrorController(Profile* profile) {
171 return SigninErrorControllerFactory::GetForProfile(profile); 171 return SigninErrorControllerFactory::GetForProfile(profile);
172 } 172 }
173 173
174 Profile* SetActiveProfileToGuestIfLocked() { 174 bool SetActiveProfileToGuestIfLocked() {
175 Profile* active_profile = ProfileManager::GetLastUsedProfile(); 175 ProfileManager* profile_manager = g_browser_process->profile_manager();
176 DCHECK(active_profile);
177 176
178 if (active_profile->IsGuestSession()) 177 const base::FilePath& active_profile_path =
179 return active_profile; 178 profile_manager->GetLastUsedProfileDir(profile_manager->user_data_dir());
179 const base::FilePath& guest_path = ProfileManager::GetGuestProfilePath();
180 if (active_profile_path == guest_path)
181 return true;
180 182
181 ProfileManager* profile_manager = g_browser_process->profile_manager();
182 const ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); 183 const ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
183 size_t index = cache.GetIndexOfProfileWithPath(active_profile->GetPath()); 184 size_t index = cache.GetIndexOfProfileWithPath(active_profile_path);
184 if (!cache.ProfileIsSigninRequiredAtIndex(index)) 185 if (!cache.ProfileIsSigninRequiredAtIndex(index)) {
185 return NULL; 186 return false;
186 187 }
noms (inactive) 2015/01/29 22:18:11 nit: noesss, no {}
Mike Lerman 2015/01/29 22:22:10 Done.
187 // Profile loads synchronously if it was not previously created.
188 Profile* guest_profile = profile_manager->GetProfile(
189 ProfileManager::GetGuestProfilePath());
190 DCHECK(guest_profile);
191 188
192 PrefService* local_state = g_browser_process->local_state(); 189 PrefService* local_state = g_browser_process->local_state();
193 DCHECK(local_state); 190 DCHECK(local_state);
194 local_state->SetString(prefs::kProfileLastUsed, 191 local_state->SetString(
195 guest_profile->GetPath().BaseName().MaybeAsASCII()); 192 prefs::kProfileLastUsed,
196 return guest_profile; 193 guest_path.BaseName().MaybeAsASCII());
194 return true;
197 } 195 }
198 196
199 } // namespace profiles 197 } // namespace profiles
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profiles_state.h ('k') | chrome/browser/ui/cocoa/profiles/user_manager_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698