OLD | NEW |
---|---|
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 Loading... | |
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 if (active_profile_path == ProfileManager::GetGuestProfilePath()) | |
noms (inactive)
2015/01/29 16:15:13
nit: can we store this into a variable so that we
Mike Lerman
2015/01/29 16:51:40
Done.
| |
180 return true; | |
180 | 181 |
181 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
182 const ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 182 const ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
183 size_t index = cache.GetIndexOfProfileWithPath(active_profile->GetPath()); | 183 size_t index = cache.GetIndexOfProfileWithPath(active_profile_path); |
184 if (!cache.ProfileIsSigninRequiredAtIndex(index)) | 184 if (!cache.ProfileIsSigninRequiredAtIndex(index)) |
185 return NULL; | 185 return false; |
186 | |
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 | 186 |
192 PrefService* local_state = g_browser_process->local_state(); | 187 PrefService* local_state = g_browser_process->local_state(); |
193 DCHECK(local_state); | 188 DCHECK(local_state); |
194 local_state->SetString(prefs::kProfileLastUsed, | 189 local_state->SetString( |
195 guest_profile->GetPath().BaseName().MaybeAsASCII()); | 190 prefs::kProfileLastUsed, |
196 return guest_profile; | 191 ProfileManager::GetGuestProfilePath().BaseName().MaybeAsASCII()); |
192 return true; | |
197 } | 193 } |
198 | 194 |
199 } // namespace profiles | 195 } // namespace profiles |
OLD | NEW |