chromium/extensions/common/features/simple_feature.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.

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

#include "extensions/common/features/simple_feature.h"

#include <algorithm>
#include <map>
#include <string_view>
#include <utility>
#include <vector>

#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "components/crx_file/id_util.h"
#include "content/public/common/content_features.h"
#include "extensions/common/extension_api.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/features/feature.h"
#include "extensions/common/features/feature_channel.h"
#include "extensions/common/features/feature_developer_mode_only.h"
#include "extensions/common/features/feature_flags.h"
#include "extensions/common/features/feature_provider.h"
#include "extensions/common/features/feature_session_type.h"
#include "extensions/common/manifest_handlers/background_info.h"
#include "extensions/common/mojom/context_type.mojom.h"
#include "extensions/common/switches.h"

HashedIdInHex;
ManifestLocation;

namespace extensions {

namespace {

struct AllowlistInfo {};
// A singleton copy of the --allowlisted-extension-id so that we don't need to
// copy it from the CommandLine each time.
base::LazyInstance<AllowlistInfo>::Leaky g_allowlist_info =;

Feature::Availability IsAvailableToManifestForBind(
    const HashedExtensionId& hashed_id,
    Manifest::Type type,
    ManifestLocation location,
    int manifest_version,
    Feature::Platform platform,
    int context_id,
    const Feature* feature) {}

Feature::Availability IsAvailableToEnvironmentForBind(int context_id,
                                                      const Feature* feature) {}

// Gets a human-readable name for the given extension type, suitable for giving
// to developers in an error message.
std::string GetDisplayName(Manifest::Type type) {}

// Gets a human-readable name for the given context type, suitable for giving
// to developers in an error message.
std::string GetDisplayName(mojom::ContextType context) {}

std::string GetDisplayName(mojom::FeatureSessionType session_type) {}

// Gets a human-readable list of the display names (pluralized, comma separated
// with the "and" in the correct place) for each of |enum_types|.
template <typename EnumType>
std::string ListDisplayNames(const std::vector<EnumType>& enum_types) {}

bool IsCommandLineSwitchEnabled(base::CommandLine* command_line,
                                const std::string& switch_name) {}

bool IsAllowlistedForTest(const HashedExtensionId& hashed_id) {}

}  // namespace

SimpleFeature::ScopedThreadUnsafeAllowlistForTest::
    ScopedThreadUnsafeAllowlistForTest(const std::string& id)
    :{}

SimpleFeature::ScopedThreadUnsafeAllowlistForTest::
    ~ScopedThreadUnsafeAllowlistForTest() {}

SimpleFeature::SimpleFeature()
    :{}

SimpleFeature::~SimpleFeature() = default;

Feature::Availability SimpleFeature::IsAvailableToManifest(
    const HashedExtensionId& hashed_id,
    Manifest::Type type,
    ManifestLocation location,
    int manifest_version,
    Platform platform,
    int context_id) const {}

Feature::Availability SimpleFeature::IsAvailableToContextForBind(
    const Extension* extension,
    mojom::ContextType context,
    const GURL& url,
    Feature::Platform platform,
    int context_id,
    const ContextData* context_data,
    const Feature* feature) {}

Feature::Availability SimpleFeature::IsAvailableToContextImpl(
    const Extension* extension,
    mojom::ContextType context,
    const GURL& url,
    Platform platform,
    int context_id,
    bool check_developer_mode,
    const ContextData& context_data) const {}

Feature::Availability SimpleFeature::IsAvailableToEnvironment(
    int context_id) const {}

std::string SimpleFeature::GetAvailabilityMessage(
    AvailabilityResult result,
    Manifest::Type type,
    const GURL& url,
    mojom::ContextType context,
    version_info::Channel channel,
    mojom::FeatureSessionType session_type) const {}

Feature::Availability SimpleFeature::CreateAvailability(
    AvailabilityResult result) const {}

Feature::Availability SimpleFeature::CreateAvailability(
    AvailabilityResult result, Manifest::Type type) const {}

Feature::Availability SimpleFeature::CreateAvailability(
    AvailabilityResult result,
    const GURL& url) const {}

Feature::Availability SimpleFeature::CreateAvailability(
    AvailabilityResult result,
    mojom::ContextType context) const {}

Feature::Availability SimpleFeature::CreateAvailability(
    AvailabilityResult result,
    version_info::Channel channel) const {}

Feature::Availability SimpleFeature::CreateAvailability(
    AvailabilityResult result,
    mojom::FeatureSessionType session_type) const {}

bool SimpleFeature::IsInternal() const {}

bool SimpleFeature::IsIdInBlocklist(const HashedExtensionId& hashed_id) const {}

bool SimpleFeature::IsIdInAllowlist(const HashedExtensionId& hashed_id) const {}

// static
bool SimpleFeature::IsIdInArray(const ExtensionId& extension_id,
                                const char* const array[],
                                size_t array_length) {}

// static
bool SimpleFeature::IsIdInList(const HashedExtensionId& hashed_id,
                               const std::vector<std::string>& list) {}

bool SimpleFeature::MatchesManifestLocation(
    ManifestLocation manifest_location) const {}

bool SimpleFeature::MatchesSessionTypes(
    mojom::FeatureSessionType session_type) const {}

bool SimpleFeature::RequiresDelegatedAvailabilityCheck() const {}

bool SimpleFeature::HasDelegatedAvailabilityCheckHandler() const {}

void SimpleFeature::SetDelegatedAvailabilityCheckHandler(
    DelegatedAvailabilityCheckHandler handler) {}

Feature::Availability SimpleFeature::CheckDependencies(
    const base::RepeatingCallback<Availability(const Feature*)>& checker)
    const {}

// static
bool SimpleFeature::IsValidExtensionId(const ExtensionId& extension_id) {}

// static
bool SimpleFeature::IsValidHashedExtensionId(
    const HashedExtensionId& hashed_id) {}

void SimpleFeature::set_blocklist(
    std::initializer_list<const char* const> blocklist) {}

void SimpleFeature::set_command_line_switch(
    std::string_view command_line_switch) {}

void SimpleFeature::set_contexts(
    std::initializer_list<mojom::ContextType> contexts) {}

void SimpleFeature::set_dependencies(
    std::initializer_list<const char* const> dependencies) {}

void SimpleFeature::set_extension_types(
    std::initializer_list<Manifest::Type> types) {}

void SimpleFeature::set_feature_flag(std::string_view feature_flag) {}

void SimpleFeature::set_session_types(
    std::initializer_list<mojom::FeatureSessionType> types) {}

void SimpleFeature::set_matches(
    std::initializer_list<const char* const> matches) {}

void SimpleFeature::set_platforms(std::initializer_list<Platform> platforms) {}

void SimpleFeature::set_allowlist(
    std::initializer_list<const char* const> allowlist) {}

Feature::Availability SimpleFeature::GetEnvironmentAvailability(
    Platform platform,
    version_info::Channel channel,
    mojom::FeatureSessionType session_type,
    int context_id,
    bool check_developer_mode) const {}

Feature::Availability SimpleFeature::GetManifestAvailability(
    const HashedExtensionId& hashed_id,
    Manifest::Type type,
    ManifestLocation location,
    int manifest_version) const {}

Feature::Availability SimpleFeature::GetContextAvailability(
    mojom::ContextType context,
    const GURL& url,
    bool is_for_service_worker) const {}

Feature::Availability SimpleFeature::RunDelegatedAvailabilityCheck(
    const Extension* extension,
    mojom::ContextType context,
    const GURL& url,
    Platform platform,
    int context_id,
    bool check_developer_mode,
    const ContextData& context_data) const {}

}  // namespace extensions