#include "chrome/browser/web_applications/commands/install_from_sync_command.h"
#include <memory>
#include <utility>
#include "base/containers/flat_set.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/to_string.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/web_applications/commands/web_app_command.h"
#include "chrome/browser/web_applications/generated_icon_fix_util.h"
#include "chrome/browser/web_applications/install_bounce_metric.h"
#include "chrome/browser/web_applications/locks/shared_web_contents_with_app_lock.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_helpers.h"
#include "chrome/browser/web_applications/web_app_icon_operations.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_app_data_retriever.h"
#include "chrome/browser/web_applications/web_contents/web_contents_manager.h"
#include "components/webapps/browser/install_result_code.h"
#include "components/webapps/browser/installable/installable_logging.h"
#include "components/webapps/browser/installable/installable_metrics.h"
#include "components/webapps/browser/web_contents/web_app_url_loader.h"
#include "content/public/browser/web_contents.h"
namespace web_app {
namespace {
WebAppInstallFinalizer::FinalizeOptions GetFinalizerOptionForSyncInstall() { … }
}
InstallFromSyncCommand::Params::~Params() = default;
InstallFromSyncCommand::Params::Params(
const webapps::AppId& app_id,
const webapps::ManifestId& manifest_id,
const GURL& start_url,
const std::string& title,
const GURL& scope,
const std::optional<SkColor>& theme_color,
const std::optional<mojom::UserDisplayMode>& user_display_mode,
const std::vector<apps::IconInfo>& icons)
: … { … }
InstallFromSyncCommand::Params::Params(const Params&) = default;
InstallFromSyncCommand::InstallFromSyncCommand(
Profile* profile,
const Params& params,
OnceInstallCallback install_callback)
: … { … }
InstallFromSyncCommand::~InstallFromSyncCommand() = default;
void InstallFromSyncCommand::StartWithLock(
std::unique_ptr<SharedWebContentsWithAppLock> lock) { … }
void InstallFromSyncCommand::SetFallbackTriggeredForTesting(
base::OnceCallback<void(webapps::InstallResultCode code)> callback) { … }
void InstallFromSyncCommand::OnWebAppUrlLoadedGetWebAppInstallInfo(
webapps::WebAppUrlLoaderResult result) { … }
void InstallFromSyncCommand::OnGetWebAppInstallInfo(
std::unique_ptr<WebAppInstallInfo> web_app_info) { … }
void InstallFromSyncCommand::OnDidPerformInstallableCheck(
blink::mojom::ManifestPtr opt_manifest,
bool valid_manifest_for_web_app,
webapps::InstallableStatusCode error_code) { … }
void InstallFromSyncCommand::OnIconsRetrievedFinalizeInstall(
FinalizeMode mode,
IconsDownloadedResult result,
IconsMap icons_map,
DownloadedIconsHttpResults icons_http_results) { … }
void InstallFromSyncCommand::OnInstallFinalized(
FinalizeMode mode,
const webapps::AppId& app_id,
webapps::InstallResultCode code) { … }
void InstallFromSyncCommand::InstallFallback(webapps::InstallResultCode code) { … }
void InstallFromSyncCommand::ReportResultAndDestroy(
const webapps::AppId& app_id,
webapps::InstallResultCode code) { … }
}