chromium/components/webapps/browser/banners/app_banner_manager.cc

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/webapps/browser/banners/app_banner_manager.h"

#include <algorithm>
#include <optional>
#include <string>
#include <utility>
#include <vector>

#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/observer_list.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "components/back_forward_cache/back_forward_cache_disable.h"
#include "components/password_manager/content/common/web_ui_constants.h"
#include "components/site_engagement/content/site_engagement_service.h"
#include "components/webapps/browser/banners/app_banner_metrics.h"
#include "components/webapps/browser/banners/app_banner_settings_helper.h"
#include "components/webapps/browser/banners/install_banner_config.h"
#include "components/webapps/browser/banners/installable_web_app_check_result.h"
#include "components/webapps/browser/banners/web_app_banner_data.h"
#include "components/webapps/browser/features.h"
#include "components/webapps/browser/installable/installable_data.h"
#include "components/webapps/browser/installable/installable_logging.h"
#include "components/webapps/browser/installable/installable_manager.h"
#include "components/webapps/browser/installable/installable_metrics.h"
#include "components/webapps/browser/webapps_client.h"
#include "components/webapps/common/switches.h"
#include "content/public/browser/back_forward_cache.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_utils.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/net_errors.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/blink/public/common/manifest/manifest_util.h"
#include "third_party/blink/public/common/permissions_policy/permissions_policy.h"
#include "third_party/blink/public/mojom/installation/installation.mojom.h"
#include "third_party/blink/public/mojom/manifest/manifest.mojom.h"
#include "third_party/skia/include/core/SkBitmap.h"

namespace webapps {
namespace {

bool IsManifestUrlChange(const InstallableData& result) {}

}  // namespace

class AppBannerManager::StatusReporter {};

namespace {

int gTimeDeltaInDaysForTesting =;

InstallableParams ParamsToGetManifest() {}

// Logs installable status codes to the console.
class ConsoleStatusReporter : public AppBannerManager::StatusReporter {};

// Tracks installable status codes via an UMA histogram.
class TrackingStatusReporter : public AppBannerManager::StatusReporter {};

class NullStatusReporter : public AppBannerManager::StatusReporter {};

void TrackBeforeInstallEventPrompt(AppBannerManager::State state) {}
}  // anonymous namespace

namespace test {
bool g_disable_banner_triggering_for_testing =;
}

// static
AppBannerManager* AppBannerManager::FromWebContents(
    content::WebContents* web_contents) {}

// static
base::Time AppBannerManager::GetCurrentTime() {}

// static
void AppBannerManager::SetTimeDeltaForTesting(int days) {}

std::optional<GURL> AppBannerManager::validated_url() const {}

InstallableWebAppCheckResult AppBannerManager::GetInstallableWebAppCheckResult()
    const {}

std::optional<InstallBannerConfig> AppBannerManager::GetCurrentBannerConfig()
    const {}

std::optional<WebAppBannerData> AppBannerManager::GetCurrentWebAppBannerData()
    const {}

void AppBannerManager::RequestAppBanner() {}

void AppBannerManager::OnInstall(blink::mojom::DisplayMode display,
                                 bool set_current_web_app_not_installable) {}

void AppBannerManager::SendBannerAccepted() {}

void AppBannerManager::SendBannerDismissed() {}

void AppBannerManager::AddObserver(Observer* observer) {}

void AppBannerManager::RemoveObserver(Observer* observer) {}

base::WeakPtr<AppBannerManager> AppBannerManager::GetWeakPtr() {}

bool AppBannerManager::TriggeringDisabledForTesting() const {}

bool AppBannerManager::IsPromptAvailableForTesting() const {}

AppBannerManager::AppBannerManager(content::WebContents* web_contents)
    :{}

AppBannerManager::~AppBannerManager() = default;

AppBannerManager::UrlType AppBannerManager::GetUrlType(
    content::RenderFrameHost* render_frame_host,
    const GURL& url) {}

bool AppBannerManager::ShouldDeferToRelatedNonWebApp(
    const blink::mojom::Manifest& manifest) const {}

std::optional<std::string> AppBannerManager::GetWebOrNativeAppIdentifier()
    const {}

std::string AppBannerManager::GetBannerType() const {}

bool AppBannerManager::HasSufficientEngagement() const {}

bool AppBannerManager::ShouldBypassEngagementChecks() const {}

void AppBannerManager::OnDidGetManifest(const InstallableData& data) {}

void AppBannerManager::PerformInstallableChecks() {}

void AppBannerManager::OnNativeAppInstallableCheckComplete(
    base::expected<NativeAppBannerData, InstallableStatusCode> result) {}

void AppBannerManager::PerformInstallableWebAppCheck() {}

void AppBannerManager::OnDidPerformInstallableWebAppCheck(
    const InstallableData& data) {}

void AppBannerManager::CheckSufficientEngagement() {}

void AppBannerManager::ReportStatus(InstallableStatusCode code) {}

void AppBannerManager::ResetBindings() {}

void AppBannerManager::ResetCurrentPageDataInternal() {}

void AppBannerManager::Terminate(InstallableStatusCode code) {}

InstallableStatusCode AppBannerManager::TerminationCodeFromState() const {}

void AppBannerManager::SetInstallableWebAppCheckResult(
    InstallableWebAppCheckResult result) {}

void AppBannerManager::RecheckInstallabilityForLoadedPage() {}

void AppBannerManager::Stop(InstallableStatusCode code) {}

void AppBannerManager::SendBannerPromptRequest() {}

void AppBannerManager::UpdateState(State state) {}

void AppBannerManager::DidFinishNavigation(content::NavigationHandle* handle) {}

void AppBannerManager::DidFinishLoad(
    content::RenderFrameHost* render_frame_host,
    const GURL& validated_url) {}

void AppBannerManager::DidFailLoad(content::RenderFrameHost* render_frame_host,
                                   const GURL& validated_url,
                                   int error_code) {}

void AppBannerManager::DidUpdateWebManifestURL(
    content::RenderFrameHost* target_frame,
    const GURL& manifest_url) {}

void AppBannerManager::MediaStartedPlaying(const MediaPlayerInfo& media_info,
                                           const content::MediaPlayerId& id) {}

void AppBannerManager::MediaStoppedPlaying(
    const MediaPlayerInfo& media_info,
    const content::MediaPlayerId& id,
    WebContentsObserver::MediaStoppedReason reason) {}

void AppBannerManager::WebContentsDestroyed() {}

void AppBannerManager::OnEngagementEvent(
    content::WebContents* contents,
    const GURL& url,
    double score,
    double old_score,
    site_engagement::EngagementType /*type*/,
    const std::optional<webapps::AppId>& /*app_id*/) {}

bool AppBannerManager::IsRunning() const {}

// static
std::u16string AppBannerManager::GetInstallableWebAppName(
    content::WebContents* web_contents) {}
// static
std::string AppBannerManager::GetInstallableWebAppManifestId(
    content::WebContents* web_contents) {}

bool AppBannerManager::IsProbablyPromotableWebApp(
    bool ignore_existing_installations) const {}

bool AppBannerManager::IsPromotableWebApp() const {}

bool AppBannerManager::MaybeConsumeInstallAnimation() {}

void AppBannerManager::OnBannerPromptReply(
    const InstallBannerConfig& install_config,
    mojo::Remote<blink::mojom::AppBannerController> controller,
    blink::mojom::AppBannerPromptReply reply) {}

void AppBannerManager::ShowBannerForCurrentPageState() {}

void AppBannerManager::DisplayAppBanner() {}

}  // namespace webapps