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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 186 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
187 | 187 |
188 const base::FilePath& active_profile_path = | 188 const base::FilePath& active_profile_path = |
189 profile_manager->GetLastUsedProfileDir(profile_manager->user_data_dir()); | 189 profile_manager->GetLastUsedProfileDir(profile_manager->user_data_dir()); |
190 const base::FilePath& guest_path = ProfileManager::GetGuestProfilePath(); | 190 const base::FilePath& guest_path = ProfileManager::GetGuestProfilePath(); |
191 if (active_profile_path == guest_path) | 191 if (active_profile_path == guest_path) |
192 return true; | 192 return true; |
193 | 193 |
194 const ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 194 const ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
195 size_t index = cache.GetIndexOfProfileWithPath(active_profile_path); | 195 size_t index = cache.GetIndexOfProfileWithPath(active_profile_path); |
196 if (!cache.ProfileIsSigninRequiredAtIndex(index)) | 196 if (index == std::string::npos || |
| 197 !cache.ProfileIsSigninRequiredAtIndex(index)) { |
197 return false; | 198 return false; |
| 199 } |
198 | 200 |
199 PrefService* local_state = g_browser_process->local_state(); | 201 PrefService* local_state = g_browser_process->local_state(); |
200 DCHECK(local_state); | 202 DCHECK(local_state); |
201 local_state->SetString( | 203 local_state->SetString( |
202 prefs::kProfileLastUsed, | 204 prefs::kProfileLastUsed, |
203 guest_path.BaseName().MaybeAsASCII()); | 205 guest_path.BaseName().MaybeAsASCII()); |
204 return true; | 206 return true; |
205 } | 207 } |
206 | 208 |
207 } // namespace profiles | 209 } // namespace profiles |
OLD | NEW |