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

Desktop PWAs: Do not launch web apps during shutdown

If the browser process is shutting down,
WebAppLaunchManager::OpenApplication now exits early instead of
attempting to launch a web app.

Bug: 1121894
Change-Id: Ic67f4c89a02082d13d867a8484b3b2c368c96900
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2608095Reviewed-by: default avatarcalamity <calamity@chromium.org>
Commit-Queue: Eric Willigers <ericwilligers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840063}
parent 5a85be43
...@@ -13,6 +13,12 @@ ...@@ -13,6 +13,12 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "build/chromeos_buildflags.h" #include "build/chromeos_buildflags.h"
#include "chrome/app/chrome_command_ids.h" #include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/apps/app_service/app_launch_params.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/apps/app_service/browser_app_launcher.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/devtools/protocol/browser_handler.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h" #include "chrome/browser/sessions/tab_restore_service_factory.h"
#include "chrome/browser/themes/custom_theme_supplier.h" #include "chrome/browser/themes/custom_theme_supplier.h"
#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_properties.h"
...@@ -45,6 +51,7 @@ ...@@ -45,6 +51,7 @@
#include "chrome/browser/web_applications/web_app_provider.h" #include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "chrome/test/base/ui_test_utils.h" #include "chrome/test/base/ui_test_utils.h"
#include "components/services/app_service/public/mojom/types.mojom.h"
#include "components/sessions/core/tab_restore_service.h" #include "components/sessions/core/tab_restore_service.h"
#include "content/public/common/content_features.h" #include "content/public/common/content_features.h"
#include "content/public/test/background_color_change_waiter.h" #include "content/public/test/background_color_change_waiter.h"
...@@ -55,6 +62,7 @@ ...@@ -55,6 +62,7 @@
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "ui/base/clipboard/clipboard.h" #include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/clipboard_buffer.h" #include "ui/base/clipboard/clipboard_buffer.h"
#include "ui/base/window_open_disposition.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
...@@ -955,6 +963,26 @@ IN_PROC_BROWSER_TEST_F(WebAppBrowserTest, PermissionBubble) { ...@@ -955,6 +963,26 @@ IN_PROC_BROWSER_TEST_F(WebAppBrowserTest, PermissionBubble) {
"navigator.geolocation.getCurrentPosition(function(){});")); "navigator.geolocation.getCurrentPosition(function(){});"));
} }
// Check that no web app is launched during shutdown.
IN_PROC_BROWSER_TEST_F(WebAppBrowserTest, Shutdown) {
const GURL app_url = GetSecureAppURL();
const AppId app_id = InstallPWA(app_url);
apps::AppLaunchParams params(
app_id, apps::mojom::LaunchContainer::kLaunchContainerWindow,
WindowOpenDisposition::NEW_WINDOW,
apps::mojom::AppLaunchSource::kSourceTest);
BrowserHandler handler(nullptr, std::string());
handler.Close();
ui_test_utils::WaitForBrowserToClose();
content::WebContents* const web_contents =
apps::AppServiceProxyFactory::GetForProfile(profile())
->BrowserAppLauncher()
->LaunchAppWithParams(std::move(params));
EXPECT_EQ(web_contents, nullptr);
}
// Ensure that web app windows with blank titles don't display the URL as a // Ensure that web app windows with blank titles don't display the URL as a
// default window title. // default window title.
IN_PROC_BROWSER_TEST_F(WebAppBrowserTest, EmptyTitlesDoNotDisplayUrl) { IN_PROC_BROWSER_TEST_F(WebAppBrowserTest, EmptyTitlesDoNotDisplayUrl) {
......
...@@ -136,8 +136,11 @@ WebAppLaunchManager::~WebAppLaunchManager() = default; ...@@ -136,8 +136,11 @@ WebAppLaunchManager::~WebAppLaunchManager() = default;
content::WebContents* WebAppLaunchManager::OpenApplication( content::WebContents* WebAppLaunchManager::OpenApplication(
apps::AppLaunchParams&& params) { apps::AppLaunchParams&& params) {
if (!provider_->registrar().IsInstalled(params.app_id)) if (Browser::GetBrowserCreationStatusForProfile(profile_) !=
Browser::BrowserCreationStatus::kOk ||
!provider_->registrar().IsInstalled(params.app_id)) {
return nullptr; return nullptr;
}
if (params.container == apps::mojom::LaunchContainer::kLaunchContainerWindow) if (params.container == apps::mojom::LaunchContainer::kLaunchContainerWindow)
RecordAppWindowLaunch(profile_, params.app_id); RecordAppWindowLaunch(profile_, params.app_id);
......
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