chromium/chrome/browser/extensions/webstore_installer.cc

// Copyright 2012 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/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 {

// Key used to attach the Approval to the DownloadItem.
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[] =;

// TODO(rockot): Share this duplicated constant with the extension updater.
// See http://crbug.com/371398.
const char kAuthUserQueryKey[] =;

constexpr base::TimeDelta kTimeRemainingThreshold =;

// Folder for downloading crx files from the webstore. This is used so that the
// crx files don't go via the usual downloads folder.
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

namespace extensions {

// static
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) {}

// http://crbug.com/165634
// http://crbug.com/126013
// The current working theory is that one of the many pointers dereferenced in
// here is occasionally deleted before all of its referers are nullified,
// probably in a callback race. After this comment is released, the crash
// reports should narrow down exactly which pointer it is.  Collapsing all the
// early-returns into a single branch makes it hard to see exactly which pointer
// it is.
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() {}

}  // namespace extensions