chromium/chrome/browser/component_updater/soda_component_installer.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "chrome/browser/component_updater/soda_component_installer.h"

#include <memory>
#include <optional>
#include <utility>

#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/task/task_traits.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/component_updater/soda_language_pack_component_installer.h"
#include "components/component_updater/component_updater_service.h"
#include "components/crx_file/id_util.h"
#include "components/live_caption/caption_util.h"
#include "components/live_caption/pref_names.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/soda/constants.h"
#include "components/update_client/update_client_errors.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "crypto/sha2.h"

#if BUILDFLAG(IS_WIN)
#include <windows.h>

#include <aclapi.h>

#include "base/win/scoped_localalloc.h"
#include "base/win/sid.h"
#endif

BrowserThread;

namespace component_updater {

namespace {

// The SHA256 of the SubjectPublicKeyInfo used to sign the component.
// The component id is: icnkogojpkfjeajonkmlplionaamopkf
constexpr uint8_t kSodaPublicKeySHA256[32] =;

static_assert;

constexpr char kSodaManifestName[] =;

#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_APPLE)

constexpr base::FilePath::CharType kSodaIndicatorFile[] =
#if defined(ARCH_CPU_X86)
    FILE_PATH_LITERAL("SODAFiles/arch_x86");
#elif defined(ARCH_CPU_X86_64)
    FILE_PATH_LITERAL("SODAFiles/arch_x64");
#elif defined(ARCH_CPU_ARM64)
    FILE_PATH_LITERAL("SODAFiles/arch_arm64");
#else
    {};
#endif

static_assert(sizeof(kSodaIndicatorFile) > 0, "Unknown CPU architecture.");

#endif

}  // namespace

SodaComponentInstallerPolicy::SodaComponentInstallerPolicy(
    OnSodaComponentInstalledCallback on_installed_callback,
    OnSodaComponentReadyCallback on_ready_callback)
    :{}

SodaComponentInstallerPolicy::~SodaComponentInstallerPolicy() = default;

const std::string SodaComponentInstallerPolicy::GetExtensionId() {}

void SodaComponentInstallerPolicy::UpdateSodaComponentOnDemand() {}

update_client::CrxInstaller::Result
SodaComponentInstallerPolicy::SetComponentDirectoryPermission(
    const base::FilePath& install_dir) {}

bool SodaComponentInstallerPolicy::SupportsGroupPolicyEnabledComponentUpdates()
    const {}

bool SodaComponentInstallerPolicy::RequiresNetworkEncryption() const {}

update_client::CrxInstaller::Result
SodaComponentInstallerPolicy::OnCustomInstall(
    const base::Value::Dict& manifest,
    const base::FilePath& install_dir) {}

void SodaComponentInstallerPolicy::OnCustomUninstall() {}

bool SodaComponentInstallerPolicy::VerifyInstallation(
    const base::Value::Dict& manifest,
    const base::FilePath& install_dir) const {}

void SodaComponentInstallerPolicy::ComponentReady(
    const base::Version& version,
    const base::FilePath& install_dir,
    base::Value::Dict manifest) {}

base::FilePath SodaComponentInstallerPolicy::GetRelativeInstallDir() const {}

void SodaComponentInstallerPolicy::GetHash(std::vector<uint8_t>* hash) const {}

std::string SodaComponentInstallerPolicy::GetName() const {}

update_client::InstallerAttributes
SodaComponentInstallerPolicy::GetInstallerAttributes() const {}

void UpdateSodaInstallDirPref(PrefService* prefs,
                              const base::FilePath& install_dir) {}

void RegisterSodaComponent(ComponentUpdateService* cus,
                           PrefService* global_prefs,
                           base::OnceClosure on_ready_callback,
                           base::OnceClosure on_registered_callback) {}

void RegisterSodaLanguageComponent(
    ComponentUpdateService* cus,
    const std::string& language,
    PrefService* global_prefs,
    OnSodaLanguagePackComponentReadyCallback on_ready_callback) {}

}  // namespace component_updater