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

Unified 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, 5 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_browser_main.cc
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index 203e732549c7370dddd7348fb0dbf844e42b14a0..a190555a5fed6ec5dfb0abbaf403d8042d77685f 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -90,6 +90,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/javascript_dialogs/chrome_javascript_native_dialog_factory.h"
+#include "chrome/browser/ui/profile_error_dialog.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"
@@ -403,8 +404,10 @@ Profile* CreatePrimaryProfile(const content::MainFunctionParams& parameters,
TRACE_EVENT0("startup", "ChromeBrowserMainParts::CreateProfile")
base::Time start = base::Time::Now();
- if (profiles::IsMultipleProfilesEnabled() &&
- parsed_command_line.HasSwitch(switches::kProfileDirectory)) {
+ bool profile_dir_specified =
+ profiles::IsMultipleProfilesEnabled() &&
+ parsed_command_line.HasSwitch(switches::kProfileDirectory);
+ if (profile_dir_specified) {
profiles::SetLastUsedProfile(
parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory));
// Clear kProfilesLastActive since the user only wants to launch a specific
@@ -415,7 +418,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
@@ -423,44 +426,31 @@ Profile* CreatePrimaryProfile(const content::MainFunctionParams& parameters,
DCHECK_EQ(user_data_dir.value(),
g_browser_process->profile_manager()->user_data_dir().value());
profile = ProfileManager::GetActiveUserProfile();
+
+ // 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.";
+
#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);
+
+ 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) {
- UMA_HISTOGRAM_LONG_TIMES(
- "Startup.CreateFirstProfile", base::Time::Now() - start);
- 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.";
-#endif // !defined(OS_WIN)
- return NULL;
+ UMA_HISTOGRAM_LONG_TIMES(
+ "Startup.CreateFirstProfile", base::Time::Now() - start);
+ return profile;
}
#if defined(OS_MACOSX)
« 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