2016-07-20 20:03:38 +02:00
|
|
|
// Copyright (c) 2016 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.
|
|
|
|
|
|
|
|
// APIs must also be registered in
|
2018-06-08 18:53:10 +02:00
|
|
|
// libcef/common/extensions/api/_*_features.json files and possibly
|
|
|
|
// CefExtensionsDispatcherDelegate::PopulateSourceMap. See
|
2016-07-20 20:03:38 +02:00
|
|
|
// libcef/common/extensions/api/README.txt for additional details.
|
|
|
|
|
|
|
|
#include "libcef/browser/extensions/chrome_api_registration.h"
|
|
|
|
|
|
|
|
#include "libcef/browser/extensions/api/tabs/tabs_api.h"
|
|
|
|
|
2018-06-08 18:53:10 +02:00
|
|
|
#include "chrome/browser/extensions/api/content_settings/content_settings_api.h"
|
2023-01-30 18:43:54 +01:00
|
|
|
#include "chrome/browser/extensions/api/pdf_viewer_private/pdf_viewer_private_api.h"
|
2016-07-20 20:03:38 +02:00
|
|
|
#include "chrome/browser/extensions/api/resources_private/resources_private_api.h"
|
2017-08-30 13:46:21 +02:00
|
|
|
#include "extensions/browser/api/alarms/alarms_api.h"
|
2017-09-11 20:42:30 +02:00
|
|
|
#include "extensions/browser/api/storage/storage_api.h"
|
2016-07-20 20:03:38 +02:00
|
|
|
#include "extensions/browser/extension_function_registry.h"
|
|
|
|
|
|
|
|
namespace extensions {
|
|
|
|
namespace api {
|
|
|
|
namespace cef {
|
|
|
|
|
|
|
|
namespace cefimpl = extensions::cef;
|
|
|
|
|
2020-12-02 23:31:49 +01:00
|
|
|
#define EXTENSION_FUNCTION_NAME(classname) classname::static_function_name()
|
2016-07-20 20:03:38 +02:00
|
|
|
|
2017-08-04 00:55:19 +02:00
|
|
|
// Maintain the same order as https://developer.chrome.com/extensions/api_index
|
|
|
|
// so chrome://extensions-support looks nice.
|
|
|
|
const char* const kSupportedAPIs[] = {
|
2017-08-30 13:46:21 +02:00
|
|
|
"alarms",
|
|
|
|
EXTENSION_FUNCTION_NAME(AlarmsCreateFunction),
|
|
|
|
EXTENSION_FUNCTION_NAME(AlarmsGetFunction),
|
|
|
|
EXTENSION_FUNCTION_NAME(AlarmsGetAllFunction),
|
|
|
|
EXTENSION_FUNCTION_NAME(AlarmsClearFunction),
|
|
|
|
EXTENSION_FUNCTION_NAME(AlarmsClearAllFunction),
|
2018-06-08 18:53:10 +02:00
|
|
|
"contentSettings",
|
|
|
|
EXTENSION_FUNCTION_NAME(ContentSettingsContentSettingClearFunction),
|
|
|
|
EXTENSION_FUNCTION_NAME(ContentSettingsContentSettingGetFunction),
|
|
|
|
EXTENSION_FUNCTION_NAME(ContentSettingsContentSettingSetFunction),
|
|
|
|
EXTENSION_FUNCTION_NAME(
|
|
|
|
ContentSettingsContentSettingGetResourceIdentifiersFunction),
|
2023-01-30 18:43:54 +01:00
|
|
|
"pdfViewerPrivate",
|
|
|
|
EXTENSION_FUNCTION_NAME(PdfViewerPrivateIsAllowedLocalFileAccessFunction),
|
2023-02-27 19:52:38 +01:00
|
|
|
EXTENSION_FUNCTION_NAME(PdfViewerPrivateIsPdfOcrAlwaysActiveFunction),
|
2023-01-30 18:43:54 +01:00
|
|
|
"resourcesPrivate",
|
|
|
|
EXTENSION_FUNCTION_NAME(ResourcesPrivateGetStringsFunction),
|
2017-09-11 20:42:30 +02:00
|
|
|
"storage",
|
|
|
|
EXTENSION_FUNCTION_NAME(StorageStorageAreaGetFunction),
|
|
|
|
EXTENSION_FUNCTION_NAME(StorageStorageAreaSetFunction),
|
|
|
|
EXTENSION_FUNCTION_NAME(StorageStorageAreaRemoveFunction),
|
|
|
|
EXTENSION_FUNCTION_NAME(StorageStorageAreaClearFunction),
|
|
|
|
EXTENSION_FUNCTION_NAME(StorageStorageAreaGetBytesInUseFunction),
|
2017-08-04 00:55:19 +02:00
|
|
|
"tabs",
|
|
|
|
EXTENSION_FUNCTION_NAME(cefimpl::TabsGetFunction),
|
2017-09-28 15:40:26 +02:00
|
|
|
EXTENSION_FUNCTION_NAME(cefimpl::TabsCreateFunction),
|
2021-06-16 21:54:26 +02:00
|
|
|
EXTENSION_FUNCTION_NAME(cefimpl::TabsUpdateFunction),
|
2017-08-04 00:55:19 +02:00
|
|
|
EXTENSION_FUNCTION_NAME(cefimpl::TabsExecuteScriptFunction),
|
|
|
|
EXTENSION_FUNCTION_NAME(cefimpl::TabsInsertCSSFunction),
|
2020-10-08 21:54:42 +02:00
|
|
|
EXTENSION_FUNCTION_NAME(cefimpl::TabsRemoveCSSFunction),
|
2017-08-04 00:55:19 +02:00
|
|
|
EXTENSION_FUNCTION_NAME(cefimpl::TabsSetZoomFunction),
|
|
|
|
EXTENSION_FUNCTION_NAME(cefimpl::TabsGetZoomFunction),
|
|
|
|
EXTENSION_FUNCTION_NAME(cefimpl::TabsSetZoomSettingsFunction),
|
|
|
|
EXTENSION_FUNCTION_NAME(cefimpl::TabsGetZoomSettingsFunction),
|
|
|
|
nullptr, // Indicates end of array.
|
|
|
|
};
|
|
|
|
|
2016-07-20 20:03:38 +02:00
|
|
|
// Only add APIs to this list that have been tested in CEF.
|
|
|
|
// static
|
|
|
|
bool ChromeFunctionRegistry::IsSupported(const std::string& name) {
|
2017-08-04 00:55:19 +02:00
|
|
|
for (size_t i = 0; kSupportedAPIs[i] != nullptr; ++i) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (name == kSupportedAPIs[i]) {
|
2016-07-20 20:03:38 +02:00
|
|
|
return true;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2016-07-20 20:03:38 +02:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only add APIs to this list that have been tested in CEF.
|
|
|
|
// static
|
|
|
|
void ChromeFunctionRegistry::RegisterAll(ExtensionFunctionRegistry* registry) {
|
2017-08-30 13:46:21 +02:00
|
|
|
registry->RegisterFunction<AlarmsCreateFunction>();
|
|
|
|
registry->RegisterFunction<AlarmsGetFunction>();
|
|
|
|
registry->RegisterFunction<AlarmsGetAllFunction>();
|
|
|
|
registry->RegisterFunction<AlarmsClearFunction>();
|
|
|
|
registry->RegisterFunction<AlarmsClearAllFunction>();
|
2018-06-08 18:53:10 +02:00
|
|
|
registry->RegisterFunction<ContentSettingsContentSettingClearFunction>();
|
|
|
|
registry->RegisterFunction<ContentSettingsContentSettingGetFunction>();
|
|
|
|
registry->RegisterFunction<ContentSettingsContentSettingSetFunction>();
|
|
|
|
registry->RegisterFunction<
|
|
|
|
ContentSettingsContentSettingGetResourceIdentifiersFunction>();
|
2023-01-30 18:43:54 +01:00
|
|
|
registry
|
|
|
|
->RegisterFunction<PdfViewerPrivateIsAllowedLocalFileAccessFunction>();
|
2023-02-27 19:52:38 +01:00
|
|
|
registry->RegisterFunction<PdfViewerPrivateIsPdfOcrAlwaysActiveFunction>();
|
2023-01-30 18:43:54 +01:00
|
|
|
registry->RegisterFunction<ResourcesPrivateGetStringsFunction>();
|
2017-09-11 20:42:30 +02:00
|
|
|
registry->RegisterFunction<StorageStorageAreaGetFunction>();
|
|
|
|
registry->RegisterFunction<StorageStorageAreaSetFunction>();
|
|
|
|
registry->RegisterFunction<StorageStorageAreaRemoveFunction>();
|
|
|
|
registry->RegisterFunction<StorageStorageAreaClearFunction>();
|
|
|
|
registry->RegisterFunction<StorageStorageAreaGetBytesInUseFunction>();
|
2017-08-04 00:55:19 +02:00
|
|
|
registry->RegisterFunction<cefimpl::TabsExecuteScriptFunction>();
|
|
|
|
registry->RegisterFunction<cefimpl::TabsInsertCSSFunction>();
|
2020-10-08 21:54:42 +02:00
|
|
|
registry->RegisterFunction<cefimpl::TabsRemoveCSSFunction>();
|
2016-10-17 20:14:44 +02:00
|
|
|
registry->RegisterFunction<cefimpl::TabsGetFunction>();
|
2017-09-28 15:40:26 +02:00
|
|
|
registry->RegisterFunction<cefimpl::TabsCreateFunction>();
|
2021-06-16 21:54:26 +02:00
|
|
|
registry->RegisterFunction<cefimpl::TabsUpdateFunction>();
|
2016-07-20 20:03:38 +02:00
|
|
|
registry->RegisterFunction<cefimpl::TabsSetZoomFunction>();
|
|
|
|
registry->RegisterFunction<cefimpl::TabsGetZoomFunction>();
|
|
|
|
registry->RegisterFunction<cefimpl::TabsSetZoomSettingsFunction>();
|
|
|
|
registry->RegisterFunction<cefimpl::TabsGetZoomSettingsFunction>();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace cef
|
|
|
|
} // namespace api
|
|
|
|
} // namespace extensions
|