chromium/components/update_client/utils.cc

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

#include "components/update_client/utils.h"

#include <stddef.h>

#include <cmath>
#include <cstring>
#include <memory>
#include <utility>
#include <vector>

#include "base/check.h"
#include "base/containers/contains.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/memory_mapped_file.h"
#include "base/functional/callback.h"
#include "base/json/json_file_value_serializer.h"
#include "base/path_service.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/system/sys_info.h"
#include "base/threading/platform_thread.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/time/time.h"
#include "base/values.h"
#include "components/crx_file/id_util.h"
#include "components/update_client/component.h"
#include "components/update_client/configurator.h"
#include "components/update_client/network.h"
#include "components/update_client/update_client.h"
#include "components/update_client/update_client_errors.h"
#include "crypto/secure_hash.h"
#include "crypto/sha2.h"
#include "url/gurl.h"

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

#include "base/win/windows_version.h"
#endif  // BUILDFLAG(IS_WIN)

namespace update_client {

const char kArchAmd64[] =;
const char kArchIntel[] =;
const char kArchArm64[] =;

bool HasDiffUpdate(const Component& component) {}

bool IsHttpServerError(int status_code) {}

bool DeleteFileAndEmptyParentDirectory(const base::FilePath& filepath) {}

bool DeleteEmptyDirectory(const base::FilePath& dir_path) {}

std::string GetCrxComponentID(const CrxComponent& component) {}

std::string GetCrxIdFromPublicKeyHash(base::span<const uint8_t> pk_hash) {}

bool VerifyFileHash256(const base::FilePath& filepath,
                       const std::string& expected_hash_str) {}

bool IsValidBrand(const std::string& brand) {}

// Helper function.
// Returns true if |part| matches the expression
// ^[<special_chars>a-zA-Z0-9]{min_length,max_length}$
bool IsValidInstallerAttributePart(const std::string& part,
                                   const std::string& special_chars,
                                   size_t min_length,
                                   size_t max_length) {}

// Returns true if the |name| parameter matches ^[-_a-zA-Z0-9]{1,256}$ .
bool IsValidInstallerAttributeName(const std::string& name) {}

// Returns true if the |value| parameter matches ^[-.,;+_=$a-zA-Z0-9]{0,256}$ .
bool IsValidInstallerAttributeValue(const std::string& value) {}

bool IsValidInstallerAttribute(const InstallerAttribute& attr) {}

void RemoveUnsecureUrls(std::vector<GURL>* urls) {}

CrxInstaller::Result InstallFunctionWrapper(
    base::OnceCallback<bool()> callback) {}

std::optional<base::Value::Dict> ReadManifest(
    const base::FilePath& unpack_path) {}

std::string GetArchitecture() {}

bool RetryDeletePathRecursively(const base::FilePath& path) {}

bool RetryDeletePathRecursivelyCustom(
    const base::FilePath& path,
    size_t tries,
    const base::TimeDelta& seconds_between_tries) {}

}  // namespace update_client