electron/shell/common/extensions/electron_extensions_api_provider.cc
electron-roller[bot] 4c3014944c
chore: bump chromium to 129.0.6664.0 (main) (#43329)
* chore: bump chromium in DEPS to 129.0.6657.0

* chore: update patches

* chore: bump chromium in DEPS to 129.0.6658.0

* chore: update patches

* 5743786: [ServiceWorker] Populate service worker start token to WorkerId.

https://chromium-review.googlesource.com/c/chromium/src/+/5743786

* 5784424: [Extensions] Move ownership of Dispatcher to ExtensionsRendererClient

https://chromium-review.googlesource.com/c/chromium/src/+/5784424

* chore: bump chromium in DEPS to 129.0.6659.0

* chore: bump chromium in DEPS to 129.0.6660.0

* chore: update patches

* chore: bump chromium in DEPS to 129.0.6662.0

* chore: bump chromium in DEPS to 129.0.6664.0

* 5789627: [Partitioned Popins] (3) `popin` feature triggers third-party storage partitioning

https://chromium-review.googlesource.com/c/chromium/src/+/5789627

* 5791367: Remove some chrome:: namespace from chrome/browser/app_mode/*

https://chromium-review.googlesource.com/c/chromium/src/+/5791367

* 5791522: [SCK] Skip redundant getShareableContentWithCompletionHandler

https://chromium-review.googlesource.com/c/chromium/src/+/5791522

* 5761330: Send refresh rate prefs b/w RefreshRateController and DisplayPrivate

https://chromium-review.googlesource.com/c/chromium/src/+/5761330

* chore: fixup patch indices

* 5793591: Remove unused GetHeader overload

https://chromium-review.googlesource.com/c/chromium/src/+/5793591

* 5787624: [Extensions] Simplify ExtensionsRendererClient::RenderThreadStarted()

https://chromium-review.googlesource.com/c/chromium/src/+/5787624

* 5721709: Fix Incorrect last_accessed_time Tracking for Tabs

https://chromium-review.googlesource.com/c/chromium/src/+/5721709

* 5789215: [Extensions] Add a //chrome/common/extensions build target

https://chromium-review.googlesource.com/c/chromium/src/+/5789215

* Roll V8 from 48f669a0758c to eee3eb91d01c

48f669a075..eee3eb91d0

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2024-08-19 14:52:53 -04:00

111 lines
4.2 KiB
C++

// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "shell/common/extensions/electron_extensions_api_provider.h"
#include <memory>
#include <string>
#include "base/containers/span.h"
#include "chrome/common/extensions/chrome_manifest_url_handlers.h"
#include "chrome/common/extensions/manifest_handlers/minimum_chrome_version_checker.h" // nogncheck
#include "electron/buildflags/buildflags.h"
#include "electron/shell/common/extensions/api/generated_schemas.h"
#include "extensions/common/alias.h"
#include "extensions/common/features/feature_provider.h"
#include "extensions/common/features/json_feature_provider_source.h"
#include "extensions/common/features/simple_feature.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_handler.h"
#include "extensions/common/manifest_handler_registry.h"
#include "extensions/common/manifest_handlers/permissions_parser.h"
#include "extensions/common/manifest_url_handlers.h"
#include "extensions/common/permissions/permissions_info.h"
#include "shell/common/extensions/api/api_features.h"
#include "shell/common/extensions/api/manifest_features.h"
#include "shell/common/extensions/api/permission_features.h"
namespace extensions {
constexpr APIPermissionInfo::InitInfo permissions_to_register[] = {
{mojom::APIPermissionID::kDevtools, "devtools",
APIPermissionInfo::kFlagImpliesFullURLAccess |
APIPermissionInfo::kFlagCannotBeOptional |
APIPermissionInfo::kFlagInternal},
{mojom::APIPermissionID::kResourcesPrivate, "resourcesPrivate",
APIPermissionInfo::kFlagCannotBeOptional},
#if BUILDFLAG(ENABLE_PDF_VIEWER)
{mojom::APIPermissionID::kPdfViewerPrivate, "pdfViewerPrivate"},
#endif
{mojom::APIPermissionID::kManagement, "management"},
{mojom::APIPermissionID::kTab, "tabs",
APIPermissionInfo::kFlagRequiresManagementUIWarning},
{mojom::APIPermissionID::kScripting, "scripting",
APIPermissionInfo::kFlagRequiresManagementUIWarning},
};
base::span<const APIPermissionInfo::InitInfo> GetPermissionInfos() {
return base::make_span(permissions_to_register);
}
base::span<const Alias> GetPermissionAliases() {
return base::span<const Alias>();
}
} // namespace extensions
namespace electron {
ElectronExtensionsAPIProvider::ElectronExtensionsAPIProvider() = default;
ElectronExtensionsAPIProvider::~ElectronExtensionsAPIProvider() = default;
void ElectronExtensionsAPIProvider::AddAPIFeatures(
extensions::FeatureProvider* provider) {
extensions::AddElectronAPIFeatures(provider);
}
void ElectronExtensionsAPIProvider::AddManifestFeatures(
extensions::FeatureProvider* provider) {
extensions::AddElectronManifestFeatures(provider);
}
void ElectronExtensionsAPIProvider::AddPermissionFeatures(
extensions::FeatureProvider* provider) {
extensions::AddElectronPermissionFeatures(provider);
}
void ElectronExtensionsAPIProvider::AddBehaviorFeatures(
extensions::FeatureProvider* provider) {
// No shell-specific behavior features.
}
void ElectronExtensionsAPIProvider::AddAPIJSONSources(
extensions::JSONFeatureProviderSource* json_source) {
// json_source->LoadJSON(IDR_SHELL_EXTENSION_API_FEATURES);
}
bool ElectronExtensionsAPIProvider::IsAPISchemaGenerated(
const std::string& name) {
return extensions::api::ElectronGeneratedSchemas::IsGenerated(name);
}
std::string_view ElectronExtensionsAPIProvider::GetAPISchema(
const std::string& name) {
return extensions::api::ElectronGeneratedSchemas::Get(name);
}
void ElectronExtensionsAPIProvider::RegisterPermissions(
extensions::PermissionsInfo* permissions_info) {
permissions_info->RegisterPermissions(extensions::GetPermissionInfos(),
extensions::GetPermissionAliases());
}
void ElectronExtensionsAPIProvider::RegisterManifestHandlers() {
extensions::ManifestHandlerRegistry* registry =
extensions::ManifestHandlerRegistry::Get();
registry->RegisterHandler(
std::make_unique<extensions::DevToolsPageHandler>());
registry->RegisterHandler(
std::make_unique<extensions::MinimumChromeVersionChecker>());
}
} // namespace electron