chromium/chrome/common/extensions/webstore_override.cc

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

#include "chrome/common/extensions/webstore_override.h"

#include <array>
#include <string>
#include <string_view>

#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/containers/span.h"
#include "base/no_destructor.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h"
#include "extensions/common/context_data.h"
#include "extensions/common/extension.h"
#include "extensions/common/features/feature.h"
#include "extensions/common/mojom/context_type.mojom.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace {

// The set of features which this delegated availability check should apply to,
// which correspond to the features used by the webstore.
constexpr static std::array<std::string_view, 2> kWebstoreOverrideFeatureList =;

// Returns true if the "apps-gallery-url" command line flag has been used to
// specify a webstore override URL and if that URL is the same origin with the
// `url` this function is called with.
//
// Normally the APIs used by the webstore are only exposed to the actual domain
// used by the store, but this delegated availability check allows them to be
// exposed on a specified override URL. This is used both for our own API test
// and externally by the webstore team.
//
// Called by `SimpleFeature::IsAvailableToContextImpl()`, once that function
// determines that the feature has a "delegated availability check" and runs
// the check that was installed by `CreateAvailabilityCheckMap()` when the
// Extensions client was initialized.
bool AreWebstoreFeaturesAvailable(const std::string& api_full_name,
                                  const extensions::Extension* extension,
                                  extensions::mojom::ContextType context,
                                  const GURL& url,
                                  extensions::Feature::Platform platform,
                                  int context_id,
                                  bool check_developer_mode,
                                  const extensions::ContextData& context_data) {}

}  // namespace

namespace extensions::webstore_override {

Feature::FeatureDelegatedAvailabilityCheckMap CreateAvailabilityCheckMap() {}

}  // namespace extensions::webstore_override