Commit cb41ede1 authored by Rohit Agarwal's avatar Rohit Agarwal Committed by Commit Bot

Revert "Restart in the profile type that invoked it."

This reverts commit ca5efa8e.

Reason for revert:

A regression bug was crbug.com/1009377 created because of this CL.

Original change's description:
> Restart in the profile type that invoked it.
>
> If the user started the browser in incognito mode and
> triggered a restart in regular mode, the browser was started
> in the incognito mode. Similarly, if the user started in the
> regular mode and triggered a restart in the incognito mode,
> the browser was started in the regular mode.
>
> The fix is to find the profile type that invoked the restart.
> Then use this type to modify old switch arguments which are used
> to create the new cmd line arguments for restart.
>
> Bug: 999085
> Change-Id: Ide6e86aabb90b5a333ec10ea23e3add62a3d0e34
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1789582
> Reviewed-by: Vasilii Sukhanov <vasilii@chromium.org>
> Reviewed-by: Ramin Halavati <rhalavati@chromium.org>
> Commit-Queue: Rohit Agarwal <roagarwal@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#694717}

TBR=vasilii@chromium.org,rhalavati@chromium.org,roagarwal@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 999085
Change-Id: Ie3351c13cdb8f01f1e5c5088c7c6e72f936d569f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1839793Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Commit-Queue: Rohit Agarwal <roagarwal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703239}
parent 2b9cdf6b
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/buildflags.h" #include "chrome/common/buildflags.h"
#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/keep_alive_registry/keep_alive_registry.h" #include "components/keep_alive_registry/keep_alive_registry.h"
#include "components/language/core/browser/pref_names.h" #include "components/language/core/browser/pref_names.h"
...@@ -247,32 +246,10 @@ void AttemptRestart() { ...@@ -247,32 +246,10 @@ void AttemptRestart() {
} }
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
auto* browser_list = BrowserList::GetInstance();
// TODO(beng): Can this use ProfileManager::GetLoadedProfiles instead? // TODO(beng): Can this use ProfileManager::GetLoadedProfiles instead?
for (auto* browser : *browser_list) for (auto* browser : *BrowserList::GetInstance())
content::BrowserContext::SaveSessionState(browser->profile()); content::BrowserContext::SaveSessionState(browser->profile());
Browser* last_active_browser = browser_list->GetLastActive();
if (last_active_browser) {
Profile* last_profile = last_active_browser->profile();
if (last_profile) {
// We remove profile type decorators from the current run arguments and
// then append the last profile type that invoked the restart, in the old
// switch arguments. The old switch arguments are later used to create a
// new command line for restart phase.
base::CommandLine& old_cl(*base::CommandLine::ForCurrentProcess());
old_cl.RemoveSwitch(switches::kGuest);
old_cl.RemoveSwitch(switches::kIncognito);
if (last_profile->IsIncognitoProfile())
old_cl.AppendSwitch(switches::kIncognito);
else if (last_profile->IsGuestSession())
old_cl.AppendSwitch(switches::kGuest);
}
}
PrefService* pref_service = g_browser_process->local_state(); PrefService* pref_service = g_browser_process->local_state();
pref_service->SetBoolean(prefs::kWasRestarted, true); pref_service->SetBoolean(prefs::kWasRestarted, true);
......
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