chromium/chrome/browser/web_applications/web_app_command_scheduler.cc

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

#include "chrome/browser/web_applications/web_app_command_scheduler.h"

#include <memory>
#include <optional>

#include "base/check_is_test.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/metrics/histogram_functions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/types/expected.h"
#include "base/values.h"
#include "base/version.h"
#include "build/build_config.h"
#include "chrome/browser/profiles/keep_alive/profile_keep_alive_types.h"
#include "chrome/browser/profiles/keep_alive/scoped_profile_keep_alive.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/web_applications/commands/clear_browsing_data_command.h"
#include "chrome/browser/web_applications/commands/compute_app_size_command.h"
#include "chrome/browser/web_applications/commands/dedupe_install_urls_command.h"
#include "chrome/browser/web_applications/commands/external_app_resolution_command.h"
#include "chrome/browser/web_applications/commands/fetch_install_info_from_install_url_command.h"
#include "chrome/browser/web_applications/commands/fetch_installability_for_chrome_management.h"
#include "chrome/browser/web_applications/commands/fetch_manifest_and_install_command.h"
#include "chrome/browser/web_applications/commands/install_app_locally_command.h"
#include "chrome/browser/web_applications/commands/install_from_info_command.h"
#include "chrome/browser/web_applications/commands/install_from_sync_command.h"
#include "chrome/browser/web_applications/commands/internal/callback_command.h"
#include "chrome/browser/web_applications/commands/launch_web_app_command.h"
#include "chrome/browser/web_applications/commands/manifest_update_check_command.h"
#include "chrome/browser/web_applications/commands/manifest_update_finalize_command.h"
#include "chrome/browser/web_applications/commands/navigate_and_trigger_install_dialog_command.h"
#include "chrome/browser/web_applications/commands/os_integration_synchronize_command.h"
#include "chrome/browser/web_applications/commands/run_on_os_login_command.h"
#include "chrome/browser/web_applications/commands/set_user_display_mode_command.h"
#include "chrome/browser/web_applications/commands/update_file_handler_command.h"
#include "chrome/browser/web_applications/commands/update_protocol_handler_approval_command.h"
#include "chrome/browser/web_applications/commands/web_app_icon_diagnostic_command.h"
#include "chrome/browser/web_applications/commands/web_app_uninstall_command.h"
#include "chrome/browser/web_applications/isolated_web_apps/check_isolated_web_app_bundle_installability_command.h"
#include "chrome/browser/web_applications/isolated_web_apps/cleanup_orphaned_isolated_web_apps_command.h"
#include "chrome/browser/web_applications/isolated_web_apps/get_controlled_frame_partition_command.h"
#include "chrome/browser/web_applications/isolated_web_apps/get_isolated_web_app_browsing_data_command.h"
#include "chrome/browser/web_applications/isolated_web_apps/install_isolated_web_app_command.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_apply_update_command.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_install_command_helper.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_install_source.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_prepare_and_store_update_command.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_url_info.h"
#include "chrome/browser/web_applications/isolated_web_apps/signed_web_bundle_metadata.h"
#include "chrome/browser/web_applications/locks/all_apps_lock.h"
#include "chrome/browser/web_applications/locks/app_lock.h"
#include "chrome/browser/web_applications/locks/noop_lock.h"
#include "chrome/browser/web_applications/locks/shared_web_contents_lock.h"
#include "chrome/browser/web_applications/locks/shared_web_contents_with_app_lock.h"
#include "chrome/browser/web_applications/os_integration/os_integration_sub_manager.h"
#include "chrome/browser/web_applications/proto/web_app_install_state.pb.h"
#include "chrome/browser/web_applications/web_app_command_manager.h"
#include "chrome/browser/web_applications/web_app_constants.h"
#include "chrome/browser/web_applications/web_app_install_params.h"
#include "chrome/browser/web_applications/web_app_proto_utils.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/web_applications/web_app_sync_bridge.h"
#include "chrome/browser/web_applications/web_app_ui_manager.h"
#include "chrome/browser/web_applications/web_contents/web_app_data_retriever.h"
#include "chrome/browser/web_applications/web_contents/web_contents_manager.h"
#include "chrome/common/chrome_features.h"
#include "components/keep_alive_registry/keep_alive_registry.h"
#include "components/keep_alive_registry/keep_alive_types.h"
#include "components/keep_alive_registry/scoped_keep_alive.h"
#include "components/webapps/browser/installable/installable_metrics.h"
#include "components/webapps/browser/web_contents/web_app_url_loader.h"
#include "content/public/browser/storage_partition_config.h"
#include "content/public/browser/web_contents.h"

#if !BUILDFLAG(IS_CHROMEOS)
#include "chrome/browser/web_applications/jobs/link_capturing.h"
#endif

namespace web_app {

WebAppCommandScheduler::WebAppCommandScheduler(Profile& profile)
    :{}

WebAppCommandScheduler::~WebAppCommandScheduler() = default;

void WebAppCommandScheduler::SetProvider(base::PassKey<WebAppProvider>,
                                         WebAppProvider& provider) {}

void WebAppCommandScheduler::Shutdown() {}

void WebAppCommandScheduler::FetchManifestAndInstall(
    webapps::WebappInstallSource install_surface,
    base::WeakPtr<content::WebContents> contents,
    WebAppInstallDialogCallback dialog_callback,
    OnceInstallCallback callback,
    FallbackBehavior behavior,
    const base::Location& location) {}

void WebAppCommandScheduler::FetchInstallInfoFromInstallUrl(
    webapps::ManifestId manifest_id,
    GURL install_url,
    webapps::ManifestId parent_manifest_id,
    base::OnceCallback<void(std::unique_ptr<WebAppInstallInfo>)> callback) {}

void WebAppCommandScheduler::FetchInstallInfoFromInstallUrl(
    webapps::ManifestId manifest_id,
    GURL install_url,
    base::OnceCallback<void(std::unique_ptr<WebAppInstallInfo>)> callback) {}

void WebAppCommandScheduler::InstallFromInfoNoIntegrationForTesting(
    std::unique_ptr<WebAppInstallInfo> install_info,
    bool overwrite_existing_manifest_fields,
    webapps::WebappInstallSource install_surface,
    OnceInstallCallback install_callback,
    const base::Location& location) {}

void WebAppCommandScheduler::InstallFromInfoWithParams(
    std::unique_ptr<WebAppInstallInfo> install_info,
    bool overwrite_existing_manifest_fields,
    webapps::WebappInstallSource install_surface,
    OnceInstallCallback install_callback,
    const WebAppInstallParams& install_params,
    const base::Location& location) {}

void WebAppCommandScheduler::InstallExternallyManagedApp(
    const ExternalInstallOptions& external_install_options,
    std::optional<webapps::AppId> installed_placeholder_app_id,
    ExternalAppResolutionCommand::InstalledCallback installed_callback,
    const base::Location& location) {}

void WebAppCommandScheduler::PersistFileHandlersUserChoice(
    const webapps::AppId& app_id,
    bool allowed,
    base::OnceClosure callback,
    const base::Location& location) {}

void WebAppCommandScheduler::ScheduleManifestUpdateCheck(
    const GURL& url,
    const webapps::AppId& app_id,
    base::Time check_time,
    base::WeakPtr<content::WebContents> contents,
    ManifestUpdateCheckCommand::CompletedCallback callback,
    const base::Location& location) {}

void WebAppCommandScheduler::ScheduleManifestUpdateFinalize(
    const GURL& url,
    const webapps::AppId& app_id,
    std::unique_ptr<WebAppInstallInfo> install_info,
    std::unique_ptr<ScopedKeepAlive> optional_keep_alive,
    std::unique_ptr<ScopedProfileKeepAlive> optional_profile_keep_alive,
    ManifestWriteCallback callback,
    const base::Location& location) {}

void WebAppCommandScheduler::FetchInstallabilityForChromeManagement(
    const GURL& url,
    base::WeakPtr<content::WebContents> web_contents,
    FetchInstallabilityForChromeManagementCallback callback,
    const base::Location& location) {}

void WebAppCommandScheduler::ScheduleNavigateAndTriggerInstallDialog(
    const GURL& install_url,
    const GURL& origin,
    bool is_renderer_initiated,
    NavigateAndTriggerInstallDialogCommandCallback callback,
    const base::Location& location) {}

void WebAppCommandScheduler::InstallIsolatedWebApp(
    const IsolatedWebAppUrlInfo& url_info,
    const IsolatedWebAppInstallSource& install_source,
    const std::optional<base::Version>& expected_version,
    std::unique_ptr<ScopedKeepAlive> optional_keep_alive,
    std::unique_ptr<ScopedProfileKeepAlive> optional_profile_keep_alive,
    InstallIsolatedWebAppCallback callback,
    const base::Location& call_location) {}

void WebAppCommandScheduler::CleanupOrphanedIsolatedApps(
    CleanupOrphanedIsolatedWebAppsCallback callback,
    const base::Location& call_location) {}

void WebAppCommandScheduler::PrepareAndStoreIsolatedWebAppUpdate(
    const IsolatedWebAppUpdatePrepareAndStoreCommand::UpdateInfo& update_info,
    const IsolatedWebAppUrlInfo& url_info,
    std::unique_ptr<ScopedKeepAlive> optional_keep_alive,
    std::unique_ptr<ScopedProfileKeepAlive> optional_profile_keep_alive,
    base::OnceCallback<void(IsolatedWebAppUpdatePrepareAndStoreCommandResult)>
        callback,
    const base::Location& call_location) {}

void WebAppCommandScheduler::ApplyPendingIsolatedWebAppUpdate(
    const IsolatedWebAppUrlInfo& url_info,
    std::unique_ptr<ScopedKeepAlive> optional_keep_alive,
    std::unique_ptr<ScopedProfileKeepAlive> optional_profile_keep_alive,
    base::OnceCallback<void(
        base::expected<void, IsolatedWebAppApplyUpdateCommandError>)> callback,
    const base::Location& call_location) {}

// Given the |bundle_metadata| of a Signed Web Bundle, schedules a command to
// check the installability of the bundle.
void WebAppCommandScheduler::CheckIsolatedWebAppBundleInstallability(
    const SignedWebBundleMetadata& bundle_metadata,
    base::OnceCallback<void(IsolatedInstallabilityCheckResult,
                            std::optional<base::Version>)> callback,
    const base::Location& call_location) {}

void WebAppCommandScheduler::GetIsolatedWebAppBrowsingData(
    base::OnceCallback<void(base::flat_map<url::Origin, int64_t>)> callback,
    const base::Location& call_location) {}

void WebAppCommandScheduler::GetControlledFramePartition(
    const IsolatedWebAppUrlInfo& url_info,
    const std::string& partition_name,
    bool in_memory,
    base::OnceCallback<void(std::optional<content::StoragePartitionConfig>)>
        callback,
    const base::Location& location) {}

void WebAppCommandScheduler::InstallFromSync(const WebApp& web_app,
                                             OnceInstallCallback callback,
                                             const base::Location& location) {}

void WebAppCommandScheduler::RemoveInstallUrlMaybeUninstall(
    std::optional<webapps::AppId> app_id,
    WebAppManagement::Type install_source,
    const GURL& install_url,
    webapps::WebappUninstallSource uninstall_source,
    UninstallJob::Callback callback,
    const base::Location& location) {}

void WebAppCommandScheduler::RemoveInstallManagementMaybeUninstall(
    const webapps::AppId& app_id,
    WebAppManagement::Type install_source,
    webapps::WebappUninstallSource uninstall_source,
    UninstallJob::Callback callback,
    const base::Location& location) {}

void WebAppCommandScheduler::RemoveUserUninstallableManagements(
    const webapps::AppId& app_id,
    webapps::WebappUninstallSource uninstall_source,
    UninstallJob::Callback callback,
    const base::Location& location) {}

void WebAppCommandScheduler::RemoveAllManagementTypesAndUninstall(
    base::PassKey<WebAppSyncBridge>,
    const webapps::AppId& app_id,
    webapps::WebappUninstallSource uninstall_source,
    UninstallJob::Callback callback,
    const base::Location& location) {}

void WebAppCommandScheduler::UninstallAllUserInstalledWebApps(
    webapps::WebappUninstallSource uninstall_source,
    UninstallAllUserInstalledWebAppsCommand::Callback callback,
    const base::Location& location) {}

void WebAppCommandScheduler::SetRunOnOsLoginMode(
    const webapps::AppId& app_id,
    RunOnOsLoginMode login_mode,
    base::OnceClosure callback,
    const base::Location& location) {}

void WebAppCommandScheduler::SyncRunOnOsLoginMode(
    const webapps::AppId& app_id,
    base::OnceClosure callback,
    const base::Location& location) {}

void WebAppCommandScheduler::UpdateProtocolHandlerUserApproval(
    const webapps::AppId& app_id,
    const std::string& protocol_scheme,
    ApiApprovalState approval_state,
    base::OnceClosure callback,
    const base::Location& location) {}

void WebAppCommandScheduler::ClearWebAppBrowsingData(
    const base::Time& begin_time,
    const base::Time& end_time,
    base::OnceClosure done,
    const base::Location& location) {}

void WebAppCommandScheduler::SetAppIsDisabled(const webapps::AppId& app_id,
                                              bool is_disabled,
                                              base::OnceClosure callback,
                                              const base::Location& location) {}

void WebAppCommandScheduler::ComputeAppSize(
    const webapps::AppId& app_id,
    base::OnceCallback<void(std::optional<ComputedAppSize>)> callback) {}

void WebAppCommandScheduler::LaunchApp(
    const webapps::AppId& app_id,
    const base::CommandLine& command_line,
    const base::FilePath& current_directory,
    const std::optional<GURL>& url_handler_launch_url,
    const std::optional<GURL>& protocol_handler_launch_url,
    const std::optional<GURL>& file_launch_url,
    const std::vector<base::FilePath>& launch_files,
    LaunchWebAppCallback callback,
    const base::Location& location) {}

void WebAppCommandScheduler::LaunchApp(const webapps::AppId& app_id,
                                       const std::optional<GURL>& url,
                                       LaunchWebAppCallback callback,
                                       const base::Location& location) {}

void WebAppCommandScheduler::LaunchAppWithCustomParams(
    apps::AppLaunchParams params,
    LaunchWebAppCallback callback,
    const base::Location& location) {}

void WebAppCommandScheduler::InstallAppLocally(const webapps::AppId& app_id,
                                               base::OnceClosure callback,
                                               const base::Location& location) {}

void WebAppCommandScheduler::SynchronizeOsIntegration(
    const webapps::AppId& app_id,
    base::OnceClosure synchronize_callback,
    std::optional<SynchronizeOsOptions> synchronize_options,
    bool upgrade_to_fully_installed_if_installed,
    const base::Location& location) {}

void WebAppCommandScheduler::SetUserDisplayMode(
    const webapps::AppId& app_id,
    mojom::UserDisplayMode user_display_mode,
    base::OnceClosure callback,
    const base::Location& location) {}

void WebAppCommandScheduler::ScheduleDedupeInstallUrls(
    base::OnceClosure callback,
    const base::Location& location) {}

void WebAppCommandScheduler::SetAppCapturesSupportedLinksDisableOverlapping(
    const webapps::AppId app_id,
    bool set_to_preferred,
    base::OnceClosure done,
    const base::Location& location) {}

void WebAppCommandScheduler::RunIconDiagnosticsForApp(
    const webapps::AppId& app_id,
    WebAppIconDiagnosticResultCallback result_callback,
    const base::Location& location) {}

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

void WebAppCommandScheduler::LaunchApp(apps::AppLaunchParams params,
                                       LaunchWebAppWindowSetting option,
                                       LaunchWebAppCallback callback,
                                       const base::Location& location) {}

void WebAppCommandScheduler::LaunchAppWithKeepAlives(
    apps::AppLaunchParams params,
    LaunchWebAppWindowSetting launch_setting,
    LaunchWebAppCallback callback,
    std::unique_ptr<ScopedProfileKeepAlive> profile_keep_alive,
    std::unique_ptr<ScopedKeepAlive> browser_keep_alive,
    const base::Location& location) {}

bool WebAppCommandScheduler::IsShuttingDown() const {}

}  // namespace web_app