Commit 22f6f3ff authored by Daniel Murphy's avatar Daniel Murphy Committed by Chromium LUCI CQ

[WebAppProvider] Listen to OnWebAppUninstalled in chrome://apps

The chrome://apps page can often be loaded / reloaded during WebApp
uninstall. Since the event it listens to occurs before uninstall, it
can miss this and still display stale apps. This change also has the
site listen to OnWebAppUninstalled() to ensure this does not happen.

R=cmp@chromium.org

Bug: 1164590
Change-Id: I6f02363c3b3afd5ae396e680617de78f099eef13
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2625333
Commit-Queue: Daniel Murphy <dmurph@chromium.org>
Auto-Submit: Daniel Murphy <dmurph@chromium.org>
Reviewed-by: default avatarChase Phillips <cmp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843237}
parent 19d90bc4
......@@ -573,9 +573,25 @@ void AppLauncherHandler::OnWebAppWillBeUninstalled(
const web_app::AppId& app_id) {
std::unique_ptr<base::DictionaryValue> app_info =
std::make_unique<base::DictionaryValue>();
// Since |isUninstall| is true below, the only item needed in the app_info
// dictionary is the id.
app_info->SetString(kInfoIdKey, app_id);
// Since |isUninstaLL| is true below, the only item needed in the app_info
web_ui()->CallJavascriptFunctionUnsafe(
"ntp.appRemoved", *app_info, /*isUninstall=*/base::Value(true),
base::Value(!extension_id_prompting_.empty()));
}
void AppLauncherHandler::OnWebAppUninstalled(const web_app::AppId& app_id) {
// This can be redundant in most cases, however it is not uncommon for the
// chrome://apps page to be loaded, or reloaded, during the uninstallation of
// an app. In this state, the app is still in the registry, but the
// |OnWebAppWillBeUninstalled| event has already been sent. Thus we also
// listen to this event, to ensure that the app is removed.
std::unique_ptr<base::DictionaryValue> app_info =
std::make_unique<base::DictionaryValue>();
// Since |isUninstall| is true below, the only item needed in the app_info
// dictionary is the id.
app_info->SetString(kInfoIdKey, app_id);
web_ui()->CallJavascriptFunctionUnsafe(
"ntp.appRemoved", *app_info, /*isUninstall=*/base::Value(true),
base::Value(!extension_id_prompting_.empty()));
......
......@@ -96,6 +96,7 @@ class AppLauncherHandler
// web_app::AppRegistrarObserver:
void OnWebAppInstalled(const web_app::AppId& app_id) override;
void OnWebAppWillBeUninstalled(const web_app::AppId& app_id) override;
void OnWebAppUninstalled(const web_app::AppId& app_id) override;
void OnAppRegistrarDestroyed() override;
// Populate the given dictionary with all installed app info.
......
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