#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_prepare_and_store_update_command.h"
#include <memory>
#include <optional>
#include <ostream>
#include <sstream>
#include <string>
#include <string_view>
#include <utility>
#include "base/check.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/functional/overloaded.h"
#include "base/memory/ptr_util.h"
#include "base/sequence_checker.h"
#include "base/strings/strcat.h"
#include "base/types/expected.h"
#include "base/types/expected_macros.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/web_applications/callback_utils.h"
#include "chrome/browser/web_applications/commands/web_app_command.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_features.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_install_command_helper.h"
#include "chrome/browser/web_applications/isolated_web_apps/pending_install_info.h"
#include "chrome/browser/web_applications/locks/app_lock.h"
#include "chrome/browser/web_applications/web_app.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_registry_update.h"
#include "chrome/browser/web_applications/web_app_sync_bridge.h"
#include "chrome/browser/web_applications/web_app_utils.h"
#include "chrome/browser/web_applications/web_contents/web_contents_manager.h"
#include "components/webapps/browser/web_contents/web_app_url_loader.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/web_contents.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
namespace web_app {
IsolatedWebAppUpdatePrepareAndStoreCommandSuccess::
IsolatedWebAppUpdatePrepareAndStoreCommandSuccess(
base::Version update_version,
IsolatedWebAppStorageLocation destination_location)
: … { … }
IsolatedWebAppUpdatePrepareAndStoreCommandSuccess::
~IsolatedWebAppUpdatePrepareAndStoreCommandSuccess() = default;
IsolatedWebAppUpdatePrepareAndStoreCommandSuccess::
IsolatedWebAppUpdatePrepareAndStoreCommandSuccess(
const IsolatedWebAppUpdatePrepareAndStoreCommandSuccess& other) =
default;
std::ostream& operator<<(
std::ostream& os,
const IsolatedWebAppUpdatePrepareAndStoreCommandSuccess& success) { … }
std::ostream& operator<<(
std::ostream& os,
const IsolatedWebAppUpdatePrepareAndStoreCommandError& error) { … }
IsolatedWebAppUpdatePrepareAndStoreCommand::
IsolatedWebAppUpdatePrepareAndStoreCommand(
UpdateInfo update_info,
IsolatedWebAppUrlInfo url_info,
std::unique_ptr<content::WebContents> web_contents,
std::unique_ptr<ScopedKeepAlive> optional_keep_alive,
std::unique_ptr<ScopedProfileKeepAlive> optional_profile_keep_alive,
base::OnceCallback<
void(IsolatedWebAppUpdatePrepareAndStoreCommandResult)> callback,
std::unique_ptr<IsolatedWebAppInstallCommandHelper> command_helper)
: … { … }
IsolatedWebAppUpdatePrepareAndStoreCommand::
~IsolatedWebAppUpdatePrepareAndStoreCommand() { … }
void IsolatedWebAppUpdatePrepareAndStoreCommand::StartWithLock(
std::unique_ptr<AppLock> lock) { … }
void IsolatedWebAppUpdatePrepareAndStoreCommand::CheckIfUpdateIsStillApplicable(
base::OnceClosure next_step_callback) { … }
void IsolatedWebAppUpdatePrepareAndStoreCommand::CopyToProfileDirectory(
base::OnceClosure next_step_callback) { … }
void IsolatedWebAppUpdatePrepareAndStoreCommand::OnCopiedToProfileDirectory(
base::OnceClosure next_step_callback,
base::expected<IsolatedWebAppStorageLocation, std::string> new_location) { … }
void IsolatedWebAppUpdatePrepareAndStoreCommand::CheckTrustAndSignatures(
base::OnceCallback<
void(std::optional<web_package::SignedWebBundleIntegrityBlock>)>
next_step_callback) { … }
void IsolatedWebAppUpdatePrepareAndStoreCommand::CreateStoragePartition(
base::OnceClosure next_step_callback,
std::optional<web_package::SignedWebBundleIntegrityBlock> integrity_block) { … }
void IsolatedWebAppUpdatePrepareAndStoreCommand::LoadInstallUrl(
base::OnceClosure next_step_callback) { … }
void IsolatedWebAppUpdatePrepareAndStoreCommand::
CheckInstallabilityAndRetrieveManifest(
base::OnceCallback<void(blink::mojom::ManifestPtr)>
next_step_callback) { … }
void IsolatedWebAppUpdatePrepareAndStoreCommand::
ValidateManifestAndCreateInstallInfo(
base::OnceCallback<void(WebAppInstallInfo)> next_step_callback,
blink::mojom::ManifestPtr manifest) { … }
void IsolatedWebAppUpdatePrepareAndStoreCommand::
RetrieveIconsAndPopulateInstallInfo(
base::OnceCallback<void(WebAppInstallInfo)> next_step_callback,
WebAppInstallInfo install_info) { … }
void IsolatedWebAppUpdatePrepareAndStoreCommand::Finalize(
WebAppInstallInfo info) { … }
void IsolatedWebAppUpdatePrepareAndStoreCommand::OnFinalized(
const base::Version& update_version,
bool success) { … }
void IsolatedWebAppUpdatePrepareAndStoreCommand::ReportFailure(
std::string_view message) { … }
void IsolatedWebAppUpdatePrepareAndStoreCommand::ReportSuccess(
const base::Version& update_version) { … }
Profile& IsolatedWebAppUpdatePrepareAndStoreCommand::profile() { … }
IsolatedWebAppUpdatePrepareAndStoreCommand::UpdateInfo::UpdateInfo(
IwaSourceWithModeAndFileOp source,
std::optional<base::Version> expected_version)
: … { … }
IsolatedWebAppUpdatePrepareAndStoreCommand::UpdateInfo::~UpdateInfo() = default;
IsolatedWebAppUpdatePrepareAndStoreCommand::UpdateInfo::UpdateInfo(
const UpdateInfo&) = default;
IsolatedWebAppUpdatePrepareAndStoreCommand::UpdateInfo&
IsolatedWebAppUpdatePrepareAndStoreCommand::UpdateInfo::operator=(
const UpdateInfo&) = default;
base::Value
IsolatedWebAppUpdatePrepareAndStoreCommand::UpdateInfo::AsDebugValue() const { … }
}