#include "chrome/browser/web_applications/commands/external_app_resolution_command.h"
#include <memory>
#include <optional>
#include <utility>
#include "base/barrier_closure.h"
#include "base/containers/extend.h"
#include "base/containers/flat_set.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/notreached.h"
#include "base/strings/to_string.h"
#include "base/values.h"
#include "chrome/browser/web_applications/commands/web_app_command.h"
#include "chrome/browser/web_applications/commands/web_app_uninstall_command.h"
#include "chrome/browser/web_applications/external_install_options.h"
#include "chrome/browser/web_applications/externally_managed_app_manager.h"
#include "chrome/browser/web_applications/jobs/install_from_info_job.h"
#include "chrome/browser/web_applications/jobs/install_placeholder_job.h"
#include "chrome/browser/web_applications/jobs/uninstall/remove_install_url_job.h"
#include "chrome/browser/web_applications/jobs/uninstall/web_app_uninstall_and_replace_job.h"
#include "chrome/browser/web_applications/locks/all_apps_lock.h"
#include "chrome/browser/web_applications/locks/shared_web_contents_with_app_lock.h"
#include "chrome/browser/web_applications/locks/web_app_lock_manager.h"
#include "chrome/browser/web_applications/proto/web_app_proto_package.pb.h"
#include "chrome/browser/web_applications/web_app_command_manager.h"
#include "chrome/browser/web_applications/web_app_command_scheduler.h"
#include "chrome/browser/web_applications/web_app_constants.h"
#include "chrome/browser/web_applications/web_app_helpers.h"
#include "chrome/browser/web_applications/web_app_icon_operations.h"
#include "chrome/browser/web_applications/web_app_install_finalizer.h"
#include "chrome/browser/web_applications/web_app_install_info.h"
#include "chrome/browser/web_applications/web_app_install_utils.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/web_applications/web_app_registrar.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/services/app_service/public/cpp/app_launch_util.h"
#include "components/webapps/browser/install_result_code.h"
#include "components/webapps/browser/uninstall_result_code.h"
#include "components/webapps/browser/web_contents/web_app_url_loader.h"
#include "components/webapps/common/web_app_id.h"
#include "content/public/browser/web_contents.h"
namespace web_app {
ExternalAppResolutionCommand::ExternalAppResolutionCommand(
Profile& profile,
const ExternalInstallOptions& install_options,
std::optional<webapps::AppId> installed_placeholder_app_id,
InstalledCallback installed_callback)
: … { … }
ExternalAppResolutionCommand::~ExternalAppResolutionCommand() = default;
void ExternalAppResolutionCommand::SetDataRetrieverForTesting(
std::unique_ptr<WebAppDataRetriever> data_retriever) { … }
void ExternalAppResolutionCommand::SetOnLockUpgradedCallbackForTesting(
base::OnceClosure callback) { … }
void ExternalAppResolutionCommand::OnShutdown(
base::PassKey<WebAppCommandManager>) const { … }
void ExternalAppResolutionCommand::StartWithLock(
std::unique_ptr<SharedWebContentsLock> lock) { … }
WebAppProvider& ExternalAppResolutionCommand::provider() const { … }
void ExternalAppResolutionCommand::Abort(webapps::InstallResultCode code) { … }
void ExternalAppResolutionCommand::OnUrlLoadedAndBranchInstallation(
webapps::WebAppUrlLoaderResult result) { … }
void ExternalAppResolutionCommand::OnGetWebAppInstallInfoInCommand(
std::unique_ptr<WebAppInstallInfo> web_app_info) { … }
void ExternalAppResolutionCommand::OnDidPerformInstallableCheck(
blink::mojom::ManifestPtr opt_manifest,
bool valid_manifest_for_web_app,
webapps::InstallableStatusCode error_code) { … }
void ExternalAppResolutionCommand::OnPreparedForIconRetrieving(
IconUrlSizeSet icon_urls,
bool skip_page_favicons,
webapps::WebAppUrlLoaderResult result) { … }
void ExternalAppResolutionCommand::OnIconsRetrievedUpgradeLockDescription(
IconsDownloadedResult result,
IconsMap icons_map,
DownloadedIconsHttpResults icons_http_results) { … }
void ExternalAppResolutionCommand::OnLockUpgradedFinalizeInstall(
bool icon_download_failed,
std::unique_ptr<SharedWebContentsWithAppLock> apps_lock) { … }
void ExternalAppResolutionCommand::OnInstallFinalized(
const webapps::AppId& app_id,
webapps::InstallResultCode code) { … }
void ExternalAppResolutionCommand::
OnUninstallAndReplaceCompletedUninstallPlaceholder(
bool uninstall_triggered) { … }
void ExternalAppResolutionCommand::OnAllAppsLockGrantedRemovePlaceholder(
std::unique_ptr<AllAppsLock> lock) { … }
void ExternalAppResolutionCommand::OnPlaceholderUninstalledMaybeRelaunch(
webapps::UninstallResultCode result) { … }
void ExternalAppResolutionCommand::OnLaunch(base::WeakPtr<Browser>,
base::WeakPtr<content::WebContents>,
apps::LaunchContainer,
base::Value debug_value) { … }
void ExternalAppResolutionCommand::OnPlaceHolderAppLockAcquired(
std::unique_ptr<SharedWebContentsWithAppLock> apps_lock) { … }
void ExternalAppResolutionCommand::OnPlaceHolderInstalled(
webapps::InstallResultCode code,
webapps::AppId app_id) { … }
void ExternalAppResolutionCommand::InstallFromInfo() { … }
void ExternalAppResolutionCommand::OnInstallFromInfoAppLockAcquired(
std::unique_ptr<SharedWebContentsWithAppLock> apps_lock) { … }
void ExternalAppResolutionCommand::OnInstallFromInfoCompleted(
webapps::AppId app_id,
webapps::InstallResultCode code) { … }
void ExternalAppResolutionCommand::OnUninstallAndReplaceCompleted(
bool is_offline_install,
bool uninstall_triggered) { … }
void ExternalAppResolutionCommand::TryAppInfoFactoryOnFailure(
ExternallyManagedAppManager::InstallResult result) { … }
ExternallyManagedAppManager::InstallResult
ExternalAppResolutionCommand::PrepareResult(
bool is_offline_install,
ExternallyManagedAppManager::InstallResult result) { … }
}