chromium/extensions/common/extension.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/extension.h"

#include <stddef.h>

#include <algorithm>
#include <iterator>
#include <memory>
#include <string>
#include <string_view>
#include <utility>

#include "base/base64.h"
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/files/file_path.h"
#include "base/i18n/rtl.h"
#include "base/json/json_writer.h"
#include "base/memory/singleton.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/timer/elapsed_timer.h"
#include "base/version.h"
#include "components/crx_file/id_util.h"
#include "content/public/common/url_constants.h"
#include "extensions/common/constants.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_handler.h"
#include "extensions/common/manifest_handlers/incognito_info.h"
#include "extensions/common/manifest_handlers/permissions_parser.h"
#include "extensions/common/permissions/permission_set.h"
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/common/permissions/permissions_info.h"
#include "extensions/common/switches.h"
#include "extensions/common/url_pattern.h"
#include "net/base/filename_util.h"
#include "url/url_util.h"

ManifestLocation;

namespace extensions {

keys;
values;
errors;

namespace {

constexpr int kMinimumSupportedManifestVersion =;
constexpr int kMaximumSupportedManifestVersion =;
constexpr int kPEMOutputColumns =;
static_assert;
bool g_silence_deprecated_manifest_version_warnings =;

// KEY MARKERS
constexpr char kKeyBeginHeaderMarker[] =;
constexpr char kKeyBeginFooterMarker[] =;
constexpr char kKeyInfoEndMarker[] =;
constexpr char kPublic[] =;
constexpr char kPrivate[] =;

// Bail out on larger inputs to prevent out-of-memory failures.
constexpr int kMaxInputSizeBytes =;

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

// Returns true if the given |manifest_version| is supported for the specified
// |type| of extension. Optionally populates |warning| if an InstallWarning
// should be added.
bool IsManifestSupported(int manifest_version,
                         Manifest::Type type,
                         ManifestLocation location,
                         int creation_flags,
                         std::string* warning) {}

// Computes the |extension_id| from the given parameters. On success, returns
// true. On failure, populates |error| and returns false.
bool ComputeExtensionID(const base::Value::Dict& manifest,
                        const base::FilePath& path,
                        int creation_flags,
                        std::u16string* error,
                        ExtensionId* extension_id) {}

std::u16string InvalidManifestVersionError(const char* manifest_version_error,
                                           bool is_platform_app) {}

}  // namespace

const int Extension::kInitFromValueFlagBits =;

const char Extension::kMimeType[] =;

const int Extension::kValidWebExtentSchemes =;

const int Extension::kValidHostPermissionSchemes =;

//
// Extension
//

// static
void Extension::set_silence_deprecated_manifest_version_warnings_for_testing(
    bool silence) {}

// static
scoped_refptr<Extension> Extension::Create(const base::FilePath& path,
                                           ManifestLocation location,
                                           const base::Value::Dict& value,
                                           int flags,
                                           std::string* utf8_error) {}

// TODO(sungguk): Continue removing std::string errors and replacing
// with std::u16string. See http://crbug.com/71980.
scoped_refptr<Extension> Extension::Create(const base::FilePath& path,
                                           ManifestLocation location,
                                           const base::Value::Dict& value,
                                           int flags,
                                           const ExtensionId& explicit_id,
                                           std::string* utf8_error) {}

Manifest::Type Extension::GetType() const {}

// static
GURL Extension::GetResourceURL(const GURL& extension_url,
                               const std::string& relative_path) {}

bool Extension::ResourceMatches(const URLPatternSet& pattern_set,
                                const std::string& resource) const {}

ExtensionResource Extension::GetResource(std::string_view relative_path) const {}

ExtensionResource Extension::GetResource(
    const base::FilePath& relative_file_path) const {}

// TODO(rafaelw): Move ParsePEMKeyBytes, ProducePEM & FormatPEMForOutput to a
// util class in base:
// http://code.google.com/p/chromium/issues/detail?id=13572
// static
bool Extension::ParsePEMKeyBytes(const std::string& input,
                                 std::string* output) {}

// static
bool Extension::ProducePEM(const std::string& input, std::string* output) {}

// static
bool Extension::FormatPEMForFileOutput(const std::string& input,
                                       std::string* output,
                                       bool is_public) {}

// static
GURL Extension::GetBaseURLFromExtensionId(const ExtensionId& extension_id) {}

// static
url::Origin Extension::CreateOriginFromExtensionId(
    const ExtensionId& extension_id) {}

bool Extension::OverlapsWithOrigin(const GURL& origin) const {}

Extension::ManifestData* Extension::GetManifestData(const std::string& key)
    const {}

void Extension::SetManifestData(const std::string& key,
                                std::unique_ptr<Extension::ManifestData> data) {}

void Extension::SetGUID(const ExtensionGuid& guid) {}

const ExtensionGuid& Extension::guid() const {}

ManifestLocation Extension::location() const {}

const ExtensionId& Extension::id() const {}

const HashedExtensionId& Extension::hashed_id() const {}

std::string Extension::VersionString() const {}

std::string Extension::DifferentialFingerprint() const {}

std::string Extension::GetVersionForDisplay() const {}

void Extension::AddInstallWarning(InstallWarning new_warning) {}

void Extension::AddInstallWarnings(std::vector<InstallWarning> new_warnings) {}

bool Extension::is_app() const {}

bool Extension::is_platform_app() const {}

bool Extension::is_hosted_app() const {}

bool Extension::is_legacy_packaged_app() const {}

bool Extension::is_extension() const {}

bool Extension::is_shared_module() const {}

bool Extension::is_theme() const {}

bool Extension::is_login_screen_extension() const {}

bool Extension::is_chromeos_system_extension() const {}

void Extension::AddWebExtentPattern(const URLPattern& pattern) {}

Extension::Extension(const base::FilePath& path,
                     std::unique_ptr<extensions::Manifest> manifest)
    :{}

Extension::~Extension() {}

bool Extension::InitFromValue(int flags, std::u16string* error) {}

bool Extension::LoadRequiredFeatures(std::u16string* error) {}

bool Extension::LoadName(std::u16string* error) {}

bool Extension::LoadVersion(std::u16string* error) {}

bool Extension::LoadAppFeatures(std::u16string* error) {}

bool Extension::LoadExtent(const char* key,
                           URLPatternSet* extent,
                           const char* list_error,
                           const char* value_error,
                           std::u16string* error) {}

bool Extension::LoadSharedFeatures(std::u16string* error) {}

bool Extension::LoadDescription(std::u16string* error) {}

bool Extension::LoadManifestVersion(std::u16string* error) {}

bool Extension::LoadShortName(std::u16string* error) {}

ExtensionInfo::ExtensionInfo(const base::Value::Dict* manifest,
                             const ExtensionId& id,
                             const base::FilePath& path,
                             ManifestLocation location)
    :{}

ExtensionInfo::ExtensionInfo(ExtensionInfo&&) noexcept = default;

ExtensionInfo& ExtensionInfo::operator=(ExtensionInfo&&) = default;

ExtensionInfo::~ExtensionInfo() = default;

}   // namespace extensions