Chromium Code Reviews| Index: chrome/browser/chrome_browser_main.cc |
| diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc |
| index 372835ac723201c3e81d8f1a66323a613054e845..bfc1fd5d01eefec584bf01d5749b6c2cf0685d91 100644 |
| --- a/chrome/browser/chrome_browser_main.cc |
| +++ b/chrome/browser/chrome_browser_main.cc |
| @@ -88,6 +88,8 @@ |
| #include "chrome/browser/ui/app_modal/chrome_javascript_native_dialog_factory.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/browser_finder.h" |
| +#include "chrome/browser/ui/profile_error_dialog.h" |
| +#include "chrome/browser/ui/simple_message_box.h" |
| #include "chrome/browser/ui/startup/bad_flags_prompt.h" |
| #include "chrome/browser/ui/startup/default_browser_prompt.h" |
| #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| @@ -391,7 +393,7 @@ Profile* CreatePrimaryProfile(const content::MainFunctionParams& parameters, |
| profile_list->Clear(); |
| } |
| - Profile* profile = NULL; |
| + Profile* profile = nullptr; |
| #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
| // On ChromeOS and Android the ProfileManager will use the same path as the |
| // one we got passed. GetActiveUserProfile will therefore use the correct path |
| @@ -400,27 +402,22 @@ Profile* CreatePrimaryProfile(const content::MainFunctionParams& parameters, |
| g_browser_process->profile_manager()->user_data_dir().value()); |
| profile = ProfileManager::GetActiveUserProfile(); |
| #else |
| - base::FilePath profile_path = |
| - GetStartupProfilePath(user_data_dir, parsed_command_line); |
| - |
| - profile = g_browser_process->profile_manager()->GetProfile( |
| - profile_path); |
| - |
| - // If we're using the --new-profile-management flag and this profile is |
| - // signed out, then we should show the user manager instead. By switching |
| - // the active profile to the guest profile we ensure that no |
| - // browser windows will be opened for the guest profile. |
| - if (switches::IsNewProfileManagement() && |
| - profile && |
| - !profile->IsGuestSession()) { |
| - ProfileAttributesEntry* entry; |
| - bool has_entry = g_browser_process->profile_manager()-> |
| - GetProfileAttributesStorage(). |
| - GetProfileAttributesWithPath(profile_path, &entry); |
| - if (has_entry && entry->IsSigninRequired()) { |
| - profile = g_browser_process->profile_manager()->GetProfile( |
| - ProfileManager::GetGuestProfilePath()); |
| - } |
| + profile = GetStartupProfile(user_data_dir, parsed_command_line); |
| + |
| + bool profile_dir_specified = |
| + profiles::IsMultipleProfilesEnabled() && |
| + parsed_command_line.HasSwitch(switches::kProfileDirectory); |
| + |
| + if (!profile && !profile_dir_specified) |
| + profile = GetFallbackStartupProfile(); |
| + |
| + if (!profile) { |
| + ProfileErrorType error_type = profile_dir_specified ? |
| + PROFILE_ERROR_CREATE_FAILURE_SPECIFIED : |
| + PROFILE_ERROR_CREATE_FAILURE_ALL; |
| + |
| + ShowProfileErrorDialog(error_type, IDS_COULDNT_STARTUP_PROFILE_ERROR); |
| + return nullptr; |
| } |
| #endif // defined(OS_CHROMEOS) || defined(OS_ANDROID) |
| if (profile) { |
| @@ -429,14 +426,12 @@ Profile* CreatePrimaryProfile(const content::MainFunctionParams& parameters, |
| return profile; |
| } |
| -#if !defined(OS_WIN) |
| // TODO(port): fix this. See comments near the definition of |
| // user_data_dir. It is better to CHECK-fail here than it is to |
| // silently exit because of missing code in the above test. |
| CHECK(profile) << "Cannot get default profile."; |
|
Peter Kasting
2016/06/16 06:37:49
This block should be moved up into the #if defined
WC Leung
2016/06/19 17:56:19
Done.
|
| -#endif // !defined(OS_WIN) |
| - return NULL; |
| + return nullptr; |
| } |
| #if defined(OS_MACOSX) |