Commit 853d3de8 authored by Alan Cutter's avatar Alan Cutter Committed by Commit Bot

Make PWAInstallView::Update defensive towards the existence of tab helpers

This CL makes the PWA Omnibox install icon check the existence of
both the AppBannerManager and the WebAppTabHelperBase as the presence of
one is not 1:1 with the other.

Bug: 953409
Change-Id: I310aa4c1613eb1d4037cb417c7b5c0d51215eb35
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1585282
Auto-Submit: Alan Cutter <alancutter@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Dominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#654778}
parent fdaf0951
...@@ -30,20 +30,17 @@ bool PwaInstallView::Update() { ...@@ -30,20 +30,17 @@ bool PwaInstallView::Update() {
if (!web_contents) if (!web_contents)
return false; return false;
banners::AppBannerManager* manager = auto* manager = banners::AppBannerManager::FromWebContents(web_contents);
banners::AppBannerManager::FromWebContents(web_contents);
// May not be present e.g. in incognito mode. // May not be present e.g. in incognito mode.
if (!manager) if (!manager)
return false; return false;
bool is_installable = manager->IsProbablyInstallable(); bool is_probably_installable = manager->IsProbablyInstallable();
bool is_installed = auto* tab_helper =
web_app::WebAppTabHelperBase::FromWebContents(web_contents) web_app::WebAppTabHelperBase::FromWebContents(web_contents);
->HasAssociatedApp(); bool is_installed = tab_helper && tab_helper->HasAssociatedApp();
bool show_install_button = is_installable && !is_installed;
// TODO(crbug.com/907351): When installability is unknown and we're still in bool show_install_button = is_probably_installable && !is_installed;
// the scope of a previously-determined installable site, display it as still
// being installable.
if (show_install_button && manager->MaybeConsumeInstallAnimation()) if (show_install_button && manager->MaybeConsumeInstallAnimation())
AnimateIn(base::nullopt); AnimateIn(base::nullopt);
......
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