Commit 83548522 authored by Alan Cutter's avatar Alan Cutter Committed by Commit Bot

Update AppBannerManager method names to refer to non-web app related apps

This CL updates AppBannerManager methods:
 - ShouldDeferToRelatedApplication => ShouldDeferToRelatedNonWebApp
 - IsSupportedAppPlatform => IsSupportedNonWebAppPlatform
 - IsRelatedAppInstalled => IsRelatedNonWebAppInstalled
to be more clear that they're checking for related non-web apps.

This distinction is important now that we have the chromeos_play
platform which is used to list web apps on the Play store.

Change-Id: I0014b4977078ee46a97b11777b442506b5b2d566
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2483712
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Auto-Submit: Alan Cutter <alancutter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818364}
parent 1bb11089
......@@ -253,14 +253,14 @@ bool AppBannerManager::CheckIfShouldShowBanner() {
return false;
}
bool AppBannerManager::ShouldDeferToRelatedApplication() const {
bool AppBannerManager::ShouldDeferToRelatedNonWebApp() const {
for (const auto& related_app : manifest_.related_applications) {
if (manifest_.prefer_related_applications &&
IsSupportedAppPlatform(
IsSupportedNonWebAppPlatform(
related_app.platform.value_or(base::string16()))) {
return true;
}
if (IsRelatedAppInstalled(related_app))
if (IsRelatedNonWebAppInstalled(related_app))
return true;
}
return false;
......@@ -397,7 +397,7 @@ void AppBannerManager::OnDidPerformInstallableWebAppCheck(
return;
}
if (ShouldDeferToRelatedApplication()) {
if (ShouldDeferToRelatedNonWebApp()) {
SetInstallableWebAppCheckResult(
InstallableWebAppCheckResult::kByUserRequest);
Stop(PREFER_RELATED_APPLICATIONS);
......
......@@ -195,9 +195,9 @@ class AppBannerManager : public content::WebContentsObserver,
// GetAppIdentifier() must return a valid value for this method to work.
bool CheckIfShouldShowBanner();
// Returns whether the site would prefer a related application be installed
// instead of the PWA or a related application is already installed.
bool ShouldDeferToRelatedApplication() const;
// Returns whether the site would prefer a related non-web app be installed
// instead of the PWA or a related non-web app is already installed.
bool ShouldDeferToRelatedNonWebApp() const;
// Return a string identifying this app for metrics.
virtual std::string GetAppIdentifier();
......@@ -219,11 +219,14 @@ class AppBannerManager : public content::WebContentsObserver,
bool ShouldBypassEngagementChecks() const;
// Returns whether installation of apps from |platform| is supported on the
// current device.
virtual bool IsSupportedAppPlatform(const base::string16& platform) const = 0;
// Returns whether |related_app| is already installed.
virtual bool IsRelatedAppInstalled(
// current device and the platform delivers apps considered replacements for
// web apps.
virtual bool IsSupportedNonWebAppPlatform(
const base::string16& platform) const = 0;
// Returns whether |related_app| is already installed and considered a
// replacement for the manifest's web app.
virtual bool IsRelatedNonWebAppInstalled(
const blink::Manifest::RelatedApplication& related_app) const = 0;
// Returns whether the current page is already installed as a web app, or
......
......@@ -551,13 +551,13 @@ void AppBannerManagerAndroid::HideAmbientBadge() {
infobar_service->RemoveInfoBar(ambient_badge_infobar);
}
bool AppBannerManagerAndroid::IsSupportedAppPlatform(
bool AppBannerManagerAndroid::IsSupportedNonWebAppPlatform(
const base::string16& platform) const {
// TODO(https://crbug.com/949430): Implement for Android apps.
return false;
}
bool AppBannerManagerAndroid::IsRelatedAppInstalled(
bool AppBannerManagerAndroid::IsRelatedNonWebAppInstalled(
const blink::Manifest::RelatedApplication& related_app) const {
// TODO(https://crbug.com/949430): Implement for Android apps.
return false;
......
......@@ -97,8 +97,9 @@ class AppBannerManagerAndroid
void MaybeShowAmbientBadge() override;
base::WeakPtr<AppBannerManager> GetWeakPtr() override;
void InvalidateWeakPtrs() override;
bool IsSupportedAppPlatform(const base::string16& platform) const override;
bool IsRelatedAppInstalled(
bool IsSupportedNonWebAppPlatform(
const base::string16& platform) const override;
bool IsRelatedNonWebAppInstalled(
const blink::Manifest::RelatedApplication& related_app) const override;
private:
......
......@@ -128,11 +128,12 @@ class AppBannerManagerTest : public AppBannerManager {
void InvalidateWeakPtrs() override { weak_factory_.InvalidateWeakPtrs(); }
bool IsSupportedAppPlatform(const base::string16& platform) const override {
bool IsSupportedNonWebAppPlatform(
const base::string16& platform) const override {
return base::EqualsASCII(platform, "chrome_web_store");
}
bool IsRelatedAppInstalled(
bool IsRelatedNonWebAppInstalled(
const blink::Manifest::RelatedApplication& related_app) const override {
// Corresponds to the id listed in manifest_listing_related_chrome_app.json.
return base::EqualsASCII(related_app.platform.value_or(base::string16()),
......
......@@ -103,7 +103,7 @@ void AppBannerManagerDesktop::InvalidateWeakPtrs() {
weak_factory_.InvalidateWeakPtrs();
}
bool AppBannerManagerDesktop::IsSupportedAppPlatform(
bool AppBannerManagerDesktop::IsSupportedNonWebAppPlatform(
const base::string16& platform) const {
if (base::EqualsASCII(platform, kPlatformChromeWebStore))
return true;
......@@ -119,7 +119,7 @@ bool AppBannerManagerDesktop::IsSupportedAppPlatform(
return false;
}
bool AppBannerManagerDesktop::IsRelatedAppInstalled(
bool AppBannerManagerDesktop::IsRelatedNonWebAppInstalled(
const blink::Manifest::RelatedApplication& related_app) const {
if (!related_app.id || related_app.id->empty() || !related_app.platform ||
related_app.platform->empty()) {
......
......@@ -57,8 +57,9 @@ class AppBannerManagerDesktop
// AppBannerManager overrides.
base::WeakPtr<AppBannerManager> GetWeakPtr() override;
void InvalidateWeakPtrs() override;
bool IsSupportedAppPlatform(const base::string16& platform) const override;
bool IsRelatedAppInstalled(
bool IsSupportedNonWebAppPlatform(
const base::string16& platform) const override;
bool IsRelatedNonWebAppInstalled(
const blink::Manifest::RelatedApplication& related_app) const override;
// Called when the web app install initiated by a banner has completed.
......
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