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

Side by Side Diff: chrome/browser/chrome_browser_main.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 | « no previous file | chrome/browser/profiles/profiles_state.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chrome_browser_main.h" 5 #include "chrome/browser/chrome_browser_main.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) 346 #if defined(OS_CHROMEOS) || defined(OS_ANDROID)
347 // On ChromeOS and Android the ProfileManager will use the same path as the 347 // On ChromeOS and Android the ProfileManager will use the same path as the
348 // one we got passed. GetActiveUserProfile will therefore use the correct path 348 // one we got passed. GetActiveUserProfile will therefore use the correct path
349 // automatically. 349 // automatically.
350 DCHECK_EQ(user_data_dir.value(), 350 DCHECK_EQ(user_data_dir.value(),
351 g_browser_process->profile_manager()->user_data_dir().value()); 351 g_browser_process->profile_manager()->user_data_dir().value());
352 profile = ProfileManager::GetActiveUserProfile(); 352 profile = ProfileManager::GetActiveUserProfile();
353 #else 353 #else
354 base::FilePath profile_path = 354 base::FilePath profile_path =
355 GetStartupProfilePath(user_data_dir, parsed_command_line); 355 GetStartupProfilePath(user_data_dir, parsed_command_line);
356 const ProfileInfoCache& cache =
357 g_browser_process->profile_manager()->GetProfileInfoCache();
358
359 // If we are trying to load a profile that has been deleted (for example from
360 // an old shortcut, or using an incorrect kProfileDirectory argument), set
361 // the active profile to Guest to force showing the User Manager.
362 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_path);
363 if (profile_index == std::string::npos)
364 profile_path = ProfileManager::GetGuestProfilePath();
356 365
357 // Without NewAvatarMenu, replace guest with any existing profile. 366 // Without NewAvatarMenu, replace guest with any existing profile.
358 if (!switches::IsNewAvatarMenu() && 367 if (!switches::IsNewAvatarMenu() &&
359 profile_path == ProfileManager::GetGuestProfilePath()) { 368 profile_path == ProfileManager::GetGuestProfilePath()) {
360 profile_path = g_browser_process->profile_manager()->GetProfileInfoCache(). 369 profile_path = cache.GetPathOfProfileAtIndex(0);
361 GetPathOfProfileAtIndex(0);
362 } 370 }
371
363 profile = g_browser_process->profile_manager()->GetProfile( 372 profile = g_browser_process->profile_manager()->GetProfile(
364 profile_path); 373 profile_path);
365 374
366 // If we're using the --new-profile-management flag and this profile is 375 // If we're using the --new-profile-management flag and this profile is
367 // signed out, then we should show the user manager instead. By switching 376 // signed out, then we should show the user manager instead. By switching
368 // the active profile to the guest profile we ensure that no 377 // the active profile to the guest profile we ensure that no
369 // browser windows will be opened for the guest profile. 378 // browser windows will be opened for the guest profile.
370 if (switches::IsNewProfileManagement() && 379 if (switches::IsNewProfileManagement() &&
371 profile && 380 profile &&
372 !profile->IsGuestSession()) { 381 !profile->IsGuestSession()) {
373 ProfileInfoCache& cache = 382 if (cache.ProfileIsSigninRequiredAtIndex(profile_index)) {
374 g_browser_process->profile_manager()->GetProfileInfoCache();
375 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_path);
376
377 if (profile_index != std::string::npos &&
378 cache.ProfileIsSigninRequiredAtIndex(profile_index)) {
379 profile = g_browser_process->profile_manager()->GetProfile( 383 profile = g_browser_process->profile_manager()->GetProfile(
380 ProfileManager::GetGuestProfilePath()); 384 ProfileManager::GetGuestProfilePath());
381 } 385 }
382 } 386 }
383 #endif // defined(OS_CHROMEOS) || defined(OS_ANDROID) 387 #endif // defined(OS_CHROMEOS) || defined(OS_ANDROID)
384 if (profile) { 388 if (profile) {
385 UMA_HISTOGRAM_LONG_TIMES( 389 UMA_HISTOGRAM_LONG_TIMES(
386 "Startup.CreateFirstProfile", base::Time::Now() - start); 390 "Startup.CreateFirstProfile", base::Time::Now() - start);
387 return profile; 391 return profile;
388 } 392 }
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 chromeos::CrosSettings::Shutdown(); 1757 chromeos::CrosSettings::Shutdown();
1754 #endif // defined(OS_CHROMEOS) 1758 #endif // defined(OS_CHROMEOS)
1755 #endif // defined(OS_ANDROID) 1759 #endif // defined(OS_ANDROID)
1756 } 1760 }
1757 1761
1758 // Public members: 1762 // Public members:
1759 1763
1760 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { 1764 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) {
1761 chrome_extra_parts_.push_back(parts); 1765 chrome_extra_parts_.push_back(parts);
1762 } 1766 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/profiles_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698