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

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

Issue 1042923003: Fail gracefully when starting Chrome with an invalid kProfileDirectory. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 8 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
« no previous file with comments | « chrome/browser/chrome_browser_main.cc ('k') | chrome/browser/ui/browser_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_main.cc ('k') | chrome/browser/ui/browser_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698