chromium/extensions/common/file_util.cc

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

#include "extensions/common/file_util.h"

#include <stddef.h>
#include <stdint.h>

#include <map>
#include <optional>
#include <set>
#include <string>
#include <string_view>
#include <utility>
#include <vector>

#include "base/containers/contains.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/json/json_file_value_serializer.h"
#include "base/logging.h"
#include "base/metrics/field_trial.h"
#include "base/strings/escape.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/extension_l10n_util.h"
#include "extensions/common/extension_set.h"
#include "extensions/common/icons/extension_icon_set.h"
#include "extensions/common/image_util.h"
#include "extensions/common/install_warning.h"
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_handler.h"
#include "extensions/common/manifest_handlers/default_locale_handler.h"
#include "extensions/common/manifest_handlers/icons_handler.h"
#include "extensions/strings/grit/extensions_strings.h"
#include "net/base/filename_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"

ManifestLocation;

namespace extensions::file_util {
namespace {

enum SafeInstallationFlag {};
SafeInstallationFlag g_use_safe_installation =;

bool g_report_error_for_invisible_icon =;

// Returns true if the given file path exists and is not zero-length.
bool ValidateFilePath(const base::FilePath& path) {}

// Returns true if the extension installation should flush all files and the
// directory.
bool UseSafeInstallation() {}

enum FlushOneOrAllFiles {};

// Flush all files in a directory or just one.  When flushing all files, it
// makes sure every file is on disk.  When flushing one file only, it ensures
// all parent directories are on disk.
void FlushFilesInDir(const base::FilePath& path,
                     FlushOneOrAllFiles one_or_all_files) {}

}  // namespace

const base::FilePath::CharType kTempDirectoryName[] =);

void SetUseSafeInstallation(bool use_safe_installation) {}

base::FilePath InstallExtension(const base::FilePath& unpacked_source_dir,
                                const std::string& id,
                                const std::string& version,
                                const base::FilePath& extensions_dir) {}

void UninstallExtension(const base::FilePath& profile_dir,
                        const base::FilePath& extensions_install_dir,
                        const base::FilePath& extension_dir_to_delete) {}

scoped_refptr<Extension> LoadExtension(const base::FilePath& extension_path,
                                       ManifestLocation location,
                                       int flags,
                                       std::string* error) {}

scoped_refptr<Extension> LoadExtension(const base::FilePath& extension_path,
                                       const ExtensionId& extension_id,
                                       ManifestLocation location,
                                       int flags,
                                       std::string* error) {}

scoped_refptr<Extension> LoadExtension(
    const base::FilePath& extension_path,
    const base::FilePath::CharType* manifest_file,
    const ExtensionId& extension_id,
    ManifestLocation location,
    int flags,
    std::string* error) {}

std::optional<base::Value::Dict> LoadManifest(
    const base::FilePath& extension_path,
    std::string* error) {}

std::optional<base::Value::Dict> LoadManifest(
    const base::FilePath& extension_path,
    const base::FilePath::CharType* manifest_filename,
    std::string* error) {}

bool ValidateExtension(const Extension* extension,
                       std::string* error,
                       std::vector<InstallWarning>* warnings) {}

std::vector<base::FilePath> FindPrivateKeyFiles(
    const base::FilePath& extension_dir) {}

bool CheckForIllegalFilenames(const base::FilePath& extension_path,
                              std::string* error) {}

bool CheckForWindowsReservedFilenames(const base::FilePath& extension_dir,
                                      std::string* error) {}

base::FilePath GetInstallTempDir(const base::FilePath& extensions_dir) {}

base::FilePath ExtensionURLToRelativeFilePath(const GURL& url) {}

void SetReportErrorForInvisibleIconForTesting(bool value) {}

bool ValidateExtensionIconSet(const ExtensionIconSet& icon_set,
                              const Extension* extension,
                              const char* manifest_key,
                              std::string* error) {}

MessageBundle* LoadMessageBundle(
    const base::FilePath& extension_path,
    const std::string& default_locale,
    extension_l10n_util::GzippedMessagesPermission gzip_permission,
    std::string* error) {}

base::FilePath GetVerifiedContentsPath(const base::FilePath& extension_path) {}
base::FilePath GetComputedHashesPath(const base::FilePath& extension_path) {}
base::FilePath GetIndexedRulesetDirectoryRelativePath() {}
base::FilePath GetIndexedRulesetRelativePath(int static_ruleset_id) {}

std::vector<base::FilePath> GetReservedMetadataFilePaths(
    const base::FilePath& extension_path) {}

}  // namespace extensions::file_util