Commit 43ca70a1 authored by Eric Willigers's avatar Eric Willigers Committed by Chromium LUCI CQ

DisconnectV1AppFromLauncher allows for destroyed tabs

MultiProfileBrowserStatusMonitor::DisconnectV1AppFromLauncher now exits
early instead of crashing, if the tab has already been destroyed.

Addresses flaky test
SystemWebAppManagerMultiDesktopLaunchBrowserTest.LaunchToActiveDesktop

Bug: 1154381
Change-Id: I899e98abc4333c3c47bc0643882fac8dff3f9081
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2567087
Commit-Queue: Eric Willigers <ericwilligers@chromium.org>
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Reviewed-by: default avatarNancy Wang <nancylingwang@chromium.org>
Auto-Submit: Eric Willigers <ericwilligers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833021}
parent f849f26d
...@@ -211,6 +211,7 @@ ash::AppStatus LauncherControllerHelper::GetAppStatus( ...@@ -211,6 +211,7 @@ ash::AppStatus LauncherControllerHelper::GetAppStatus(
} }
std::string LauncherControllerHelper::GetAppID(content::WebContents* tab) { std::string LauncherControllerHelper::GetAppID(content::WebContents* tab) {
DCHECK(tab);
ProfileManager* profile_manager = g_browser_process->profile_manager(); ProfileManager* profile_manager = g_browser_process->profile_manager();
if (profile_manager) { if (profile_manager) {
const std::vector<Profile*> profile_list = const std::vector<Profile*> profile_list =
......
...@@ -88,14 +88,13 @@ void MultiProfileBrowserStatusMonitor::RemoveV1AppFromShelf(Browser* browser) { ...@@ -88,14 +88,13 @@ void MultiProfileBrowserStatusMonitor::RemoveV1AppFromShelf(Browser* browser) {
void MultiProfileBrowserStatusMonitor::ConnectV1AppToLauncher( void MultiProfileBrowserStatusMonitor::ConnectV1AppToLauncher(
Browser* browser) { Browser* browser) {
content::WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
if (!web_contents)
return;
// Adding a V1 app to the launcher consists of two actions: Add the browser // Adding a V1 app to the launcher consists of two actions: Add the browser
// (launcher item) and add the content (launcher item status). // (launcher item) and add the content (launcher item status).
BrowserStatusMonitor::AddV1AppToShelf(browser); BrowserStatusMonitor::AddV1AppToShelf(browser);
content::WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
if (web_contents)
launcher_controller_->UpdateAppState(web_contents, false /*remove*/); launcher_controller_->UpdateAppState(web_contents, false /*remove*/);
} }
...@@ -103,7 +102,10 @@ void MultiProfileBrowserStatusMonitor::DisconnectV1AppFromLauncher( ...@@ -103,7 +102,10 @@ void MultiProfileBrowserStatusMonitor::DisconnectV1AppFromLauncher(
Browser* browser) { Browser* browser) {
// Removing a V1 app from the launcher requires to remove the content and // Removing a V1 app from the launcher requires to remove the content and
// the launcher item. // the launcher item.
launcher_controller_->UpdateAppState( content::WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents(), true /*remove*/); browser->tab_strip_model()->GetActiveWebContents();
if (web_contents)
launcher_controller_->UpdateAppState(web_contents, true /*remove*/);
BrowserStatusMonitor::RemoveV1AppFromShelf(browser); BrowserStatusMonitor::RemoveV1AppFromShelf(browser);
} }
...@@ -517,15 +517,8 @@ class SystemWebAppManagerMultiDesktopLaunchBrowserTest ...@@ -517,15 +517,8 @@ class SystemWebAppManagerMultiDesktopLaunchBrowserTest
AccountId account_id2_; AccountId account_id2_;
}; };
#if defined(OS_CHROMEOS)
// https://crbug.com/1154381
#define MAYBE_LaunchToActiveDesktop DISABLED_LaunchToActiveDesktop
#else
#define MAYBE_LaunchToActiveDesktop LaunchToActiveDesktop
#endif
IN_PROC_BROWSER_TEST_F(SystemWebAppManagerMultiDesktopLaunchBrowserTest, IN_PROC_BROWSER_TEST_F(SystemWebAppManagerMultiDesktopLaunchBrowserTest,
MAYBE_LaunchToActiveDesktop) { LaunchToActiveDesktop) {
// Login two users. // Login two users.
LoginUser(account_id1_); LoginUser(account_id1_);
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
......
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