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

Side by Side Diff: chrome/browser/chrome_browser_main.cc

Issue 2047483003: Add fallback behavior if the last used profile cannot initialize (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bug-614753-fix
Patch Set: Fix a mistake in a comment. (Didn't check Atom reflow output, sorry :-( ) Created 4 years, 4 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/app/generated_resources.grd ('k') | chrome/browser/profiles/profiles_state.h » ('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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 #include "chrome/browser/profiles/profile_attributes_storage.h" 83 #include "chrome/browser/profiles/profile_attributes_storage.h"
84 #include "chrome/browser/profiles/profile_manager.h" 84 #include "chrome/browser/profiles/profile_manager.h"
85 #include "chrome/browser/profiles/profiles_state.h" 85 #include "chrome/browser/profiles/profiles_state.h"
86 #include "chrome/browser/shell_integration.h" 86 #include "chrome/browser/shell_integration.h"
87 #include "chrome/browser/tracing/navigation_tracing.h" 87 #include "chrome/browser/tracing/navigation_tracing.h"
88 #include "chrome/browser/translate/translate_service.h" 88 #include "chrome/browser/translate/translate_service.h"
89 #include "chrome/browser/ui/app_list/app_list_service.h" 89 #include "chrome/browser/ui/app_list/app_list_service.h"
90 #include "chrome/browser/ui/browser.h" 90 #include "chrome/browser/ui/browser.h"
91 #include "chrome/browser/ui/browser_finder.h" 91 #include "chrome/browser/ui/browser_finder.h"
92 #include "chrome/browser/ui/javascript_dialogs/chrome_javascript_native_dialog_f actory.h" 92 #include "chrome/browser/ui/javascript_dialogs/chrome_javascript_native_dialog_f actory.h"
93 #include "chrome/browser/ui/profile_error_dialog.h"
93 #include "chrome/browser/ui/startup/bad_flags_prompt.h" 94 #include "chrome/browser/ui/startup/bad_flags_prompt.h"
94 #include "chrome/browser/ui/startup/default_browser_prompt.h" 95 #include "chrome/browser/ui/startup/default_browser_prompt.h"
95 #include "chrome/browser/ui/startup/startup_browser_creator.h" 96 #include "chrome/browser/ui/startup/startup_browser_creator.h"
96 #include "chrome/browser/ui/uma_browsing_activity_observer.h" 97 #include "chrome/browser/ui/uma_browsing_activity_observer.h"
97 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" 98 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
98 #include "chrome/common/channel_info.h" 99 #include "chrome/common/channel_info.h"
99 #include "chrome/common/chrome_constants.h" 100 #include "chrome/common/chrome_constants.h"
100 #include "chrome/common/chrome_features.h" 101 #include "chrome/common/chrome_features.h"
101 #include "chrome/common/chrome_paths.h" 102 #include "chrome/common/chrome_paths.h"
102 #include "chrome/common/chrome_result_codes.h" 103 #include "chrome/common/chrome_result_codes.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 397
397 // Initializes the primary profile, possibly doing some user prompting to pick 398 // Initializes the primary profile, possibly doing some user prompting to pick
398 // a fallback profile. Returns the newly created profile, or NULL if startup 399 // a fallback profile. Returns the newly created profile, or NULL if startup
399 // should not continue. 400 // should not continue.
400 Profile* CreatePrimaryProfile(const content::MainFunctionParams& parameters, 401 Profile* CreatePrimaryProfile(const content::MainFunctionParams& parameters,
401 const base::FilePath& user_data_dir, 402 const base::FilePath& user_data_dir,
402 const base::CommandLine& parsed_command_line) { 403 const base::CommandLine& parsed_command_line) {
403 TRACE_EVENT0("startup", "ChromeBrowserMainParts::CreateProfile") 404 TRACE_EVENT0("startup", "ChromeBrowserMainParts::CreateProfile")
404 405
405 base::Time start = base::Time::Now(); 406 base::Time start = base::Time::Now();
406 if (profiles::IsMultipleProfilesEnabled() && 407 bool profile_dir_specified =
407 parsed_command_line.HasSwitch(switches::kProfileDirectory)) { 408 profiles::IsMultipleProfilesEnabled() &&
409 parsed_command_line.HasSwitch(switches::kProfileDirectory);
410 if (profile_dir_specified) {
408 profiles::SetLastUsedProfile( 411 profiles::SetLastUsedProfile(
409 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); 412 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory));
410 // Clear kProfilesLastActive since the user only wants to launch a specific 413 // Clear kProfilesLastActive since the user only wants to launch a specific
411 // profile. 414 // profile.
412 ListPrefUpdate update(g_browser_process->local_state(), 415 ListPrefUpdate update(g_browser_process->local_state(),
413 prefs::kProfilesLastActive); 416 prefs::kProfilesLastActive);
414 base::ListValue* profile_list = update.Get(); 417 base::ListValue* profile_list = update.Get();
415 profile_list->Clear(); 418 profile_list->Clear();
416 } 419 }
417 420
418 Profile* profile = NULL; 421 Profile* profile = nullptr;
419 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) 422 #if defined(OS_CHROMEOS) || defined(OS_ANDROID)
420 // On ChromeOS and Android the ProfileManager will use the same path as the 423 // On ChromeOS and Android the ProfileManager will use the same path as the
421 // one we got passed. GetActiveUserProfile will therefore use the correct path 424 // one we got passed. GetActiveUserProfile will therefore use the correct path
422 // automatically. 425 // automatically.
423 DCHECK_EQ(user_data_dir.value(), 426 DCHECK_EQ(user_data_dir.value(),
424 g_browser_process->profile_manager()->user_data_dir().value()); 427 g_browser_process->profile_manager()->user_data_dir().value());
425 profile = ProfileManager::GetActiveUserProfile(); 428 profile = ProfileManager::GetActiveUserProfile();
429
430 // TODO(port): fix this. See comments near the definition of |user_data_dir|.
431 // It is better to CHECK-fail here than it is to silently exit because of
432 // missing code in the above test.
433 CHECK(profile) << "Cannot get default profile.";
434
426 #else 435 #else
427 base::FilePath profile_path = 436 profile = GetStartupProfile(user_data_dir, parsed_command_line);
428 GetStartupProfilePath(user_data_dir, parsed_command_line);
429 437
430 profile = g_browser_process->profile_manager()->GetProfile( 438 if (!profile && !profile_dir_specified)
431 profile_path); 439 profile = GetFallbackStartupProfile();
432 440
433 // If we're using the --new-profile-management flag and this profile is 441 if (!profile) {
434 // signed out, then we should show the user manager instead. By switching 442 ProfileErrorType error_type = profile_dir_specified ?
435 // the active profile to the guest profile we ensure that no 443 PROFILE_ERROR_CREATE_FAILURE_SPECIFIED :
436 // browser windows will be opened for the guest profile. 444 PROFILE_ERROR_CREATE_FAILURE_ALL;
437 if (switches::IsNewProfileManagement() && 445
438 profile && 446 ShowProfileErrorDialog(error_type, IDS_COULDNT_STARTUP_PROFILE_ERROR);
439 !profile->IsGuestSession()) { 447 return nullptr;
440 ProfileAttributesEntry* entry;
441 bool has_entry = g_browser_process->profile_manager()->
442 GetProfileAttributesStorage().
443 GetProfileAttributesWithPath(profile_path, &entry);
444 if (has_entry && entry->IsSigninRequired()) {
445 profile = g_browser_process->profile_manager()->GetProfile(
446 ProfileManager::GetGuestProfilePath());
447 }
448 } 448 }
449 #endif // defined(OS_CHROMEOS) || defined(OS_ANDROID) 449 #endif // defined(OS_CHROMEOS) || defined(OS_ANDROID)
450 if (profile) {
451 UMA_HISTOGRAM_LONG_TIMES(
452 "Startup.CreateFirstProfile", base::Time::Now() - start);
453 return profile;
454 }
455 450
456 #if !defined(OS_WIN) 451 UMA_HISTOGRAM_LONG_TIMES(
457 // TODO(port): fix this. See comments near the definition of 452 "Startup.CreateFirstProfile", base::Time::Now() - start);
458 // user_data_dir. It is better to CHECK-fail here than it is to 453 return profile;
459 // silently exit because of missing code in the above test.
460 CHECK(profile) << "Cannot get default profile.";
461 #endif // !defined(OS_WIN)
462
463 return NULL;
464 } 454 }
465 455
466 #if defined(OS_MACOSX) 456 #if defined(OS_MACOSX)
467 OSStatus KeychainCallback(SecKeychainEvent keychain_event, 457 OSStatus KeychainCallback(SecKeychainEvent keychain_event,
468 SecKeychainCallbackInfo* info, void* context) { 458 SecKeychainCallbackInfo* info, void* context) {
469 return noErr; 459 return noErr;
470 } 460 }
471 #endif // defined(OS_MACOSX) 461 #endif // defined(OS_MACOSX)
472 462
473 void RegisterComponentsForUpdate() { 463 void RegisterComponentsForUpdate() {
(...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after
2072 chromeos::CrosSettings::Shutdown(); 2062 chromeos::CrosSettings::Shutdown();
2073 #endif // defined(OS_CHROMEOS) 2063 #endif // defined(OS_CHROMEOS)
2074 #endif // defined(OS_ANDROID) 2064 #endif // defined(OS_ANDROID)
2075 } 2065 }
2076 2066
2077 // Public members: 2067 // Public members:
2078 2068
2079 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { 2069 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) {
2080 chrome_extra_parts_.push_back(parts); 2070 chrome_extra_parts_.push_back(parts);
2081 } 2071 }
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/profiles/profiles_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698