1a0991a9b9
* chore: bump chromium in DEPS to 122.0.6239.2 * chore: update patches * refactor: extensions replaced StringPiece with string_view Ref: https://chromium-review.googlesource.com/c/chromium/src/+/5171926 * chore: bump chromium in DEPS to 122.0.6240.0 * chore: update patches * chore: bump chromium in DEPS to 122.0.6241.5 * chore: bump chromium in DEPS to 122.0.6245.0 * chore: bump chromium in DEPS to 122.0.6247.0 * chore: bump chromium in DEPS to 122.0.6249.0 * chore: bump chromium in DEPS to 122.0.6251.0 * 5192010: Rename {absl => std}::optional in //chrome/ https://chromium-review.googlesource.com/c/chromium/src/+/5192010 * 5109767: CodeHealth: Fix leaked raw_ptr in Linux ProcessSingleton https://chromium-review.googlesource.com/c/chromium/src/+/5109767 * 5105227: [media_preview] Show requested device in permission bubble https://chromium-review.googlesource.com/c/chromium/src/+/5105227 * chore: bump chromium in DEPS to 122.0.6253.0 * chore: update patches * 5180720: Polish tiled browser window UI on Linux | https://chromium-review.googlesource.com/c/chromium/src/+/5180720 * chore: update patches * chore: bump chromium in DEPS to 122.0.6255.0 * chore: update patches * 5186276: [autopip] Make "allow once" per navigation | https://chromium-review.googlesource.com/c/chromium/src/+/5186276 * chore: bump chromium in DEPS to 122.0.6257.0 * chore: bump chromium in DEPS to 122.0.6259.0 * chore: update patches * 5190661: Automated T* -> raw_ptr<T> rewrite "refresh" | https://chromium-review.googlesource.com/c/chromium/src/+/5190661 * 5206106: Make sure RenderFrameHosts are active when printing | https://chromium-review.googlesource.com/c/chromium/src/+/5206106 * 5202674: Reland "Automated T* -> raw_ptr<T> rewrite 'refresh'" https://chromium-review.googlesource.com/c/chromium/src/+/5202674 * fixup CodeHealth: Fix leaked raw_ptr in Linux ProcessSingleton https://chromium-review.googlesource.com/c/chromium/src/+/5109767 * fixup 5206106: Make sure RenderFrameHosts are active when printing * Make legacy ToV8() helpers private to ScriptPromiseResolver, their only user https://chromium-review.googlesource.com/c/chromium/src/+/5207474 * fixup CodeHealth: Fix leaked raw_ptr in Linux ProcessSingleton * fixup 5186276: [autopip] Make "allow once" per navigation https://chromium-review.googlesource.com/c/chromium/src/+/5186276 * chore: update patches after rebase * chore: bump chromium in DEPS to 122.0.6260.0 * 5191363: Mark LOG(FATAL) [[noreturn]] https://chromium-review.googlesource.com/c/chromium/src/+/5191363 * fixup 5186276: [autopip] Make "allow once" per navigation https://chromium-review.googlesource.com/c/chromium/src/+/5186276 * fixup Make legacy ToV8() helpers private to ScriptPromiseResolver https://chromium-review.googlesource.com/c/chromium/src/+/5207474 * chore: update patches * chore: bump chromium in DEPS to 122.0.6261.0 * chore: update patches * chore: restore patch that was mistakenly removed * 5181931: Improve LoginHandler (Part 9 / N) https://chromium-review.googlesource.com/c/chromium/src/+/5181931 * Dispatch SiteInstanceGotProcess() only when both process and site are set. https://chromium-review.googlesource.com/c/chromium/src/+/5142354 * 5171446: [AsyncSB] Pass navigation_id into CreateURLLoaderThrottles https://chromium-review.googlesource.com/c/chromium/src/+/5171446 * 5213708: Move DownloadTargetInfo into components/download https://chromium-review.googlesource.com/c/chromium/src/+/5213708 * extensions: Add a loader for Controlled Frame embedder scripts https://chromium-review.googlesource.com/c/chromium/src/+/5202765 * [CSC][Zoom] Add initial_zoom_level to DisplayMediaInformation https://chromium-review.googlesource.com/c/chromium/src/+/5168626 * chore: bump chromium in DEPS to 123.0.6262.0 * chore: bump chromium in DEPS to 122.0.6261.6 * fix: suppress clang -Wimplicit-const-int-float-conversion * fixup 5191363: Mark LOG(FATAL) [[noreturn]] for Windows https://chromium-review.googlesource.com/c/chromium/src/+/5191363 * 5167921: Remove Widget::IsTranslucentWindowOpacitySupported https://chromium-review.googlesource.com/c/chromium/src/+/5167921 Also 5148392: PinnedState: Support pinned state in PlatformWindowState | https://chromium-review.googlesource.com/c/chromium/src/+/5148392 * fixup: 5180720: Polish tiled browser window UI on Linux https://chromium-review.googlesource.com/c/chromium/src/+/5180720 * 5170669: clipboard: Migrate DOMException constructors to RejectWith- https://chromium-review.googlesource.com/c/chromium/src/+/5170669 * 5178824: [Fullscreen] Record UKM data https://chromium-review.googlesource.com/c/chromium/src/+/5178824 * chore: update patches after rebase --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: VerteDinde <vertedinde@electronjs.org> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
111 lines
4.2 KiB
C++
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 "base/strings/utf_string_conversions.h"
|
|
#include "chrome/common/extensions/chrome_manifest_url_handlers.h"
|
|
#include "chrome/common/extensions/manifest_handlers/minimum_chrome_version_checker.h"
|
|
#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_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
|