Commit 5dd94398 authored by Xi Cheng's avatar Xi Cheng Committed by Commit Bot

Make kNotificationLaunchId take precedence over kProfileDirectory

... in CreatePrimaryProfile(). This is consistent with the logic in
GetStartupProfilePath() in startup_browser_creator.cc file.

Bug: 734095, 833663
Change-Id: Ic74bf5af947d0ef75006169676ed3bfcad7cde91
Reviewed-on: https://chromium-review.googlesource.com/1037930Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarTommy Martino <tmartino@chromium.org>
Commit-Queue: Xi Cheng <chengx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555298}
parent f0e7b46d
......@@ -441,12 +441,31 @@ Profile* CreatePrimaryProfile(const content::MainFunctionParams& parameters,
TRACE_EVENT0("startup", "ChromeBrowserMainParts::CreateProfile")
base::Time start = base::Time::Now();
bool set_last_used_profile = false;
// If the browser is launched due to activation on Windows native
// notification, the profile id encoded in the notification launch id should
// be chosen over all others.
#if defined(OS_WIN)
if (parsed_command_line.HasSwitch(switches::kNotificationLaunchId)) {
profiles::SetLastUsedProfile(
base::UTF16ToUTF8(parsed_command_line.GetSwitchValueNative(
switches::kNotificationLaunchId)));
set_last_used_profile = true;
}
#endif // defined(OS_WIN)
bool profile_dir_specified =
profiles::IsMultipleProfilesEnabled() &&
parsed_command_line.HasSwitch(switches::kProfileDirectory);
if (profile_dir_specified) {
if (!set_last_used_profile && profile_dir_specified) {
profiles::SetLastUsedProfile(
parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory));
set_last_used_profile = true;
}
if (set_last_used_profile) {
// Clear kProfilesLastActive since the user only wants to launch a specific
// profile.
ListPrefUpdate update(g_browser_process->local_state(),
......@@ -472,7 +491,7 @@ Profile* CreatePrimaryProfile(const content::MainFunctionParams& parameters,
#else
profile = GetStartupProfile(user_data_dir, parsed_command_line);
if (!profile && !profile_dir_specified)
if (!profile && !set_last_used_profile)
profile = GetFallbackStartupProfile();
if (!profile) {
......
......@@ -786,7 +786,7 @@ bool StartupBrowserCreator::LaunchBrowserForLastProfiles(
}
#if defined(OS_WIN)
if (command_line.HasSwitch(switches::kNotificationLaunchId)) {
if (was_windows_notification_launch) {
LogUserManagerShowupStatus(
UserManagerShowupStatus::kLastUsedProfileCannotOpen);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment