#include "chrome/browser/extensions/webstore_installer.h"
#include <stddef.h>
#include <stdint.h>
#include <limits>
#include <memory>
#include <set>
#include <string_view>
#include <utility>
#include <vector>
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/metrics/field_trial.h"
#include "base/path_service.h"
#include "base/rand_util.h"
#include "base/strings/escape.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/download/download_crx_util.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/download/download_stats.h"
#include "chrome/browser/extensions/crx_installer.h"
#include "chrome/browser/extensions/install_tracker.h"
#include "chrome/browser/extensions/install_tracker_factory.h"
#include "chrome/browser/extensions/install_verifier.h"
#include "chrome/browser/extensions/shared_module_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/grit/generated_resources.h"
#include "components/crx_file/id_util.h"
#include "components/download/public/common/download_url_parameters.h"
#include "components/update_client/update_query_params.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_file_task_runner.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/install/crx_install_error.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/extension_urls.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_handlers/shared_module_info.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
BrowserContext;
BrowserThread;
DownloadManager;
NavigationController;
DownloadItem;
DownloadUrlParameters;
namespace {
const char kApprovalKey[] = …;
const char kInvalidIdError[] = …;
const char kDownloadDirectoryError[] = …;
const char kDownloadCanceledError[] = …;
const char kDownloadInterruptedError[] = …;
const char kInvalidDownloadError[] = …;
const char kDependencyNotFoundError[] = …;
const char kDependencyNotSharedModuleError[] = …;
const char kInlineInstallSource[] = …;
const char kDefaultInstallSource[] = …;
const char kAppLauncherInstallSource[] = …;
const char kAuthUserQueryKey[] = …;
constexpr base::TimeDelta kTimeRemainingThreshold = …;
const base::FilePath::CharType kWebstoreDownloadFolder[] = …);
base::FilePath* g_download_directory_for_tests = …;
base::FilePath GetDownloadFilePath(const base::FilePath& download_directory,
const extensions::ExtensionId& id) { … }
void MaybeAppendAuthUserParameter(const std::string& authuser, GURL* url) { … }
std::string GetErrorMessageForDownloadInterrupt(
download::DownloadInterruptReason reason) { … }
}
namespace extensions {
GURL WebstoreInstaller::GetWebstoreInstallURL(
const std::string& extension_id,
InstallSource source) { … }
WebstoreInstaller::Approval::Approval() = default;
std::unique_ptr<WebstoreInstaller::Approval>
WebstoreInstaller::Approval::CreateWithInstallPrompt(Profile* profile) { … }
std::unique_ptr<WebstoreInstaller::Approval>
WebstoreInstaller::Approval::CreateForSharedModule(Profile* profile) { … }
std::unique_ptr<WebstoreInstaller::Approval>
WebstoreInstaller::Approval::CreateWithNoInstallPrompt(
Profile* profile,
const extensions::ExtensionId& extension_id,
base::Value::Dict parsed_manifest,
bool strict_manifest_check) { … }
WebstoreInstaller::Approval::~Approval() { … }
const WebstoreInstaller::Approval* WebstoreInstaller::GetAssociatedApproval(
const DownloadItem& download) { … }
WebstoreInstaller::WebstoreInstaller(Profile* profile,
SuccessCallback success_callback,
FailureCallback failure_callback,
content::WebContents* web_contents,
const extensions::ExtensionId& id,
std::unique_ptr<Approval> approval,
InstallSource source)
: … { … }
void WebstoreInstaller::Start() { … }
void WebstoreInstaller::OnInstallerDone(
const std::optional<CrxInstallError>& error) { … }
void WebstoreInstaller::OnExtensionInstalled(
content::BrowserContext* browser_context,
const Extension* extension,
bool is_update) { … }
void WebstoreInstaller::SetDownloadDirectoryForTests(
base::FilePath* directory) { … }
WebstoreInstaller::~WebstoreInstaller() { … }
void WebstoreInstaller::OnDownloadStarted(
const extensions::ExtensionId& extension_id,
DownloadItem* item,
download::DownloadInterruptReason interrupt_reason) { … }
void WebstoreInstaller::OnDownloadUpdated(DownloadItem* download) { … }
void WebstoreInstaller::OnDownloadDestroyed(DownloadItem* download) { … }
void WebstoreInstaller::DownloadNextPendingModule() { … }
void WebstoreInstaller::DownloadCrx(const extensions::ExtensionId& extension_id,
InstallSource source) { … }
void WebstoreInstaller::StartDownload(
const extensions::ExtensionId& extension_id,
const base::FilePath& file) { … }
void WebstoreInstaller::UpdateDownloadProgress() { … }
void WebstoreInstaller::StartCrxInstaller(const DownloadItem& download) { … }
void WebstoreInstaller::ReportFailure(const std::string& error,
FailureReason reason) { … }
void WebstoreInstaller::ReportSuccess() { … }
}