2018-09-04 11:43:21 +02:00
|
|
|
// 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 "libcef/common/extensions/extensions_api_provider.h"
|
|
|
|
|
|
|
|
#include "libcef/common/extensions/chrome_generated_schemas.h"
|
|
|
|
|
|
|
|
#include "cef/grit/cef_resources.h"
|
2023-01-02 23:59:03 +01:00
|
|
|
// #include "cef/libcef/common/extensions/api/generated_schemas.h"
|
2018-09-04 11:43:21 +02:00
|
|
|
#include "cef/libcef/common/extensions/api/cef_api_features.h"
|
|
|
|
#include "cef/libcef/common/extensions/api/cef_manifest_features.h"
|
|
|
|
#include "cef/libcef/common/extensions/api/cef_permission_features.h"
|
|
|
|
#include "chrome/common/extensions/chrome_manifest_handlers.h"
|
2018-10-02 14:14:11 +02:00
|
|
|
#include "chrome/common/extensions/permissions/chrome_api_permissions.h"
|
2018-09-04 11:43:21 +02:00
|
|
|
#include "extensions/common/features/json_feature_provider_source.h"
|
|
|
|
#include "extensions/common/permissions/permissions_info.h"
|
|
|
|
|
|
|
|
namespace extensions {
|
|
|
|
|
2018-10-02 14:14:11 +02:00
|
|
|
CefExtensionsAPIProvider::CefExtensionsAPIProvider() {}
|
2018-09-04 11:43:21 +02:00
|
|
|
|
|
|
|
void CefExtensionsAPIProvider::AddAPIFeatures(FeatureProvider* provider) {
|
|
|
|
AddCEFAPIFeatures(provider);
|
|
|
|
}
|
|
|
|
|
2018-10-02 14:14:11 +02:00
|
|
|
void CefExtensionsAPIProvider::AddManifestFeatures(FeatureProvider* provider) {
|
2018-09-04 11:43:21 +02:00
|
|
|
AddCEFManifestFeatures(provider);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefExtensionsAPIProvider::AddPermissionFeatures(
|
|
|
|
FeatureProvider* provider) {
|
|
|
|
AddCEFPermissionFeatures(provider);
|
|
|
|
}
|
|
|
|
|
2018-10-02 14:14:11 +02:00
|
|
|
void CefExtensionsAPIProvider::AddBehaviorFeatures(FeatureProvider* provider) {
|
2018-09-04 11:43:21 +02:00
|
|
|
// No CEF-specific behavior features.
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefExtensionsAPIProvider::AddAPIJSONSources(
|
|
|
|
JSONFeatureProviderSource* json_source) {
|
|
|
|
// Extension API features specific to CEF. See
|
|
|
|
// libcef/common/extensions/api/README.txt for additional details.
|
|
|
|
json_source->LoadJSON(IDR_CEF_EXTENSION_API_FEATURES);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefExtensionsAPIProvider::IsAPISchemaGenerated(const std::string& name) {
|
|
|
|
// Schema for CEF-only APIs.
|
|
|
|
// TODO(cef): Enable if/when CEF exposes its own Mojo APIs. See
|
|
|
|
// libcef/common/extensions/api/README.txt for details.
|
|
|
|
// if (api::cef::CefGeneratedSchemas::IsGenerated(name))
|
|
|
|
// return true;
|
|
|
|
|
|
|
|
// Chrome APIs whitelisted by CEF.
|
2023-01-02 23:59:03 +01:00
|
|
|
if (api::cef::ChromeGeneratedSchemas::IsGenerated(name)) {
|
2018-09-04 11:43:21 +02:00
|
|
|
return true;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2018-09-04 11:43:21 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
base::StringPiece CefExtensionsAPIProvider::GetAPISchema(
|
|
|
|
const std::string& name) {
|
|
|
|
// Schema for CEF-only APIs.
|
|
|
|
// TODO(cef): Enable if/when CEF exposes its own Mojo APIs. See
|
|
|
|
// libcef/common/extensions/api/README.txt for details.
|
|
|
|
// if (api::cef::CefGeneratedSchemas::IsGenerated(name))
|
|
|
|
// return api::cef::CefGeneratedSchemas::Get(name);
|
|
|
|
|
|
|
|
// Chrome APIs whitelisted by CEF.
|
2023-01-02 23:59:03 +01:00
|
|
|
if (api::cef::ChromeGeneratedSchemas::IsGenerated(name)) {
|
2018-09-04 11:43:21 +02:00
|
|
|
return api::cef::ChromeGeneratedSchemas::Get(name);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2018-09-04 11:43:21 +02:00
|
|
|
|
|
|
|
return base::StringPiece();
|
|
|
|
}
|
|
|
|
|
2018-10-02 14:14:11 +02:00
|
|
|
void CefExtensionsAPIProvider::RegisterPermissions(
|
2018-09-04 11:43:21 +02:00
|
|
|
PermissionsInfo* permissions_info) {
|
2018-10-02 14:14:11 +02:00
|
|
|
permissions_info->RegisterPermissions(
|
|
|
|
chrome_api_permissions::GetPermissionInfos(),
|
|
|
|
chrome_api_permissions::GetPermissionAliases());
|
2018-09-04 11:43:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefExtensionsAPIProvider::RegisterManifestHandlers() {
|
|
|
|
RegisterChromeManifestHandlers();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace extensions
|