Commit 13b535ca authored by Alexey Baskakov's avatar Alexey Baskakov Committed by Commit Bot

WebApp: Do not call NotifyWebAppInstalled on web app update.

Fix: OnWebAppInstalled must not be called on web app manifest update.

Test added.

This CL fixes the code which is disabled behind
kDesktopPWAsWithoutExtensions flag. No behavior change in ToT.

Bug: 860581
Change-Id: I06673f13b493f4f96aadce7ab8ba4457846210fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2172150
Commit-Queue: Alexey Baskakov <loyso@chromium.org>
Reviewed-by: default avatarAlan Cutter <alancutter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#765406}
parent 20ce56b7
......@@ -49,6 +49,9 @@ class BookmarkAppRegistrar : public web_app::AppRegistrar,
BookmarkAppRegistrar* AsBookmarkAppRegistrar() override;
// ExtensionRegistryObserver:
// OnExtensionInstalled is not handled here.
// AppRegistrar::NotifyWebAppInstalled is triggered by
// BookmarkAppInstallFinalizer::OnExtensionInstalled().
void OnExtensionUninstalled(content::BrowserContext* browser_context,
const Extension* extension,
UninstallReason reason) override;
......
......@@ -25,6 +25,7 @@
#include "chrome/browser/web_applications/components/web_app_provider_base.h"
#include "chrome/browser/web_applications/system_web_app_manager.h"
#include "chrome/browser/web_applications/test/test_system_web_app_installation.h"
#include "chrome/browser/web_applications/test/web_app_install_observer.h"
#include "chrome/browser/web_applications/test/web_app_test.h"
#include "chrome/common/chrome_features.h"
#include "chrome/test/base/in_process_browser_test.h"
......@@ -531,6 +532,14 @@ IN_PROC_BROWSER_TEST_P(ManifestUpdateManagerBrowserTest,
AppId app_id = InstallWebApp();
EXPECT_EQ(GetProvider().registrar().GetAppThemeColor(app_id), SK_ColorBLUE);
// Check that OnWebAppInstalled and OnWebAppUninstalled are not called
// if in-place web app update happens.
WebAppInstallObserver install_observer(&GetProvider().registrar());
install_observer.SetWebAppInstalledDelegate(
base::BindLambdaForTesting([](const AppId& app_id) { NOTREACHED(); }));
install_observer.SetWebAppUninstalledDelegate(
base::BindLambdaForTesting([](const AppId& app_id) { NOTREACHED(); }));
OverrideManifest(kManifestTemplate, {kInstallableIconList, "red"});
EXPECT_EQ(GetResultAfterPageLoad(GetAppURL(), &app_id),
ManifestUpdateResult::kAppUpdated);
......
......@@ -460,7 +460,9 @@ void WebAppInstallFinalizer::OnDatabaseCommitCompleted(
return;
}
registrar().NotifyWebAppInstalled(app_id);
if (is_new_install)
registrar().NotifyWebAppInstalled(app_id);
std::move(callback).Run(
app_id, is_new_install ? InstallResultCode::kSuccessNewInstall
: InstallResultCode::kSuccessAlreadyInstalled);
......
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