#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) { … }
}
class AppBannerManager::StatusReporter { … };
namespace {
int gTimeDeltaInDaysForTesting = …;
InstallableParams ParamsToGetManifest() { … }
class ConsoleStatusReporter : public AppBannerManager::StatusReporter { … };
class TrackingStatusReporter : public AppBannerManager::StatusReporter { … };
class NullStatusReporter : public AppBannerManager::StatusReporter { … };
void TrackBeforeInstallEventPrompt(AppBannerManager::State state) { … }
}
namespace test {
bool g_disable_banner_triggering_for_testing = …;
}
AppBannerManager* AppBannerManager::FromWebContents(
content::WebContents* web_contents) { … }
base::Time AppBannerManager::GetCurrentTime() { … }
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 ,
const std::optional<webapps::AppId>& ) { … }
bool AppBannerManager::IsRunning() const { … }
std::u16string AppBannerManager::GetInstallableWebAppName(
content::WebContents* web_contents) { … }
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() { … }
}