mirror of
https://github.com/chenasraf/webview_cef.git
synced 2026-05-17 17:48:07 +00:00
Linux Support! (#88)
* init platform linux * +linux * fix cmake link problem * run cef window on linux (#66) Co-authored-by: zhixinyan <zhixinyan@baidu.com> * linux auto download prebuilt files * off-screen rendering,methodchannel... (#69) * run cef window on linux * linux auto download prebuilt files * off-screen rendering,methodchannel --------- Co-authored-by: zhixinyan <zhixinyan@baidu.com> * fix warnings & compile err * process keyevent for linux * Merge main to linux (#73) * Added cookie visitor to manage cookies * Added cookie visitor to manage cookies * Macos support cookie visitor --------- Co-authored-by: zhixinyan <zhixinyan@baidu.com> * fix opengl support, add support file * bump ver to 0.0.9 * let CEF detect how to load a specific url Current example implementation blocked local file loading. * Jsbridge (#2) support jsbridge/jschannel * check bins files are newest version or not * bump ver to 0.1.0 * bump ver to 0.1.0 * [mac] fix x86 mac frame blink * Update Instructions of macOS on macOS, manual work has to be done for placing CEF lib inside the repo. So we can not use the plugin directly as of now. --------- Co-authored-by: zhixinyan <zhixinyan@baidu.com> Co-authored-by: Prome <levi.hao96@gmail.com> Co-authored-by: BullsEye <18664297+BullsEye34@users.noreply.github.com> * unified windows and linux interface * fixed some methodchannel bugs * solve channel run in muti-thread casue some crash * try to solve cef grab gtk main loop cause crash * provide arm64 prebuilt package * fix character type convert errors * rebuild the data struct of unified interface * fix build errors on linux * fix build errors on linux * unified interface for all three platforms! * fix build error --------- Co-authored-by: Prome <levi.hao96@gmail.com> Co-authored-by: zhixinyan <zhixinyan@baidu.com> Co-authored-by: BullsEye <18664297+BullsEye34@users.noreply.github.com>
This commit is contained in:
20
.metadata
20
.metadata
@@ -4,7 +4,7 @@
|
||||
# This file should be version controlled.
|
||||
|
||||
version:
|
||||
revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||
revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
|
||||
channel: stable
|
||||
|
||||
project_type: plugin
|
||||
@@ -13,17 +13,17 @@ project_type: plugin
|
||||
migration:
|
||||
platforms:
|
||||
- platform: root
|
||||
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||
- platform: ios
|
||||
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||
create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
|
||||
base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
|
||||
- platform: linux
|
||||
create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
|
||||
base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
|
||||
- platform: macos
|
||||
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||
create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
|
||||
base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
|
||||
- platform: windows
|
||||
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||
create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
|
||||
base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
|
||||
|
||||
# User provided section
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ void WebviewApp::OnContextInitialized() {
|
||||
std::string url = "https://www.flutter.dev/";
|
||||
|
||||
CefWindowInfo window_info;
|
||||
window_info.SetAsWindowless(nullptr);
|
||||
window_info.SetAsWindowless(0);
|
||||
|
||||
// Create the first browser window.
|
||||
CefBrowserHost::CreateBrowser(window_info, m_handler, url, browser_settings,
|
||||
|
||||
@@ -32,9 +32,8 @@ public:
|
||||
command_line->AppendSwitch("use-mock-keychain");
|
||||
command_line->AppendSwitch("single-process");
|
||||
#endif
|
||||
#ifdef _DEBUG
|
||||
command_line->AppendSwitch("renderer-startup-dialog");
|
||||
command_line->AppendSwitch("no-sandbox");
|
||||
#ifdef __linux__
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
void setOnVisitComplete(std::function<void(std::map<std::string, std::map<std::string, std::string>>)> complete);
|
||||
|
||||
//CefCookieVisitor
|
||||
bool Visit(const CefCookie& cookie, int count, int total, bool& deleteCookie);
|
||||
bool Visit(const CefCookie& cookie, int count, int total, bool& deleteCookie) override;
|
||||
|
||||
std::map<std::string, std::map<std::string, std::string>> getVisitedCookies();
|
||||
|
||||
|
||||
@@ -267,7 +267,7 @@ bool WebviewHandler::StartDragging(CefRefPtr<CefBrowser> browser,
|
||||
return true;
|
||||
}
|
||||
|
||||
void WebviewHandler::sendKeyEvent(CefKeyEvent ev)
|
||||
void WebviewHandler::sendKeyEvent(CefKeyEvent& ev)
|
||||
{
|
||||
BrowserList::const_iterator it = browser_list_.begin();
|
||||
if (it != browser_list_.end()) {
|
||||
|
||||
@@ -23,8 +23,8 @@ public:
|
||||
std::function<void(std::string title)> onTitleChangedCb;
|
||||
std::function<void(std::map<std::string, std::map<std::string, std::string>>)> onAllCookieVisitedCb;
|
||||
std::function<void(std::map<std::string, std::map<std::string, std::string>>)> onUrlCookieVisitedCb;
|
||||
std::function<void(std::string channelName, std::string message, std::string js_callback_id, std::string frameId)> onJavaScriptChannelMessage;
|
||||
|
||||
std::function<void(std::string, std::string, std::string, std::string)> onJavaScriptChannelMessage;
|
||||
|
||||
explicit WebviewHandler();
|
||||
~WebviewHandler();
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
void changeSize(float a_dpi, int width, int height);
|
||||
void cursorClick(int x, int y, bool up);
|
||||
void cursorMove(int x, int y, bool dragging);
|
||||
void sendKeyEvent(CefKeyEvent ev);
|
||||
void sendKeyEvent(CefKeyEvent& ev);
|
||||
void loadUrl(std::string url);
|
||||
void goForward();
|
||||
void goBack();
|
||||
|
||||
320
common/webview_plugin.cc
Normal file
320
common/webview_plugin.cc
Normal file
@@ -0,0 +1,320 @@
|
||||
#include "webview_plugin.h"
|
||||
#include "webview_app.h"
|
||||
|
||||
#ifdef OS_MAC
|
||||
#include <include/wrapper/cef_library_loader.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
#include <iostream>
|
||||
// #include <mutex>
|
||||
|
||||
namespace webview_cef {
|
||||
bool init = false;
|
||||
bool isFocused = false;
|
||||
std::function<void(std::string, WValue*)> invokeFunc;
|
||||
|
||||
CefRefPtr<WebviewHandler> handler(new WebviewHandler());
|
||||
CefRefPtr<WebviewApp> app(new WebviewApp(handler));
|
||||
CefMainArgs mainArgs;
|
||||
|
||||
static int cursorAction(WValue *args, std::string name) {
|
||||
if (!args || webview_value_get_len(args) != 2) {
|
||||
return 0;
|
||||
}
|
||||
int x = int(webview_value_get_int(webview_value_get_list_value(args, 0)));
|
||||
int y = int(webview_value_get_int(webview_value_get_list_value(args, 1)));
|
||||
if (!x && !y) {
|
||||
return 0;
|
||||
}
|
||||
if (name.compare("cursorClickDown") == 0) {
|
||||
handler.get()->cursorClick(x, y, false);
|
||||
}
|
||||
else if (name.compare("cursorClickUp") == 0) {
|
||||
handler.get()->cursorClick(x, y, true);
|
||||
}
|
||||
else if (name.compare("cursorMove") == 0) {
|
||||
handler.get()->cursorMove(x, y, false);
|
||||
}
|
||||
else if (name.compare("cursorDragging") == 0) {
|
||||
handler.get()->cursorMove(x, y, true);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void initCEFProcesses(CefMainArgs args){
|
||||
mainArgs = args;
|
||||
CefExecuteProcess(mainArgs, app, nullptr);
|
||||
}
|
||||
|
||||
void initCEFProcesses(){
|
||||
#ifdef OS_MAC
|
||||
CefScopedLibraryLoader loader;
|
||||
if(!loader.LoadInMain()) {
|
||||
printf("load cef err");
|
||||
}
|
||||
#endif
|
||||
CefExecuteProcess(mainArgs, app, nullptr);
|
||||
}
|
||||
|
||||
void sendKeyEvent(CefKeyEvent& ev)
|
||||
{
|
||||
handler.get()->sendKeyEvent(ev);
|
||||
}
|
||||
|
||||
void startCEF() {
|
||||
CefSettings cefs;
|
||||
cefs.windowless_rendering_enabled = true;
|
||||
#ifndef OS_MAC
|
||||
cefs.no_sandbox = true;
|
||||
#endif
|
||||
|
||||
#ifdef OS_MAC
|
||||
cefs.external_message_pump = true;
|
||||
//CefString(&cefs.browser_subprocess_path) = "/Library/Chaches";
|
||||
#endif
|
||||
|
||||
CefInitialize(mainArgs, cefs, app.get(), nullptr);
|
||||
|
||||
#ifdef OS_WIN
|
||||
CefRunMessageLoop();
|
||||
CefShutdown();
|
||||
#endif
|
||||
}
|
||||
|
||||
void doMessageLoopWork()
|
||||
{
|
||||
CefDoMessageLoopWork();
|
||||
}
|
||||
|
||||
int HandleMethodCall(std::string name, WValue* values, WValue* response) {
|
||||
int result = -1;
|
||||
if (name.compare("loadUrl") == 0) {
|
||||
if (const auto url = webview_value_get_string(values)) {
|
||||
handler.get()->loadUrl(url);
|
||||
result = 1;
|
||||
}
|
||||
}
|
||||
else if (name.compare("setSize") == 0) {
|
||||
const auto dpi = webview_value_get_double(webview_value_get_list_value(values, 0));
|
||||
const auto width = webview_value_get_double(webview_value_get_list_value(values, 1));
|
||||
const auto height = webview_value_get_double(webview_value_get_list_value(values, 2));
|
||||
handler.get()->changeSize((float)dpi, (int)std::round(width), (int)std::round(height));
|
||||
result = 1;
|
||||
}
|
||||
else if (name.compare("cursorClickDown") == 0
|
||||
|| name.compare("cursorClickUp") == 0
|
||||
|| name.compare("cursorMove") == 0
|
||||
|| name.compare("cursorDragging") == 0) {
|
||||
result = cursorAction(values, name);
|
||||
}
|
||||
else if (name.compare("setScrollDelta") == 0) {
|
||||
auto x = webview_value_get_int(webview_value_get_list_value(values, 0));
|
||||
auto y = webview_value_get_int(webview_value_get_list_value(values, 1));
|
||||
auto deltaX = webview_value_get_int(webview_value_get_list_value(values, 2));
|
||||
auto deltaY = webview_value_get_int(webview_value_get_list_value(values, 3));
|
||||
handler.get()->sendScrollEvent((int)x, (int)y, (int)deltaX, (int)deltaY);
|
||||
result = 1;
|
||||
}
|
||||
else if (name.compare("goForward") == 0) {
|
||||
handler.get()->goForward();
|
||||
result = 1;
|
||||
}
|
||||
else if (name.compare("goBack") == 0) {
|
||||
handler.get()->goBack();
|
||||
result = 1;
|
||||
}
|
||||
else if (name.compare("reload") == 0) {
|
||||
handler.get()->reload();
|
||||
result = 1;
|
||||
}
|
||||
else if (name.compare("openDevTools") == 0) {
|
||||
handler.get()->openDevTools();
|
||||
result = 1;
|
||||
}
|
||||
else if (name.compare("setClientFocus") == 0) {
|
||||
isFocused = webview_value_get_bool(webview_value_get_list_value(values, 0));
|
||||
result = 1;
|
||||
}
|
||||
else if(name.compare("setCookie") == 0){
|
||||
const auto domain = webview_value_get_string(webview_value_get_list_value(values, 0));
|
||||
const auto key = webview_value_get_string(webview_value_get_list_value(values, 1));
|
||||
const auto value = webview_value_get_string(webview_value_get_list_value(values, 2));
|
||||
handler.get()->setCookie(domain, key, value);
|
||||
result = 1;
|
||||
}
|
||||
else if (name.compare("deleteCookie") == 0) {
|
||||
const auto domain = webview_value_get_string(webview_value_get_list_value(values, 0));
|
||||
const auto key = webview_value_get_string(webview_value_get_list_value(values, 1));
|
||||
handler.get()->deleteCookie(domain, key);
|
||||
result = 1;
|
||||
}
|
||||
else if (name.compare("visitAllCookies") == 0) {
|
||||
handler.get()->visitAllCookies();
|
||||
result = 1;
|
||||
}
|
||||
else if (name.compare("visitUrlCookies") == 0) {
|
||||
const auto domain = webview_value_get_string(webview_value_get_list_value(values, 0));
|
||||
const auto isHttpOnly = webview_value_get_bool(webview_value_get_list_value(values, 1));
|
||||
handler.get()->visitUrlCookies(domain, isHttpOnly);
|
||||
result = 1;
|
||||
}
|
||||
else if(name.compare("setJavaScriptChannels") == 0){
|
||||
auto len = webview_value_get_len(values);
|
||||
std::vector<std::string> channels;
|
||||
for(size_t i = 0; i < len; i++){
|
||||
auto channel = webview_value_get_string(webview_value_get_list_value(values, i));
|
||||
channels.push_back(channel);
|
||||
}
|
||||
handler.get()->setJavaScriptChannels(channels);
|
||||
result = 1;
|
||||
}
|
||||
else if (name.compare("sendJavaScriptChannelCallBack") == 0) {
|
||||
const auto error = webview_value_get_bool(webview_value_get_list_value(values, 0));
|
||||
const auto ret = webview_value_get_string(webview_value_get_list_value(values, 1));
|
||||
const auto callbackId = webview_value_get_string(webview_value_get_list_value(values, 2));
|
||||
const auto frameId = webview_value_get_string(webview_value_get_list_value(values, 3));
|
||||
handler.get()->sendJavaScriptChannelCallBack(error, ret,callbackId,frameId);
|
||||
result = 1;
|
||||
}
|
||||
else if(name.compare("executeJavaScript") == 0){
|
||||
const auto code = webview_value_get_string(webview_value_get_list_value(values, 0));
|
||||
handler.get()->executeJavaScript(code);
|
||||
result = 1;
|
||||
}
|
||||
else {
|
||||
result = 0;
|
||||
}
|
||||
if(response == nullptr){
|
||||
response = webview_value_new_null();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void SwapBufferFromBgraToRgba(void* _dest, const void* _src, int width, int height) {
|
||||
int32_t* dest = (int32_t*)_dest;
|
||||
int32_t* src = (int32_t*)_src;
|
||||
int32_t rgba;
|
||||
int32_t bgra;
|
||||
int length = width * height;
|
||||
for (int i = 0; i < length; i++) {
|
||||
bgra = src[i];
|
||||
// BGRA in hex = 0xAARRGGBB.
|
||||
rgba = (bgra & 0x00ff0000) >> 16 // Red >> Blue.
|
||||
| (bgra & 0xff00ff00) // Green Alpha.
|
||||
| (bgra & 0x000000ff) << 16; // Blue >> Red.
|
||||
dest[i] = rgba;
|
||||
}
|
||||
}
|
||||
|
||||
void setPaintCallBack(std::function<void(const void *, int32_t, int32_t)> callback) {
|
||||
if (!init)
|
||||
{
|
||||
handler.get()->onPaintCallback = callback;
|
||||
handler.get()->onUrlChangedCb = [](std::string url)
|
||||
{
|
||||
if (invokeFunc)
|
||||
{
|
||||
WValue *wUrl = webview_value_new_string(const_cast<char *>(url.c_str()));
|
||||
invokeFunc("urlChanged", wUrl);
|
||||
webview_value_unref(wUrl);
|
||||
}
|
||||
};
|
||||
|
||||
handler.get()->onTitleChangedCb = [](std::string title)
|
||||
{
|
||||
if (invokeFunc)
|
||||
{
|
||||
WValue *wTitle = webview_value_new_string(const_cast<char *>(title.c_str()));
|
||||
invokeFunc("titleChanged", wTitle);
|
||||
webview_value_unref(wTitle);
|
||||
}
|
||||
};
|
||||
|
||||
handler.get()->onAllCookieVisitedCb = [](std::map<std::string, std::map<std::string, std::string>> cookies)
|
||||
{
|
||||
if (invokeFunc)
|
||||
{
|
||||
WValue* retMap = webview_value_new_map();
|
||||
for (auto &cookie : cookies)
|
||||
{
|
||||
WValue* tempMap = webview_value_new_map();
|
||||
for (auto &c : cookie.second)
|
||||
{
|
||||
WValue * val = webview_value_new_string(const_cast<char *>(c.second.c_str()));
|
||||
webview_value_set_string(tempMap, c.first.c_str(), val);
|
||||
webview_value_unref(val);
|
||||
}
|
||||
webview_value_set_string(retMap, cookie.first.c_str(), tempMap);
|
||||
webview_value_unref(tempMap);
|
||||
}
|
||||
invokeFunc("allCookiesVisited", retMap);
|
||||
webview_value_unref(retMap);
|
||||
}
|
||||
};
|
||||
|
||||
handler.get()->onUrlCookieVisitedCb = [](std::map<std::string, std::map<std::string, std::string>> cookies)
|
||||
{
|
||||
if (invokeFunc)
|
||||
{
|
||||
WValue* retMap = webview_value_new_map();
|
||||
for (auto &cookie : cookies)
|
||||
{
|
||||
WValue* tempMap = webview_value_new_map();
|
||||
for (auto &c : cookie.second)
|
||||
{
|
||||
WValue * val = webview_value_new_string(const_cast<char *>(c.second.c_str()));
|
||||
webview_value_set_string(tempMap, c.first.c_str(), val);
|
||||
webview_value_unref(val);
|
||||
}
|
||||
webview_value_set_string(retMap, cookie.first.c_str(), tempMap);
|
||||
webview_value_unref(tempMap);
|
||||
}
|
||||
invokeFunc("urlCookiesVisited", retMap);
|
||||
webview_value_unref(retMap);
|
||||
}
|
||||
};
|
||||
|
||||
handler.get()->onJavaScriptChannelMessage = [](std::string channelName, std::string message, std::string callbackId, std::string frameId)
|
||||
{
|
||||
if (invokeFunc)
|
||||
{
|
||||
WValue* retMap = webview_value_new_map();
|
||||
WValue* channel = webview_value_new_string(const_cast<char *>(channelName.c_str()));
|
||||
WValue* msg = webview_value_new_string(const_cast<char *>(message.c_str()));
|
||||
WValue* cbId = webview_value_new_string(const_cast<char *>(callbackId.c_str()));
|
||||
WValue* fId = webview_value_new_string(const_cast<char *>(frameId.c_str()));
|
||||
webview_value_set_string(retMap, "channel", channel);
|
||||
webview_value_set_string(retMap, "message", msg);
|
||||
webview_value_set_string(retMap, "callbackId", cbId);
|
||||
webview_value_set_string(retMap, "frameId", fId);
|
||||
invokeFunc("javascriptChannelMessage", retMap);
|
||||
webview_value_unref(retMap);
|
||||
webview_value_unref(channel);
|
||||
webview_value_unref(msg);
|
||||
webview_value_unref(cbId);
|
||||
webview_value_unref(fId);
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(OS_WIN)
|
||||
//windows run in multi thread
|
||||
new std::thread(startCEF);
|
||||
#else
|
||||
//mac、linux run in main thread
|
||||
startCEF();
|
||||
#endif
|
||||
init = true;
|
||||
}
|
||||
}
|
||||
|
||||
void setInvokeMethodFunc(std::function<void(std::string, WValue*)> func){
|
||||
invokeFunc = func;
|
||||
}
|
||||
|
||||
bool getPluginIsFocused() {
|
||||
return isFocused;
|
||||
}
|
||||
}
|
||||
21
common/webview_plugin.h
Normal file
21
common/webview_plugin.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef WEBVIEW_PLUGIN_H
|
||||
#define WEBVIEW_PLUGIN_H
|
||||
|
||||
#include <functional>
|
||||
#include <include/cef_base.h>
|
||||
#include "webview_value.h"
|
||||
|
||||
namespace webview_cef {
|
||||
void initCEFProcesses(CefMainArgs args);
|
||||
void initCEFProcesses();
|
||||
void startCEF();
|
||||
void doMessageLoopWork();
|
||||
void sendKeyEvent(CefKeyEvent& ev);
|
||||
int HandleMethodCall(std::string name, WValue* values, WValue* response);
|
||||
void SwapBufferFromBgraToRgba(void* _dest, const void* _src, int width, int height);
|
||||
void setPaintCallBack(std::function<void(const void*, int32_t , int32_t )> callback);
|
||||
void setInvokeMethodFunc(std::function<void(std::string, WValue*)> func);
|
||||
bool getPluginIsFocused();
|
||||
}
|
||||
|
||||
#endif //WEBVIEW_PLUGIN_H
|
||||
917
common/webview_value.cc
Normal file
917
common/webview_value.cc
Normal file
@@ -0,0 +1,917 @@
|
||||
#include "webview_value.h"
|
||||
#include <memory>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable: 4996)
|
||||
#include <BaseTsd.h>
|
||||
typedef SSIZE_T ssize_t;
|
||||
#endif
|
||||
|
||||
#define return_val_if_fail(p, ret) if(!(p)) return (ret)
|
||||
#define return_if_fail(p) if(!(p)) return
|
||||
|
||||
struct webview_value{
|
||||
WValueType type;
|
||||
int ref_count;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
WValue parent;
|
||||
bool value;
|
||||
} WValueBool;
|
||||
|
||||
typedef struct {
|
||||
WValue parent;
|
||||
int64_t value;
|
||||
} WValueInt;
|
||||
|
||||
typedef struct {
|
||||
WValue parent;
|
||||
float value;
|
||||
} WValueFloat;
|
||||
|
||||
typedef struct {
|
||||
WValue parent;
|
||||
double value;
|
||||
} WValueDouble;
|
||||
|
||||
typedef struct {
|
||||
WValue parent;
|
||||
char* value;
|
||||
} WValueString;
|
||||
|
||||
typedef struct {
|
||||
WValue parent;
|
||||
uint8_t* values;
|
||||
size_t values_length;
|
||||
} WValueUint8List;
|
||||
|
||||
typedef struct {
|
||||
WValue parent;
|
||||
int32_t* values;
|
||||
size_t values_length;
|
||||
} WValueInt32List;
|
||||
|
||||
typedef struct {
|
||||
WValue parent;
|
||||
int64_t* values;
|
||||
size_t values_length;
|
||||
} WValueInt64List;
|
||||
|
||||
typedef struct {
|
||||
WValue parent;
|
||||
float* values;
|
||||
size_t values_length;
|
||||
} WValueFloatList;
|
||||
|
||||
typedef struct {
|
||||
WValue parent;
|
||||
double* values;
|
||||
size_t values_length;
|
||||
} WValueDoubleList;
|
||||
|
||||
struct WPtrArray {
|
||||
void **pdata;
|
||||
size_t len;
|
||||
size_t capacity;
|
||||
void (*free_func)(void*);
|
||||
};
|
||||
|
||||
WPtrArray* webview_ptr_array_new_with_free_func(void (*free_func)(void*)) {
|
||||
WPtrArray* array = (WPtrArray*)malloc(sizeof(WPtrArray));
|
||||
array->pdata = NULL;
|
||||
array->len = 0;
|
||||
array->capacity = 0;
|
||||
array->free_func = free_func;
|
||||
return array;
|
||||
}
|
||||
|
||||
void webview_ptr_array_free(WPtrArray* array) {
|
||||
if (array->free_func) {
|
||||
for (size_t i = 0; i < array->len; i++) {
|
||||
array->free_func(array->pdata[i]);
|
||||
}
|
||||
}
|
||||
free(array->pdata);
|
||||
free(array);
|
||||
}
|
||||
|
||||
void webview_ptr_array_unref(WPtrArray* array) {
|
||||
if (array) {
|
||||
webview_ptr_array_free(array);
|
||||
}
|
||||
}
|
||||
|
||||
void webview_ptr_array_add(WPtrArray* array, void* data) {
|
||||
if (array->len == array->capacity) {
|
||||
size_t new_capacity = array->capacity == 0 ? 16 : array->capacity * 2;
|
||||
void** new_pdata = (void**)realloc(array->pdata, new_capacity * sizeof(void*));
|
||||
if (new_pdata) {
|
||||
array->pdata = new_pdata;
|
||||
array->capacity = new_capacity;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
array->pdata[array->len++] = data;
|
||||
}
|
||||
|
||||
void* webview_ptr_array_index(WPtrArray* array, size_t index) {
|
||||
if (index >= array->len) {
|
||||
return NULL;
|
||||
}
|
||||
return array->pdata[index];
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
WValue parent;
|
||||
WPtrArray* values;
|
||||
} WValueList;
|
||||
|
||||
typedef struct {
|
||||
WValue parent;
|
||||
WPtrArray* keys;
|
||||
WPtrArray* values;
|
||||
} WValueMap;
|
||||
|
||||
static WValue* webview_value_new(WValueType type, size_t size) {
|
||||
WValue* self = static_cast<WValue*>(malloc(size));
|
||||
self->type = type;
|
||||
self->ref_count = 1;
|
||||
return self;
|
||||
}
|
||||
|
||||
static ssize_t webview_value_lookup_index(WValue* self, WValue* key) {
|
||||
return_val_if_fail(self->type == Webview_Value_Type_Map, size_t(-1));
|
||||
|
||||
for (size_t i = 0; i < webview_value_get_len(self); i++) {
|
||||
WValue* k = webview_value_get_key(self, i);
|
||||
if (webview_value_equals(k, key)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Helper function to match GDestroyNotify type.
|
||||
static void webview_value_destroy(void *value) {
|
||||
webview_value_unref(static_cast<WValue*>(value));
|
||||
}
|
||||
|
||||
WValue* webview_value_new_null() {
|
||||
return webview_value_new(Webview_Value_Type_Null, sizeof(WValue));
|
||||
}
|
||||
|
||||
WValue* webview_value_new_bool(bool value) {
|
||||
WValueBool* self = reinterpret_cast<WValueBool*>(
|
||||
webview_value_new(Webview_Value_Type_Bool, sizeof(WValueBool)));
|
||||
self->value = value ? true : false;
|
||||
return reinterpret_cast<WValue*>(self);
|
||||
}
|
||||
|
||||
WValue* webview_value_new_int(int64_t value) {
|
||||
WValueInt* self = reinterpret_cast<WValueInt*>(
|
||||
webview_value_new(Webview_Value_Type_Int, sizeof(WValueInt)));
|
||||
self->value = value;
|
||||
return reinterpret_cast<WValue*>(self);
|
||||
}
|
||||
|
||||
WValue* webview_value_new_float(float value) {
|
||||
WValueFloat* self = reinterpret_cast<WValueFloat*>(
|
||||
webview_value_new(Webview_Value_Type_Float, sizeof(WValueFloat)));
|
||||
self->value = value;
|
||||
return reinterpret_cast<WValue*>(self);
|
||||
}
|
||||
|
||||
WValue* webview_value_new_double(double value) {
|
||||
WValueDouble* self = reinterpret_cast<WValueDouble*>(
|
||||
webview_value_new(Webview_Value_Type_Double, sizeof(WValueDouble)));
|
||||
self->value = value;
|
||||
return reinterpret_cast<WValue*>(self);
|
||||
}
|
||||
|
||||
WValue* webview_value_new_string(const char* value) {
|
||||
WValueString* self = reinterpret_cast<WValueString*>(
|
||||
webview_value_new(Webview_Value_Type_String, sizeof(WValueString)));
|
||||
self->value = strdup(value);
|
||||
return reinterpret_cast<WValue*>(self);
|
||||
}
|
||||
|
||||
WValue* webview_value_new_string_len(const char* value,
|
||||
size_t value_length) {
|
||||
WValueString* self = reinterpret_cast<WValueString*>(
|
||||
webview_value_new(Webview_Value_Type_String, sizeof(WValueString)));
|
||||
if (value_length == 0) {
|
||||
self->value = strdup("");
|
||||
} else {
|
||||
self->value = new char[value_length + 1];
|
||||
strncpy(self->value, value, value_length);
|
||||
self->value[value_length] = '\0';
|
||||
}
|
||||
return reinterpret_cast<WValue*>(self);
|
||||
}
|
||||
|
||||
WValue* webview_value_new_uint8_list(const uint8_t* data,
|
||||
size_t data_length) {
|
||||
WValueUint8List* self = reinterpret_cast<WValueUint8List*>(
|
||||
webview_value_new(Webview_Value_Type_Uint8_List, sizeof(WValueUint8List)));
|
||||
self->values_length = data_length;
|
||||
self->values = static_cast<uint8_t*>(malloc(sizeof(uint8_t) * data_length));
|
||||
memcpy(self->values, data, sizeof(uint8_t) * data_length);
|
||||
return reinterpret_cast<WValue*>(self);
|
||||
}
|
||||
|
||||
WValue* webview_value_new_int32_list(const int32_t* data,
|
||||
size_t data_length) {
|
||||
WValueInt32List* self = reinterpret_cast<WValueInt32List*>(
|
||||
webview_value_new(Webview_Value_Type_Int32_List, sizeof(WValueInt32List)));
|
||||
self->values_length = data_length;
|
||||
self->values = static_cast<int32_t*>(malloc(sizeof(int32_t) * data_length));
|
||||
memcpy(self->values, data, sizeof(int32_t) * data_length);
|
||||
return reinterpret_cast<WValue*>(self);
|
||||
}
|
||||
|
||||
WValue* webview_value_new_int64_list(const int64_t* data,
|
||||
size_t data_length) {
|
||||
WValueInt64List* self = reinterpret_cast<WValueInt64List*>(
|
||||
webview_value_new(Webview_Value_Type_Int64_List, sizeof(WValueInt64List)));
|
||||
self->values_length = data_length;
|
||||
self->values = static_cast<int64_t*>(malloc(sizeof(int64_t) * data_length));
|
||||
memcpy(self->values, data, sizeof(int64_t) * data_length);
|
||||
return reinterpret_cast<WValue*>(self);
|
||||
}
|
||||
|
||||
WValue* webview_value_new_float_list(const float* data,
|
||||
size_t data_length) {
|
||||
WValueFloatList* self = reinterpret_cast<WValueFloatList*>(
|
||||
webview_value_new(Webview_Value_Type_Float_List, sizeof(WValueFloatList)));
|
||||
self->values_length = data_length;
|
||||
self->values = static_cast<float*>(malloc(sizeof(float) * data_length));
|
||||
memcpy(self->values, data, sizeof(float) * data_length);
|
||||
return reinterpret_cast<WValue*>(self);
|
||||
}
|
||||
|
||||
WValue* webview_value_new_double_list(const double* data,
|
||||
size_t data_length) {
|
||||
WValueDoubleList* self = reinterpret_cast<WValueDoubleList*>(
|
||||
webview_value_new(Webview_Value_Type_Double_List, sizeof(WValueDoubleList)));
|
||||
self->values_length = data_length;
|
||||
self->values = static_cast<double*>(malloc(sizeof(double) * data_length));
|
||||
memcpy(self->values, data, sizeof(double) * data_length);
|
||||
return reinterpret_cast<WValue*>(self);
|
||||
}
|
||||
|
||||
WValue* webview_value_new_list() {
|
||||
WValueList* self = reinterpret_cast<WValueList*>(
|
||||
webview_value_new(Webview_Value_Type_List, sizeof(WValueList)));
|
||||
self->values = webview_ptr_array_new_with_free_func(webview_value_destroy);
|
||||
return reinterpret_cast<WValue*>(self);
|
||||
}
|
||||
|
||||
WValue* webview_value_new_map() {
|
||||
WValueMap* self = reinterpret_cast<WValueMap*>(
|
||||
webview_value_new(Webview_Value_Type_Map, sizeof(WValueMap)));
|
||||
self->keys = webview_ptr_array_new_with_free_func(webview_value_destroy);
|
||||
self->values = webview_ptr_array_new_with_free_func(webview_value_destroy);
|
||||
return reinterpret_cast<WValue*>(self);
|
||||
}
|
||||
|
||||
WValue* webview_value_ref(WValue* self) {
|
||||
return_val_if_fail(self != nullptr, nullptr);
|
||||
self->ref_count++;
|
||||
return self;
|
||||
}
|
||||
|
||||
void webview_value_unref(WValue *self)
|
||||
{
|
||||
return_if_fail(self != nullptr);
|
||||
return_if_fail(self->ref_count > 0);
|
||||
self->ref_count--;
|
||||
if (self->ref_count != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (self->type)
|
||||
{
|
||||
case Webview_Value_Type_String:
|
||||
{
|
||||
WValueString *v = reinterpret_cast<WValueString *>(self);
|
||||
free(v->value);
|
||||
break;
|
||||
}
|
||||
case Webview_Value_Type_Uint8_List:
|
||||
{
|
||||
WValueUint8List *v = reinterpret_cast<WValueUint8List *>(self);
|
||||
free(v->values);
|
||||
break;
|
||||
}
|
||||
case Webview_Value_Type_Int32_List:
|
||||
{
|
||||
WValueInt32List *v = reinterpret_cast<WValueInt32List *>(self);
|
||||
free(v->values);
|
||||
break;
|
||||
}
|
||||
case Webview_Value_Type_Int64_List:
|
||||
{
|
||||
WValueInt64List *v = reinterpret_cast<WValueInt64List *>(self);
|
||||
free(v->values);
|
||||
break;
|
||||
}
|
||||
case Webview_Value_Type_Float_List:
|
||||
{
|
||||
WValueFloatList *v = reinterpret_cast<WValueFloatList *>(self);
|
||||
free(v->values);
|
||||
break;
|
||||
}
|
||||
case Webview_Value_Type_Double_List:
|
||||
{
|
||||
WValueDoubleList *v = reinterpret_cast<WValueDoubleList *>(self);
|
||||
free(v->values);
|
||||
break;
|
||||
}
|
||||
case Webview_Value_Type_List:
|
||||
{
|
||||
WValueList *v = reinterpret_cast<WValueList *>(self);
|
||||
webview_ptr_array_unref(v->values);
|
||||
break;
|
||||
}
|
||||
case Webview_Value_Type_Map:
|
||||
{
|
||||
WValueMap *v = reinterpret_cast<WValueMap *>(self);
|
||||
webview_ptr_array_unref(v->keys);
|
||||
webview_ptr_array_unref(v->values);
|
||||
break;
|
||||
}
|
||||
case Webview_Value_Type_Null:
|
||||
case Webview_Value_Type_Bool:
|
||||
case Webview_Value_Type_Int:
|
||||
case Webview_Value_Type_Float:
|
||||
case Webview_Value_Type_Double:
|
||||
break;
|
||||
}
|
||||
free(self);
|
||||
}
|
||||
|
||||
WValueType webview_value_get_type(WValue* self) {
|
||||
return_val_if_fail(self != nullptr, Webview_Value_Type_Null);
|
||||
return self->type;
|
||||
}
|
||||
|
||||
bool webview_value_equals(WValue *a, WValue *b)
|
||||
{
|
||||
return_val_if_fail(a != nullptr, false);
|
||||
return_val_if_fail(b != nullptr, false);
|
||||
|
||||
if (a->type != b->type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (a->type)
|
||||
{
|
||||
case Webview_Value_Type_Null:
|
||||
return true;
|
||||
case Webview_Value_Type_Bool:
|
||||
return webview_value_get_bool(a) == webview_value_get_bool(b);
|
||||
case Webview_Value_Type_Int:
|
||||
return webview_value_get_int(a) == webview_value_get_int(b);
|
||||
case Webview_Value_Type_Float:
|
||||
return webview_value_get_float(a) == webview_value_get_float(b);
|
||||
case Webview_Value_Type_Double:
|
||||
return webview_value_get_double(a) == webview_value_get_double(b);
|
||||
case Webview_Value_Type_String:
|
||||
{
|
||||
WValueString *a_ = reinterpret_cast<WValueString *>(a);
|
||||
WValueString *b_ = reinterpret_cast<WValueString *>(b);
|
||||
return strcmp(a_->value, b_->value) == 0;
|
||||
}
|
||||
case Webview_Value_Type_Uint8_List:
|
||||
{
|
||||
if (webview_value_get_len(a) != webview_value_get_len(b))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
const uint8_t *values_a = webview_value_get_uint8_list(a);
|
||||
const uint8_t *values_b = webview_value_get_uint8_list(b);
|
||||
for (size_t i = 0; i < webview_value_get_len(a); i++)
|
||||
{
|
||||
if (values_a[i] != values_b[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case Webview_Value_Type_Int32_List:
|
||||
{
|
||||
if (webview_value_get_len(a) != webview_value_get_len(b))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
const int32_t *values_a = webview_value_get_int32_list(a);
|
||||
const int32_t *values_b = webview_value_get_int32_list(b);
|
||||
for (size_t i = 0; i < webview_value_get_len(a); i++)
|
||||
{
|
||||
if (values_a[i] != values_b[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case Webview_Value_Type_Int64_List:
|
||||
{
|
||||
if (webview_value_get_len(a) != webview_value_get_len(b))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
const int64_t *values_a = webview_value_get_int64_list(a);
|
||||
const int64_t *values_b = webview_value_get_int64_list(b);
|
||||
for (size_t i = 0; i < webview_value_get_len(a); i++)
|
||||
{
|
||||
if (values_a[i] != values_b[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case Webview_Value_Type_Float_List:
|
||||
{
|
||||
if (webview_value_get_len(a) != webview_value_get_len(b))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
const float *values_a = webview_value_get_float_list(a);
|
||||
const float *values_b = webview_value_get_float_list(b);
|
||||
for (size_t i = 0; i < webview_value_get_len(a); i++)
|
||||
{
|
||||
if (values_a[i] != values_b[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case Webview_Value_Type_Double_List:
|
||||
{
|
||||
if (webview_value_get_len(a) != webview_value_get_len(b))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
const double *values_a = webview_value_get_double_list(a);
|
||||
const double *values_b = webview_value_get_double_list(b);
|
||||
for (size_t i = 0; i < webview_value_get_len(a); i++)
|
||||
{
|
||||
if (values_a[i] != values_b[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case Webview_Value_Type_List:
|
||||
{
|
||||
if (webview_value_get_len(a) != webview_value_get_len(b))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (size_t i = 0; i < webview_value_get_len(a); i++)
|
||||
{
|
||||
if (!webview_value_equals(webview_value_get_list_value(a, i),
|
||||
webview_value_get_list_value(b, i)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case Webview_Value_Type_Map:
|
||||
{
|
||||
if (webview_value_get_len(a) != webview_value_get_len(b))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (size_t i = 0; i < webview_value_get_len(a); i++)
|
||||
{
|
||||
WValue *key = webview_value_get_key(a, i);
|
||||
WValue *value_b = webview_value_get_by_key(b, key);
|
||||
if (value_b == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
WValue *value_a = webview_value_get_key(a, i);
|
||||
if (!webview_value_equals(value_a, value_b))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void webview_value_append_take(WValue* self, WValue* value) {
|
||||
return_if_fail(self != nullptr);
|
||||
return_if_fail(self->type == Webview_Value_Type_List);
|
||||
return_if_fail(value != nullptr);
|
||||
|
||||
|
||||
WValueList* v = reinterpret_cast<WValueList*>(self);
|
||||
webview_ptr_array_add(v->values, value);
|
||||
}
|
||||
|
||||
void webview_value_append(WValue* self, WValue* value) {
|
||||
return_if_fail(self != nullptr);
|
||||
return_if_fail(self->type == Webview_Value_Type_List);
|
||||
return_if_fail(value != nullptr);
|
||||
|
||||
webview_value_append_take(self, webview_value_ref(value));
|
||||
}
|
||||
|
||||
void webview_value_set_take(WValue* self, WValue* key, WValue* value)
|
||||
{
|
||||
return_if_fail(self != nullptr);
|
||||
return_if_fail(self->type == Webview_Value_Type_Map);
|
||||
return_if_fail(key != nullptr);
|
||||
return_if_fail(value != nullptr);
|
||||
|
||||
WValueMap* v = reinterpret_cast<WValueMap*>(self);
|
||||
ssize_t index = webview_value_lookup_index(self, key);
|
||||
if (index < 0) {
|
||||
webview_ptr_array_add(v->keys, key);
|
||||
webview_ptr_array_add(v->values, value);
|
||||
}
|
||||
else {
|
||||
webview_value_destroy(v->keys->pdata[index]);
|
||||
v->keys->pdata[index] = key;
|
||||
webview_value_destroy(v->values->pdata[index]);
|
||||
v->values->pdata[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
void webview_value_set(WValue* self, WValue* key, WValue* value) {
|
||||
return_if_fail(self != nullptr);
|
||||
return_if_fail(self->type == Webview_Value_Type_Map);
|
||||
return_if_fail(key != nullptr);
|
||||
return_if_fail(value != nullptr);
|
||||
|
||||
webview_value_set_take(self, webview_value_ref(key), webview_value_ref(value));
|
||||
}
|
||||
|
||||
void webview_value_set_string(WValue* self,const char* key,WValue* value) {
|
||||
return_if_fail(self != nullptr);
|
||||
return_if_fail(self->type == Webview_Value_Type_Map);
|
||||
return_if_fail(key != nullptr);
|
||||
return_if_fail(value != nullptr);
|
||||
|
||||
webview_value_set_take(self, webview_value_new_string(key), webview_value_ref(value));
|
||||
}
|
||||
|
||||
bool webview_value_get_bool(WValue* self) {
|
||||
return_val_if_fail(self != nullptr, false);
|
||||
return_val_if_fail(self->type == Webview_Value_Type_Bool, false);
|
||||
WValueBool* v = reinterpret_cast<WValueBool*>(self);
|
||||
return v->value;
|
||||
}
|
||||
|
||||
int64_t webview_value_get_int(WValue* self) {
|
||||
return_val_if_fail(self != nullptr, 0);
|
||||
return_val_if_fail(self->type == Webview_Value_Type_Int, 0);
|
||||
WValueInt* v = reinterpret_cast<WValueInt*>(self);
|
||||
return v->value;
|
||||
}
|
||||
|
||||
float webview_value_get_float(WValue* self) {
|
||||
return_val_if_fail(self != nullptr, 0.0);
|
||||
return_val_if_fail(self->type == Webview_Value_Type_Float, 0.0);
|
||||
WValueFloat* v = reinterpret_cast<WValueFloat*>(self);
|
||||
return v->value;
|
||||
}
|
||||
|
||||
double webview_value_get_double(WValue* self) {
|
||||
return_val_if_fail(self != nullptr, 0.0);
|
||||
return_val_if_fail(self->type == Webview_Value_Type_Double, 0.0);
|
||||
WValueDouble* v = reinterpret_cast<WValueDouble*>(self);
|
||||
return v->value;
|
||||
}
|
||||
|
||||
const char* webview_value_get_string(WValue* self) {
|
||||
return_val_if_fail(self != nullptr, nullptr);
|
||||
return_val_if_fail(self->type == Webview_Value_Type_String, nullptr);
|
||||
WValueString* v = reinterpret_cast<WValueString*>(self);
|
||||
return v->value;
|
||||
}
|
||||
|
||||
const uint8_t* webview_value_get_uint8_list(WValue* self) {
|
||||
return_val_if_fail(self != nullptr, nullptr);
|
||||
return_val_if_fail(self->type == Webview_Value_Type_Uint8_List, nullptr);
|
||||
WValueUint8List* v = reinterpret_cast<WValueUint8List*>(self);
|
||||
return v->values;
|
||||
}
|
||||
|
||||
const int32_t* webview_value_get_int32_list(WValue* self) {
|
||||
return_val_if_fail(self != nullptr, nullptr);
|
||||
return_val_if_fail(self->type == Webview_Value_Type_Int32_List, nullptr);
|
||||
WValueInt32List* v = reinterpret_cast<WValueInt32List*>(self);
|
||||
return v->values;
|
||||
}
|
||||
|
||||
const int64_t* webview_value_get_int64_list(WValue* self) {
|
||||
return_val_if_fail(self != nullptr, nullptr);
|
||||
return_val_if_fail(self->type == Webview_Value_Type_Int64_List, nullptr);
|
||||
WValueInt64List* v = reinterpret_cast<WValueInt64List*>(self);
|
||||
return v->values;
|
||||
}
|
||||
|
||||
const float* webview_value_get_float_list(WValue* self) {
|
||||
return_val_if_fail(self != nullptr, nullptr);
|
||||
return_val_if_fail(self->type == Webview_Value_Type_Float_List, nullptr);
|
||||
WValueFloatList* v = reinterpret_cast<WValueFloatList*>(self);
|
||||
return v->values;
|
||||
}
|
||||
|
||||
const double* webview_value_get_double_list(WValue* self) {
|
||||
return_val_if_fail(self != nullptr, nullptr);
|
||||
return_val_if_fail(self->type == Webview_Value_Type_Double_List, nullptr);
|
||||
WValueDoubleList* v = reinterpret_cast<WValueDoubleList*>(self);
|
||||
return v->values;
|
||||
}
|
||||
|
||||
size_t webview_value_get_len(WValue *self)
|
||||
{
|
||||
return_val_if_fail(self != nullptr, 0);
|
||||
return_val_if_fail(self->type == Webview_Value_Type_Uint8_List ||
|
||||
self->type == Webview_Value_Type_Int32_List ||
|
||||
self->type == Webview_Value_Type_Int64_List ||
|
||||
self->type == Webview_Value_Type_Float_List ||
|
||||
self->type == Webview_Value_Type_Double_List ||
|
||||
self->type == Webview_Value_Type_List ||
|
||||
self->type == Webview_Value_Type_Map,
|
||||
0);
|
||||
|
||||
switch (self->type)
|
||||
{
|
||||
case Webview_Value_Type_Uint8_List:
|
||||
{
|
||||
WValueUint8List *v = reinterpret_cast<WValueUint8List *>(self);
|
||||
return v->values_length;
|
||||
}
|
||||
case Webview_Value_Type_Int32_List:
|
||||
{
|
||||
WValueInt32List *v = reinterpret_cast<WValueInt32List *>(self);
|
||||
return v->values_length;
|
||||
}
|
||||
case Webview_Value_Type_Int64_List:
|
||||
{
|
||||
WValueInt64List *v = reinterpret_cast<WValueInt64List *>(self);
|
||||
return v->values_length;
|
||||
}
|
||||
case Webview_Value_Type_Float_List:
|
||||
{
|
||||
WValueFloatList *v = reinterpret_cast<WValueFloatList *>(self);
|
||||
return v->values_length;
|
||||
}
|
||||
case Webview_Value_Type_Double_List:
|
||||
{
|
||||
WValueDoubleList *v = reinterpret_cast<WValueDoubleList *>(self);
|
||||
return v->values_length;
|
||||
}
|
||||
case Webview_Value_Type_List:
|
||||
{
|
||||
WValueList *v = reinterpret_cast<WValueList *>(self);
|
||||
return v->values->len;
|
||||
}
|
||||
case Webview_Value_Type_Map:
|
||||
{
|
||||
WValueMap *v = reinterpret_cast<WValueMap *>(self);
|
||||
return v->keys->len;
|
||||
}
|
||||
case Webview_Value_Type_Null:
|
||||
case Webview_Value_Type_Bool:
|
||||
case Webview_Value_Type_Int:
|
||||
case Webview_Value_Type_Float:
|
||||
case Webview_Value_Type_Double:
|
||||
case Webview_Value_Type_String:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
WValue* webview_value_get_list_value(WValue* self, size_t index) {
|
||||
return_val_if_fail(self != nullptr, nullptr);
|
||||
return_val_if_fail(self->type == Webview_Value_Type_List, nullptr);
|
||||
|
||||
WValueList* v = reinterpret_cast<WValueList*>(self);
|
||||
return static_cast<WValue*>(webview_ptr_array_index(v->values, index));
|
||||
}
|
||||
|
||||
WValue* webview_value_get_key(WValue* value, size_t index)
|
||||
{
|
||||
return_val_if_fail(value != nullptr, nullptr);
|
||||
return_val_if_fail(value->type == Webview_Value_Type_Map, nullptr);
|
||||
|
||||
WValueMap* v = reinterpret_cast<WValueMap*>(value);
|
||||
return static_cast<WValue*>(webview_ptr_array_index(v->keys, index));
|
||||
}
|
||||
|
||||
WValue* webview_value_get_value(WValue* value, size_t index)
|
||||
{
|
||||
return_val_if_fail(value != nullptr, nullptr);
|
||||
return_val_if_fail(value->type == Webview_Value_Type_Map, nullptr);
|
||||
|
||||
WValueMap* v = reinterpret_cast<WValueMap*>(value);
|
||||
return static_cast<WValue*>(webview_ptr_array_index(v->values, index));
|
||||
}
|
||||
|
||||
WValue* webview_value_get_map_key(WValue* self, size_t index) {
|
||||
return_val_if_fail(self != nullptr, nullptr);
|
||||
return_val_if_fail(self->type == Webview_Value_Type_Map, nullptr);
|
||||
|
||||
WValueMap* v = reinterpret_cast<WValueMap*>(self);
|
||||
return static_cast<WValue*>(webview_ptr_array_index(v->keys, index));
|
||||
}
|
||||
|
||||
WValue* webview_value_get_map_value(WValue* self, size_t index) {
|
||||
return_val_if_fail(self != nullptr, nullptr);
|
||||
return_val_if_fail(self->type == Webview_Value_Type_Map, nullptr);
|
||||
|
||||
WValueMap* v = reinterpret_cast<WValueMap*>(self);
|
||||
return static_cast<WValue*>(webview_ptr_array_index(v->values, index));
|
||||
}
|
||||
|
||||
WValue* webview_value_get_by_key(WValue* self, WValue* key) {
|
||||
return_val_if_fail(self != nullptr, nullptr);
|
||||
return_val_if_fail(self->type == Webview_Value_Type_Map, nullptr);
|
||||
|
||||
ssize_t index = webview_value_lookup_index(self, key);
|
||||
if (index < 0) {
|
||||
return nullptr;
|
||||
}
|
||||
return webview_value_get_map_value(self, index);
|
||||
}
|
||||
|
||||
WValue* webview_value_get_by_string(WValue* self, const char* key) {
|
||||
return_val_if_fail(self != nullptr, nullptr);
|
||||
WValue* string_key = webview_value_new_string(key);
|
||||
WValue* value = webview_value_get_by_key(self, string_key);
|
||||
// Explicit unref used because the g_autoptr is triggering a false positive
|
||||
// with clang-tidy.
|
||||
webview_value_unref(string_key);
|
||||
return value;
|
||||
}
|
||||
|
||||
char* webview_value_to_string(WValue* value) {
|
||||
return_val_if_fail(value != nullptr, nullptr);
|
||||
switch (value->type)
|
||||
{
|
||||
case Webview_Value_Type_Null:
|
||||
return strdup("null");
|
||||
case Webview_Value_Type_Bool:
|
||||
return strdup(webview_value_get_bool(value) ? "true" : "false");
|
||||
case Webview_Value_Type_String:
|
||||
return strdup(webview_value_get_string(value));
|
||||
case Webview_Value_Type_Int:
|
||||
{
|
||||
char buf[32];
|
||||
snprintf(buf, sizeof(buf), "%" PRId64, webview_value_get_int(value));
|
||||
return strdup(buf);
|
||||
}
|
||||
case Webview_Value_Type_Float:
|
||||
{
|
||||
char buf[32];
|
||||
snprintf(buf, sizeof(buf), "%f", webview_value_get_float(value));
|
||||
return strdup(buf);
|
||||
}
|
||||
case Webview_Value_Type_Double:
|
||||
{
|
||||
char buf[32];
|
||||
snprintf(buf, sizeof(buf), "%f", webview_value_get_double(value));
|
||||
return strdup(buf);
|
||||
}
|
||||
case Webview_Value_Type_Uint8_List:
|
||||
{
|
||||
char *str = strdup("[");
|
||||
size_t len = webview_value_get_len(value);
|
||||
for(size_t i = 0; i < len; i++){
|
||||
uint8_t item = webview_value_get_uint8_list(value)[i];
|
||||
char buf[32];
|
||||
snprintf(buf, sizeof(buf), "%d", item);
|
||||
strcat(str, buf);
|
||||
if(i != len - 1){
|
||||
strcat(str, ",");
|
||||
}
|
||||
}
|
||||
strcat(str, "]");
|
||||
return str;
|
||||
}
|
||||
case Webview_Value_Type_Int32_List:
|
||||
{
|
||||
char *str = strdup("[");
|
||||
size_t len = webview_value_get_len(value);
|
||||
for(size_t i = 0; i < len; i++){
|
||||
int32_t item = webview_value_get_int32_list(value)[i];
|
||||
char buf[32];
|
||||
snprintf(buf, sizeof(buf), "%d", item);
|
||||
strcat(str, buf);
|
||||
if(i != len - 1){
|
||||
strcat(str, ",");
|
||||
}
|
||||
}
|
||||
strcat(str, "]");
|
||||
return str;
|
||||
}
|
||||
case Webview_Value_Type_Int64_List:
|
||||
{
|
||||
char *str = strdup("[");
|
||||
size_t len = webview_value_get_len(value);
|
||||
for(size_t i = 0; i < len; i++){
|
||||
int64_t item = webview_value_get_int64_list(value)[i];
|
||||
char buf[32];
|
||||
snprintf(buf, sizeof(buf), "%" PRId64, item);
|
||||
strcat(str, buf);
|
||||
if(i != len - 1){
|
||||
strcat(str, ",");
|
||||
}
|
||||
}
|
||||
strcat(str, "]");
|
||||
return str;
|
||||
}
|
||||
case Webview_Value_Type_Float_List:
|
||||
{
|
||||
char *str = strdup("[");
|
||||
size_t len = webview_value_get_len(value);
|
||||
for(size_t i = 0; i < len; i++){
|
||||
float item = webview_value_get_float_list(value)[i];
|
||||
char buf[32];
|
||||
snprintf(buf, sizeof(buf), "%f", item);
|
||||
strcat(str, buf);
|
||||
if(i != len - 1){
|
||||
strcat(str, ",");
|
||||
}
|
||||
}
|
||||
strcat(str, "]");
|
||||
return str;
|
||||
}
|
||||
case Webview_Value_Type_Double_List:
|
||||
{
|
||||
char *str = strdup("[");
|
||||
size_t len = webview_value_get_len(value);
|
||||
for(size_t i = 0; i < len; i++){
|
||||
double item = webview_value_get_double_list(value)[i];
|
||||
char buf[32];
|
||||
snprintf(buf, sizeof(buf), "%f", item);
|
||||
strcat(str, buf);
|
||||
if(i != len - 1){
|
||||
strcat(str, ",");
|
||||
}
|
||||
}
|
||||
strcat(str, "]");
|
||||
return str;
|
||||
}
|
||||
case Webview_Value_Type_List:
|
||||
{
|
||||
char *str = strdup("[");
|
||||
size_t len = webview_value_get_len(value);
|
||||
for(size_t i = 0; i < len; i++){
|
||||
WValue *item = webview_value_get_list_value(value, i);
|
||||
char *item_str = webview_value_to_string(item);
|
||||
strcat(str, item_str);
|
||||
free(item_str);
|
||||
if(i != len - 1){
|
||||
strcat(str, ",");
|
||||
}
|
||||
}
|
||||
strcat(str, "]");
|
||||
return str;
|
||||
}
|
||||
case Webview_Value_Type_Map:
|
||||
{
|
||||
char *str = strdup("{");
|
||||
size_t len = webview_value_get_len(value);
|
||||
for(size_t i = 0; i < len; i++){
|
||||
WValue *key = webview_value_get_map_key(value, i);
|
||||
WValue *item = webview_value_get_map_value(value, i);
|
||||
char *key_str = webview_value_to_string(key);
|
||||
char *item_str = webview_value_to_string(item);
|
||||
strcat(str, key_str);
|
||||
strcat(str, ":");
|
||||
strcat(str, item_str);
|
||||
free(key_str);
|
||||
free(item_str);
|
||||
if(i != len - 1){
|
||||
strcat(str, ",");
|
||||
}
|
||||
}
|
||||
strcat(str, "}");
|
||||
return str;
|
||||
}
|
||||
default:
|
||||
return strdup("<unknown type>");
|
||||
}
|
||||
}
|
||||
80
common/webview_value.h
Normal file
80
common/webview_value.h
Normal file
@@ -0,0 +1,80 @@
|
||||
#ifndef WEBVIEW_CEF_VALUE_H_
|
||||
#define WEBVIEW_CEF_VALUE_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The type of a value.
|
||||
*
|
||||
* the values are represented as a follows:
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct webview_value WValue;
|
||||
|
||||
typedef enum {
|
||||
Webview_Value_Type_Null,
|
||||
Webview_Value_Type_Bool,
|
||||
Webview_Value_Type_Int,
|
||||
Webview_Value_Type_Float,
|
||||
Webview_Value_Type_Double,
|
||||
Webview_Value_Type_String,
|
||||
Webview_Value_Type_Uint8_List,
|
||||
Webview_Value_Type_Int32_List,
|
||||
Webview_Value_Type_Int64_List,
|
||||
Webview_Value_Type_Float_List,
|
||||
Webview_Value_Type_Double_List,
|
||||
Webview_Value_Type_List,
|
||||
Webview_Value_Type_Map,
|
||||
}WValueType;
|
||||
|
||||
WValue* webview_value_new_null();
|
||||
WValue* webview_value_new_bool(bool value);
|
||||
WValue* webview_value_new_int(int64_t value);
|
||||
WValue* webview_value_new_float(float value);
|
||||
WValue* webview_value_new_double(double value);
|
||||
WValue* webview_value_new_string(const char* value);
|
||||
WValue* webview_value_new_string_len(const char* value, size_t len);
|
||||
WValue* webview_value_new_uint8_list(const uint8_t* value, size_t len);
|
||||
WValue* webview_value_new_int32_list(const int32_t* value, size_t len);
|
||||
WValue* webview_value_new_int64_list(const int64_t* value, size_t len);
|
||||
WValue* webview_value_new_float_list(const float* value, size_t len);
|
||||
WValue* webview_value_new_double_list(const double* value, size_t len);
|
||||
WValue* webview_value_new_list();
|
||||
WValue* webview_value_new_map();
|
||||
WValue* webview_value_ref(WValue* value);
|
||||
void webview_value_unref(WValue* value);
|
||||
WValueType webview_value_get_type(WValue* value);
|
||||
bool webview_value_equals(WValue* value1, WValue* value2);
|
||||
void webview_value_append(WValue* parent, WValue* child);
|
||||
void webview_value_set(WValue* parent, WValue* key, WValue* child);
|
||||
void webview_value_set_string(WValue* parent, const char* key, WValue* child);
|
||||
bool webview_value_get_bool(WValue* value);
|
||||
int64_t webview_value_get_int(WValue* value);
|
||||
float webview_value_get_float(WValue* value);
|
||||
double webview_value_get_double(WValue* value);
|
||||
const char* webview_value_get_string(WValue* value);
|
||||
size_t webview_value_get_len(WValue* value);
|
||||
const uint8_t* webview_value_get_uint8_list(WValue* value);
|
||||
const int32_t* webview_value_get_int32_list(WValue* value);
|
||||
const int64_t* webview_value_get_int64_list(WValue* value);
|
||||
const float* webview_value_get_float_list(WValue* value);
|
||||
const double* webview_value_get_double_list(WValue* value);
|
||||
WValue* webview_value_get_list_value(WValue* value, size_t index);
|
||||
WValue* webview_value_get_key(WValue* value, size_t index);
|
||||
WValue* webview_value_get_value(WValue* value, size_t index);
|
||||
WValue* webview_value_get_by_key(WValue* value, WValue* key);
|
||||
WValue* webview_value_get_by_string(WValue* value, const char* key);
|
||||
char* webview_value_to_string(WValue* value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //WEBVIEW_CEF_VALUE_H_
|
||||
3
example/.gitignore
vendored
3
example/.gitignore
vendored
@@ -46,4 +46,5 @@ app.*.map.json
|
||||
/android/app/profile
|
||||
/android/app/release
|
||||
|
||||
GPUCache
|
||||
GPUCache
|
||||
DawnCache
|
||||
30
example/.metadata
Normal file
30
example/.metadata
Normal file
@@ -0,0 +1,30 @@
|
||||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled.
|
||||
|
||||
version:
|
||||
revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
|
||||
channel: stable
|
||||
|
||||
project_type: app
|
||||
|
||||
# Tracks metadata for the flutter migrate command
|
||||
migration:
|
||||
platforms:
|
||||
- platform: root
|
||||
create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
|
||||
base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
|
||||
- platform: linux
|
||||
create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
|
||||
base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
|
||||
|
||||
# User provided section
|
||||
|
||||
# List of Local paths (relative to this file) that should be
|
||||
# ignored by the migrate tool.
|
||||
#
|
||||
# Files that are not part of the templates will be ignored by default.
|
||||
unmanaged_files:
|
||||
- 'lib/main.dart'
|
||||
- 'ios/Runner.xcodeproj/project.pbxproj'
|
||||
1
example/linux/.gitignore
vendored
Normal file
1
example/linux/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
flutter/ephemeral
|
||||
145
example/linux/CMakeLists.txt
Normal file
145
example/linux/CMakeLists.txt
Normal file
@@ -0,0 +1,145 @@
|
||||
# Project-level configuration.
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(runner LANGUAGES CXX)
|
||||
|
||||
# The name of the executable created for the application. Change this to change
|
||||
# the on-disk name of your application.
|
||||
set(BINARY_NAME "example")
|
||||
# The unique GTK application identifier for this application. See:
|
||||
# https://wiki.gnome.org/HowDoI/ChooseApplicationID
|
||||
set(APPLICATION_ID "com.example.example")
|
||||
|
||||
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
|
||||
# versions of CMake.
|
||||
cmake_policy(SET CMP0063 NEW)
|
||||
|
||||
# Load bundled libraries from the lib/ directory relative to the binary.
|
||||
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
|
||||
|
||||
# Root filesystem for cross-building.
|
||||
if(FLUTTER_TARGET_PLATFORM_SYSROOT)
|
||||
set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
|
||||
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
endif()
|
||||
|
||||
# Define build configuration options.
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_BUILD_TYPE "Debug" CACHE
|
||||
STRING "Flutter build mode" FORCE)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||
"Debug" "Profile" "Release")
|
||||
endif()
|
||||
|
||||
# Compilation settings that should be applied to most targets.
|
||||
#
|
||||
# Be cautious about adding new options here, as plugins use this function by
|
||||
# default. In most cases, you should add new options to specific targets instead
|
||||
# of modifying this function.
|
||||
function(APPLY_STANDARD_SETTINGS TARGET)
|
||||
target_compile_features(${TARGET} PUBLIC cxx_std_17)
|
||||
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
|
||||
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
|
||||
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
|
||||
endfunction()
|
||||
|
||||
# Flutter library and tool build rules.
|
||||
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
|
||||
add_subdirectory(${FLUTTER_MANAGED_DIR})
|
||||
|
||||
# System-level dependencies.
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
|
||||
|
||||
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
|
||||
|
||||
# Define the application target. To change its name, change BINARY_NAME above,
|
||||
# not the value here, or `flutter run` will no longer work.
|
||||
#
|
||||
# Any new source files that you add to the application should be added here.
|
||||
add_executable(${BINARY_NAME}
|
||||
"main.cc"
|
||||
"my_application.cc"
|
||||
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
|
||||
)
|
||||
|
||||
# Apply the standard set of build settings. This can be removed for applications
|
||||
# that need different build settings.
|
||||
apply_standard_settings(${BINARY_NAME})
|
||||
|
||||
# Add dependency libraries. Add any application-specific dependencies here.
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
|
||||
|
||||
# Run the Flutter tool portions of the build. This must not be removed.
|
||||
add_dependencies(${BINARY_NAME} flutter_assemble)
|
||||
|
||||
# Only the install-generated bundle's copy of the executable will launch
|
||||
# correctly, since the resources must in the right relative locations. To avoid
|
||||
# people trying to run the unbundled copy, put it in a subdirectory instead of
|
||||
# the default top-level location.
|
||||
set_target_properties(${BINARY_NAME}
|
||||
PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
|
||||
)
|
||||
|
||||
# Generated plugin build rules, which manage building the plugins and adding
|
||||
# them to the application.
|
||||
include(flutter/generated_plugins.cmake)
|
||||
|
||||
|
||||
# === Installation ===
|
||||
# By default, "installing" just makes a relocatable bundle in the build
|
||||
# directory.
|
||||
set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
|
||||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
|
||||
endif()
|
||||
|
||||
# Start with a clean build bundle directory every time.
|
||||
install(CODE "
|
||||
file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
|
||||
" COMPONENT Runtime)
|
||||
|
||||
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
|
||||
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
|
||||
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
# Solved: Flutter build failed with locales is Directory
|
||||
#
|
||||
# foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
|
||||
# install(FILES "${bundled_library}"
|
||||
# DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
# COMPONENT Runtime)
|
||||
# endforeach(bundled_library)
|
||||
if(PLUGIN_BUNDLED_LIBRARIES)
|
||||
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
|
||||
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
COMPONENT Runtime)
|
||||
endif()
|
||||
|
||||
# Fully re-copy the assets directory on each build to avoid having stale files
|
||||
# from a previous install.
|
||||
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
|
||||
install(CODE "
|
||||
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
|
||||
" COMPONENT Runtime)
|
||||
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
|
||||
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
|
||||
|
||||
# Install the AOT library on non-Debug builds only.
|
||||
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
COMPONENT Runtime)
|
||||
endif()
|
||||
88
example/linux/flutter/CMakeLists.txt
Normal file
88
example/linux/flutter/CMakeLists.txt
Normal file
@@ -0,0 +1,88 @@
|
||||
# This file controls Flutter-level build steps. It should not be edited.
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
|
||||
|
||||
# Configuration provided via flutter tool.
|
||||
include(${EPHEMERAL_DIR}/generated_config.cmake)
|
||||
|
||||
# TODO: Move the rest of this into files in ephemeral. See
|
||||
# https://github.com/flutter/flutter/issues/57146.
|
||||
|
||||
# Serves the same purpose as list(TRANSFORM ... PREPEND ...),
|
||||
# which isn't available in 3.10.
|
||||
function(list_prepend LIST_NAME PREFIX)
|
||||
set(NEW_LIST "")
|
||||
foreach(element ${${LIST_NAME}})
|
||||
list(APPEND NEW_LIST "${PREFIX}${element}")
|
||||
endforeach(element)
|
||||
set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# === Flutter Library ===
|
||||
# System-level dependencies.
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
|
||||
pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
|
||||
pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
|
||||
|
||||
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
|
||||
|
||||
# Published to parent scope for install step.
|
||||
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
|
||||
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
|
||||
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
|
||||
set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
|
||||
|
||||
list(APPEND FLUTTER_LIBRARY_HEADERS
|
||||
"fl_basic_message_channel.h"
|
||||
"fl_binary_codec.h"
|
||||
"fl_binary_messenger.h"
|
||||
"fl_dart_project.h"
|
||||
"fl_engine.h"
|
||||
"fl_json_message_codec.h"
|
||||
"fl_json_method_codec.h"
|
||||
"fl_message_codec.h"
|
||||
"fl_method_call.h"
|
||||
"fl_method_channel.h"
|
||||
"fl_method_codec.h"
|
||||
"fl_method_response.h"
|
||||
"fl_plugin_registrar.h"
|
||||
"fl_plugin_registry.h"
|
||||
"fl_standard_message_codec.h"
|
||||
"fl_standard_method_codec.h"
|
||||
"fl_string_codec.h"
|
||||
"fl_value.h"
|
||||
"fl_view.h"
|
||||
"flutter_linux.h"
|
||||
)
|
||||
list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
|
||||
add_library(flutter INTERFACE)
|
||||
target_include_directories(flutter INTERFACE
|
||||
"${EPHEMERAL_DIR}"
|
||||
)
|
||||
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
|
||||
target_link_libraries(flutter INTERFACE
|
||||
PkgConfig::GTK
|
||||
PkgConfig::GLIB
|
||||
PkgConfig::GIO
|
||||
)
|
||||
add_dependencies(flutter flutter_assemble)
|
||||
|
||||
# === Flutter tool backend ===
|
||||
# _phony_ is a non-existent file to force this command to run every time,
|
||||
# since currently there's no way to get a full input/output list from the
|
||||
# flutter tool.
|
||||
add_custom_command(
|
||||
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/_phony_
|
||||
COMMAND ${CMAKE_COMMAND} -E env
|
||||
${FLUTTER_TOOL_ENVIRONMENT}
|
||||
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
|
||||
${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(flutter_assemble DEPENDS
|
||||
"${FLUTTER_LIBRARY}"
|
||||
${FLUTTER_LIBRARY_HEADERS}
|
||||
)
|
||||
15
example/linux/flutter/generated_plugin_registrant.cc
Normal file
15
example/linux/flutter/generated_plugin_registrant.cc
Normal file
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <webview_cef/webview_cef_plugin.h>
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) webview_cef_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "WebviewCefPlugin");
|
||||
webview_cef_plugin_register_with_registrar(webview_cef_registrar);
|
||||
}
|
||||
15
example/linux/flutter/generated_plugin_registrant.h
Normal file
15
example/linux/flutter/generated_plugin_registrant.h
Normal file
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#ifndef GENERATED_PLUGIN_REGISTRANT_
|
||||
#define GENERATED_PLUGIN_REGISTRANT_
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
|
||||
// Registers Flutter plugins.
|
||||
void fl_register_plugins(FlPluginRegistry* registry);
|
||||
|
||||
#endif // GENERATED_PLUGIN_REGISTRANT_
|
||||
24
example/linux/flutter/generated_plugins.cmake
Normal file
24
example/linux/flutter/generated_plugins.cmake
Normal file
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# Generated file, do not edit.
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
webview_cef
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
)
|
||||
|
||||
set(PLUGIN_BUNDLED_LIBRARIES)
|
||||
|
||||
foreach(plugin ${FLUTTER_PLUGIN_LIST})
|
||||
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
|
||||
endforeach(plugin)
|
||||
|
||||
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
|
||||
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
|
||||
endforeach(ffi_plugin)
|
||||
8
example/linux/main.cc
Normal file
8
example/linux/main.cc
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "my_application.h"
|
||||
#include <webview_cef/webview_cef_plugin.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
initCEFProcesses(argc, argv);
|
||||
g_autoptr(MyApplication) app = my_application_new();
|
||||
return g_application_run(G_APPLICATION(app), argc, argv);
|
||||
}
|
||||
107
example/linux/my_application.cc
Normal file
107
example/linux/my_application.cc
Normal file
@@ -0,0 +1,107 @@
|
||||
#include "my_application.h"
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#include <gdk/gdkx.h>
|
||||
#endif
|
||||
|
||||
#include "flutter/generated_plugin_registrant.h"
|
||||
#include <webview_cef/webview_cef_plugin.h>
|
||||
|
||||
struct _MyApplication {
|
||||
GtkApplication parent_instance;
|
||||
char** dart_entrypoint_arguments;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
|
||||
|
||||
// Implements GApplication::activate.
|
||||
static void my_application_activate(GApplication* application) {
|
||||
MyApplication* self = MY_APPLICATION(application);
|
||||
GtkWindow* window =
|
||||
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
|
||||
|
||||
// Use a header bar when running in GNOME as this is the common style used
|
||||
// by applications and is the setup most users will be using (e.g. Ubuntu
|
||||
// desktop).
|
||||
// If running on X and not using GNOME then just use a traditional title bar
|
||||
// in case the window manager does more exotic layout, e.g. tiling.
|
||||
// If running on Wayland assume the header bar will work (may need changing
|
||||
// if future cases occur).
|
||||
gboolean use_header_bar = TRUE;
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
GdkScreen* screen = gtk_window_get_screen(window);
|
||||
if (GDK_IS_X11_SCREEN(screen)) {
|
||||
const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
|
||||
if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
|
||||
use_header_bar = FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (use_header_bar) {
|
||||
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
|
||||
gtk_widget_show(GTK_WIDGET(header_bar));
|
||||
gtk_header_bar_set_title(header_bar, "example");
|
||||
gtk_header_bar_set_show_close_button(header_bar, TRUE);
|
||||
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
|
||||
} else {
|
||||
gtk_window_set_title(window, "example");
|
||||
}
|
||||
|
||||
gtk_window_set_default_size(window, 1280, 720);
|
||||
gtk_widget_show(GTK_WIDGET(window));
|
||||
|
||||
g_autoptr(FlDartProject) project = fl_dart_project_new();
|
||||
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
|
||||
|
||||
FlView* view = fl_view_new(project);
|
||||
g_signal_connect(view, "key_press_event", G_CALLBACK(processKeyEventForCEF), nullptr);
|
||||
g_signal_connect(view, "key_release_event", G_CALLBACK(processKeyEventForCEF), nullptr);
|
||||
gtk_widget_show(GTK_WIDGET(view));
|
||||
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
|
||||
|
||||
fl_register_plugins(FL_PLUGIN_REGISTRY(view));
|
||||
|
||||
gtk_widget_grab_focus(GTK_WIDGET(view));
|
||||
}
|
||||
|
||||
// Implements GApplication::local_command_line.
|
||||
static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) {
|
||||
MyApplication* self = MY_APPLICATION(application);
|
||||
// Strip out the first argument as it is the binary name.
|
||||
self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
|
||||
|
||||
g_autoptr(GError) error = nullptr;
|
||||
if (!g_application_register(application, nullptr, &error)) {
|
||||
g_warning("Failed to register: %s", error->message);
|
||||
*exit_status = 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
g_application_activate(application);
|
||||
*exit_status = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Implements GObject::dispose.
|
||||
static void my_application_dispose(GObject* object) {
|
||||
MyApplication* self = MY_APPLICATION(object);
|
||||
g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
|
||||
G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
|
||||
}
|
||||
|
||||
static void my_application_class_init(MyApplicationClass* klass) {
|
||||
G_APPLICATION_CLASS(klass)->activate = my_application_activate;
|
||||
G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
|
||||
G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
|
||||
}
|
||||
|
||||
static void my_application_init(MyApplication* self) {}
|
||||
|
||||
MyApplication* my_application_new() {
|
||||
return MY_APPLICATION(g_object_new(my_application_get_type(),
|
||||
"application-id", APPLICATION_ID,
|
||||
"flags", G_APPLICATION_NON_UNIQUE,
|
||||
nullptr));
|
||||
}
|
||||
18
example/linux/my_application.h
Normal file
18
example/linux/my_application.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef FLUTTER_MY_APPLICATION_H_
|
||||
#define FLUTTER_MY_APPLICATION_H_
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
|
||||
GtkApplication)
|
||||
|
||||
/**
|
||||
* my_application_new:
|
||||
*
|
||||
* Creates a new Flutter-based application.
|
||||
*
|
||||
* Returns: a new #MyApplication.
|
||||
*/
|
||||
MyApplication* my_application_new();
|
||||
|
||||
#endif // FLUTTER_MY_APPLICATION_H_
|
||||
@@ -15,6 +15,7 @@ class WebViewController extends ValueNotifier<bool> {
|
||||
int _textureId = 0;
|
||||
bool _isDisposed = false;
|
||||
WebviewEventsListener? _listener;
|
||||
bool _focusEditable = false;
|
||||
|
||||
final Map<String, JavascriptChannel> _javascriptChannels =
|
||||
<String, JavascriptChannel>{};
|
||||
@@ -124,6 +125,10 @@ class WebViewController extends ValueNotifier<bool> {
|
||||
return _pluginChannel.invokeMethod('openDevTools');
|
||||
}
|
||||
|
||||
Future<void> setClientFocus(bool focus) {
|
||||
return _pluginChannel.invokeMethod('setClientFocus', [focus]);
|
||||
}
|
||||
|
||||
Future<void> setCookie(String domain, String key, String val) async {
|
||||
if (_isDisposed) {
|
||||
return;
|
||||
@@ -168,7 +173,7 @@ class WebViewController extends ValueNotifier<bool> {
|
||||
});
|
||||
|
||||
return _pluginChannel.invokeMethod('setJavaScriptChannels',
|
||||
[_extractJavascriptChannelNames(channels).toList()]);
|
||||
_extractJavascriptChannelNames(channels).toList());
|
||||
}
|
||||
|
||||
Future<void> sendJavaScriptChannelCallBack(
|
||||
@@ -282,6 +287,7 @@ class WebView extends StatefulWidget {
|
||||
|
||||
class WebViewState extends State<WebView> {
|
||||
final GlobalKey _key = GlobalKey();
|
||||
late final _focusNode = FocusNode();
|
||||
|
||||
WebViewController get _controller => widget.controller;
|
||||
|
||||
@@ -295,21 +301,38 @@ class WebViewState extends State<WebView> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox.expand(key: _key, child: _buildInner());
|
||||
return Focus(
|
||||
autofocus: true,
|
||||
focusNode: _focusNode,
|
||||
canRequestFocus: true,
|
||||
debugLabel: "webview_cef",
|
||||
onFocusChange: (focused) {
|
||||
_controller.setClientFocus(focused);
|
||||
},
|
||||
child: SizedBox.expand(key: _key, child: _buildInner()),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInner() {
|
||||
return NotificationListener<SizeChangedLayoutNotification>(
|
||||
onNotification: (notification) {
|
||||
_reportSurfaceSize(context);
|
||||
return true;
|
||||
},
|
||||
child: SizeChangedLayoutNotifier(
|
||||
child: Listener(
|
||||
onNotification: (notification) {
|
||||
_reportSurfaceSize(context);
|
||||
return true;
|
||||
},
|
||||
child: SizeChangedLayoutNotifier(
|
||||
child: Listener(
|
||||
onPointerHover: (ev) {
|
||||
_controller._cursorMove(ev.localPosition);
|
||||
},
|
||||
onPointerDown: (ev) {
|
||||
if (!_focusNode.hasFocus) {
|
||||
_focusNode.requestFocus();
|
||||
Future.delayed(const Duration(milliseconds: 50), () {
|
||||
if (!_focusNode.hasFocus) {
|
||||
_focusNode.requestFocus();
|
||||
}
|
||||
});
|
||||
}
|
||||
_controller._cursorClickDown(ev.localPosition);
|
||||
},
|
||||
onPointerUp: (ev) {
|
||||
@@ -329,7 +352,9 @@ class WebViewState extends State<WebView> {
|
||||
event.panDelta.dx.round(), event.panDelta.dy.round());
|
||||
},
|
||||
child: Texture(textureId: _controller._textureId),
|
||||
)));
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _reportSurfaceSize(BuildContext context) async {
|
||||
|
||||
17
lib/webview_cef_method_channel.dart
Normal file
17
lib/webview_cef_method_channel.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'webview_cef_platform_interface.dart';
|
||||
|
||||
/// An implementation of [WebviewCefPlatform] that uses method channels.
|
||||
class MethodChannelWebviewCef extends WebviewCefPlatform {
|
||||
/// The method channel used to interact with the native platform.
|
||||
@visibleForTesting
|
||||
final methodChannel = const MethodChannel('webview_cef');
|
||||
|
||||
@override
|
||||
Future<String?> getPlatformVersion() async {
|
||||
final version = await methodChannel.invokeMethod<String>('getPlatformVersion');
|
||||
return version;
|
||||
}
|
||||
}
|
||||
29
lib/webview_cef_platform_interface.dart
Normal file
29
lib/webview_cef_platform_interface.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
|
||||
|
||||
import 'webview_cef_method_channel.dart';
|
||||
|
||||
abstract class WebviewCefPlatform extends PlatformInterface {
|
||||
/// Constructs a WebviewCefPlatform.
|
||||
WebviewCefPlatform() : super(token: _token);
|
||||
|
||||
static final Object _token = Object();
|
||||
|
||||
static WebviewCefPlatform _instance = MethodChannelWebviewCef();
|
||||
|
||||
/// The default instance of [WebviewCefPlatform] to use.
|
||||
///
|
||||
/// Defaults to [MethodChannelWebviewCef].
|
||||
static WebviewCefPlatform get instance => _instance;
|
||||
|
||||
/// Platform-specific implementations should set this with their own
|
||||
/// platform-specific class that extends [WebviewCefPlatform] when
|
||||
/// they register themselves.
|
||||
static set instance(WebviewCefPlatform instance) {
|
||||
PlatformInterface.verifyToken(instance, _token);
|
||||
_instance = instance;
|
||||
}
|
||||
|
||||
Future<String?> getPlatformVersion() {
|
||||
throw UnimplementedError('platformVersion() has not been implemented.');
|
||||
}
|
||||
}
|
||||
20
linux/.gitignore
vendored
Normal file
20
linux/.gitignore
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
flutter/
|
||||
|
||||
# Visual Studio user-specific files.
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# Visual Studio build-related files.
|
||||
x64/
|
||||
x86/
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
|
||||
cmake-build-debug
|
||||
prebuilt.zip
|
||||
112
linux/CMakeLists.txt
Normal file
112
linux/CMakeLists.txt
Normal file
@@ -0,0 +1,112 @@
|
||||
# The Flutter tooling requires that developers have CMake 3.10 or later
|
||||
# installed. You should not increase this version, as doing so will cause
|
||||
# the plugin to fail to compile for some customers of the plugin.
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
#supass warning
|
||||
cmake_policy(SET CMP0074 NEW)
|
||||
|
||||
# Project-level configuration.
|
||||
set(PROJECT_NAME "webview_cef")
|
||||
project(${PROJECT_NAME} LANGUAGES CXX C)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../third/download.cmake)
|
||||
prepare_prebuilt_files(${CMAKE_CURRENT_SOURCE_DIR}/../third/cef)
|
||||
|
||||
set(CEF_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../third/cef")
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CEF_ROOT}/cmake")
|
||||
find_package(CEF REQUIRED)
|
||||
|
||||
# This value is used when generating builds using this plugin, so it must
|
||||
# not be changed.
|
||||
set(PLUGIN_NAME "webview_cef_plugin")
|
||||
|
||||
# Define the plugin library target. Its name must not be changed (see comment
|
||||
# on PLUGIN_NAME above).
|
||||
#
|
||||
# Any new source files that you add to the plugin should be added here.
|
||||
add_library(${PLUGIN_NAME} SHARED
|
||||
"webview_cef_plugin.cc"
|
||||
"webview_cef_keyevent.h"
|
||||
"webview_cef_texture.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_app.cc"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_app.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_handler.cc"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_handler.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_plugin.cc"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_plugin.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_value.cc"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_value.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_js_handler.cc"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_js_handler.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_cookieVisitor.cc"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../common/webview_cookieVisitor.h"
|
||||
)
|
||||
|
||||
# Apply a standard set of build settings that are configured in the
|
||||
# application-level CMakeLists.txt. This can be removed for plugins that want
|
||||
# full control over build settings.
|
||||
apply_standard_settings(${PLUGIN_NAME})
|
||||
|
||||
# Symbols are hidden by default to reduce the chance of accidental conflicts
|
||||
# between plugins. This should not be removed; any symbols that should be
|
||||
# exported should be explicitly exported with the FLUTTER_PLUGIN_EXPORT macro.
|
||||
set_target_properties(${PLUGIN_NAME} PROPERTIES
|
||||
CXX_VISIBILITY_PRESET hidden)
|
||||
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
|
||||
|
||||
# Source include directories and library dependencies. Add any plugin-specific
|
||||
# dependencies here.
|
||||
target_include_directories(${PLUGIN_NAME} INTERFACE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)
|
||||
target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
|
||||
|
||||
target_include_directories(${PLUGIN_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../common")
|
||||
|
||||
#########################################cef#########################################
|
||||
set(CEF_TARGET ${PLUGIN_NAME})
|
||||
ADD_LOGICAL_TARGET("libcef_lib" "${CEF_LIB_DEBUG}" "${CEF_LIB_RELEASE}")
|
||||
SET_CEF_TARGET_OUT_DIR()
|
||||
add_subdirectory(${CEF_LIBCEF_DLL_WRAPPER_PATH} libcef_dll_wrapper)
|
||||
|
||||
# Find required libraries and update compiler/linker variables.
|
||||
FIND_LINUX_LIBRARIES("gmodule-2.0 gtk+-3.0 gthread-2.0 gtk+-unix-print-3.0 xi")
|
||||
|
||||
# Executable target.
|
||||
# add_executable(${CEF_TARGET} ${CEFCLIENT_SRCS})
|
||||
SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_TARGET})
|
||||
add_dependencies(${CEF_TARGET} libcef_dll_wrapper)
|
||||
target_link_libraries(${CEF_TARGET} PUBLIC libcef_lib libcef_dll_wrapper "GL" ${CEF_STANDARD_LIBS})
|
||||
|
||||
# Set rpath so that libraries can be placed next to the executable.
|
||||
set_target_properties(${CEF_TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN")
|
||||
set_target_properties(${CEF_TARGET} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
set_target_properties(${CEF_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CEF_TARGET_OUT_DIR})
|
||||
|
||||
# We don't call deprecated GTK functions, and they can cause build failures, so disable them.
|
||||
add_definitions("-DGTK_DISABLE_DEPRECATED")
|
||||
|
||||
# Set SUID permissions on the chrome-sandbox target.
|
||||
SET_LINUX_SUID_PERMISSIONS("${CEF_TARGET}" "${CEF_TARGET_OUT_DIR}/chrome-sandbox")
|
||||
|
||||
#set CEF binary and resource files which need to copy to the target output directory
|
||||
set(cef_library_list "")
|
||||
foreach(FILE ${CEF_BINARY_FILES})
|
||||
list(APPEND cef_library_list ${CEF_BINARY_DIR}/${FILE})
|
||||
endforeach()
|
||||
foreach(FILE ${CEF_RESOURCE_FILES})
|
||||
|
||||
list(APPEND cef_library_list ${CEF_RESOURCE_DIR}/${FILE})
|
||||
endforeach(FILE)
|
||||
#######################################cef end#######################################
|
||||
|
||||
# List of absolute paths to libraries that should be bundled with the plugin.
|
||||
# This list could contain prebuilt libraries, or libraries created by an
|
||||
# external build triggered from this build file.
|
||||
set(webview_cef_bundled_libraries
|
||||
""
|
||||
${cef_library_list}
|
||||
PARENT_SCOPE
|
||||
)
|
||||
30
linux/include/webview_cef/webview_cef_plugin.h
Normal file
30
linux/include/webview_cef/webview_cef_plugin.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef FLUTTER_PLUGIN_WEBVIEW_CEF_PLUGIN_H_
|
||||
#define FLUTTER_PLUGIN_WEBVIEW_CEF_PLUGIN_H_
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#ifdef FLUTTER_PLUGIN_IMPL
|
||||
#define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default")))
|
||||
#else
|
||||
#define FLUTTER_PLUGIN_EXPORT
|
||||
#endif
|
||||
|
||||
typedef struct _WebviewCefPlugin WebviewCefPlugin;
|
||||
typedef struct {
|
||||
GObjectClass parent_class;
|
||||
} WebviewCefPluginClass;
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT GType webview_cef_plugin_get_type();
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void webview_cef_plugin_register_with_registrar(
|
||||
FlPluginRegistrar* registrar);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void initCEFProcesses(int argc, char** argv);
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT gboolean processKeyEventForCEF(GtkWidget* widget, GdkEventKey* event, gpointer data);
|
||||
|
||||
#endif // FLUTTER_PLUGIN_WEBVIEW_CEF_PLUGIN_H_
|
||||
850
linux/webview_cef_keyevent.h
Normal file
850
linux/webview_cef_keyevent.h
Normal file
@@ -0,0 +1,850 @@
|
||||
#ifndef WEBVIEW_CEF_KEYEVENT_H_
|
||||
#define WEBVIEW_CEF_KEYEVENT_H_
|
||||
|
||||
// #include <flutter_linux/flutter_linux.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gdk/gdkkeysyms-compat.h>
|
||||
|
||||
#define XK_3270 // for XK_3270_BackTab
|
||||
#include <X11/XF86keysym.h>
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
#include <X11/keysym.h>
|
||||
|
||||
enum KeyboardCode {
|
||||
VKEY_BACK = 0x08,
|
||||
VKEY_TAB = 0x09,
|
||||
VKEY_BACKTAB = 0x0A,
|
||||
VKEY_CLEAR = 0x0C,
|
||||
VKEY_RETURN = 0x0D,
|
||||
VKEY_SHIFT = 0x10,
|
||||
VKEY_CONTROL = 0x11,
|
||||
VKEY_MENU = 0x12,
|
||||
VKEY_PAUSE = 0x13,
|
||||
VKEY_CAPITAL = 0x14,
|
||||
VKEY_KANA = 0x15,
|
||||
VKEY_HANGUL = 0x15,
|
||||
VKEY_JUNJA = 0x17,
|
||||
VKEY_FINAL = 0x18,
|
||||
VKEY_HANJA = 0x19,
|
||||
VKEY_KANJI = 0x19,
|
||||
VKEY_ESCAPE = 0x1B,
|
||||
VKEY_CONVERT = 0x1C,
|
||||
VKEY_NONCONVERT = 0x1D,
|
||||
VKEY_ACCEPT = 0x1E,
|
||||
VKEY_MODECHANGE = 0x1F,
|
||||
VKEY_SPACE = 0x20,
|
||||
VKEY_PRIOR = 0x21,
|
||||
VKEY_NEXT = 0x22,
|
||||
VKEY_END = 0x23,
|
||||
VKEY_HOME = 0x24,
|
||||
VKEY_LEFT = 0x25,
|
||||
VKEY_UP = 0x26,
|
||||
VKEY_RIGHT = 0x27,
|
||||
VKEY_DOWN = 0x28,
|
||||
VKEY_SELECT = 0x29,
|
||||
VKEY_PRINT = 0x2A,
|
||||
VKEY_EXECUTE = 0x2B,
|
||||
VKEY_SNAPSHOT = 0x2C,
|
||||
VKEY_INSERT = 0x2D,
|
||||
VKEY_DELETE = 0x2E,
|
||||
VKEY_HELP = 0x2F,
|
||||
VKEY_0 = 0x30,
|
||||
VKEY_1 = 0x31,
|
||||
VKEY_2 = 0x32,
|
||||
VKEY_3 = 0x33,
|
||||
VKEY_4 = 0x34,
|
||||
VKEY_5 = 0x35,
|
||||
VKEY_6 = 0x36,
|
||||
VKEY_7 = 0x37,
|
||||
VKEY_8 = 0x38,
|
||||
VKEY_9 = 0x39,
|
||||
VKEY_A = 0x41,
|
||||
VKEY_B = 0x42,
|
||||
VKEY_C = 0x43,
|
||||
VKEY_D = 0x44,
|
||||
VKEY_E = 0x45,
|
||||
VKEY_F = 0x46,
|
||||
VKEY_G = 0x47,
|
||||
VKEY_H = 0x48,
|
||||
VKEY_I = 0x49,
|
||||
VKEY_J = 0x4A,
|
||||
VKEY_K = 0x4B,
|
||||
VKEY_L = 0x4C,
|
||||
VKEY_M = 0x4D,
|
||||
VKEY_N = 0x4E,
|
||||
VKEY_O = 0x4F,
|
||||
VKEY_P = 0x50,
|
||||
VKEY_Q = 0x51,
|
||||
VKEY_R = 0x52,
|
||||
VKEY_S = 0x53,
|
||||
VKEY_T = 0x54,
|
||||
VKEY_U = 0x55,
|
||||
VKEY_V = 0x56,
|
||||
VKEY_W = 0x57,
|
||||
VKEY_X = 0x58,
|
||||
VKEY_Y = 0x59,
|
||||
VKEY_Z = 0x5A,
|
||||
VKEY_LWIN = 0x5B,
|
||||
VKEY_COMMAND = VKEY_LWIN, // Provide the Mac name for convenience.
|
||||
VKEY_RWIN = 0x5C,
|
||||
VKEY_APPS = 0x5D,
|
||||
VKEY_SLEEP = 0x5F,
|
||||
VKEY_NUMPAD0 = 0x60,
|
||||
VKEY_NUMPAD1 = 0x61,
|
||||
VKEY_NUMPAD2 = 0x62,
|
||||
VKEY_NUMPAD3 = 0x63,
|
||||
VKEY_NUMPAD4 = 0x64,
|
||||
VKEY_NUMPAD5 = 0x65,
|
||||
VKEY_NUMPAD6 = 0x66,
|
||||
VKEY_NUMPAD7 = 0x67,
|
||||
VKEY_NUMPAD8 = 0x68,
|
||||
VKEY_NUMPAD9 = 0x69,
|
||||
VKEY_MULTIPLY = 0x6A,
|
||||
VKEY_ADD = 0x6B,
|
||||
VKEY_SEPARATOR = 0x6C,
|
||||
VKEY_SUBTRACT = 0x6D,
|
||||
VKEY_DECIMAL = 0x6E,
|
||||
VKEY_DIVIDE = 0x6F,
|
||||
VKEY_F1 = 0x70,
|
||||
VKEY_F2 = 0x71,
|
||||
VKEY_F3 = 0x72,
|
||||
VKEY_F4 = 0x73,
|
||||
VKEY_F5 = 0x74,
|
||||
VKEY_F6 = 0x75,
|
||||
VKEY_F7 = 0x76,
|
||||
VKEY_F8 = 0x77,
|
||||
VKEY_F9 = 0x78,
|
||||
VKEY_F10 = 0x79,
|
||||
VKEY_F11 = 0x7A,
|
||||
VKEY_F12 = 0x7B,
|
||||
VKEY_F13 = 0x7C,
|
||||
VKEY_F14 = 0x7D,
|
||||
VKEY_F15 = 0x7E,
|
||||
VKEY_F16 = 0x7F,
|
||||
VKEY_F17 = 0x80,
|
||||
VKEY_F18 = 0x81,
|
||||
VKEY_F19 = 0x82,
|
||||
VKEY_F20 = 0x83,
|
||||
VKEY_F21 = 0x84,
|
||||
VKEY_F22 = 0x85,
|
||||
VKEY_F23 = 0x86,
|
||||
VKEY_F24 = 0x87,
|
||||
VKEY_NUMLOCK = 0x90,
|
||||
VKEY_SCROLL = 0x91,
|
||||
VKEY_LSHIFT = 0xA0,
|
||||
VKEY_RSHIFT = 0xA1,
|
||||
VKEY_LCONTROL = 0xA2,
|
||||
VKEY_RCONTROL = 0xA3,
|
||||
VKEY_LMENU = 0xA4,
|
||||
VKEY_RMENU = 0xA5,
|
||||
VKEY_BROWSER_BACK = 0xA6,
|
||||
VKEY_BROWSER_FORWARD = 0xA7,
|
||||
VKEY_BROWSER_REFRESH = 0xA8,
|
||||
VKEY_BROWSER_STOP = 0xA9,
|
||||
VKEY_BROWSER_SEARCH = 0xAA,
|
||||
VKEY_BROWSER_FAVORITES = 0xAB,
|
||||
VKEY_BROWSER_HOME = 0xAC,
|
||||
VKEY_VOLUME_MUTE = 0xAD,
|
||||
VKEY_VOLUME_DOWN = 0xAE,
|
||||
VKEY_VOLUME_UP = 0xAF,
|
||||
VKEY_MEDIA_NEXT_TRACK = 0xB0,
|
||||
VKEY_MEDIA_PREV_TRACK = 0xB1,
|
||||
VKEY_MEDIA_STOP = 0xB2,
|
||||
VKEY_MEDIA_PLAY_PAUSE = 0xB3,
|
||||
VKEY_MEDIA_LAUNCH_MAIL = 0xB4,
|
||||
VKEY_MEDIA_LAUNCH_MEDIA_SELECT = 0xB5,
|
||||
VKEY_MEDIA_LAUNCH_APP1 = 0xB6,
|
||||
VKEY_MEDIA_LAUNCH_APP2 = 0xB7,
|
||||
VKEY_OEM_1 = 0xBA,
|
||||
VKEY_OEM_PLUS = 0xBB,
|
||||
VKEY_OEM_COMMA = 0xBC,
|
||||
VKEY_OEM_MINUS = 0xBD,
|
||||
VKEY_OEM_PERIOD = 0xBE,
|
||||
VKEY_OEM_2 = 0xBF,
|
||||
VKEY_OEM_3 = 0xC0,
|
||||
VKEY_OEM_4 = 0xDB,
|
||||
VKEY_OEM_5 = 0xDC,
|
||||
VKEY_OEM_6 = 0xDD,
|
||||
VKEY_OEM_7 = 0xDE,
|
||||
VKEY_OEM_8 = 0xDF,
|
||||
VKEY_OEM_102 = 0xE2,
|
||||
VKEY_OEM_103 = 0xE3, // GTV KEYCODE_MEDIA_REWIND
|
||||
VKEY_OEM_104 = 0xE4, // GTV KEYCODE_MEDIA_FAST_FORWARD
|
||||
VKEY_PROCESSKEY = 0xE5,
|
||||
VKEY_PACKET = 0xE7,
|
||||
VKEY_DBE_SBCSCHAR = 0xF3,
|
||||
VKEY_DBE_DBCSCHAR = 0xF4,
|
||||
VKEY_ATTN = 0xF6,
|
||||
VKEY_CRSEL = 0xF7,
|
||||
VKEY_EXSEL = 0xF8,
|
||||
VKEY_EREOF = 0xF9,
|
||||
VKEY_PLAY = 0xFA,
|
||||
VKEY_ZOOM = 0xFB,
|
||||
VKEY_NONAME = 0xFC,
|
||||
VKEY_PA1 = 0xFD,
|
||||
VKEY_OEM_CLEAR = 0xFE,
|
||||
VKEY_UNKNOWN = 0,
|
||||
|
||||
// POSIX specific VKEYs. Note that as of Windows SDK 7.1, 0x97-9F, 0xD8-DA,
|
||||
// and 0xE8 are unassigned.
|
||||
VKEY_WLAN = 0x97,
|
||||
VKEY_POWER = 0x98,
|
||||
VKEY_BRIGHTNESS_DOWN = 0xD8,
|
||||
VKEY_BRIGHTNESS_UP = 0xD9,
|
||||
VKEY_KBD_BRIGHTNESS_DOWN = 0xDA,
|
||||
VKEY_KBD_BRIGHTNESS_UP = 0xE8,
|
||||
|
||||
// Windows does not have a specific key code for AltGr. We use the unused 0xE1
|
||||
// (VK_OEM_AX) code to represent AltGr, matching the behaviour of Firefox on
|
||||
// Linux.
|
||||
VKEY_ALTGR = 0xE1,
|
||||
// Windows does not have a specific key code for Compose. We use the unused
|
||||
// 0xE6 (VK_ICO_CLEAR) code to represent Compose.
|
||||
VKEY_COMPOSE = 0xE6,
|
||||
};
|
||||
|
||||
KeyboardCode KeyboardCodeFromXKeysym(unsigned int keysym) {
|
||||
switch (keysym) {
|
||||
case XK_BackSpace:
|
||||
return VKEY_BACK;
|
||||
case XK_Delete:
|
||||
case XK_KP_Delete:
|
||||
return VKEY_DELETE;
|
||||
case XK_Tab:
|
||||
case XK_KP_Tab:
|
||||
case XK_ISO_Left_Tab:
|
||||
case XK_3270_BackTab:
|
||||
return VKEY_TAB;
|
||||
case XK_Linefeed:
|
||||
case XK_Return:
|
||||
case XK_KP_Enter:
|
||||
case XK_ISO_Enter:
|
||||
return VKEY_RETURN;
|
||||
case XK_Clear:
|
||||
case XK_KP_Begin: // NumPad 5 without Num Lock, for crosbug.com/29169.
|
||||
return VKEY_CLEAR;
|
||||
case XK_KP_Space:
|
||||
case XK_space:
|
||||
return VKEY_SPACE;
|
||||
case XK_Home:
|
||||
case XK_KP_Home:
|
||||
return VKEY_HOME;
|
||||
case XK_End:
|
||||
case XK_KP_End:
|
||||
return VKEY_END;
|
||||
case XK_Page_Up:
|
||||
case XK_KP_Page_Up: // aka XK_KP_Prior
|
||||
return VKEY_PRIOR;
|
||||
case XK_Page_Down:
|
||||
case XK_KP_Page_Down: // aka XK_KP_Next
|
||||
return VKEY_NEXT;
|
||||
case XK_Left:
|
||||
case XK_KP_Left:
|
||||
return VKEY_LEFT;
|
||||
case XK_Right:
|
||||
case XK_KP_Right:
|
||||
return VKEY_RIGHT;
|
||||
case XK_Down:
|
||||
case XK_KP_Down:
|
||||
return VKEY_DOWN;
|
||||
case XK_Up:
|
||||
case XK_KP_Up:
|
||||
return VKEY_UP;
|
||||
case XK_Escape:
|
||||
return VKEY_ESCAPE;
|
||||
case XK_Kana_Lock:
|
||||
case XK_Kana_Shift:
|
||||
return VKEY_KANA;
|
||||
case XK_Hangul:
|
||||
return VKEY_HANGUL;
|
||||
case XK_Hangul_Hanja:
|
||||
return VKEY_HANJA;
|
||||
case XK_Kanji:
|
||||
return VKEY_KANJI;
|
||||
case XK_Henkan:
|
||||
return VKEY_CONVERT;
|
||||
case XK_Muhenkan:
|
||||
return VKEY_NONCONVERT;
|
||||
case XK_Zenkaku_Hankaku:
|
||||
return VKEY_DBE_DBCSCHAR;
|
||||
case XK_A:
|
||||
case XK_a:
|
||||
return VKEY_A;
|
||||
case XK_B:
|
||||
case XK_b:
|
||||
return VKEY_B;
|
||||
case XK_C:
|
||||
case XK_c:
|
||||
return VKEY_C;
|
||||
case XK_D:
|
||||
case XK_d:
|
||||
return VKEY_D;
|
||||
case XK_E:
|
||||
case XK_e:
|
||||
return VKEY_E;
|
||||
case XK_F:
|
||||
case XK_f:
|
||||
return VKEY_F;
|
||||
case XK_G:
|
||||
case XK_g:
|
||||
return VKEY_G;
|
||||
case XK_H:
|
||||
case XK_h:
|
||||
return VKEY_H;
|
||||
case XK_I:
|
||||
case XK_i:
|
||||
return VKEY_I;
|
||||
case XK_J:
|
||||
case XK_j:
|
||||
return VKEY_J;
|
||||
case XK_K:
|
||||
case XK_k:
|
||||
return VKEY_K;
|
||||
case XK_L:
|
||||
case XK_l:
|
||||
return VKEY_L;
|
||||
case XK_M:
|
||||
case XK_m:
|
||||
return VKEY_M;
|
||||
case XK_N:
|
||||
case XK_n:
|
||||
return VKEY_N;
|
||||
case XK_O:
|
||||
case XK_o:
|
||||
return VKEY_O;
|
||||
case XK_P:
|
||||
case XK_p:
|
||||
return VKEY_P;
|
||||
case XK_Q:
|
||||
case XK_q:
|
||||
return VKEY_Q;
|
||||
case XK_R:
|
||||
case XK_r:
|
||||
return VKEY_R;
|
||||
case XK_S:
|
||||
case XK_s:
|
||||
return VKEY_S;
|
||||
case XK_T:
|
||||
case XK_t:
|
||||
return VKEY_T;
|
||||
case XK_U:
|
||||
case XK_u:
|
||||
return VKEY_U;
|
||||
case XK_V:
|
||||
case XK_v:
|
||||
return VKEY_V;
|
||||
case XK_W:
|
||||
case XK_w:
|
||||
return VKEY_W;
|
||||
case XK_X:
|
||||
case XK_x:
|
||||
return VKEY_X;
|
||||
case XK_Y:
|
||||
case XK_y:
|
||||
return VKEY_Y;
|
||||
case XK_Z:
|
||||
case XK_z:
|
||||
return VKEY_Z;
|
||||
|
||||
case XK_0:
|
||||
case XK_1:
|
||||
case XK_2:
|
||||
case XK_3:
|
||||
case XK_4:
|
||||
case XK_5:
|
||||
case XK_6:
|
||||
case XK_7:
|
||||
case XK_8:
|
||||
case XK_9:
|
||||
return static_cast<KeyboardCode>(VKEY_0 + (keysym - XK_0));
|
||||
|
||||
case XK_parenright:
|
||||
return VKEY_0;
|
||||
case XK_exclam:
|
||||
return VKEY_1;
|
||||
case XK_at:
|
||||
return VKEY_2;
|
||||
case XK_numbersign:
|
||||
return VKEY_3;
|
||||
case XK_dollar:
|
||||
return VKEY_4;
|
||||
case XK_percent:
|
||||
return VKEY_5;
|
||||
case XK_asciicircum:
|
||||
return VKEY_6;
|
||||
case XK_ampersand:
|
||||
return VKEY_7;
|
||||
case XK_asterisk:
|
||||
return VKEY_8;
|
||||
case XK_parenleft:
|
||||
return VKEY_9;
|
||||
|
||||
case XK_KP_0:
|
||||
case XK_KP_1:
|
||||
case XK_KP_2:
|
||||
case XK_KP_3:
|
||||
case XK_KP_4:
|
||||
case XK_KP_5:
|
||||
case XK_KP_6:
|
||||
case XK_KP_7:
|
||||
case XK_KP_8:
|
||||
case XK_KP_9:
|
||||
return static_cast<KeyboardCode>(VKEY_NUMPAD0 + (keysym - XK_KP_0));
|
||||
|
||||
case XK_multiply:
|
||||
case XK_KP_Multiply:
|
||||
return VKEY_MULTIPLY;
|
||||
case XK_KP_Add:
|
||||
return VKEY_ADD;
|
||||
case XK_KP_Separator:
|
||||
return VKEY_SEPARATOR;
|
||||
case XK_KP_Subtract:
|
||||
return VKEY_SUBTRACT;
|
||||
case XK_KP_Decimal:
|
||||
return VKEY_DECIMAL;
|
||||
case XK_KP_Divide:
|
||||
return VKEY_DIVIDE;
|
||||
case XK_KP_Equal:
|
||||
case XK_equal:
|
||||
case XK_plus:
|
||||
return VKEY_OEM_PLUS;
|
||||
case XK_comma:
|
||||
case XK_less:
|
||||
return VKEY_OEM_COMMA;
|
||||
case XK_minus:
|
||||
case XK_underscore:
|
||||
return VKEY_OEM_MINUS;
|
||||
case XK_greater:
|
||||
case XK_period:
|
||||
return VKEY_OEM_PERIOD;
|
||||
case XK_colon:
|
||||
case XK_semicolon:
|
||||
return VKEY_OEM_1;
|
||||
case XK_question:
|
||||
case XK_slash:
|
||||
return VKEY_OEM_2;
|
||||
case XK_asciitilde:
|
||||
case XK_quoteleft:
|
||||
return VKEY_OEM_3;
|
||||
case XK_bracketleft:
|
||||
case XK_braceleft:
|
||||
return VKEY_OEM_4;
|
||||
case XK_backslash:
|
||||
case XK_bar:
|
||||
return VKEY_OEM_5;
|
||||
case XK_bracketright:
|
||||
case XK_braceright:
|
||||
return VKEY_OEM_6;
|
||||
case XK_quoteright:
|
||||
case XK_quotedbl:
|
||||
return VKEY_OEM_7;
|
||||
case XK_ISO_Level5_Shift:
|
||||
return VKEY_OEM_8;
|
||||
case XK_Shift_L:
|
||||
case XK_Shift_R:
|
||||
return VKEY_SHIFT;
|
||||
case XK_Control_L:
|
||||
case XK_Control_R:
|
||||
return VKEY_CONTROL;
|
||||
case XK_Meta_L:
|
||||
case XK_Meta_R:
|
||||
case XK_Alt_L:
|
||||
case XK_Alt_R:
|
||||
return VKEY_MENU;
|
||||
case XK_ISO_Level3_Shift:
|
||||
return VKEY_ALTGR;
|
||||
case XK_Multi_key:
|
||||
return VKEY_COMPOSE;
|
||||
case XK_Pause:
|
||||
return VKEY_PAUSE;
|
||||
case XK_Caps_Lock:
|
||||
return VKEY_CAPITAL;
|
||||
case XK_Num_Lock:
|
||||
return VKEY_NUMLOCK;
|
||||
case XK_Scroll_Lock:
|
||||
return VKEY_SCROLL;
|
||||
case XK_Select:
|
||||
return VKEY_SELECT;
|
||||
case XK_Print:
|
||||
return VKEY_PRINT;
|
||||
case XK_Execute:
|
||||
return VKEY_EXECUTE;
|
||||
case XK_Insert:
|
||||
case XK_KP_Insert:
|
||||
return VKEY_INSERT;
|
||||
case XK_Help:
|
||||
return VKEY_HELP;
|
||||
case XK_Super_L:
|
||||
return VKEY_LWIN;
|
||||
case XK_Super_R:
|
||||
return VKEY_RWIN;
|
||||
case XK_Menu:
|
||||
return VKEY_APPS;
|
||||
case XK_F1:
|
||||
case XK_F2:
|
||||
case XK_F3:
|
||||
case XK_F4:
|
||||
case XK_F5:
|
||||
case XK_F6:
|
||||
case XK_F7:
|
||||
case XK_F8:
|
||||
case XK_F9:
|
||||
case XK_F10:
|
||||
case XK_F11:
|
||||
case XK_F12:
|
||||
case XK_F13:
|
||||
case XK_F14:
|
||||
case XK_F15:
|
||||
case XK_F16:
|
||||
case XK_F17:
|
||||
case XK_F18:
|
||||
case XK_F19:
|
||||
case XK_F20:
|
||||
case XK_F21:
|
||||
case XK_F22:
|
||||
case XK_F23:
|
||||
case XK_F24:
|
||||
return static_cast<KeyboardCode>(VKEY_F1 + (keysym - XK_F1));
|
||||
case XK_KP_F1:
|
||||
case XK_KP_F2:
|
||||
case XK_KP_F3:
|
||||
case XK_KP_F4:
|
||||
return static_cast<KeyboardCode>(VKEY_F1 + (keysym - XK_KP_F1));
|
||||
|
||||
case XK_guillemotleft:
|
||||
case XK_guillemotright:
|
||||
case XK_degree:
|
||||
// In the case of canadian multilingual keyboard layout, VKEY_OEM_102 is
|
||||
// assigned to ugrave key.
|
||||
case XK_ugrave:
|
||||
case XK_Ugrave:
|
||||
case XK_brokenbar:
|
||||
return VKEY_OEM_102; // international backslash key in 102 keyboard.
|
||||
|
||||
// When evdev is in use, /usr/share/X11/xkb/symbols/inet maps F13-18 keys
|
||||
// to the special XF86XK symbols to support Microsoft Ergonomic keyboards:
|
||||
// https://bugs.freedesktop.org/show_bug.cgi?id=5783
|
||||
// In Chrome, we map these X key symbols back to F13-18 since we don't have
|
||||
// VKEYs for these XF86XK symbols.
|
||||
case XF86XK_Tools:
|
||||
return VKEY_F13;
|
||||
case XF86XK_Launch5:
|
||||
return VKEY_F14;
|
||||
case XF86XK_Launch6:
|
||||
return VKEY_F15;
|
||||
case XF86XK_Launch7:
|
||||
return VKEY_F16;
|
||||
case XF86XK_Launch8:
|
||||
return VKEY_F17;
|
||||
case XF86XK_Launch9:
|
||||
return VKEY_F18;
|
||||
case XF86XK_Refresh:
|
||||
case XF86XK_History:
|
||||
case XF86XK_OpenURL:
|
||||
case XF86XK_AddFavorite:
|
||||
case XF86XK_Go:
|
||||
case XF86XK_ZoomIn:
|
||||
case XF86XK_ZoomOut:
|
||||
// ui::AcceleratorGtk tries to convert the XF86XK_ keysyms on Chrome
|
||||
// startup. It's safe to return VKEY_UNKNOWN here since ui::AcceleratorGtk
|
||||
// also checks a Gdk keysym. http://crbug.com/109843
|
||||
return VKEY_UNKNOWN;
|
||||
// For supporting multimedia buttons on a USB keyboard.
|
||||
case XF86XK_Back:
|
||||
return VKEY_BROWSER_BACK;
|
||||
case XF86XK_Forward:
|
||||
return VKEY_BROWSER_FORWARD;
|
||||
case XF86XK_Reload:
|
||||
return VKEY_BROWSER_REFRESH;
|
||||
case XF86XK_Stop:
|
||||
return VKEY_BROWSER_STOP;
|
||||
case XF86XK_Search:
|
||||
return VKEY_BROWSER_SEARCH;
|
||||
case XF86XK_Favorites:
|
||||
return VKEY_BROWSER_FAVORITES;
|
||||
case XF86XK_HomePage:
|
||||
return VKEY_BROWSER_HOME;
|
||||
case XF86XK_AudioMute:
|
||||
return VKEY_VOLUME_MUTE;
|
||||
case XF86XK_AudioLowerVolume:
|
||||
return VKEY_VOLUME_DOWN;
|
||||
case XF86XK_AudioRaiseVolume:
|
||||
return VKEY_VOLUME_UP;
|
||||
case XF86XK_AudioNext:
|
||||
return VKEY_MEDIA_NEXT_TRACK;
|
||||
case XF86XK_AudioPrev:
|
||||
return VKEY_MEDIA_PREV_TRACK;
|
||||
case XF86XK_AudioStop:
|
||||
return VKEY_MEDIA_STOP;
|
||||
case XF86XK_AudioPlay:
|
||||
return VKEY_MEDIA_PLAY_PAUSE;
|
||||
case XF86XK_Mail:
|
||||
return VKEY_MEDIA_LAUNCH_MAIL;
|
||||
case XF86XK_LaunchA: // F3 on an Apple keyboard.
|
||||
return VKEY_MEDIA_LAUNCH_APP1;
|
||||
case XF86XK_LaunchB: // F4 on an Apple keyboard.
|
||||
case XF86XK_Calculator:
|
||||
return VKEY_MEDIA_LAUNCH_APP2;
|
||||
case XF86XK_WLAN:
|
||||
return VKEY_WLAN;
|
||||
case XF86XK_PowerOff:
|
||||
return VKEY_POWER;
|
||||
case XF86XK_MonBrightnessDown:
|
||||
return VKEY_BRIGHTNESS_DOWN;
|
||||
case XF86XK_MonBrightnessUp:
|
||||
return VKEY_BRIGHTNESS_UP;
|
||||
case XF86XK_KbdBrightnessDown:
|
||||
return VKEY_KBD_BRIGHTNESS_DOWN;
|
||||
case XF86XK_KbdBrightnessUp:
|
||||
return VKEY_KBD_BRIGHTNESS_UP;
|
||||
|
||||
// TODO(sad): some keycodes are still missing.
|
||||
}
|
||||
return VKEY_UNKNOWN;
|
||||
}
|
||||
|
||||
// From content/browser/renderer_host/input/web_input_event_util_posix.cc.
|
||||
KeyboardCode GdkEventToWindowsKeyCode(const GdkEventKey* event) {
|
||||
static const unsigned int kHardwareCodeToGDKKeyval[] = {
|
||||
0, // 0x00:
|
||||
0, // 0x01:
|
||||
0, // 0x02:
|
||||
0, // 0x03:
|
||||
0, // 0x04:
|
||||
0, // 0x05:
|
||||
0, // 0x06:
|
||||
0, // 0x07:
|
||||
0, // 0x08:
|
||||
0, // 0x09: GDK_Escape
|
||||
GDK_1, // 0x0A: GDK_1
|
||||
GDK_2, // 0x0B: GDK_2
|
||||
GDK_3, // 0x0C: GDK_3
|
||||
GDK_4, // 0x0D: GDK_4
|
||||
GDK_5, // 0x0E: GDK_5
|
||||
GDK_6, // 0x0F: GDK_6
|
||||
GDK_7, // 0x10: GDK_7
|
||||
GDK_8, // 0x11: GDK_8
|
||||
GDK_9, // 0x12: GDK_9
|
||||
GDK_0, // 0x13: GDK_0
|
||||
GDK_minus, // 0x14: GDK_minus
|
||||
GDK_equal, // 0x15: GDK_equal
|
||||
0, // 0x16: GDK_BackSpace
|
||||
0, // 0x17: GDK_Tab
|
||||
GDK_q, // 0x18: GDK_q
|
||||
GDK_w, // 0x19: GDK_w
|
||||
GDK_e, // 0x1A: GDK_e
|
||||
GDK_r, // 0x1B: GDK_r
|
||||
GDK_t, // 0x1C: GDK_t
|
||||
GDK_y, // 0x1D: GDK_y
|
||||
GDK_u, // 0x1E: GDK_u
|
||||
GDK_i, // 0x1F: GDK_i
|
||||
GDK_o, // 0x20: GDK_o
|
||||
GDK_p, // 0x21: GDK_p
|
||||
GDK_bracketleft, // 0x22: GDK_bracketleft
|
||||
GDK_bracketright, // 0x23: GDK_bracketright
|
||||
0, // 0x24: GDK_Return
|
||||
0, // 0x25: GDK_Control_L
|
||||
GDK_a, // 0x26: GDK_a
|
||||
GDK_s, // 0x27: GDK_s
|
||||
GDK_d, // 0x28: GDK_d
|
||||
GDK_f, // 0x29: GDK_f
|
||||
GDK_g, // 0x2A: GDK_g
|
||||
GDK_h, // 0x2B: GDK_h
|
||||
GDK_j, // 0x2C: GDK_j
|
||||
GDK_k, // 0x2D: GDK_k
|
||||
GDK_l, // 0x2E: GDK_l
|
||||
GDK_semicolon, // 0x2F: GDK_semicolon
|
||||
GDK_apostrophe, // 0x30: GDK_apostrophe
|
||||
GDK_grave, // 0x31: GDK_grave
|
||||
0, // 0x32: GDK_Shift_L
|
||||
GDK_backslash, // 0x33: GDK_backslash
|
||||
GDK_z, // 0x34: GDK_z
|
||||
GDK_x, // 0x35: GDK_x
|
||||
GDK_c, // 0x36: GDK_c
|
||||
GDK_v, // 0x37: GDK_v
|
||||
GDK_b, // 0x38: GDK_b
|
||||
GDK_n, // 0x39: GDK_n
|
||||
GDK_m, // 0x3A: GDK_m
|
||||
GDK_comma, // 0x3B: GDK_comma
|
||||
GDK_period, // 0x3C: GDK_period
|
||||
GDK_slash, // 0x3D: GDK_slash
|
||||
0, // 0x3E: GDK_Shift_R
|
||||
0, // 0x3F:
|
||||
0, // 0x40:
|
||||
0, // 0x41:
|
||||
0, // 0x42:
|
||||
0, // 0x43:
|
||||
0, // 0x44:
|
||||
0, // 0x45:
|
||||
0, // 0x46:
|
||||
0, // 0x47:
|
||||
0, // 0x48:
|
||||
0, // 0x49:
|
||||
0, // 0x4A:
|
||||
0, // 0x4B:
|
||||
0, // 0x4C:
|
||||
0, // 0x4D:
|
||||
0, // 0x4E:
|
||||
0, // 0x4F:
|
||||
0, // 0x50:
|
||||
0, // 0x51:
|
||||
0, // 0x52:
|
||||
0, // 0x53:
|
||||
0, // 0x54:
|
||||
0, // 0x55:
|
||||
0, // 0x56:
|
||||
0, // 0x57:
|
||||
0, // 0x58:
|
||||
0, // 0x59:
|
||||
0, // 0x5A:
|
||||
0, // 0x5B:
|
||||
0, // 0x5C:
|
||||
0, // 0x5D:
|
||||
0, // 0x5E:
|
||||
0, // 0x5F:
|
||||
0, // 0x60:
|
||||
0, // 0x61:
|
||||
0, // 0x62:
|
||||
0, // 0x63:
|
||||
0, // 0x64:
|
||||
0, // 0x65:
|
||||
0, // 0x66:
|
||||
0, // 0x67:
|
||||
0, // 0x68:
|
||||
0, // 0x69:
|
||||
0, // 0x6A:
|
||||
0, // 0x6B:
|
||||
0, // 0x6C:
|
||||
0, // 0x6D:
|
||||
0, // 0x6E:
|
||||
0, // 0x6F:
|
||||
0, // 0x70:
|
||||
0, // 0x71:
|
||||
0, // 0x72:
|
||||
GDK_Super_L, // 0x73: GDK_Super_L
|
||||
GDK_Super_R, // 0x74: GDK_Super_R
|
||||
};
|
||||
|
||||
// |windows_key_code| has to include a valid virtual-key code even when we
|
||||
// use non-US layouts, e.g. even when we type an 'A' key of a US keyboard
|
||||
// on the Hebrew layout, |windows_key_code| should be VK_A.
|
||||
// On the other hand, |event->keyval| value depends on the current
|
||||
// GdkKeymap object, i.e. when we type an 'A' key of a US keyboard on
|
||||
// the Hebrew layout, |event->keyval| becomes GDK_hebrew_shin and this
|
||||
// KeyboardCodeFromXKeysym() call returns 0.
|
||||
// To improve compatibilty with Windows, we use |event->hardware_keycode|
|
||||
// for retrieving its Windows key-code for the keys when the
|
||||
// WebCore::windows_key_codeForEvent() call returns 0.
|
||||
// We shouldn't use |event->hardware_keycode| for keys that GdkKeymap
|
||||
// objects cannot change because |event->hardware_keycode| doesn't change
|
||||
// even when we change the layout options, e.g. when we swap a control
|
||||
// key and a caps-lock key, GTK doesn't swap their
|
||||
// |event->hardware_keycode| values but swap their |event->keyval| values.
|
||||
KeyboardCode windows_key_code = KeyboardCodeFromXKeysym(event->keyval);
|
||||
if (windows_key_code) {
|
||||
return windows_key_code;
|
||||
}
|
||||
|
||||
if (event->hardware_keycode < std::size(kHardwareCodeToGDKKeyval)) {
|
||||
int keyval = kHardwareCodeToGDKKeyval[event->hardware_keycode];
|
||||
if (keyval) {
|
||||
return KeyboardCodeFromXKeysym(keyval);
|
||||
}
|
||||
}
|
||||
|
||||
// This key is one that keyboard-layout drivers cannot change.
|
||||
// Use |event->keyval| to retrieve its |windows_key_code| value.
|
||||
return KeyboardCodeFromXKeysym(event->keyval);
|
||||
}
|
||||
|
||||
// From content/browser/renderer_host/input/web_input_event_util_posix.cc.
|
||||
KeyboardCode GetWindowsKeyCodeWithoutLocation(KeyboardCode key_code) {
|
||||
switch (key_code) {
|
||||
case VKEY_LCONTROL:
|
||||
case VKEY_RCONTROL:
|
||||
return VKEY_CONTROL;
|
||||
case VKEY_LSHIFT:
|
||||
case VKEY_RSHIFT:
|
||||
return VKEY_SHIFT;
|
||||
case VKEY_LMENU:
|
||||
case VKEY_RMENU:
|
||||
return VKEY_MENU;
|
||||
default:
|
||||
return key_code;
|
||||
}
|
||||
}
|
||||
|
||||
int GetCefStateModifiers(guint state) {
|
||||
int modifiers = 0;
|
||||
if (state & GDK_SHIFT_MASK) {
|
||||
modifiers |= EVENTFLAG_SHIFT_DOWN;
|
||||
}
|
||||
if (state & GDK_LOCK_MASK) {
|
||||
modifiers |= EVENTFLAG_CAPS_LOCK_ON;
|
||||
}
|
||||
if (state & GDK_CONTROL_MASK) {
|
||||
modifiers |= EVENTFLAG_CONTROL_DOWN;
|
||||
}
|
||||
if (state & GDK_MOD1_MASK) {
|
||||
modifiers |= EVENTFLAG_ALT_DOWN;
|
||||
}
|
||||
if (state & GDK_BUTTON1_MASK) {
|
||||
modifiers |= EVENTFLAG_LEFT_MOUSE_BUTTON;
|
||||
}
|
||||
if (state & GDK_BUTTON2_MASK) {
|
||||
modifiers |= EVENTFLAG_MIDDLE_MOUSE_BUTTON;
|
||||
}
|
||||
if (state & GDK_BUTTON3_MASK) {
|
||||
modifiers |= EVENTFLAG_RIGHT_MOUSE_BUTTON;
|
||||
}
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
// From content/browser/renderer_host/input/web_input_event_builders_gtk.cc.
|
||||
// Gets the corresponding control character of a specified key code. See:
|
||||
// http://en.wikipedia.org/wiki/Control_characters
|
||||
// We emulate Windows behavior here.
|
||||
int GetControlCharacter(KeyboardCode windows_key_code, bool shift) {
|
||||
if (windows_key_code >= VKEY_A && windows_key_code <= VKEY_Z) {
|
||||
// ctrl-A ~ ctrl-Z map to \x01 ~ \x1A
|
||||
return windows_key_code - VKEY_A + 1;
|
||||
}
|
||||
if (shift) {
|
||||
// following graphics chars require shift key to input.
|
||||
switch (windows_key_code) {
|
||||
// ctrl-@ maps to \x00 (Null byte)
|
||||
case VKEY_2:
|
||||
return 0;
|
||||
// ctrl-^ maps to \x1E (Record separator, Information separator two)
|
||||
case VKEY_6:
|
||||
return 0x1E;
|
||||
// ctrl-_ maps to \x1F (Unit separator, Information separator one)
|
||||
case VKEY_OEM_MINUS:
|
||||
return 0x1F;
|
||||
// Returns 0 for all other keys to avoid inputting unexpected chars.
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
switch (windows_key_code) {
|
||||
// ctrl-[ maps to \x1B (Escape)
|
||||
case VKEY_OEM_4:
|
||||
return 0x1B;
|
||||
// ctrl-\ maps to \x1C (File separator, Information separator four)
|
||||
case VKEY_OEM_5:
|
||||
return 0x1C;
|
||||
// ctrl-] maps to \x1D (Group separator, Information separator three)
|
||||
case VKEY_OEM_6:
|
||||
return 0x1D;
|
||||
// ctrl-Enter maps to \x0A (Line feed)
|
||||
case VKEY_RETURN:
|
||||
return 0x0A;
|
||||
// Returns 0 for all other keys to avoid inputting unexpected chars.
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //WEBVIEW_CEF_KEYEVENT_H_
|
||||
303
linux/webview_cef_plugin.cc
Normal file
303
linux/webview_cef_plugin.cc
Normal file
@@ -0,0 +1,303 @@
|
||||
#include "include/webview_cef/webview_cef_plugin.h"
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <webview_plugin.h>
|
||||
#include "webview_cef_keyevent.h"
|
||||
#include "webview_cef_texture.h"
|
||||
|
||||
#define WEBVIEW_CEF_PLUGIN(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj), webview_cef_plugin_get_type(), \
|
||||
WebviewCefPlugin))
|
||||
|
||||
struct _WebviewCefPlugin
|
||||
{
|
||||
GObject parent_instance;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(WebviewCefPlugin, webview_cef_plugin, g_object_get_type())
|
||||
|
||||
static FlTextureRegistrar* texture_register;
|
||||
|
||||
static FlValue* encode_wavlue_to_flvalue(WValue *args){
|
||||
WValueType type = webview_value_get_type(args);
|
||||
switch(type){
|
||||
case Webview_Value_Type_Bool:
|
||||
return fl_value_new_bool(webview_value_get_bool(args));
|
||||
case Webview_Value_Type_Int:
|
||||
return fl_value_new_int(webview_value_get_int(args));
|
||||
case Webview_Value_Type_Float:
|
||||
return fl_value_new_float(webview_value_get_float(args));
|
||||
case Webview_Value_Type_Double:
|
||||
return fl_value_new_float(webview_value_get_double(args));
|
||||
case Webview_Value_Type_String:
|
||||
return fl_value_new_string(webview_value_get_string(args));
|
||||
case Webview_Value_Type_Uint8_List:{
|
||||
size_t len = webview_value_get_len(args);
|
||||
const uint8_t* val = webview_value_get_uint8_list(args);
|
||||
return fl_value_new_uint8_list(val, len);
|
||||
}
|
||||
case Webview_Value_Type_Int32_List:{
|
||||
size_t len = webview_value_get_len(args);
|
||||
const int32_t* val = webview_value_get_int32_list(args);
|
||||
return fl_value_new_int32_list(val, len);
|
||||
}
|
||||
case Webview_Value_Type_Int64_List:{
|
||||
size_t len = webview_value_get_len(args);
|
||||
const int64_t* val = webview_value_get_int64_list(args);
|
||||
return fl_value_new_int64_list(val, len);
|
||||
}
|
||||
case Webview_Value_Type_Float_List:{
|
||||
size_t len = webview_value_get_len(args);
|
||||
const float* val = webview_value_get_float_list(args);
|
||||
return fl_value_new_float32_list(val, len);
|
||||
}
|
||||
case Webview_Value_Type_Double_List:{
|
||||
size_t len = webview_value_get_len(args);
|
||||
const double* val = webview_value_get_double_list(args);
|
||||
return fl_value_new_float_list(val, len);
|
||||
}
|
||||
case Webview_Value_Type_List:{
|
||||
FlValue * ret = fl_value_new_list();
|
||||
size_t len = webview_value_get_len(args);
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
FlValue * val = encode_wavlue_to_flvalue(webview_value_get_value(args, i));
|
||||
fl_value_append(ret, val);
|
||||
fl_value_unref(val);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
case Webview_Value_Type_Map:{
|
||||
FlValue * ret = fl_value_new_map();
|
||||
size_t len = webview_value_get_len(args);
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
FlValue * key = encode_wavlue_to_flvalue(webview_value_get_key(args, i));
|
||||
FlValue * val = encode_wavlue_to_flvalue(webview_value_get_value(args, i));
|
||||
fl_value_set(ret, key, val);
|
||||
fl_value_unref(key);
|
||||
fl_value_unref(val);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
default:
|
||||
return fl_value_new_null();
|
||||
}
|
||||
}
|
||||
|
||||
static WValue* encode_flvalue_to_wvalue(FlValue* args){
|
||||
FlValueType argsType = fl_value_get_type(args);
|
||||
switch (argsType){
|
||||
case FL_VALUE_TYPE_BOOL:
|
||||
return webview_value_new_bool(fl_value_get_bool(args));
|
||||
case FL_VALUE_TYPE_INT:
|
||||
return webview_value_new_int(fl_value_get_int(args));
|
||||
case FL_VALUE_TYPE_FLOAT:
|
||||
return webview_value_new_double(fl_value_get_float(args));
|
||||
case FL_VALUE_TYPE_STRING:
|
||||
return webview_value_new_string(fl_value_get_string(args));
|
||||
case FL_VALUE_TYPE_UINT8_LIST:{
|
||||
size_t len = fl_value_get_length(args);
|
||||
const uint8_t* val = fl_value_get_uint8_list(args);
|
||||
return webview_value_new_uint8_list(val, len);
|
||||
}
|
||||
case FL_VALUE_TYPE_INT32_LIST:{
|
||||
size_t len = fl_value_get_length(args);
|
||||
const int32_t* val = fl_value_get_int32_list(args);
|
||||
return webview_value_new_int32_list(val, len);
|
||||
}
|
||||
case FL_VALUE_TYPE_INT64_LIST:{
|
||||
size_t len = fl_value_get_length(args);
|
||||
const int64_t* val = fl_value_get_int64_list(args);
|
||||
return webview_value_new_int64_list(val, len);
|
||||
}
|
||||
case FL_VALUE_TYPE_FLOAT32_LIST:{
|
||||
size_t len = fl_value_get_length(args);
|
||||
const float* val = fl_value_get_float32_list(args);
|
||||
return webview_value_new_float_list(val, len);
|
||||
}
|
||||
case FL_VALUE_TYPE_FLOAT_LIST:{
|
||||
size_t len = fl_value_get_length(args);
|
||||
const double* val = fl_value_get_float_list(args);
|
||||
return webview_value_new_double_list(val, len);
|
||||
}
|
||||
case FL_VALUE_TYPE_LIST:{
|
||||
WValue * ret = webview_value_new_list();
|
||||
size_t len = fl_value_get_length(args);
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
WValue * item = encode_flvalue_to_wvalue(fl_value_get_list_value(args, i));
|
||||
webview_value_append(ret, item);
|
||||
webview_value_unref(item);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
case FL_VALUE_TYPE_MAP:{
|
||||
WValue * ret = webview_value_new_map();
|
||||
size_t len = fl_value_get_length(args);
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
WValue * key = encode_flvalue_to_wvalue(fl_value_get_map_key(args, i));
|
||||
WValue * val = encode_flvalue_to_wvalue(fl_value_get_map_value(args, i));
|
||||
webview_value_set(ret, key, val);
|
||||
webview_value_unref(key);
|
||||
webview_value_unref(val);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
default:
|
||||
return webview_value_new_null();
|
||||
}
|
||||
}
|
||||
|
||||
// Called when a method call is received from Flutter.
|
||||
static void webview_cef_plugin_handle_method_call(
|
||||
WebviewCefPlugin *self,
|
||||
FlMethodCall *method_call)
|
||||
{
|
||||
g_autoptr(FlMethodResponse) response = nullptr;
|
||||
|
||||
const gchar *method = fl_method_call_get_name(method_call);
|
||||
FlValue *args = fl_method_call_get_args(method_call);
|
||||
FlValue *result = nullptr;
|
||||
if(strcmp(method, "init") == 0){
|
||||
auto texture = webview_cef_texture_new();
|
||||
fl_texture_registrar_register_texture(texture_register, FL_TEXTURE(texture));
|
||||
auto callback = [=](const void* buffer, int32_t width, int32_t height) {
|
||||
texture->width = width;
|
||||
texture->height = height;
|
||||
const auto size = width * height * 4;
|
||||
texture->buffer = new uint8_t[size];
|
||||
webview_cef::SwapBufferFromBgraToRgba((void*)texture->buffer, buffer, width, height);
|
||||
fl_texture_registrar_mark_texture_frame_available(texture_register, FL_TEXTURE(texture));
|
||||
};
|
||||
webview_cef::setPaintCallBack(callback);
|
||||
g_timeout_add(20, [](gpointer data) -> gboolean {
|
||||
webview_cef::doMessageLoopWork();
|
||||
return TRUE;
|
||||
}, NULL);
|
||||
result = fl_value_new_int((int64_t)texture);
|
||||
response = FL_METHOD_RESPONSE(fl_method_success_response_new(result));
|
||||
}else{
|
||||
WValue *encodeArgs = encode_flvalue_to_wvalue(args);
|
||||
WValue *responseArgs = nullptr;
|
||||
int ret = webview_cef::HandleMethodCall(method, encodeArgs, responseArgs);
|
||||
webview_value_unref(encodeArgs);
|
||||
if (ret > 0){
|
||||
result = encode_wavlue_to_flvalue(responseArgs);
|
||||
response = FL_METHOD_RESPONSE(fl_method_success_response_new(result));
|
||||
}
|
||||
else if (ret < 0){
|
||||
result = encode_wavlue_to_flvalue(responseArgs);
|
||||
response = FL_METHOD_RESPONSE(fl_method_error_response_new("error", "error", result));
|
||||
}
|
||||
else{
|
||||
response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new());
|
||||
}
|
||||
webview_value_unref(responseArgs);
|
||||
}
|
||||
|
||||
fl_method_call_respond(method_call, response, nullptr);
|
||||
fl_value_unref(result);
|
||||
}
|
||||
|
||||
static void webview_cef_plugin_dispose(GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS(webview_cef_plugin_parent_class)->dispose(object);
|
||||
}
|
||||
|
||||
static void webview_cef_plugin_class_init(WebviewCefPluginClass *klass)
|
||||
{
|
||||
G_OBJECT_CLASS(klass)->dispose = webview_cef_plugin_dispose;
|
||||
}
|
||||
|
||||
static void webview_cef_plugin_init(WebviewCefPlugin *self) {}
|
||||
|
||||
static void method_call_cb(FlMethodChannel *channel, FlMethodCall *method_call,
|
||||
gpointer user_data)
|
||||
{
|
||||
WebviewCefPlugin *plugin = WEBVIEW_CEF_PLUGIN(user_data);
|
||||
webview_cef_plugin_handle_method_call(plugin, method_call);
|
||||
}
|
||||
|
||||
void webview_cef_plugin_register_with_registrar(FlPluginRegistrar *registrar)
|
||||
{
|
||||
WebviewCefPlugin *plugin = WEBVIEW_CEF_PLUGIN(
|
||||
g_object_new(webview_cef_plugin_get_type(), nullptr));
|
||||
|
||||
texture_register = fl_plugin_registrar_get_texture_registrar(registrar);
|
||||
|
||||
g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
|
||||
g_autoptr(FlMethodChannel) channel =
|
||||
fl_method_channel_new(fl_plugin_registrar_get_messenger(registrar),
|
||||
"webview_cef",
|
||||
FL_METHOD_CODEC(codec));
|
||||
fl_method_channel_set_method_call_handler(channel, method_call_cb,
|
||||
g_object_ref(plugin),
|
||||
g_object_unref);
|
||||
|
||||
auto invoke = [=](std::string method, WValue* arguments) {
|
||||
FlValue *args = encode_wavlue_to_flvalue(arguments);
|
||||
fl_method_channel_invoke_method(channel, method.c_str(), args, NULL, NULL, NULL);
|
||||
fl_value_unref(args);
|
||||
};
|
||||
webview_cef::setInvokeMethodFunc(invoke);
|
||||
|
||||
g_object_unref(plugin);
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void initCEFProcesses(int argc, char** argv)
|
||||
{
|
||||
CefMainArgs main_args(argc, argv);
|
||||
webview_cef::initCEFProcesses(main_args);
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT gboolean processKeyEventForCEF(GtkWidget *widget, GdkEventKey *event, gpointer data)
|
||||
{
|
||||
if(webview_cef::getPluginIsFocused())
|
||||
{
|
||||
CefKeyEvent key_event;
|
||||
KeyboardCode windows_key_code = GdkEventToWindowsKeyCode(event);
|
||||
key_event.windows_key_code =
|
||||
GetWindowsKeyCodeWithoutLocation(windows_key_code);
|
||||
key_event.native_key_code = event->hardware_keycode;
|
||||
|
||||
key_event.modifiers = GetCefStateModifiers(event->state);
|
||||
if (event->keyval >= GDK_KP_Space && event->keyval <= GDK_KP_9) {
|
||||
key_event.modifiers |= EVENTFLAG_IS_KEY_PAD;
|
||||
}
|
||||
if (key_event.modifiers & EVENTFLAG_ALT_DOWN) {
|
||||
key_event.is_system_key = true;
|
||||
}
|
||||
|
||||
if (windows_key_code == VKEY_RETURN) {
|
||||
// We need to treat the enter key as a key press of character \r. This
|
||||
// is apparently just how webkit handles it and what it expects.
|
||||
key_event.unmodified_character = '\r';
|
||||
} else {
|
||||
// FIXME: fix for non BMP chars
|
||||
key_event.unmodified_character =
|
||||
static_cast<int>(gdk_keyval_to_unicode(event->keyval));
|
||||
}
|
||||
|
||||
// If ctrl key is pressed down, then control character shall be input.
|
||||
if (key_event.modifiers & EVENTFLAG_CONTROL_DOWN) {
|
||||
key_event.character = GetControlCharacter(
|
||||
windows_key_code, key_event.modifiers & EVENTFLAG_SHIFT_DOWN);
|
||||
} else {
|
||||
key_event.character = key_event.unmodified_character;
|
||||
}
|
||||
if (event->type == GDK_KEY_PRESS) {
|
||||
key_event.type = KEYEVENT_RAWKEYDOWN;
|
||||
webview_cef::sendKeyEvent(key_event);
|
||||
key_event.type = KEYEVENT_CHAR;
|
||||
} else {
|
||||
key_event.type = KEYEVENT_KEYUP;
|
||||
}
|
||||
webview_cef::sendKeyEvent(key_event);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
//processKeyEventForFlutter need return FALSE
|
||||
return FALSE;
|
||||
}
|
||||
58
linux/webview_cef_texture.h
Normal file
58
linux/webview_cef_texture.h
Normal file
@@ -0,0 +1,58 @@
|
||||
#ifndef WEBVIEW_CEF_TEXTURE_H_
|
||||
#define WEBVIEW_CEF_TEXTURE_H_
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
struct WebviewCefTexture{
|
||||
FlPixelBufferTexture parent_instance;
|
||||
uint8_t *buffer = nullptr; // your pixel buffer.
|
||||
uint32_t width = 0;
|
||||
uint32_t height = 0;
|
||||
};
|
||||
|
||||
struct WebviewCefTextureClass{
|
||||
FlPixelBufferTextureClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(WebviewCefTexture,
|
||||
webview_cef_texture,
|
||||
fl_pixel_buffer_texture_get_type())
|
||||
|
||||
#define WEBVIEW_CEF_TEXTURE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj), webview_cef_texture_get_type(), WebviewCefTexture))
|
||||
|
||||
static gboolean webview_cef_texture_copy_pixels(FlPixelBufferTexture *texture,
|
||||
const uint8_t **out_buffer,
|
||||
uint32_t *width,
|
||||
uint32_t *height,
|
||||
GError **error) {
|
||||
// This method is called on Render Thread. Be careful with your
|
||||
// cross-thread operation.
|
||||
|
||||
// @width and @height are initially stored the canvas size in Flutter.
|
||||
|
||||
// You must prepare your pixel buffer in RGBA format.
|
||||
// So you may do some format conversion first if your original pixel
|
||||
// buffer is not in RGBA format.
|
||||
WebviewCefTexture *_texture = WEBVIEW_CEF_TEXTURE(texture);
|
||||
if(_texture == nullptr){
|
||||
return TRUE;
|
||||
}
|
||||
*out_buffer = _texture->buffer;
|
||||
*width = _texture->width;
|
||||
*height = _texture->height;
|
||||
return TRUE;
|
||||
}
|
||||
static WebviewCefTexture* webview_cef_texture_new(){
|
||||
return WEBVIEW_CEF_TEXTURE(g_object_new(webview_cef_texture_get_type(), nullptr));
|
||||
}
|
||||
|
||||
static void webview_cef_texture_class_init(WebviewCefTextureClass *klass)
|
||||
{
|
||||
FL_PIXEL_BUFFER_TEXTURE_CLASS(klass)->copy_pixels = webview_cef_texture_copy_pixels;
|
||||
}
|
||||
static void webview_cef_texture_init(WebviewCefTexture *self) {}
|
||||
|
||||
|
||||
#endif // WEBVIEW_CEF_TEXTURE_H_
|
||||
@@ -11,49 +11,11 @@
|
||||
|
||||
extern NSObject<FlutterTextureRegistry>* tr;
|
||||
extern CGFloat scaleFactor;
|
||||
extern int64_t textureId;
|
||||
|
||||
@interface CefWrapper : NSObject<FlutterTexture>
|
||||
|
||||
+ (void) init;
|
||||
|
||||
+ (void) startCef;
|
||||
|
||||
+ (void) cursorClickUp: (int)x y:(int)y;
|
||||
|
||||
+ (void) cursorClickDown: (int)x y:(int)y;
|
||||
|
||||
+ (void) cursorMove: (int)x y:(int)y dragging:(bool)dragging;
|
||||
|
||||
+ (void) sendScrollEvent:(int)x y:(int)y deltaX:(int)deltaX deltaY:(int)deltaY;
|
||||
|
||||
+ (void) sizeChanged: (float)dpi width:(int)width height:(int)height;
|
||||
|
||||
+ (void) loadUrl: (NSString *)url;
|
||||
|
||||
+ (void) goForward;
|
||||
|
||||
+ (void) goBack;
|
||||
|
||||
+ (void) reload;
|
||||
|
||||
+ (void) openDevTools;
|
||||
|
||||
+ (void) setMethodChannel: (FlutterMethodChannel*)channel;
|
||||
|
||||
+ (void) setCookie: (NSString *)domain key:(NSString *) key value:(NSString *)value;
|
||||
|
||||
+ (void) deleteCookie: (NSString *)domain key:(NSString *) key;
|
||||
|
||||
+ (void) visitAllCookies;
|
||||
|
||||
+ (void) visitUrlCookies: (NSString *)domain isHttpOnly:(bool)isHttpOnly;
|
||||
|
||||
+ (void) setJavaScriptChannels: (NSArray *)channels;
|
||||
|
||||
+ (void) sendJavaScriptChannelCallBack: (bool)error result:(NSString *)result callbackId:(NSString *)callbackId frameId:(NSString *)frameId;
|
||||
|
||||
+ (void) executeJavaScript: (NSString *)code;
|
||||
+ (void)setMethodChannel: (FlutterMethodChannel*)channel;
|
||||
+ (FlutterResult) handleMethodCallWrapper: (FlutterMethodCall*)call;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -7,21 +7,18 @@
|
||||
|
||||
#import "CefWrapper.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "include/wrapper/cef_library_loader.h"
|
||||
#import "include/cef_app.h"
|
||||
#import "include/cef_base.h"
|
||||
#import "../../common/webview_app.h"
|
||||
#import "../../common/webview_handler.h"
|
||||
#import "../../common/webview_cookieVisitor.h"
|
||||
#import "../../common/webview_js_handler.h"
|
||||
|
||||
#import "../../common/webview_plugin.h"
|
||||
#import "../../common/webview_value.h"
|
||||
#include <thread>
|
||||
|
||||
CefRefPtr<WebviewHandler> handler(new WebviewHandler());
|
||||
CefRefPtr<WebviewApp> app(new WebviewApp(handler));
|
||||
CefMainArgs mainArgs;
|
||||
|
||||
NSObject<FlutterTextureRegistry>* tr;
|
||||
CGFloat scaleFactor = 0.0;
|
||||
CefMainArgs mainArgs;
|
||||
|
||||
static NSTimer* _timer;
|
||||
static CVPixelBufferRef buf_cache;
|
||||
@@ -34,132 +31,100 @@ FlutterMethodChannel* f_channel;
|
||||
|
||||
@implementation CefWrapper
|
||||
|
||||
+ (void)init {
|
||||
CefScopedLibraryLoader loader;
|
||||
|
||||
if(!loader.LoadInMain()) {
|
||||
printf("load cef err");
|
||||
+ (NSObject *)encode_wvalue_to_flvalue: (WValue*)args {
|
||||
WValueType type = webview_value_get_type(args);
|
||||
switch(type) {
|
||||
case Webview_Value_Type_Bool:
|
||||
return [NSNumber numberWithBool:webview_value_get_bool(args)];
|
||||
case Webview_Value_Type_Int:
|
||||
return [NSNumber numberWithInt:webview_value_get_int(args)];
|
||||
case Webview_Value_Type_Float:
|
||||
return [NSNumber numberWithFloat:webview_value_get_float(args)];
|
||||
case Webview_Value_Type_Double:
|
||||
return [NSNumber numberWithDouble:webview_value_get_double(args)];
|
||||
case Webview_Value_Type_String:
|
||||
return [NSString stringWithUTF8String:webview_value_get_string(args)];
|
||||
case Webview_Value_Type_Uint8_List:
|
||||
return [NSData dataWithBytes:webview_value_get_uint8_list(args) length:webview_value_get_len(args)];
|
||||
case Webview_Value_Type_Int32_List:
|
||||
return [NSData dataWithBytes:webview_value_get_int32_list(args) length:webview_value_get_len(args)];
|
||||
case Webview_Value_Type_Int64_List:
|
||||
return [NSData dataWithBytes:webview_value_get_int64_list(args) length:webview_value_get_len(args)];
|
||||
case Webview_Value_Type_Float_List:
|
||||
return [NSData dataWithBytes:webview_value_get_float_list(args) length:webview_value_get_len(args)];
|
||||
case Webview_Value_Type_Double_List:
|
||||
return [NSData dataWithBytes:webview_value_get_double_list(args) length:webview_value_get_len(args)];
|
||||
case Webview_Value_Type_List: {
|
||||
int len = webview_value_get_len(args);
|
||||
NSMutableArray* array = [NSMutableArray arrayWithCapacity:len];
|
||||
for(int i = 0; i < len; i++) {
|
||||
WValue* item = webview_value_get_value(args, i);
|
||||
[array addObject:[self encode_wvalue_to_flvalue:item]];
|
||||
}
|
||||
return array;
|
||||
}
|
||||
case Webview_Value_Type_Map: {
|
||||
int len = webview_value_get_len(args);
|
||||
NSMutableDictionary* dic = [NSMutableDictionary dictionaryWithCapacity:len];
|
||||
for(int i = 0; i < len; i++) {
|
||||
NSString *key = [self encode_wvalue_to_flvalue:webview_value_get_key(args, i)];
|
||||
WValue *value = webview_value_get_value(args, i);
|
||||
if (key != nil && value != nil) {
|
||||
[dic setObject:[self encode_wvalue_to_flvalue:value] forKey:key];
|
||||
}
|
||||
}
|
||||
return dic;
|
||||
}
|
||||
default:
|
||||
return nil;
|
||||
}
|
||||
|
||||
CefMainArgs main_args;
|
||||
CefExecuteProcess(main_args, nullptr, nullptr);
|
||||
}
|
||||
|
||||
+ (void)doMessageLoopWork {
|
||||
CefDoMessageLoopWork();
|
||||
}
|
||||
|
||||
+ (void)startCef {
|
||||
textureId = [tr registerTexture:[CefWrapper alloc]];
|
||||
handler.get()->onPaintCallback = [](const void* buffer, int32_t width, int32_t height) {
|
||||
NSDictionary* dic = @{
|
||||
(__bridge NSString*)kCVPixelBufferPixelFormatTypeKey: @(kCVPixelFormatType_32BGRA),
|
||||
(__bridge NSString*)kCVPixelBufferIOSurfacePropertiesKey : @{},
|
||||
(__bridge NSString*)kCVPixelBufferOpenGLCompatibilityKey : @YES,
|
||||
(__bridge NSString*)kCVPixelBufferMetalCompatibilityKey : @YES,
|
||||
};
|
||||
|
||||
static CVPixelBufferRef buf = NULL;
|
||||
CVPixelBufferCreate(kCFAllocatorDefault, width,
|
||||
height, kCVPixelFormatType_32BGRA,
|
||||
(__bridge CFDictionaryRef)dic, &buf);
|
||||
|
||||
//copy data
|
||||
CVPixelBufferLockBaseAddress(buf, 0);
|
||||
char *copyBaseAddress = (char *) CVPixelBufferGetBaseAddress(buf);
|
||||
|
||||
//MUST align pixel to pixelBuffer. Otherwise cause render issue. see https://www.codeprintr.com/thread/6563066.html about 16 bytes align
|
||||
size_t bytesPerRow = CVPixelBufferGetBytesPerRowOfPlane(buf, 0);
|
||||
char* src = (char*) buffer;
|
||||
int actureRowSize = width * 4;
|
||||
for(int line = 0; line < height; line++) {
|
||||
memcpy(copyBaseAddress, src, actureRowSize);
|
||||
src += actureRowSize;
|
||||
copyBaseAddress += bytesPerRow;
|
||||
+ (WValue*) encode_flvalue_to_wvalue: (NSObject *)value{
|
||||
if([value isKindOfClass:[NSNumber class]]) {
|
||||
NSNumber* number = (NSNumber*)value;
|
||||
if(strcmp([number objCType], @encode(BOOL)) == 0) {
|
||||
return webview_value_new_bool([number boolValue]);
|
||||
} else if(strcmp([number objCType], @encode(int)) == 0) {
|
||||
return webview_value_new_int([number intValue]);
|
||||
} else if(strcmp([number objCType], @encode(float)) == 0) {
|
||||
return webview_value_new_float([number floatValue]);
|
||||
} else if(strcmp([number objCType], @encode(double)) == 0) {
|
||||
return webview_value_new_double([number doubleValue]);
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
CVPixelBufferUnlockBaseAddress(buf, 0);
|
||||
|
||||
dispatch_semaphore_wait(lock, DISPATCH_TIME_FOREVER);
|
||||
if(buf_cache) {
|
||||
CVPixelBufferRelease(buf_cache);
|
||||
} else if([value isKindOfClass:[NSString class]]) {
|
||||
NSString* string = (NSString*)value;
|
||||
return webview_value_new_string([string UTF8String]);
|
||||
} else if([value isKindOfClass:[NSData class]]) {
|
||||
NSData* data = (NSData*)value;
|
||||
return webview_value_new_int64_list((int64_t*)data.bytes, (size_t)data.length);
|
||||
} else if([value isKindOfClass:[NSArray class]]) {
|
||||
NSArray* array = (NSArray*)value;
|
||||
int len = (int)array.count;
|
||||
WValue* wvalue = webview_value_new_list();
|
||||
for(int i = 0; i < len; i++) {
|
||||
WValue* item = [self encode_flvalue_to_wvalue:array[i]];
|
||||
webview_value_append(wvalue, item);
|
||||
webview_value_unref(item);
|
||||
}
|
||||
buf_cache = buf;
|
||||
dispatch_semaphore_signal(lock);
|
||||
[tr textureFrameAvailable:textureId];
|
||||
};
|
||||
|
||||
//url change cb
|
||||
handler.get()->onUrlChangedCb = [](std::string url) {
|
||||
[f_channel invokeMethod:@"urlChanged" arguments:[NSString stringWithCString:url.c_str() encoding:NSUTF8StringEncoding]];
|
||||
};
|
||||
//title change cb
|
||||
handler.get()->onTitleChangedCb = [](std::string title) {
|
||||
[f_channel invokeMethod:@"titleChanged" arguments:[NSString stringWithCString:title.c_str() encoding:NSUTF8StringEncoding]];
|
||||
};
|
||||
//allcookie visited cb
|
||||
handler.get()->onAllCookieVisitedCb = [](std::map<std::string, std::map<std::string, std::string>> cookies) {
|
||||
NSMutableDictionary * dict = [NSMutableDictionary dictionary];
|
||||
for(auto &cookie : cookies)
|
||||
{
|
||||
NSString * domain = [NSString stringWithCString:cookie.first.c_str() encoding:NSUTF8StringEncoding];
|
||||
NSMutableDictionary * tempdict = [NSMutableDictionary dictionary];
|
||||
for(auto &c : cookie.second)
|
||||
{
|
||||
NSString * key = [NSString stringWithCString:c.first.c_str() encoding:NSUTF8StringEncoding];
|
||||
NSString * val = [NSString stringWithCString:c.second.c_str() encoding:NSUTF8StringEncoding];
|
||||
tempdict[key] = val;
|
||||
}
|
||||
dict[domain] = tempdict;
|
||||
return wvalue;
|
||||
} else if([value isKindOfClass:[NSDictionary class]]) {
|
||||
NSDictionary* dic = (NSDictionary*)value;
|
||||
int len = (int)dic.count;
|
||||
WValue* wvalue = webview_value_new_map();
|
||||
for(int i = 0; i < len; i++) {
|
||||
WValue* key = [self encode_flvalue_to_wvalue:dic.allKeys[i]];
|
||||
WValue* item = [self encode_flvalue_to_wvalue:dic.allValues[i]];
|
||||
webview_value_set(wvalue, key, item);
|
||||
webview_value_unref(key);
|
||||
webview_value_unref(item);
|
||||
}
|
||||
[f_channel invokeMethod:@"allCookiesVisited" arguments:dict];
|
||||
};
|
||||
|
||||
//urlcookie visited cb
|
||||
handler.get()->onUrlCookieVisitedCb = [](std::map<std::string, std::map<std::string, std::string>> cookies) {
|
||||
NSMutableDictionary * dict = [NSMutableDictionary dictionary];
|
||||
for(auto &cookie : cookies)
|
||||
{
|
||||
NSString * domain = [NSString stringWithCString:cookie.first.c_str() encoding:NSUTF8StringEncoding];
|
||||
NSMutableDictionary * tempdict = [NSMutableDictionary dictionary];
|
||||
for(auto &c : cookie.second)
|
||||
{
|
||||
NSString * key = [NSString stringWithCString:c.first.c_str() encoding:NSUTF8StringEncoding];
|
||||
NSString * val = [NSString stringWithCString:c.second.c_str() encoding:NSUTF8StringEncoding];
|
||||
tempdict[key] = val;
|
||||
}
|
||||
dict[domain] = tempdict;
|
||||
}
|
||||
[f_channel invokeMethod:@"urlCookiesVisited" arguments:dict];
|
||||
};
|
||||
|
||||
//JavaScriptChannel called
|
||||
handler.get()->onJavaScriptChannelMessage = [](std::string channelName, std::string message, std::string callbackId, std::string frameId) {
|
||||
NSMutableDictionary * dict = [NSMutableDictionary dictionary];
|
||||
dict[@"channel"] = [NSString stringWithCString:channelName.c_str() encoding:NSUTF8StringEncoding];
|
||||
dict[@"message"] = [NSString stringWithCString:message.c_str() encoding:NSUTF8StringEncoding];
|
||||
dict[@"callbackId"] = [NSString stringWithCString:callbackId.c_str() encoding:NSUTF8StringEncoding];
|
||||
dict[@"frameId"] = [NSString stringWithCString:frameId.c_str() encoding:NSUTF8StringEncoding];
|
||||
[f_channel invokeMethod:@"javascriptChannelMessage" arguments:dict];
|
||||
};
|
||||
|
||||
CefSettings settings;
|
||||
settings.windowless_rendering_enabled = true;
|
||||
settings.external_message_pump = true;
|
||||
CefString(&settings.browser_subprocess_path) = "/Library/Chaches";
|
||||
|
||||
CefInitialize(mainArgs, settings, app.get(), nullptr);
|
||||
_timer = [NSTimer timerWithTimeInterval:0.016f target:self selector:@selector(doMessageLoopWork) userInfo:nil repeats:YES];
|
||||
[[NSRunLoop mainRunLoop] addTimer: _timer forMode:NSRunLoopCommonModes];
|
||||
|
||||
[NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyDown handler:^NSEvent * _Nullable(NSEvent * _Nonnull event) {
|
||||
[self processKeyboardEvent:event];
|
||||
return event;
|
||||
}];
|
||||
|
||||
[NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyUp handler:^NSEvent * _Nullable(NSEvent * _Nonnull event) {
|
||||
[self processKeyboardEvent:event];
|
||||
return event;
|
||||
}];
|
||||
return wvalue;
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)processKeyboardEvent: (NSEvent*) event {
|
||||
@@ -190,8 +155,8 @@ FlutterMethodChannel* f_channel;
|
||||
keyEvent.type = KEYEVENT_KEYUP;
|
||||
}
|
||||
}
|
||||
|
||||
handler.get()->sendKeyEvent(keyEvent);
|
||||
|
||||
webview_cef::sendKeyEvent(keyEvent);
|
||||
}
|
||||
|
||||
+ (int)getModifiersForEvent:(NSEvent*)event {
|
||||
@@ -244,46 +209,6 @@ FlutterMethodChannel* f_channel;
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
+(void)sendScrollEvent:(int)x y:(int)y deltaX:(int)deltaX deltaY:(int)deltaY {
|
||||
handler.get()->sendScrollEvent(x, y, deltaX, deltaY);
|
||||
}
|
||||
|
||||
+ (void)cursorClickUp:(int)x y:(int)y {
|
||||
handler.get()->cursorClick(x, y, true);
|
||||
}
|
||||
|
||||
+ (void)cursorClickDown:(int)x y:(int)y {
|
||||
handler.get()->cursorClick(x, y, false);
|
||||
}
|
||||
|
||||
+ (void)cursorMove:(int)x y:(int)y dragging:(bool)dragging {
|
||||
handler.get()->cursorMove(x, y, dragging);
|
||||
}
|
||||
|
||||
+ (void)sizeChanged:(float)dpi width:(int)width height:(int)height {
|
||||
handler.get()->changeSize(dpi, width, height);
|
||||
}
|
||||
|
||||
+ (void)loadUrl:(NSString*)url {
|
||||
handler.get()->loadUrl(std::string([url cStringUsingEncoding:NSUTF8StringEncoding]));
|
||||
}
|
||||
|
||||
+ (void)goForward {
|
||||
handler.get()->goForward();
|
||||
}
|
||||
|
||||
+ (void)goBack {
|
||||
handler.get()->goBack();
|
||||
}
|
||||
|
||||
+ (void)reload {
|
||||
handler.get()->reload();
|
||||
}
|
||||
|
||||
+ (void)openDevTools {
|
||||
handler.get()->openDevTools();
|
||||
}
|
||||
|
||||
- (CVPixelBufferRef _Nullable)copyPixelBuffer {
|
||||
dispatch_semaphore_wait(lock, DISPATCH_TIME_FOREVER);
|
||||
buf_temp = buf_cache;
|
||||
@@ -294,40 +219,87 @@ FlutterMethodChannel* f_channel;
|
||||
|
||||
+ (void)setMethodChannel: (FlutterMethodChannel*)channel {
|
||||
f_channel = channel;
|
||||
auto invoke = [=](std::string method, WValue* arguments){
|
||||
NSObject *arg = [self encode_wvalue_to_flvalue:arguments];
|
||||
[f_channel invokeMethod:[NSString stringWithUTF8String:method.c_str()] arguments:arg];
|
||||
};
|
||||
webview_cef::setInvokeMethodFunc(invoke);
|
||||
}
|
||||
|
||||
+ (void)setCookie: (NSString *)domain key:(NSString *) key value:(NSString *)value {
|
||||
handler.get()->setCookie(std::string([domain cStringUsingEncoding:NSUTF8StringEncoding]), std::string([key cStringUsingEncoding:NSUTF8StringEncoding]), std::string([value cStringUsingEncoding:NSUTF8StringEncoding]));
|
||||
+ (void)doMessageLoopWork {
|
||||
webview_cef::doMessageLoopWork();
|
||||
}
|
||||
|
||||
+ (void)deleteCookie: (NSString *)domain key:(NSString *) key {
|
||||
handler.get()->deleteCookie(std::string([domain cStringUsingEncoding:NSUTF8StringEncoding]), std::string([key cStringUsingEncoding:NSUTF8StringEncoding]));
|
||||
}
|
||||
+ (NSObject*) handleMethodCallWrapper: (FlutterMethodCall*)call{
|
||||
std::string name = std::string([call.method cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
if(name.compare("init") == 0){
|
||||
textureId = [tr registerTexture:[CefWrapper alloc]];
|
||||
auto callback = [](const void* buffer, int32_t width, int32_t height) {
|
||||
NSDictionary* dic = @{
|
||||
(__bridge NSString*)kCVPixelBufferPixelFormatTypeKey: @(kCVPixelFormatType_32BGRA),
|
||||
(__bridge NSString*)kCVPixelBufferIOSurfacePropertiesKey : @{},
|
||||
(__bridge NSString*)kCVPixelBufferOpenGLCompatibilityKey : @YES,
|
||||
(__bridge NSString*)kCVPixelBufferMetalCompatibilityKey : @YES,
|
||||
};
|
||||
|
||||
static CVPixelBufferRef buf = NULL;
|
||||
CVPixelBufferCreate(kCFAllocatorDefault, width,
|
||||
height, kCVPixelFormatType_32BGRA,
|
||||
(__bridge CFDictionaryRef)dic, &buf);
|
||||
|
||||
//copy data
|
||||
CVPixelBufferLockBaseAddress(buf, 0);
|
||||
char *copyBaseAddress = (char *) CVPixelBufferGetBaseAddress(buf);
|
||||
|
||||
//MUST align pixel to pixelBuffer. Otherwise cause render issue. see https://www.codeprintr.com/thread/6563066.html about 16 bytes align
|
||||
size_t bytesPerRow = CVPixelBufferGetBytesPerRowOfPlane(buf, 0);
|
||||
char* src = (char*) buffer;
|
||||
int actureRowSize = width * 4;
|
||||
for(int line = 0; line < height; line++) {
|
||||
memcpy(copyBaseAddress, src, actureRowSize);
|
||||
src += actureRowSize;
|
||||
copyBaseAddress += bytesPerRow;
|
||||
}
|
||||
CVPixelBufferUnlockBaseAddress(buf, 0);
|
||||
|
||||
dispatch_semaphore_wait(lock, DISPATCH_TIME_FOREVER);
|
||||
if(buf_cache) {
|
||||
CVPixelBufferRelease(buf_cache);
|
||||
}
|
||||
buf_cache = buf;
|
||||
dispatch_semaphore_signal(lock);
|
||||
[tr textureFrameAvailable:textureId];
|
||||
};
|
||||
webview_cef::initCEFProcesses();
|
||||
webview_cef::setPaintCallBack(callback);
|
||||
|
||||
+ (void)visitAllCookies {
|
||||
handler.get()->visitAllCookies();
|
||||
}
|
||||
|
||||
+ (void)visitUrlCookies: (NSString *)domain isHttpOnly:(bool)isHttpOnly {
|
||||
handler.get()->visitUrlCookies(std::string([domain cStringUsingEncoding:NSUTF8StringEncoding]), isHttpOnly);
|
||||
}
|
||||
|
||||
+ (void) setJavaScriptChannels: (NSArray *)channels {
|
||||
std::vector<std::string> stdChannels;
|
||||
NSEnumerator * enumerator = [channels objectEnumerator];
|
||||
NSString * value;
|
||||
while (value = [enumerator nextObject]) {
|
||||
stdChannels.push_back(std::string([value cStringUsingEncoding:NSUTF8StringEncoding]));
|
||||
_timer = [NSTimer timerWithTimeInterval:0.016f target:self selector:@selector(doMessageLoopWork) userInfo:nil repeats:YES];
|
||||
[[NSRunLoop mainRunLoop] addTimer: _timer forMode:NSRunLoopCommonModes];
|
||||
|
||||
[NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyDown handler:^NSEvent * _Nullable(NSEvent * _Nonnull event) {
|
||||
[self processKeyboardEvent:event];
|
||||
return event;
|
||||
}];
|
||||
|
||||
[NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyUp handler:^NSEvent * _Nullable(NSEvent * _Nonnull event) {
|
||||
[self processKeyboardEvent:event];
|
||||
return event;
|
||||
}];
|
||||
return [NSNumber numberWithLong:textureId];
|
||||
}else{
|
||||
WValue *encodeArgs = [self encode_flvalue_to_wvalue:call.arguments];
|
||||
WValue *responseArgs = nullptr;
|
||||
int ret = webview_cef::HandleMethodCall(name, encodeArgs, responseArgs);
|
||||
webview_value_unref(encodeArgs);
|
||||
if(ret != 0){
|
||||
NSObject *result = [self encode_wvalue_to_flvalue:responseArgs];
|
||||
webview_value_unref(responseArgs);
|
||||
return result;
|
||||
}
|
||||
else{
|
||||
webview_value_unref(responseArgs);
|
||||
}
|
||||
}
|
||||
handler.get()->setJavaScriptChannels(stdChannels);
|
||||
}
|
||||
|
||||
+ (void) sendJavaScriptChannelCallBack: (bool)error result:(NSString *)result callbackId:(NSString *)callbackId frameId:(NSString *)frameId {
|
||||
handler.get()->sendJavaScriptChannelCallBack(error, std::string([result cStringUsingEncoding:NSUTF8StringEncoding]),
|
||||
std::string([callbackId cStringUsingEncoding:NSUTF8StringEncoding]), std::string([frameId cStringUsingEncoding:NSUTF8StringEncoding]));
|
||||
}
|
||||
|
||||
+ (void) executeJavaScript: (NSString *)code {
|
||||
handler.get()->executeJavaScript(std::string([code cStringUsingEncoding:NSUTF8StringEncoding]));
|
||||
return nil;
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -17,133 +17,6 @@
|
||||
}
|
||||
|
||||
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
|
||||
|
||||
if ([@"getPlatformVersion" isEqualToString:call.method]) {
|
||||
NSOperatingSystemVersion systemVer =[[NSProcessInfo processInfo] operatingSystemVersion];
|
||||
NSString *systemVersion = [NSString stringWithFormat:@"%ld.%ld.%ld",
|
||||
(long)systemVer.majorVersion, (long)systemVer.minorVersion, (long)systemVer.patchVersion];
|
||||
result([@"macOS " stringByAppendingString:systemVersion]);
|
||||
}
|
||||
else if([@"init" isEqualToString:call.method]){
|
||||
[CefWrapper init];
|
||||
[CefWrapper startCef];
|
||||
result([NSNumber numberWithLong:textureId]);
|
||||
}
|
||||
else if([@"loadUrl" isEqualToString:call.method]){
|
||||
NSString * url = call.arguments;
|
||||
[CefWrapper loadUrl:url];
|
||||
result(nil);
|
||||
}
|
||||
else if([@"setScrollDelta" isEqualToString:call.method]){
|
||||
NSArray<NSNumber *> *_arg = call.arguments;
|
||||
NSNumber *x = [_arg objectAtIndex:0];
|
||||
NSNumber *y = [_arg objectAtIndex:1];
|
||||
NSNumber *deltaX = [_arg objectAtIndex:2];
|
||||
NSNumber *deltaY = [_arg objectAtIndex:3];
|
||||
[CefWrapper sendScrollEvent:[x intValue] y:[y intValue] deltaX:[deltaX intValue] deltaY:[deltaY intValue]];
|
||||
result(nil);
|
||||
}
|
||||
else if([@"cursorClickUp" isEqualToString:call.method]){
|
||||
NSArray<NSNumber *> *_arg = call.arguments;
|
||||
NSNumber *x = [_arg objectAtIndex:0];
|
||||
NSNumber *y = [_arg objectAtIndex:1];
|
||||
[CefWrapper cursorClickUp:[x intValue] y:[y intValue]];
|
||||
result(nil);
|
||||
}
|
||||
else if([@"cursorClickDown" isEqualToString:call.method]){
|
||||
NSArray<NSNumber *> *_arg = call.arguments;
|
||||
NSNumber *x = [_arg objectAtIndex:0];
|
||||
NSNumber *y = [_arg objectAtIndex:1];
|
||||
[CefWrapper cursorClickDown:[x intValue] y:[y intValue]];
|
||||
result(nil);
|
||||
}
|
||||
else if([@"cursorMove" isEqualToString:call.method]){
|
||||
NSArray<NSNumber *> *_arg = call.arguments;
|
||||
NSNumber *x = [_arg objectAtIndex:0];
|
||||
NSNumber *y = [_arg objectAtIndex:1];
|
||||
[CefWrapper cursorMove:[x intValue] y:[y intValue] dragging: false];
|
||||
result(nil);
|
||||
}
|
||||
else if([@"cursorDragging" isEqualToString:call.method]){
|
||||
NSArray<NSNumber *> *_arg = call.arguments;
|
||||
NSNumber *x = [_arg objectAtIndex:0];
|
||||
NSNumber *y = [_arg objectAtIndex:1];
|
||||
[CefWrapper cursorMove:[x intValue] y:[y intValue] dragging: true];
|
||||
result(nil);
|
||||
}
|
||||
else if([@"setSize" isEqualToString:call.method]){
|
||||
NSArray<NSNumber *> *_arg = call.arguments;
|
||||
NSNumber *dpi = [_arg objectAtIndex:0];
|
||||
NSNumber *width = [_arg objectAtIndex:1];
|
||||
NSNumber *height = [_arg objectAtIndex:2];
|
||||
[CefWrapper sizeChanged: [dpi floatValue] width:[width intValue] height:[height intValue]];
|
||||
result(nil);
|
||||
}
|
||||
else if([@"goForward" isEqualToString:call.method]){
|
||||
[CefWrapper goForward];
|
||||
result(nil);
|
||||
}
|
||||
else if([@"goBack" isEqualToString:call.method]){
|
||||
[CefWrapper goBack];
|
||||
result(nil);
|
||||
}
|
||||
else if([@"reload" isEqualToString:call.method]){
|
||||
[CefWrapper reload];
|
||||
result(nil);
|
||||
}
|
||||
else if([@"openDevTools" isEqualToString:call.method]){
|
||||
[CefWrapper openDevTools];
|
||||
result(nil);
|
||||
}
|
||||
else if([@"setCookie" isEqualToString:call.method]){
|
||||
NSArray<NSString *> *_arg = call.arguments;
|
||||
NSString * domain = [_arg objectAtIndex:0];
|
||||
NSString * key = [_arg objectAtIndex:1];
|
||||
NSString * value = [_arg objectAtIndex:2];
|
||||
[CefWrapper setCookie:domain key:key value:value];
|
||||
result(nil);
|
||||
}
|
||||
else if ([@"deleteCookie" isEqualToString:call.method]) {
|
||||
NSArray<NSString *> *_arg = call.arguments;
|
||||
NSString * domain = [_arg objectAtIndex:0];
|
||||
NSString * key = [_arg objectAtIndex:1];
|
||||
[CefWrapper deleteCookie:domain key:key];
|
||||
result(nil);
|
||||
}
|
||||
else if ([@"visitAllCookies" isEqualToString:call.method]) {
|
||||
[CefWrapper visitAllCookies];
|
||||
result(nil);
|
||||
}
|
||||
else if ([@"visitUrlCookies" isEqualToString:call.method]) {
|
||||
NSArray<NSString *> *_arg = call.arguments;
|
||||
NSString * domain = [_arg objectAtIndex:0];
|
||||
NSString * isHttpOnly = [_arg objectAtIndex:1];
|
||||
[CefWrapper visitUrlCookies:domain isHttpOnly:[isHttpOnly boolValue]];
|
||||
result(nil);
|
||||
}
|
||||
else if ([@"setJavaScriptChannels" isEqualToString:call.method]) {
|
||||
NSArray<NSArray *> *_arg = call.arguments;
|
||||
NSArray * channels = [_arg objectAtIndex:0];
|
||||
[CefWrapper setJavaScriptChannels:channels];
|
||||
result(nil);
|
||||
}
|
||||
else if ([@"sendJavaScriptChannelCallBack" isEqualToString:call.method]) {
|
||||
NSArray<NSString *> *_arg = call.arguments;
|
||||
NSString * error = [_arg objectAtIndex:0];
|
||||
NSString * ret = [_arg objectAtIndex:1];
|
||||
NSString * callbackId = [_arg objectAtIndex:2];
|
||||
NSString * frameId = [_arg objectAtIndex:3];
|
||||
[CefWrapper sendJavaScriptChannelCallBack:[error boolValue] result:ret callbackId:callbackId frameId:frameId];
|
||||
result(nil);
|
||||
}
|
||||
else if ([@"executeJavaScript" isEqualToString:call.method]) {
|
||||
NSArray<NSString *> *_arg = call.arguments;
|
||||
NSString * code = [_arg objectAtIndex:0];
|
||||
[CefWrapper executeJavaScript:code];
|
||||
result(nil);
|
||||
}
|
||||
else {
|
||||
result(FlutterMethodNotImplemented);
|
||||
}
|
||||
result([CefWrapper handleMethodCallWrapper:call]);
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -6,5 +6,6 @@
|
||||
#include "../../common/webview_handler.cc"
|
||||
#include "../../common/webview_cookieVisitor.cc"
|
||||
#include "../../common/webview_js_handler.cc"
|
||||
|
||||
#include "../../common/webview_plugin.cc"
|
||||
#include "../../common/webview_value.cc"
|
||||
#endif
|
||||
|
||||
@@ -25,3 +25,5 @@ flutter:
|
||||
pluginClass: WebviewCefPlugin
|
||||
windows:
|
||||
pluginClass: WebviewCefPluginCApi
|
||||
linux:
|
||||
pluginClass: WebviewCefPlugin
|
||||
|
||||
7
third/cef/.gitignore
vendored
Normal file
7
third/cef/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake
|
||||
Debug
|
||||
libcef_dll
|
||||
libcef_dll_wrapper
|
||||
Release
|
||||
Resources
|
||||
version.txt
|
||||
97
third/cef/include/base/cef_atomic_flag.h
Normal file
97
third/cef/include/base/cef_atomic_flag.h
Normal file
@@ -0,0 +1,97 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_ATOMIC_FLAG_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_ATOMIC_FLAG_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/synchronization/atomic_flag.h"
|
||||
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include "include/base/cef_thread_checker.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
///
|
||||
/// A flag that can safely be set from one thread and read from other threads.
|
||||
///
|
||||
/// This class IS NOT intended for synchronization between threads.
|
||||
///
|
||||
class AtomicFlag {
|
||||
public:
|
||||
AtomicFlag();
|
||||
|
||||
AtomicFlag(const AtomicFlag&) = delete;
|
||||
AtomicFlag& operator=(const AtomicFlag&) = delete;
|
||||
|
||||
~AtomicFlag();
|
||||
|
||||
///
|
||||
/// Set the flag. Must always be called from the same thread.
|
||||
///
|
||||
void Set();
|
||||
|
||||
///
|
||||
/// Returns true iff the flag was set. If this returns true, the current
|
||||
/// thread is guaranteed to be synchronized with all memory operations on the
|
||||
/// thread which invoked Set() up until at least the first call to Set() on
|
||||
/// it.
|
||||
///
|
||||
bool IsSet() const {
|
||||
// Inline here: this has a measurable performance impact on base::WeakPtr.
|
||||
return flag_.load(std::memory_order_acquire) != 0;
|
||||
}
|
||||
|
||||
///
|
||||
/// Resets the flag. Be careful when using this: callers might not expect
|
||||
/// IsSet() to return false after returning true once.
|
||||
///
|
||||
void UnsafeResetForTesting();
|
||||
|
||||
private:
|
||||
std::atomic<uint_fast8_t> flag_{0};
|
||||
base::ThreadChecker set_thread_checker_;
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_ATOMIC_FLAG_H_
|
||||
123
third/cef/include/base/cef_atomic_ref_count.h
Normal file
123
third/cef/include/base/cef_atomic_ref_count.h
Normal file
@@ -0,0 +1,123 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a low level implementation of atomic semantics for reference
|
||||
// counting. Please use cef_ref_counted.h directly instead.
|
||||
//
|
||||
// The Chromium implementation includes annotations to avoid some false
|
||||
// positives when using data race detection tools. Annotations are not
|
||||
// currently supported by the CEF implementation.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_ATOMIC_REF_COUNT_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_ATOMIC_REF_COUNT_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/atomic_ref_count.h"
|
||||
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include <atomic>
|
||||
|
||||
namespace base {
|
||||
|
||||
class AtomicRefCount {
|
||||
public:
|
||||
constexpr AtomicRefCount() : ref_count_(0) {}
|
||||
explicit constexpr AtomicRefCount(int initial_value)
|
||||
: ref_count_(initial_value) {}
|
||||
|
||||
///
|
||||
/// Increment a reference count.
|
||||
/// Returns the previous value of the count.
|
||||
///
|
||||
int Increment() { return Increment(1); }
|
||||
|
||||
///
|
||||
/// Increment a reference count by "increment", which must exceed 0.
|
||||
/// Returns the previous value of the count.
|
||||
///
|
||||
int Increment(int increment) {
|
||||
return ref_count_.fetch_add(increment, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
///
|
||||
/// Decrement a reference count, and return whether the result is non-zero.
|
||||
/// Insert barriers to ensure that state written before the reference count
|
||||
/// became zero will be visible to a thread that has just made the count zero.
|
||||
///
|
||||
bool Decrement() {
|
||||
// TODO(jbroman): Technically this doesn't need to be an acquire operation
|
||||
// unless the result is 1 (i.e., the ref count did indeed reach zero).
|
||||
// However, there are toolchain issues that make that not work as well at
|
||||
// present (notably TSAN doesn't like it).
|
||||
return ref_count_.fetch_sub(1, std::memory_order_acq_rel) != 1;
|
||||
}
|
||||
|
||||
///
|
||||
/// Return whether the reference count is one. If the reference count is used
|
||||
/// in the conventional way, a refrerence count of 1 implies that the current
|
||||
/// thread owns the reference and no other thread shares it. This call
|
||||
/// performs the test for a reference count of one, and performs the memory
|
||||
/// barrier needed for the owning thread to act on the object, knowing that it
|
||||
/// has exclusive access to the object.
|
||||
///
|
||||
bool IsOne() const { return ref_count_.load(std::memory_order_acquire) == 1; }
|
||||
|
||||
///
|
||||
/// Return whether the reference count is zero. With conventional object
|
||||
/// referencing counting, the object will be destroyed, so the reference count
|
||||
/// should never be zero. Hence this is generally used for a debug check.
|
||||
///
|
||||
bool IsZero() const {
|
||||
return ref_count_.load(std::memory_order_acquire) == 0;
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns the current reference count (with no barriers). This is subtle,
|
||||
/// and should be used only for debugging.
|
||||
///
|
||||
int SubtleRefCountForDebug() const {
|
||||
return ref_count_.load(std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
private:
|
||||
std::atomic_int ref_count_;
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_ATOMIC_REF_COUNT_H_
|
||||
90
third/cef/include/base/cef_auto_reset.h
Normal file
90
third/cef/include/base/cef_auto_reset.h
Normal file
@@ -0,0 +1,90 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// base::AutoReset<> is useful for setting a variable to a new value only within
|
||||
// a particular scope. An base::AutoReset<> object resets a variable to its
|
||||
// original value upon destruction, making it an alternative to writing
|
||||
// "var = false;" or "var = old_val;" at all of a block's exit points.
|
||||
//
|
||||
// This should be obvious, but note that an base::AutoReset<> instance should
|
||||
// have a shorter lifetime than its scoped_variable, to prevent invalid memory
|
||||
// writes when the base::AutoReset<> object is destroyed.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_AUTO_RESET_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_AUTO_RESET_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/auto_reset.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace base {
|
||||
|
||||
template <typename T>
|
||||
class AutoReset {
|
||||
public:
|
||||
template <typename U>
|
||||
AutoReset(T* scoped_variable, U&& new_value)
|
||||
: scoped_variable_(scoped_variable),
|
||||
original_value_(
|
||||
std::exchange(*scoped_variable_, std::forward<U>(new_value))) {}
|
||||
|
||||
AutoReset(AutoReset&& other)
|
||||
: scoped_variable_(std::exchange(other.scoped_variable_, nullptr)),
|
||||
original_value_(std::move(other.original_value_)) {}
|
||||
|
||||
AutoReset& operator=(AutoReset&& rhs) {
|
||||
scoped_variable_ = std::exchange(rhs.scoped_variable_, nullptr);
|
||||
original_value_ = std::move(rhs.original_value_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
~AutoReset() {
|
||||
if (scoped_variable_) {
|
||||
*scoped_variable_ = std::move(original_value_);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
T* scoped_variable_;
|
||||
T original_value_;
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_AUTO_RESET_H_
|
||||
86
third/cef/include/base/cef_basictypes.h
Normal file
86
third/cef/include/base/cef_basictypes.h
Normal file
@@ -0,0 +1,86 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_BASICTYPES_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_BASICTYPES_H_
|
||||
#pragma once
|
||||
|
||||
#include <limits.h> // For UINT_MAX
|
||||
#include <stddef.h> // For size_t
|
||||
|
||||
#include "include/base/cef_build.h"
|
||||
|
||||
// The NSPR system headers define 64-bit as |long| when possible, except on
|
||||
// Mac OS X. In order to not have typedef mismatches, we do the same on LP64.
|
||||
//
|
||||
// On Mac OS X, |long long| is used for 64-bit types for compatibility with
|
||||
// <inttypes.h> format macros even in the LP64 model.
|
||||
#if defined(__LP64__) && !defined(OS_MAC) && !defined(OS_OPENBSD)
|
||||
typedef long int64;
|
||||
typedef unsigned long uint64;
|
||||
#else
|
||||
typedef long long int64;
|
||||
typedef unsigned long long uint64;
|
||||
#endif
|
||||
|
||||
// TODO: Remove these type guards. These are to avoid conflicts with
|
||||
// obsolete/protypes.h in the Gecko SDK.
|
||||
#ifndef _INT32
|
||||
#define _INT32
|
||||
typedef int int32;
|
||||
#endif
|
||||
|
||||
// TODO: Remove these type guards. These are to avoid conflicts with
|
||||
// obsolete/protypes.h in the Gecko SDK.
|
||||
#ifndef _UINT32
|
||||
#define _UINT32
|
||||
typedef unsigned int uint32;
|
||||
#endif
|
||||
|
||||
#ifndef _INT16
|
||||
#define _INT16
|
||||
typedef short int16;
|
||||
#endif
|
||||
|
||||
#ifndef _UINT16
|
||||
#define _UINT16
|
||||
typedef unsigned short uint16;
|
||||
#endif
|
||||
|
||||
// UTF-16 character type.
|
||||
#ifndef char16
|
||||
#if defined(WCHAR_T_IS_UTF16)
|
||||
typedef wchar_t char16;
|
||||
#elif defined(WCHAR_T_IS_UTF32)
|
||||
typedef unsigned short char16;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_BASICTYPES_H_
|
||||
391
third/cef/include/base/cef_bind.h
Normal file
391
third/cef/include/base/cef_bind.h
Normal file
@@ -0,0 +1,391 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
///
|
||||
/// \file
|
||||
/// base::BindOnce() and base::BindRepeating() are helpers for creating
|
||||
/// base::OnceCallback and base::RepeatingCallback objects respectively.
|
||||
///
|
||||
/// For a runnable object of n-arity, the base::Bind*() family allows partial
|
||||
/// application of the first m arguments. The remaining n - m arguments must be
|
||||
/// passed when invoking the callback with Run().
|
||||
///
|
||||
/// <pre>
|
||||
/// // The first argument is bound at callback creation; the remaining
|
||||
/// // two must be passed when calling Run() on the callback object.
|
||||
/// base::OnceCallback<long(int, long)> cb = base::BindOnce(
|
||||
/// [](short x, int y, long z) { return x * y * z; }, 42);
|
||||
/// </pre>
|
||||
///
|
||||
/// When binding to a method, the receiver object must also be specified at
|
||||
/// callback creation time. When Run() is invoked, the method will be invoked on
|
||||
/// the specified receiver object.
|
||||
///
|
||||
/// <pre>
|
||||
/// class C : public base::RefCounted<C> { void F(); };
|
||||
/// auto instance = base::MakeRefCounted<C>();
|
||||
/// auto cb = base::BindOnce(&C::F, instance);
|
||||
/// std::move(cb).Run(); // Identical to instance->F()
|
||||
/// </pre>
|
||||
///
|
||||
/// See https://chromium.googlesource.com/chromium/src/+/lkgr/docs/callback.md
|
||||
/// for the full documentation.
|
||||
///
|
||||
|
||||
// Implementation notes
|
||||
//
|
||||
// If you're reading the implementation, before proceeding further, you should
|
||||
// read the top comment of base/internal/cef_bind_internal.h for a definition
|
||||
// of common terms and concepts.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_BIND_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_BIND_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/functional/bind.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "include/base/cef_build.h"
|
||||
#include "include/base/cef_compiler_specific.h"
|
||||
#include "include/base/cef_template_util.h"
|
||||
#include "include/base/internal/cef_bind_internal.h"
|
||||
|
||||
#if defined(OS_APPLE) && !HAS_FEATURE(objc_arc)
|
||||
#include "include/base/internal/cef_scoped_block_mac.h"
|
||||
#endif
|
||||
|
||||
namespace base {
|
||||
|
||||
///
|
||||
/// Bind as OnceCallback.
|
||||
///
|
||||
template <typename Functor, typename... Args>
|
||||
inline OnceCallback<cef_internal::MakeUnboundRunType<Functor, Args...>>
|
||||
BindOnce(Functor&& functor, Args&&... args) {
|
||||
static_assert(!cef_internal::IsOnceCallback<std::decay_t<Functor>>() ||
|
||||
(std::is_rvalue_reference<Functor&&>() &&
|
||||
!std::is_const<std::remove_reference_t<Functor>>()),
|
||||
"BindOnce requires non-const rvalue for OnceCallback binding."
|
||||
" I.e.: base::BindOnce(std::move(callback)).");
|
||||
static_assert(
|
||||
conjunction<cef_internal::AssertBindArgIsNotBasePassed<
|
||||
std::decay_t<Args>>...>::value,
|
||||
"Use std::move() instead of base::Passed() with base::BindOnce()");
|
||||
|
||||
return cef_internal::BindImpl<OnceCallback>(std::forward<Functor>(functor),
|
||||
std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
///
|
||||
/// Bind as RepeatingCallback.
|
||||
///
|
||||
template <typename Functor, typename... Args>
|
||||
inline RepeatingCallback<cef_internal::MakeUnboundRunType<Functor, Args...>>
|
||||
BindRepeating(Functor&& functor, Args&&... args) {
|
||||
static_assert(
|
||||
!cef_internal::IsOnceCallback<std::decay_t<Functor>>(),
|
||||
"BindRepeating cannot bind OnceCallback. Use BindOnce with std::move().");
|
||||
|
||||
return cef_internal::BindImpl<RepeatingCallback>(
|
||||
std::forward<Functor>(functor), std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
///
|
||||
/// Special cases for binding to a base::Callback without extra bound arguments.
|
||||
/// We CHECK() the validity of callback to guard against null pointers
|
||||
/// accidentally ending up in posted tasks, causing hard-to-debug crashes.
|
||||
///
|
||||
template <typename Signature>
|
||||
OnceCallback<Signature> BindOnce(OnceCallback<Signature> callback) {
|
||||
CHECK(callback);
|
||||
return callback;
|
||||
}
|
||||
|
||||
template <typename Signature>
|
||||
OnceCallback<Signature> BindOnce(RepeatingCallback<Signature> callback) {
|
||||
CHECK(callback);
|
||||
return callback;
|
||||
}
|
||||
|
||||
template <typename Signature>
|
||||
RepeatingCallback<Signature> BindRepeating(
|
||||
RepeatingCallback<Signature> callback) {
|
||||
CHECK(callback);
|
||||
return callback;
|
||||
}
|
||||
|
||||
///
|
||||
/// Unretained() allows binding a non-refcounted class, and to disable
|
||||
/// refcounting on arguments that are refcounted objects.
|
||||
///
|
||||
/// EXAMPLE OF Unretained():
|
||||
///
|
||||
/// <pre>
|
||||
/// class Foo {
|
||||
/// public:
|
||||
/// void func() { cout << "Foo:f" << endl; }
|
||||
/// };
|
||||
///
|
||||
/// // In some function somewhere.
|
||||
/// Foo foo;
|
||||
/// OnceClosure foo_callback =
|
||||
/// BindOnce(&Foo::func, Unretained(&foo));
|
||||
/// std::move(foo_callback).Run(); // Prints "Foo:f".
|
||||
/// </pre>
|
||||
///
|
||||
/// Without the Unretained() wrapper on |&foo|, the above call would fail
|
||||
/// to compile because Foo does not support the AddRef() and Release() methods.
|
||||
///
|
||||
template <typename T>
|
||||
inline cef_internal::UnretainedWrapper<T> Unretained(T* o) {
|
||||
return cef_internal::UnretainedWrapper<T>(o);
|
||||
}
|
||||
|
||||
///
|
||||
/// RetainedRef() accepts a ref counted object and retains a reference to it.
|
||||
/// When the callback is called, the object is passed as a raw pointer.
|
||||
///
|
||||
/// EXAMPLE OF RetainedRef():
|
||||
///
|
||||
/// <pre>
|
||||
/// void foo(RefCountedBytes* bytes) {}
|
||||
///
|
||||
/// scoped_refptr<RefCountedBytes> bytes = ...;
|
||||
/// OnceClosure callback = BindOnce(&foo, base::RetainedRef(bytes));
|
||||
/// std::move(callback).Run();
|
||||
/// </pre>
|
||||
///
|
||||
/// Without RetainedRef, the scoped_refptr would try to implicitly convert to
|
||||
/// a raw pointer and fail compilation:
|
||||
///
|
||||
/// <pre>
|
||||
/// OnceClosure callback = BindOnce(&foo, bytes); // ERROR!
|
||||
/// </pre>
|
||||
///
|
||||
template <typename T>
|
||||
inline cef_internal::RetainedRefWrapper<T> RetainedRef(T* o) {
|
||||
return cef_internal::RetainedRefWrapper<T>(o);
|
||||
}
|
||||
template <typename T>
|
||||
inline cef_internal::RetainedRefWrapper<T> RetainedRef(scoped_refptr<T> o) {
|
||||
return cef_internal::RetainedRefWrapper<T>(std::move(o));
|
||||
}
|
||||
|
||||
///
|
||||
/// Owned() transfers ownership of an object to the callback resulting from
|
||||
/// bind; the object will be deleted when the callback is deleted.
|
||||
///
|
||||
/// EXAMPLE OF Owned():
|
||||
///
|
||||
/// <pre>
|
||||
/// void foo(int* arg) { cout << *arg << endl }
|
||||
///
|
||||
/// int* pn = new int(1);
|
||||
/// RepeatingClosure foo_callback = BindRepeating(&foo, Owned(pn));
|
||||
///
|
||||
/// foo_callback.Run(); // Prints "1"
|
||||
/// foo_callback.Run(); // Prints "1"
|
||||
/// *pn = 2;
|
||||
/// foo_callback.Run(); // Prints "2"
|
||||
///
|
||||
/// foo_callback.Reset(); // |pn| is deleted. Also will happen when
|
||||
/// // |foo_callback| goes out of scope.
|
||||
/// </pre>
|
||||
///
|
||||
/// Without Owned(), someone would have to know to delete |pn| when the last
|
||||
/// reference to the callback is deleted.
|
||||
///
|
||||
template <typename T>
|
||||
inline cef_internal::OwnedWrapper<T> Owned(T* o) {
|
||||
return cef_internal::OwnedWrapper<T>(o);
|
||||
}
|
||||
|
||||
template <typename T, typename Deleter>
|
||||
inline cef_internal::OwnedWrapper<T, Deleter> Owned(
|
||||
std::unique_ptr<T, Deleter>&& ptr) {
|
||||
return cef_internal::OwnedWrapper<T, Deleter>(std::move(ptr));
|
||||
}
|
||||
|
||||
///
|
||||
/// OwnedRef() stores an object in the callback resulting from
|
||||
/// bind and passes a reference to the object to the bound function.
|
||||
///
|
||||
/// EXAMPLE OF OwnedRef():
|
||||
///
|
||||
/// <pre>
|
||||
/// void foo(int& arg) { cout << ++arg << endl }
|
||||
///
|
||||
/// int counter = 0;
|
||||
/// RepeatingClosure foo_callback = BindRepeating(&foo, OwnedRef(counter));
|
||||
///
|
||||
/// foo_callback.Run(); // Prints "1"
|
||||
/// foo_callback.Run(); // Prints "2"
|
||||
/// foo_callback.Run(); // Prints "3"
|
||||
///
|
||||
/// cout << counter; // Prints "0", OwnedRef creates a copy of counter.
|
||||
/// </pre>
|
||||
///
|
||||
/// Supports OnceCallbacks as well, useful to pass placeholder arguments:
|
||||
///
|
||||
/// <pre>
|
||||
/// void bar(int& ignore, const std::string& s) { cout << s << endl }
|
||||
///
|
||||
/// OnceClosure bar_callback = BindOnce(&bar, OwnedRef(0), "Hello");
|
||||
///
|
||||
/// std::move(bar_callback).Run(); // Prints "Hello"
|
||||
/// </pre>
|
||||
///
|
||||
/// Without OwnedRef() it would not be possible to pass a mutable reference to
|
||||
/// an object owned by the callback.
|
||||
///
|
||||
template <typename T>
|
||||
cef_internal::OwnedRefWrapper<std::decay_t<T>> OwnedRef(T&& t) {
|
||||
return cef_internal::OwnedRefWrapper<std::decay_t<T>>(std::forward<T>(t));
|
||||
}
|
||||
|
||||
///
|
||||
/// Passed() is for transferring movable-but-not-copyable types (eg. unique_ptr)
|
||||
/// through a RepeatingCallback. Logically, this signifies a destructive
|
||||
/// transfer of the state of the argument into the target function. Invoking
|
||||
/// RepeatingCallback::Run() twice on a callback that was created with a
|
||||
/// Passed() argument will CHECK() because the first invocation would have
|
||||
/// already transferred ownership to the target function.
|
||||
///
|
||||
/// Note that Passed() is not necessary with BindOnce(), as std::move() does the
|
||||
/// same thing. Avoid Passed() in favor of std::move() with BindOnce().
|
||||
///
|
||||
/// EXAMPLE OF Passed():
|
||||
///
|
||||
/// <pre>
|
||||
/// void TakesOwnership(std::unique_ptr<Foo> arg) { }
|
||||
/// std::unique_ptr<Foo> CreateFoo() { return std::make_unique<Foo>();
|
||||
/// }
|
||||
///
|
||||
/// auto f = std::make_unique<Foo>();
|
||||
///
|
||||
/// // |cb| is given ownership of Foo(). |f| is now NULL.
|
||||
/// // You can use std::move(f) in place of &f, but it's more verbose.
|
||||
/// RepeatingClosure cb = BindRepeating(&TakesOwnership, Passed(&f));
|
||||
///
|
||||
/// // Run was never called so |cb| still owns Foo() and deletes
|
||||
/// // it on Reset().
|
||||
/// cb.Reset();
|
||||
///
|
||||
/// // |cb| is given a new Foo created by CreateFoo().
|
||||
/// cb = BindRepeating(&TakesOwnership, Passed(CreateFoo()));
|
||||
///
|
||||
/// // |arg| in TakesOwnership() is given ownership of Foo(). |cb|
|
||||
/// // no longer owns Foo() and, if reset, would not delete Foo().
|
||||
/// cb.Run(); // Foo() is now transferred to |arg| and deleted.
|
||||
/// cb.Run(); // This CHECK()s since Foo() already been used once.
|
||||
/// </pre>
|
||||
///
|
||||
/// We offer 2 syntaxes for calling Passed(). The first takes an rvalue and is
|
||||
/// best suited for use with the return value of a function or other temporary
|
||||
/// rvalues. The second takes a pointer to the scoper and is just syntactic
|
||||
/// sugar to avoid having to write Passed(std::move(scoper)).
|
||||
///
|
||||
/// Both versions of Passed() prevent T from being an lvalue reference. The
|
||||
/// first via use of enable_if, and the second takes a T* which will not bind to
|
||||
/// T&.
|
||||
///
|
||||
template <typename T,
|
||||
std::enable_if_t<!std::is_lvalue_reference<T>::value>* = nullptr>
|
||||
inline cef_internal::PassedWrapper<T> Passed(T&& scoper) {
|
||||
return cef_internal::PassedWrapper<T>(std::move(scoper));
|
||||
}
|
||||
template <typename T>
|
||||
inline cef_internal::PassedWrapper<T> Passed(T* scoper) {
|
||||
return cef_internal::PassedWrapper<T>(std::move(*scoper));
|
||||
}
|
||||
|
||||
///
|
||||
/// IgnoreResult() is used to adapt a function or callback with a return type to
|
||||
/// one with a void return. This is most useful if you have a function with,
|
||||
/// say, a pesky ignorable bool return that you want to use with PostTask or
|
||||
/// something else that expect a callback with a void return.
|
||||
///
|
||||
/// EXAMPLE OF IgnoreResult():
|
||||
///
|
||||
/// <pre>
|
||||
/// int DoSomething(int arg) { cout << arg << endl; }
|
||||
///
|
||||
/// // Assign to a callback with a void return type.
|
||||
/// OnceCallback<void(int)> cb = BindOnce(IgnoreResult(&DoSomething));
|
||||
/// std::move(cb).Run(1); // Prints "1".
|
||||
///
|
||||
/// // Prints "2" on |ml|.
|
||||
/// ml->PostTask(FROM_HERE, BindOnce(IgnoreResult(&DoSomething), 2);
|
||||
/// </pre>
|
||||
///
|
||||
template <typename T>
|
||||
inline cef_internal::IgnoreResultHelper<T> IgnoreResult(T data) {
|
||||
return cef_internal::IgnoreResultHelper<T>(std::move(data));
|
||||
}
|
||||
|
||||
#if defined(OS_APPLE) && !HAS_FEATURE(objc_arc)
|
||||
|
||||
///
|
||||
/// RetainBlock() is used to adapt an Objective-C block when Automated Reference
|
||||
/// Counting (ARC) is disabled. This is unnecessary when ARC is enabled, as the
|
||||
/// BindOnce and BindRepeating already support blocks then.
|
||||
///
|
||||
/// EXAMPLE OF RetainBlock():
|
||||
///
|
||||
/// <pre>
|
||||
/// // Wrap the block and bind it to a callback.
|
||||
/// OnceCallback<void(int)> cb =
|
||||
/// BindOnce(RetainBlock(^(int n) { NSLog(@"%d", n); }));
|
||||
/// std::move(cb).Run(1); // Logs "1".
|
||||
/// </pre>
|
||||
///
|
||||
template <typename R, typename... Args>
|
||||
base::mac::ScopedBlock<R (^)(Args...)> RetainBlock(R (^block)(Args...)) {
|
||||
return base::mac::ScopedBlock<R (^)(Args...)>(block,
|
||||
base::scoped_policy::RETAIN);
|
||||
}
|
||||
|
||||
#endif // defined(OS_APPLE) && !HAS_FEATURE(objc_arc)
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_BIND_H_
|
||||
263
third/cef/include/base/cef_build.h
Normal file
263
third/cef/include/base/cef_build.h
Normal file
@@ -0,0 +1,263 @@
|
||||
// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
/// \file
|
||||
/// This file adds defines about the platform we're currently building on.
|
||||
///
|
||||
/// <pre>
|
||||
/// Operating System:
|
||||
/// OS_AIX / OS_ANDROID / OS_ASMJS / OS_FREEBSD / OS_FUCHSIA / OS_IOS /
|
||||
/// OS_LINUX / OS_MAC / OS_NACL (SFI or NONSFI) / OS_NETBSD / OS_OPENBSD /
|
||||
/// OS_QNX / OS_SOLARIS / OS_WIN
|
||||
/// Operating System family:
|
||||
/// OS_APPLE: IOS or MAC
|
||||
/// OS_BSD: FREEBSD or NETBSD or OPENBSD
|
||||
/// OS_POSIX: AIX or ANDROID or ASMJS or CHROMEOS or FREEBSD or IOS or LINUX
|
||||
/// or MAC or NACL or NETBSD or OPENBSD or QNX or SOLARIS
|
||||
///
|
||||
/// /!\ Note: OS_CHROMEOS is set by the build system, not this file
|
||||
///
|
||||
/// Compiler:
|
||||
/// COMPILER_MSVC / COMPILER_GCC
|
||||
///
|
||||
/// Processor:
|
||||
/// ARCH_CPU_ARM64 / ARCH_CPU_ARMEL / ARCH_CPU_MIPS / ARCH_CPU_MIPS64 /
|
||||
/// ARCH_CPU_MIPS64EL / ARCH_CPU_MIPSEL / ARCH_CPU_PPC64 / ARCH_CPU_S390 /
|
||||
/// ARCH_CPU_S390X / ARCH_CPU_X86 / ARCH_CPU_X86_64
|
||||
/// Processor family:
|
||||
/// ARCH_CPU_ARM_FAMILY: ARMEL or ARM64
|
||||
/// ARCH_CPU_MIPS_FAMILY: MIPS64EL or MIPSEL or MIPS64 or MIPS
|
||||
/// ARCH_CPU_PPC64_FAMILY: PPC64
|
||||
/// ARCH_CPU_S390_FAMILY: S390 or S390X
|
||||
/// ARCH_CPU_X86_FAMILY: X86 or X86_64
|
||||
/// Processor features:
|
||||
/// ARCH_CPU_31_BITS / ARCH_CPU_32_BITS / ARCH_CPU_64_BITS
|
||||
/// ARCH_CPU_BIG_ENDIAN / ARCH_CPU_LITTLE_ENDIAN
|
||||
/// </pre>
|
||||
///
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_BUILD_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_BUILD_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "build/build_config.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
// A set of macros to use for platform detection.
|
||||
#if defined(ANDROID)
|
||||
#define OS_ANDROID 1
|
||||
#elif defined(__APPLE__)
|
||||
// Only include TargetConditionals after testing ANDROID as some Android builds
|
||||
// on the Mac have this header available and it's not needed unless the target
|
||||
// is really an Apple platform.
|
||||
#include <TargetConditionals.h>
|
||||
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
|
||||
#define OS_IOS 1
|
||||
#else
|
||||
#define OS_MAC 1
|
||||
// For backwards compatibility.
|
||||
#define OS_MACOSX 1
|
||||
#endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
|
||||
#elif defined(__linux__)
|
||||
#if !defined(OS_CHROMEOS)
|
||||
// Do not define OS_LINUX on Chrome OS build.
|
||||
// The OS_CHROMEOS macro is defined in GN.
|
||||
#define OS_LINUX 1
|
||||
#endif // !defined(OS_CHROMEOS)
|
||||
// Include a system header to pull in features.h for glibc/uclibc macros.
|
||||
#include <unistd.h>
|
||||
#if defined(__GLIBC__) && !defined(__UCLIBC__)
|
||||
// We really are using glibc, not uClibc pretending to be glibc.
|
||||
#define LIBC_GLIBC 1
|
||||
#endif
|
||||
#elif defined(_WIN32)
|
||||
#define OS_WIN 1
|
||||
#elif defined(__Fuchsia__)
|
||||
#define OS_FUCHSIA 1
|
||||
#elif defined(__FreeBSD__)
|
||||
#define OS_FREEBSD 1
|
||||
#elif defined(__NetBSD__)
|
||||
#define OS_NETBSD 1
|
||||
#elif defined(__OpenBSD__)
|
||||
#define OS_OPENBSD 1
|
||||
#elif defined(__sun)
|
||||
#define OS_SOLARIS 1
|
||||
#elif defined(__QNXNTO__)
|
||||
#define OS_QNX 1
|
||||
#elif defined(_AIX)
|
||||
#define OS_AIX 1
|
||||
#elif defined(__asmjs__) || defined(__wasm__)
|
||||
#define OS_ASMJS 1
|
||||
#else
|
||||
#error Please add support for your platform in include/base/cef_build.h
|
||||
#endif
|
||||
// NOTE: Adding a new port? Please follow
|
||||
// https://chromium.googlesource.com/chromium/src/+/master/docs/new_port_policy.md
|
||||
|
||||
#if defined(OS_MAC) || defined(OS_IOS)
|
||||
#define OS_APPLE 1
|
||||
#endif
|
||||
|
||||
// For access to standard BSD features, use OS_BSD instead of a
|
||||
// more specific macro.
|
||||
#if defined(OS_FREEBSD) || defined(OS_NETBSD) || defined(OS_OPENBSD)
|
||||
#define OS_BSD 1
|
||||
#endif
|
||||
|
||||
// For access to standard POSIXish features, use OS_POSIX instead of a
|
||||
// more specific macro.
|
||||
#if defined(OS_AIX) || defined(OS_ANDROID) || defined(OS_ASMJS) || \
|
||||
defined(OS_FREEBSD) || defined(OS_IOS) || defined(OS_LINUX) || \
|
||||
defined(OS_CHROMEOS) || defined(OS_MAC) || defined(OS_NACL) || \
|
||||
defined(OS_NETBSD) || defined(OS_OPENBSD) || defined(OS_QNX) || \
|
||||
defined(OS_SOLARIS)
|
||||
#define OS_POSIX 1
|
||||
#endif
|
||||
|
||||
// Compiler detection. Note: clang masquerades as GCC on POSIX and as MSVC on
|
||||
// Windows.
|
||||
#if defined(__GNUC__)
|
||||
#define COMPILER_GCC 1
|
||||
#elif defined(_MSC_VER)
|
||||
#define COMPILER_MSVC 1
|
||||
#else
|
||||
#error Please add support for your compiler in build/build_config.h
|
||||
#endif
|
||||
|
||||
// Processor architecture detection. For more info on what's defined, see:
|
||||
// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
|
||||
// http://www.agner.org/optimize/calling_conventions.pdf
|
||||
// or with gcc, run: "echo | gcc -E -dM -"
|
||||
#if defined(_M_X64) || defined(__x86_64__)
|
||||
#define ARCH_CPU_X86_FAMILY 1
|
||||
#define ARCH_CPU_X86_64 1
|
||||
#define ARCH_CPU_64_BITS 1
|
||||
#define ARCH_CPU_LITTLE_ENDIAN 1
|
||||
#elif defined(_M_IX86) || defined(__i386__)
|
||||
#define ARCH_CPU_X86_FAMILY 1
|
||||
#define ARCH_CPU_X86 1
|
||||
#define ARCH_CPU_32_BITS 1
|
||||
#define ARCH_CPU_LITTLE_ENDIAN 1
|
||||
#elif defined(__s390x__)
|
||||
#define ARCH_CPU_S390_FAMILY 1
|
||||
#define ARCH_CPU_S390X 1
|
||||
#define ARCH_CPU_64_BITS 1
|
||||
#define ARCH_CPU_BIG_ENDIAN 1
|
||||
#elif defined(__s390__)
|
||||
#define ARCH_CPU_S390_FAMILY 1
|
||||
#define ARCH_CPU_S390 1
|
||||
#define ARCH_CPU_31_BITS 1
|
||||
#define ARCH_CPU_BIG_ENDIAN 1
|
||||
#elif (defined(__PPC64__) || defined(__PPC__)) && defined(__BIG_ENDIAN__)
|
||||
#define ARCH_CPU_PPC64_FAMILY 1
|
||||
#define ARCH_CPU_PPC64 1
|
||||
#define ARCH_CPU_64_BITS 1
|
||||
#define ARCH_CPU_BIG_ENDIAN 1
|
||||
#elif defined(__PPC64__)
|
||||
#define ARCH_CPU_PPC64_FAMILY 1
|
||||
#define ARCH_CPU_PPC64 1
|
||||
#define ARCH_CPU_64_BITS 1
|
||||
#define ARCH_CPU_LITTLE_ENDIAN 1
|
||||
#elif defined(__ARMEL__)
|
||||
#define ARCH_CPU_ARM_FAMILY 1
|
||||
#define ARCH_CPU_ARMEL 1
|
||||
#define ARCH_CPU_32_BITS 1
|
||||
#define ARCH_CPU_LITTLE_ENDIAN 1
|
||||
#elif defined(__aarch64__) || defined(_M_ARM64)
|
||||
#define ARCH_CPU_ARM_FAMILY 1
|
||||
#define ARCH_CPU_ARM64 1
|
||||
#define ARCH_CPU_64_BITS 1
|
||||
#define ARCH_CPU_LITTLE_ENDIAN 1
|
||||
#elif defined(__pnacl__) || defined(__asmjs__) || defined(__wasm__)
|
||||
#define ARCH_CPU_32_BITS 1
|
||||
#define ARCH_CPU_LITTLE_ENDIAN 1
|
||||
#elif defined(__MIPSEL__)
|
||||
#if defined(__LP64__)
|
||||
#define ARCH_CPU_MIPS_FAMILY 1
|
||||
#define ARCH_CPU_MIPS64EL 1
|
||||
#define ARCH_CPU_64_BITS 1
|
||||
#define ARCH_CPU_LITTLE_ENDIAN 1
|
||||
#else
|
||||
#define ARCH_CPU_MIPS_FAMILY 1
|
||||
#define ARCH_CPU_MIPSEL 1
|
||||
#define ARCH_CPU_32_BITS 1
|
||||
#define ARCH_CPU_LITTLE_ENDIAN 1
|
||||
#endif
|
||||
#elif defined(__MIPSEB__)
|
||||
#if defined(__LP64__)
|
||||
#define ARCH_CPU_MIPS_FAMILY 1
|
||||
#define ARCH_CPU_MIPS64 1
|
||||
#define ARCH_CPU_64_BITS 1
|
||||
#define ARCH_CPU_BIG_ENDIAN 1
|
||||
#else
|
||||
#define ARCH_CPU_MIPS_FAMILY 1
|
||||
#define ARCH_CPU_MIPS 1
|
||||
#define ARCH_CPU_32_BITS 1
|
||||
#define ARCH_CPU_BIG_ENDIAN 1
|
||||
#endif
|
||||
#else
|
||||
#error Please add support for your architecture in include/base/cef_build.h
|
||||
#endif
|
||||
|
||||
// Type detection for wchar_t.
|
||||
#if defined(OS_WIN)
|
||||
#define WCHAR_T_IS_UTF16
|
||||
#elif defined(OS_FUCHSIA)
|
||||
#define WCHAR_T_IS_UTF32
|
||||
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
|
||||
(__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
|
||||
#define WCHAR_T_IS_UTF32
|
||||
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
|
||||
(__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
|
||||
// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
|
||||
// compile in this mode (in particular, Chrome doesn't). This is intended for
|
||||
// other projects using base who manage their own dependencies and make sure
|
||||
// short wchar works for them.
|
||||
#define WCHAR_T_IS_UTF16
|
||||
#else
|
||||
#error Please add support for your compiler in include/base/cef_build.h
|
||||
#endif
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
// The compiler thinks std::string::const_iterator and "const char*" are
|
||||
// equivalent types.
|
||||
#define STD_STRING_ITERATOR_IS_CHAR_POINTER
|
||||
// The compiler thinks std::u16string::const_iterator and "char16*" are
|
||||
// equivalent types.
|
||||
#define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER
|
||||
#endif
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_BUILD_H_
|
||||
250
third/cef/include/base/cef_callback.h
Normal file
250
third/cef/include/base/cef_callback.h
Normal file
@@ -0,0 +1,250 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
/// \file
|
||||
/// A callback is similar in concept to a function pointer: it wraps a runnable
|
||||
/// object such as a function, method, lambda, or even another callback,
|
||||
/// allowing the runnable object to be invoked later via the callback object.
|
||||
///
|
||||
/// Unlike function pointers, callbacks are created with base::BindOnce() or
|
||||
/// base::BindRepeating() and support partial function application.
|
||||
///
|
||||
/// A base::OnceCallback may be Run() at most once; a base::RepeatingCallback
|
||||
/// may be Run() any number of times. |is_null()| is guaranteed to return true
|
||||
/// for a moved-from callback.
|
||||
///
|
||||
/// <pre>
|
||||
/// // The lambda takes two arguments, but the first argument |x| is bound at
|
||||
/// // callback creation.
|
||||
/// base::OnceCallback<int(int)> cb = base::BindOnce([] (int x, int y) {
|
||||
/// return x + y;
|
||||
/// }, 1);
|
||||
/// // Run() only needs the remaining unbound argument |y|.
|
||||
/// printf("1 + 2 = %d\n", std::move(cb).Run(2)); // Prints 3
|
||||
/// printf("cb is null? %s\n",
|
||||
/// cb.is_null() ? "true" : "false"); // Prints true
|
||||
/// std::move(cb).Run(2); // Crashes since |cb| has already run.
|
||||
/// </pre>
|
||||
///
|
||||
/// Callbacks also support cancellation. A common use is binding the receiver
|
||||
/// object as a WeakPtr<T>. If that weak pointer is invalidated, calling Run()
|
||||
/// will be a no-op. Note that |IsCancelled()| and |is_null()| are distinct:
|
||||
/// simply cancelling a callback will not also make it null.
|
||||
///
|
||||
/// See https://chromium.googlesource.com/chromium/src/+/lkgr/docs/callback.md
|
||||
/// for the full documentation.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_CALLBACK_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/functional/callback.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "include/base/cef_bind.h"
|
||||
#include "include/base/cef_callback_forward.h"
|
||||
#include "include/base/cef_logging.h"
|
||||
#include "include/base/internal/cef_callback_internal.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
template <typename R, typename... Args>
|
||||
class OnceCallback<R(Args...)> : public cef_internal::CallbackBase {
|
||||
public:
|
||||
using ResultType = R;
|
||||
using RunType = R(Args...);
|
||||
using PolymorphicInvoke = R (*)(cef_internal::BindStateBase*,
|
||||
cef_internal::PassingType<Args>...);
|
||||
|
||||
constexpr OnceCallback() = default;
|
||||
OnceCallback(std::nullptr_t) = delete;
|
||||
|
||||
explicit OnceCallback(cef_internal::BindStateBase* bind_state)
|
||||
: cef_internal::CallbackBase(bind_state) {}
|
||||
|
||||
OnceCallback(const OnceCallback&) = delete;
|
||||
OnceCallback& operator=(const OnceCallback&) = delete;
|
||||
|
||||
OnceCallback(OnceCallback&&) noexcept = default;
|
||||
OnceCallback& operator=(OnceCallback&&) noexcept = default;
|
||||
|
||||
OnceCallback(RepeatingCallback<RunType> other)
|
||||
: cef_internal::CallbackBase(std::move(other)) {}
|
||||
|
||||
OnceCallback& operator=(RepeatingCallback<RunType> other) {
|
||||
static_cast<cef_internal::CallbackBase&>(*this) = std::move(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
R Run(Args... args) const& {
|
||||
static_assert(!sizeof(*this),
|
||||
"OnceCallback::Run() may only be invoked on a non-const "
|
||||
"rvalue, i.e. std::move(callback).Run().");
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
R Run(Args... args) && {
|
||||
// Move the callback instance into a local variable before the invocation,
|
||||
// that ensures the internal state is cleared after the invocation.
|
||||
// It's not safe to touch |this| after the invocation, since running the
|
||||
// bound function may destroy |this|.
|
||||
OnceCallback cb = std::move(*this);
|
||||
PolymorphicInvoke f =
|
||||
reinterpret_cast<PolymorphicInvoke>(cb.polymorphic_invoke());
|
||||
return f(cb.bind_state_.get(), std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// Then() returns a new OnceCallback that receives the same arguments as
|
||||
// |this|, and with the return type of |then|. The returned callback will:
|
||||
// 1) Run the functor currently bound to |this| callback.
|
||||
// 2) Run the |then| callback with the result from step 1 as its single
|
||||
// argument.
|
||||
// 3) Return the value from running the |then| callback.
|
||||
//
|
||||
// Since this method generates a callback that is a replacement for `this`,
|
||||
// `this` will be consumed and reset to a null callback to ensure the
|
||||
// originally-bound functor can be run at most once.
|
||||
template <typename ThenR, typename... ThenArgs>
|
||||
OnceCallback<ThenR(Args...)> Then(OnceCallback<ThenR(ThenArgs...)> then) && {
|
||||
CHECK(then);
|
||||
return BindOnce(
|
||||
cef_internal::ThenHelper<
|
||||
OnceCallback, OnceCallback<ThenR(ThenArgs...)>>::CreateTrampoline(),
|
||||
std::move(*this), std::move(then));
|
||||
}
|
||||
|
||||
// This overload is required; even though RepeatingCallback is implicitly
|
||||
// convertible to OnceCallback, that conversion will not used when matching
|
||||
// for template argument deduction.
|
||||
template <typename ThenR, typename... ThenArgs>
|
||||
OnceCallback<ThenR(Args...)> Then(
|
||||
RepeatingCallback<ThenR(ThenArgs...)> then) && {
|
||||
CHECK(then);
|
||||
return BindOnce(
|
||||
cef_internal::ThenHelper<
|
||||
OnceCallback,
|
||||
RepeatingCallback<ThenR(ThenArgs...)>>::CreateTrampoline(),
|
||||
std::move(*this), std::move(then));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
class RepeatingCallback<R(Args...)>
|
||||
: public cef_internal::CallbackBaseCopyable {
|
||||
public:
|
||||
using ResultType = R;
|
||||
using RunType = R(Args...);
|
||||
using PolymorphicInvoke = R (*)(cef_internal::BindStateBase*,
|
||||
cef_internal::PassingType<Args>...);
|
||||
|
||||
constexpr RepeatingCallback() = default;
|
||||
RepeatingCallback(std::nullptr_t) = delete;
|
||||
|
||||
explicit RepeatingCallback(cef_internal::BindStateBase* bind_state)
|
||||
: cef_internal::CallbackBaseCopyable(bind_state) {}
|
||||
|
||||
// Copyable and movable.
|
||||
RepeatingCallback(const RepeatingCallback&) = default;
|
||||
RepeatingCallback& operator=(const RepeatingCallback&) = default;
|
||||
RepeatingCallback(RepeatingCallback&&) noexcept = default;
|
||||
RepeatingCallback& operator=(RepeatingCallback&&) noexcept = default;
|
||||
|
||||
bool operator==(const RepeatingCallback& other) const {
|
||||
return EqualsInternal(other);
|
||||
}
|
||||
|
||||
bool operator!=(const RepeatingCallback& other) const {
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
R Run(Args... args) const& {
|
||||
PolymorphicInvoke f =
|
||||
reinterpret_cast<PolymorphicInvoke>(this->polymorphic_invoke());
|
||||
return f(this->bind_state_.get(), std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
R Run(Args... args) && {
|
||||
// Move the callback instance into a local variable before the invocation,
|
||||
// that ensures the internal state is cleared after the invocation.
|
||||
// It's not safe to touch |this| after the invocation, since running the
|
||||
// bound function may destroy |this|.
|
||||
RepeatingCallback cb = std::move(*this);
|
||||
PolymorphicInvoke f =
|
||||
reinterpret_cast<PolymorphicInvoke>(cb.polymorphic_invoke());
|
||||
return f(std::move(cb).bind_state_.get(), std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// Then() returns a new RepeatingCallback that receives the same arguments as
|
||||
// |this|, and with the return type of |then|. The
|
||||
// returned callback will:
|
||||
// 1) Run the functor currently bound to |this| callback.
|
||||
// 2) Run the |then| callback with the result from step 1 as its single
|
||||
// argument.
|
||||
// 3) Return the value from running the |then| callback.
|
||||
//
|
||||
// If called on an rvalue (e.g. std::move(cb).Then(...)), this method
|
||||
// generates a callback that is a replacement for `this`. Therefore, `this`
|
||||
// will be consumed and reset to a null callback to ensure the
|
||||
// originally-bound functor will be run at most once.
|
||||
template <typename ThenR, typename... ThenArgs>
|
||||
RepeatingCallback<ThenR(Args...)> Then(
|
||||
RepeatingCallback<ThenR(ThenArgs...)> then) const& {
|
||||
CHECK(then);
|
||||
return BindRepeating(
|
||||
cef_internal::ThenHelper<
|
||||
RepeatingCallback,
|
||||
RepeatingCallback<ThenR(ThenArgs...)>>::CreateTrampoline(),
|
||||
*this, std::move(then));
|
||||
}
|
||||
|
||||
template <typename ThenR, typename... ThenArgs>
|
||||
RepeatingCallback<ThenR(Args...)> Then(
|
||||
RepeatingCallback<ThenR(ThenArgs...)> then) && {
|
||||
CHECK(then);
|
||||
return BindRepeating(
|
||||
cef_internal::ThenHelper<
|
||||
RepeatingCallback,
|
||||
RepeatingCallback<ThenR(ThenArgs...)>>::CreateTrampoline(),
|
||||
std::move(*this), std::move(then));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_CALLBACK_H_
|
||||
63
third/cef/include/base/cef_callback_forward.h
Normal file
63
third/cef/include/base/cef_callback_forward.h
Normal file
@@ -0,0 +1,63 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef INCLUDE_BASE_CEF_CALLBACK_FORWARD_H_
|
||||
#define INCLUDE_BASE_CEF_CALLBACK_FORWARD_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/functional/callback_forward.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
namespace base {
|
||||
|
||||
template <typename Signature>
|
||||
class OnceCallback;
|
||||
|
||||
template <typename Signature>
|
||||
class RepeatingCallback;
|
||||
|
||||
///
|
||||
/// Syntactic sugar to make OnceClosure<void()> and RepeatingClosure<void()>
|
||||
/// easier to declare since they will be used in a lot of APIs with delayed
|
||||
/// execution.
|
||||
///
|
||||
using OnceClosure = OnceCallback<void()>;
|
||||
using RepeatingClosure = RepeatingCallback<void()>;
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !!USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // INCLUDE_BASE_CEF_CALLBACK_FORWARD_H_
|
||||
261
third/cef/include/base/cef_callback_helpers.h
Normal file
261
third/cef/include/base/cef_callback_helpers.h
Normal file
@@ -0,0 +1,261 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This defines helpful methods for dealing with Callbacks. Because Callbacks
|
||||
// are implemented using templates, with a class per callback signature, adding
|
||||
// methods to Callback<> itself is unattractive (lots of extra code gets
|
||||
// generated). Instead, consider adding methods here.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_HELPERS_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_CALLBACK_HELPERS_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/functional/callback_helpers.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "include/base/cef_bind.h"
|
||||
#include "include/base/cef_callback.h"
|
||||
#include "include/base/cef_logging.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
namespace internal {
|
||||
|
||||
template <typename T>
|
||||
struct IsBaseCallbackImpl : std::false_type {};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct IsBaseCallbackImpl<OnceCallback<R(Args...)>> : std::true_type {};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct IsBaseCallbackImpl<RepeatingCallback<R(Args...)>> : std::true_type {};
|
||||
|
||||
template <typename T>
|
||||
struct IsOnceCallbackImpl : std::false_type {};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct IsOnceCallbackImpl<OnceCallback<R(Args...)>> : std::true_type {};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
///
|
||||
/// IsBaseCallback<T>::value is true when T is any of the Closure or Callback
|
||||
/// family of types.
|
||||
///
|
||||
template <typename T>
|
||||
using IsBaseCallback = internal::IsBaseCallbackImpl<std::decay_t<T>>;
|
||||
|
||||
///
|
||||
/// IsOnceCallback<T>::value is true when T is a OnceClosure or OnceCallback
|
||||
/// type.
|
||||
///
|
||||
template <typename T>
|
||||
using IsOnceCallback = internal::IsOnceCallbackImpl<std::decay_t<T>>;
|
||||
|
||||
///
|
||||
/// SFINAE friendly enabler allowing to overload methods for both Repeating and
|
||||
/// OnceCallbacks.
|
||||
///
|
||||
/// Usage:
|
||||
/// <pre>
|
||||
/// template <template <typename> class CallbackType,
|
||||
/// ... other template args ...,
|
||||
/// typename = EnableIfIsBaseCallback<CallbackType>>
|
||||
/// void DoStuff(CallbackType<...> cb, ...);
|
||||
/// </pre>
|
||||
///
|
||||
template <template <typename> class CallbackType>
|
||||
using EnableIfIsBaseCallback =
|
||||
std::enable_if_t<IsBaseCallback<CallbackType<void()>>::value>;
|
||||
|
||||
namespace internal {
|
||||
|
||||
template <typename... Args>
|
||||
class OnceCallbackHolder final {
|
||||
public:
|
||||
OnceCallbackHolder(OnceCallback<void(Args...)> callback,
|
||||
bool ignore_extra_runs)
|
||||
: callback_(std::move(callback)), ignore_extra_runs_(ignore_extra_runs) {
|
||||
DCHECK(callback_);
|
||||
}
|
||||
OnceCallbackHolder(const OnceCallbackHolder&) = delete;
|
||||
OnceCallbackHolder& operator=(const OnceCallbackHolder&) = delete;
|
||||
|
||||
void Run(Args... args) {
|
||||
if (has_run_.exchange(true)) {
|
||||
CHECK(ignore_extra_runs_) << "Both OnceCallbacks returned by "
|
||||
"base::SplitOnceCallback() were run. "
|
||||
"At most one of the pair should be run.";
|
||||
return;
|
||||
}
|
||||
DCHECK(callback_);
|
||||
std::move(callback_).Run(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
private:
|
||||
volatile std::atomic_bool has_run_{false};
|
||||
base::OnceCallback<void(Args...)> callback_;
|
||||
const bool ignore_extra_runs_;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
///
|
||||
/// Wraps the given OnceCallback into a RepeatingCallback that relays its
|
||||
/// invocation to the original OnceCallback on the first invocation. The
|
||||
/// following invocations are just ignored.
|
||||
///
|
||||
/// Note that this deliberately subverts the Once/Repeating paradigm of
|
||||
/// Callbacks but helps ease the migration from old-style Callbacks. Avoid if
|
||||
/// possible; use if necessary for migration.
|
||||
///
|
||||
// TODO(tzik): Remove it. https://crbug.com/730593
|
||||
template <typename... Args>
|
||||
RepeatingCallback<void(Args...)> AdaptCallbackForRepeating(
|
||||
OnceCallback<void(Args...)> callback) {
|
||||
using Helper = internal::OnceCallbackHolder<Args...>;
|
||||
return base::BindRepeating(
|
||||
&Helper::Run, std::make_unique<Helper>(std::move(callback),
|
||||
/*ignore_extra_runs=*/true));
|
||||
}
|
||||
|
||||
///
|
||||
/// Wraps the given OnceCallback and returns two OnceCallbacks with an identical
|
||||
/// signature. On first invokation of either returned callbacks, the original
|
||||
/// callback is invoked. Invoking the remaining callback results in a crash.
|
||||
///
|
||||
template <typename... Args>
|
||||
std::pair<OnceCallback<void(Args...)>, OnceCallback<void(Args...)>>
|
||||
SplitOnceCallback(OnceCallback<void(Args...)> callback) {
|
||||
using Helper = internal::OnceCallbackHolder<Args...>;
|
||||
auto wrapped_once = base::BindRepeating(
|
||||
&Helper::Run, std::make_unique<Helper>(std::move(callback),
|
||||
/*ignore_extra_runs=*/false));
|
||||
return std::make_pair(wrapped_once, wrapped_once);
|
||||
}
|
||||
|
||||
///
|
||||
/// ScopedClosureRunner is akin to std::unique_ptr<> for Closures. It ensures
|
||||
/// that the Closure is executed no matter how the current scope exits.
|
||||
/// If you are looking for "ScopedCallback", "CallbackRunner", or
|
||||
/// "CallbackScoper" this is the class you want.
|
||||
///
|
||||
class ScopedClosureRunner {
|
||||
public:
|
||||
ScopedClosureRunner();
|
||||
explicit ScopedClosureRunner(OnceClosure closure);
|
||||
ScopedClosureRunner(ScopedClosureRunner&& other);
|
||||
// Runs the current closure if it's set, then replaces it with the closure
|
||||
// from |other|. This is akin to how unique_ptr frees the contained pointer in
|
||||
// its move assignment operator. If you need to explicitly avoid running any
|
||||
// current closure, use ReplaceClosure().
|
||||
ScopedClosureRunner& operator=(ScopedClosureRunner&& other);
|
||||
~ScopedClosureRunner();
|
||||
|
||||
explicit operator bool() const { return !!closure_; }
|
||||
|
||||
// Calls the current closure and resets it, so it wont be called again.
|
||||
void RunAndReset();
|
||||
|
||||
// Replaces closure with the new one releasing the old one without calling it.
|
||||
void ReplaceClosure(OnceClosure closure);
|
||||
|
||||
// Releases the Closure without calling.
|
||||
[[nodiscard]] OnceClosure Release();
|
||||
|
||||
private:
|
||||
OnceClosure closure_;
|
||||
};
|
||||
|
||||
///
|
||||
/// Creates a null callback.
|
||||
///
|
||||
class NullCallback {
|
||||
public:
|
||||
template <typename R, typename... Args>
|
||||
operator RepeatingCallback<R(Args...)>() const {
|
||||
return RepeatingCallback<R(Args...)>();
|
||||
}
|
||||
template <typename R, typename... Args>
|
||||
operator OnceCallback<R(Args...)>() const {
|
||||
return OnceCallback<R(Args...)>();
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
/// Creates a callback that does nothing when called.
|
||||
///
|
||||
class DoNothing {
|
||||
public:
|
||||
template <typename... Args>
|
||||
operator RepeatingCallback<void(Args...)>() const {
|
||||
return Repeatedly<Args...>();
|
||||
}
|
||||
template <typename... Args>
|
||||
operator OnceCallback<void(Args...)>() const {
|
||||
return Once<Args...>();
|
||||
}
|
||||
// Explicit way of specifying a specific callback type when the compiler can't
|
||||
// deduce it.
|
||||
template <typename... Args>
|
||||
static RepeatingCallback<void(Args...)> Repeatedly() {
|
||||
return BindRepeating([](Args... args) {});
|
||||
}
|
||||
template <typename... Args>
|
||||
static OnceCallback<void(Args...)> Once() {
|
||||
return BindOnce([](Args... args) {});
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
/// Useful for creating a Closure that will delete a pointer when invoked. Only
|
||||
/// use this when necessary. In most cases MessageLoop::DeleteSoon() is a better
|
||||
/// fit.
|
||||
///
|
||||
template <typename T>
|
||||
void DeletePointer(T* obj) {
|
||||
delete obj;
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_CALLBACK_HELPERS_H_
|
||||
403
third/cef/include/base/cef_callback_list.h
Normal file
403
third/cef/include/base/cef_callback_list.h
Normal file
@@ -0,0 +1,403 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2013
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
///
|
||||
/// \file
|
||||
/// A container for a list of callbacks. Provides callers the ability to
|
||||
/// manually or automatically unregister callbacks at any time, including during
|
||||
/// callback notification.
|
||||
///
|
||||
/// TYPICAL USAGE:
|
||||
///
|
||||
/// <pre>
|
||||
/// class MyWidget {
|
||||
/// public:
|
||||
/// using CallbackList = base::RepeatingCallbackList<void(const Foo&)>;
|
||||
///
|
||||
/// // Registers |cb| to be called whenever NotifyFoo() is executed.
|
||||
/// CallbackListSubscription RegisterCallback(CallbackList::CallbackType cb) {
|
||||
/// return callback_list_.Add(std::move(cb));
|
||||
/// }
|
||||
///
|
||||
/// private:
|
||||
/// // Calls all registered callbacks, with |foo| as the supplied arg.
|
||||
/// void NotifyFoo(const Foo& foo) {
|
||||
/// callback_list_.Notify(foo);
|
||||
/// }
|
||||
///
|
||||
/// CallbackList callback_list_;
|
||||
/// };
|
||||
///
|
||||
///
|
||||
/// class MyWidgetListener {
|
||||
/// private:
|
||||
/// void OnFoo(const Foo& foo) {
|
||||
/// // Called whenever MyWidget::NotifyFoo() is executed, unless
|
||||
/// // |foo_subscription_| has been destroyed.
|
||||
/// }
|
||||
///
|
||||
/// // Automatically deregisters the callback when deleted (e.g. in
|
||||
/// // ~MyWidgetListener()). Unretained(this) is safe here since the
|
||||
/// // ScopedClosureRunner does not outlive |this|.
|
||||
/// CallbackListSubscription foo_subscription_ =
|
||||
/// MyWidget::Get()->RegisterCallback(
|
||||
/// base::BindRepeating(&MyWidgetListener::OnFoo,
|
||||
/// base::Unretained(this)));
|
||||
/// };
|
||||
/// </pre>
|
||||
///
|
||||
/// UNSUPPORTED:
|
||||
///
|
||||
/// * Destroying the CallbackList during callback notification.
|
||||
///
|
||||
/// This is possible to support, but not currently necessary.
|
||||
///
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_LIST_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_CALLBACK_LIST_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/functional/callback_list.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "include/base/cef_auto_reset.h"
|
||||
#include "include/base/cef_bind.h"
|
||||
#include "include/base/cef_callback.h"
|
||||
#include "include/base/cef_callback_helpers.h"
|
||||
#include "include/base/cef_logging.h"
|
||||
#include "include/base/cef_weak_ptr.h"
|
||||
|
||||
namespace base {
|
||||
namespace internal {
|
||||
template <typename CallbackListImpl>
|
||||
class CallbackListBase;
|
||||
} // namespace internal
|
||||
|
||||
template <typename Signature>
|
||||
class OnceCallbackList;
|
||||
|
||||
template <typename Signature>
|
||||
class RepeatingCallbackList;
|
||||
|
||||
// A trimmed-down version of ScopedClosureRunner that can be used to guarantee a
|
||||
// closure is run on destruction. This is designed to be used by
|
||||
// CallbackListBase to run CancelCallback() when this subscription dies;
|
||||
// consumers can avoid callbacks on dead objects by ensuring the subscription
|
||||
// returned by CallbackListBase::Add() does not outlive the bound object in the
|
||||
// callback. A typical way to do this is to bind a callback to a member function
|
||||
// on `this` and store the returned subscription as a member variable.
|
||||
class CallbackListSubscription {
|
||||
public:
|
||||
CallbackListSubscription();
|
||||
CallbackListSubscription(CallbackListSubscription&& subscription);
|
||||
CallbackListSubscription& operator=(CallbackListSubscription&& subscription);
|
||||
~CallbackListSubscription();
|
||||
|
||||
explicit operator bool() const { return !!closure_; }
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
friend class internal::CallbackListBase;
|
||||
|
||||
explicit CallbackListSubscription(base::OnceClosure closure);
|
||||
|
||||
void Run();
|
||||
|
||||
OnceClosure closure_;
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
|
||||
// From base/stl_util.h.
|
||||
template <class T, class Allocator, class Predicate>
|
||||
size_t EraseIf(std::list<T, Allocator>& container, Predicate pred) {
|
||||
size_t old_size = container.size();
|
||||
container.remove_if(pred);
|
||||
return old_size - container.size();
|
||||
}
|
||||
|
||||
// A traits class to break circular type dependencies between CallbackListBase
|
||||
// and its subclasses.
|
||||
template <typename CallbackList>
|
||||
struct CallbackListTraits;
|
||||
|
||||
// NOTE: It's important that Callbacks provide iterator stability when items are
|
||||
// added to the end, so e.g. a std::vector<> is not suitable here.
|
||||
template <typename Signature>
|
||||
struct CallbackListTraits<OnceCallbackList<Signature>> {
|
||||
using CallbackType = OnceCallback<Signature>;
|
||||
using Callbacks = std::list<CallbackType>;
|
||||
};
|
||||
template <typename Signature>
|
||||
struct CallbackListTraits<RepeatingCallbackList<Signature>> {
|
||||
using CallbackType = RepeatingCallback<Signature>;
|
||||
using Callbacks = std::list<CallbackType>;
|
||||
};
|
||||
|
||||
template <typename CallbackListImpl>
|
||||
class CallbackListBase {
|
||||
public:
|
||||
using CallbackType =
|
||||
typename CallbackListTraits<CallbackListImpl>::CallbackType;
|
||||
static_assert(IsBaseCallback<CallbackType>::value, "");
|
||||
|
||||
// TODO(crbug.com/1103086): Update references to use this directly and by
|
||||
// value, then remove.
|
||||
using Subscription = CallbackListSubscription;
|
||||
|
||||
CallbackListBase() = default;
|
||||
CallbackListBase(const CallbackListBase&) = delete;
|
||||
CallbackListBase& operator=(const CallbackListBase&) = delete;
|
||||
|
||||
~CallbackListBase() {
|
||||
// Destroying the list during iteration is unsupported and will cause a UAF.
|
||||
CHECK(!iterating_);
|
||||
}
|
||||
|
||||
// Registers |cb| for future notifications. Returns a CallbackListSubscription
|
||||
// whose destruction will cancel |cb|.
|
||||
[[nodiscard]] CallbackListSubscription Add(CallbackType cb) {
|
||||
DCHECK(!cb.is_null());
|
||||
return CallbackListSubscription(base::BindOnce(
|
||||
&CallbackListBase::CancelCallback, weak_ptr_factory_.GetWeakPtr(),
|
||||
callbacks_.insert(callbacks_.end(), std::move(cb))));
|
||||
}
|
||||
|
||||
// Registers |cb| for future notifications. Provides no way for the caller to
|
||||
// cancel, so this is only safe for cases where the callback is guaranteed to
|
||||
// live at least as long as this list (e.g. if it's bound on the same object
|
||||
// that owns the list).
|
||||
// TODO(pkasting): Attempt to use Add() instead and see if callers can relax
|
||||
// other lifetime/ordering mechanisms as a result.
|
||||
void AddUnsafe(CallbackType cb) {
|
||||
DCHECK(!cb.is_null());
|
||||
callbacks_.push_back(std::move(cb));
|
||||
}
|
||||
|
||||
// Registers |removal_callback| to be run after elements are removed from the
|
||||
// list of registered callbacks.
|
||||
void set_removal_callback(const RepeatingClosure& removal_callback) {
|
||||
removal_callback_ = removal_callback;
|
||||
}
|
||||
|
||||
// Returns whether the list of registered callbacks is empty (from an external
|
||||
// perspective -- meaning no remaining callbacks are live).
|
||||
bool empty() const {
|
||||
return std::all_of(callbacks_.cbegin(), callbacks_.cend(),
|
||||
[](const auto& callback) { return callback.is_null(); });
|
||||
}
|
||||
|
||||
// Calls all registered callbacks that are not canceled beforehand. If any
|
||||
// callbacks are unregistered, notifies any registered removal callback at the
|
||||
// end.
|
||||
//
|
||||
// Arguments must be copyable, since they must be supplied to all callbacks.
|
||||
// Move-only types would be destructively modified by passing them to the
|
||||
// first callback and not reach subsequent callbacks as intended.
|
||||
//
|
||||
// Notify() may be called re-entrantly, in which case the nested call
|
||||
// completes before the outer one continues. Callbacks are only ever added at
|
||||
// the end and canceled callbacks are not pruned from the list until the
|
||||
// outermost iteration completes, so existing iterators should never be
|
||||
// invalidated. However, this does mean that a callback added during a nested
|
||||
// call can be notified by outer calls -- meaning it will be notified about
|
||||
// things that happened before it was added -- if its subscription outlives
|
||||
// the reentrant Notify() call.
|
||||
template <typename... RunArgs>
|
||||
void Notify(RunArgs&&... args) {
|
||||
if (empty()) {
|
||||
return; // Nothing to do.
|
||||
}
|
||||
|
||||
{
|
||||
AutoReset<bool> iterating(&iterating_, true);
|
||||
|
||||
// Skip any callbacks that are canceled during iteration.
|
||||
// NOTE: Since RunCallback() may call Add(), it's not safe to cache the
|
||||
// value of callbacks_.end() across loop iterations.
|
||||
const auto next_valid = [this](const auto it) {
|
||||
return std::find_if_not(it, callbacks_.end(), [](const auto& callback) {
|
||||
return callback.is_null();
|
||||
});
|
||||
};
|
||||
for (auto it = next_valid(callbacks_.begin()); it != callbacks_.end();
|
||||
it = next_valid(it)) {
|
||||
// NOTE: Intentionally does not call std::forward<RunArgs>(args)...,
|
||||
// since that would allow move-only arguments.
|
||||
static_cast<CallbackListImpl*>(this)->RunCallback(it++, args...);
|
||||
}
|
||||
}
|
||||
|
||||
// Re-entrant invocations shouldn't prune anything from the list. This can
|
||||
// invalidate iterators from underneath higher call frames. It's safe to
|
||||
// simply do nothing, since the outermost frame will continue through here
|
||||
// and prune all null callbacks below.
|
||||
if (iterating_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Any null callbacks remaining in the list were canceled due to
|
||||
// Subscription destruction during iteration, and can safely be erased now.
|
||||
const size_t erased_callbacks =
|
||||
EraseIf(callbacks_, [](const auto& cb) { return cb.is_null(); });
|
||||
|
||||
// Run |removal_callback_| if any callbacks were canceled. Note that we
|
||||
// cannot simply compare list sizes before and after iterating, since
|
||||
// notification may result in Add()ing new callbacks as well as canceling
|
||||
// them. Also note that if this is a OnceCallbackList, the OnceCallbacks
|
||||
// that were executed above have all been removed regardless of whether
|
||||
// they're counted in |erased_callbacks_|.
|
||||
if (removal_callback_ &&
|
||||
(erased_callbacks || IsOnceCallback<CallbackType>::value)) {
|
||||
removal_callback_.Run(); // May delete |this|!
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
using Callbacks = typename CallbackListTraits<CallbackListImpl>::Callbacks;
|
||||
|
||||
// Holds non-null callbacks, which will be called during Notify().
|
||||
Callbacks callbacks_;
|
||||
|
||||
private:
|
||||
// Cancels the callback pointed to by |it|, which is guaranteed to be valid.
|
||||
void CancelCallback(const typename Callbacks::iterator& it) {
|
||||
if (static_cast<CallbackListImpl*>(this)->CancelNullCallback(it)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (iterating_) {
|
||||
// Calling erase() here is unsafe, since the loop in Notify() may be
|
||||
// referencing this same iterator, e.g. if adjacent callbacks'
|
||||
// Subscriptions are both destroyed when the first one is Run(). Just
|
||||
// reset the callback and let Notify() clean it up at the end.
|
||||
it->Reset();
|
||||
} else {
|
||||
callbacks_.erase(it);
|
||||
if (removal_callback_) {
|
||||
removal_callback_.Run(); // May delete |this|!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set while Notify() is traversing |callbacks_|. Used primarily to avoid
|
||||
// invalidating iterators that may be in use.
|
||||
bool iterating_ = false;
|
||||
|
||||
// Called after elements are removed from |callbacks_|.
|
||||
RepeatingClosure removal_callback_;
|
||||
|
||||
WeakPtrFactory<CallbackListBase> weak_ptr_factory_{this};
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template <typename Signature>
|
||||
class OnceCallbackList
|
||||
: public internal::CallbackListBase<OnceCallbackList<Signature>> {
|
||||
private:
|
||||
friend internal::CallbackListBase<OnceCallbackList>;
|
||||
using Traits = internal::CallbackListTraits<OnceCallbackList>;
|
||||
|
||||
// Runs the current callback, which may cancel it or any other callbacks.
|
||||
template <typename... RunArgs>
|
||||
void RunCallback(typename Traits::Callbacks::iterator it, RunArgs&&... args) {
|
||||
// OnceCallbacks still have Subscriptions with outstanding iterators;
|
||||
// splice() removes them from |callbacks_| without invalidating those.
|
||||
null_callbacks_.splice(null_callbacks_.end(), this->callbacks_, it);
|
||||
|
||||
// NOTE: Intentionally does not call std::forward<RunArgs>(args)...; see
|
||||
// comments in Notify().
|
||||
std::move(*it).Run(args...);
|
||||
}
|
||||
|
||||
// If |it| refers to an already-canceled callback, does any necessary cleanup
|
||||
// and returns true. Otherwise returns false.
|
||||
bool CancelNullCallback(const typename Traits::Callbacks::iterator& it) {
|
||||
if (it->is_null()) {
|
||||
null_callbacks_.erase(it);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Holds null callbacks whose Subscriptions are still alive, so the
|
||||
// Subscriptions will still contain valid iterators. Only needed for
|
||||
// OnceCallbacks, since RepeatingCallbacks are not canceled except by
|
||||
// Subscription destruction.
|
||||
typename Traits::Callbacks null_callbacks_;
|
||||
};
|
||||
|
||||
template <typename Signature>
|
||||
class RepeatingCallbackList
|
||||
: public internal::CallbackListBase<RepeatingCallbackList<Signature>> {
|
||||
private:
|
||||
friend internal::CallbackListBase<RepeatingCallbackList>;
|
||||
using Traits = internal::CallbackListTraits<RepeatingCallbackList>;
|
||||
// Runs the current callback, which may cancel it or any other callbacks.
|
||||
template <typename... RunArgs>
|
||||
void RunCallback(typename Traits::Callbacks::iterator it, RunArgs&&... args) {
|
||||
// NOTE: Intentionally does not call std::forward<RunArgs>(args)...; see
|
||||
// comments in Notify().
|
||||
it->Run(args...);
|
||||
}
|
||||
|
||||
// If |it| refers to an already-canceled callback, does any necessary cleanup
|
||||
// and returns true. Otherwise returns false.
|
||||
bool CancelNullCallback(const typename Traits::Callbacks::iterator& it) {
|
||||
// Because at most one Subscription can point to a given callback, and
|
||||
// RepeatingCallbacks are only reset by CancelCallback(), no one should be
|
||||
// able to request cancellation of a canceled RepeatingCallback.
|
||||
DCHECK(!it->is_null());
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
/// Syntactic sugar to parallel that used for Callbacks.
|
||||
///
|
||||
using OnceClosureList = OnceCallbackList<void()>;
|
||||
using RepeatingClosureList = RepeatingCallbackList<void()>;
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_CALLBACK_LIST_H_
|
||||
195
third/cef/include/base/cef_cancelable_callback.h
Normal file
195
third/cef/include/base/cef_cancelable_callback.h
Normal file
@@ -0,0 +1,195 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
///
|
||||
/// \file
|
||||
/// CancelableCallback is a wrapper around base::Callback that allows
|
||||
/// cancellation of a callback. CancelableCallback takes a reference on the
|
||||
/// wrapped callback until this object is destroyed or Reset()/Cancel() are
|
||||
/// called.
|
||||
///
|
||||
/// NOTE:
|
||||
///
|
||||
/// Calling CancelableCallback::Cancel() brings the object back to its natural,
|
||||
/// default-constructed state, i.e., CancelableCallback::callback() will return
|
||||
/// a null callback.
|
||||
///
|
||||
/// THREAD-SAFETY:
|
||||
///
|
||||
/// CancelableCallback objects must be created on, posted to, cancelled on, and
|
||||
/// destroyed on the same thread.
|
||||
///
|
||||
///
|
||||
/// EXAMPLE USAGE:
|
||||
///
|
||||
/// In the following example, the test is verifying that RunIntensiveTest()
|
||||
/// Quit()s the message loop within 4 seconds. The cancelable callback is posted
|
||||
/// to the message loop, the intensive test runs, the message loop is run,
|
||||
/// then the callback is cancelled.
|
||||
///
|
||||
/// <pre>
|
||||
/// RunLoop run_loop;
|
||||
///
|
||||
/// void TimeoutCallback(const std::string& timeout_message) {
|
||||
/// FAIL() << timeout_message;
|
||||
/// run_loop.QuitWhenIdle();
|
||||
/// }
|
||||
///
|
||||
/// CancelableOnceClosure timeout(
|
||||
/// base::BindOnce(&TimeoutCallback, "Test timed out."));
|
||||
/// ThreadTaskRunnerHandle::Get()->PostDelayedTask(FROM_HERE,
|
||||
/// timeout.callback(),
|
||||
/// TimeDelta::FromSeconds(4));
|
||||
/// RunIntensiveTest();
|
||||
/// run_loop.Run();
|
||||
/// // Hopefully this is hit before the timeout callback runs.
|
||||
/// timeout.Cancel();
|
||||
/// </pre>
|
||||
///
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_CANCELABLE_CALLBACK_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_CANCELABLE_CALLBACK_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/cancelable_callback.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "include/base/cef_bind.h"
|
||||
#include "include/base/cef_callback.h"
|
||||
#include "include/base/cef_compiler_specific.h"
|
||||
#include "include/base/cef_logging.h"
|
||||
#include "include/base/cef_weak_ptr.h"
|
||||
#include "include/base/internal/cef_callback_internal.h"
|
||||
|
||||
namespace base {
|
||||
namespace internal {
|
||||
|
||||
template <typename CallbackType>
|
||||
class CancelableCallbackImpl {
|
||||
public:
|
||||
CancelableCallbackImpl() = default;
|
||||
CancelableCallbackImpl(const CancelableCallbackImpl&) = delete;
|
||||
CancelableCallbackImpl& operator=(const CancelableCallbackImpl&) = delete;
|
||||
|
||||
// |callback| must not be null.
|
||||
explicit CancelableCallbackImpl(CallbackType callback)
|
||||
: callback_(std::move(callback)) {
|
||||
DCHECK(callback_);
|
||||
}
|
||||
|
||||
~CancelableCallbackImpl() = default;
|
||||
|
||||
// Cancels and drops the reference to the wrapped callback.
|
||||
void Cancel() {
|
||||
weak_ptr_factory_.InvalidateWeakPtrs();
|
||||
callback_.Reset();
|
||||
}
|
||||
|
||||
// Returns true if the wrapped callback has been cancelled.
|
||||
bool IsCancelled() const { return callback_.is_null(); }
|
||||
|
||||
// Sets |callback| as the closure that may be cancelled. |callback| may not
|
||||
// be null. Outstanding and any previously wrapped callbacks are cancelled.
|
||||
void Reset(CallbackType callback) {
|
||||
DCHECK(callback);
|
||||
// Outstanding tasks (e.g., posted to a message loop) must not be called.
|
||||
Cancel();
|
||||
callback_ = std::move(callback);
|
||||
}
|
||||
|
||||
// Returns a callback that can be disabled by calling Cancel().
|
||||
CallbackType callback() const {
|
||||
if (!callback_) {
|
||||
return CallbackType();
|
||||
}
|
||||
CallbackType forwarder;
|
||||
MakeForwarder(&forwarder);
|
||||
return forwarder;
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename... Args>
|
||||
void MakeForwarder(RepeatingCallback<void(Args...)>* out) const {
|
||||
using ForwarderType = void (CancelableCallbackImpl::*)(Args...);
|
||||
ForwarderType forwarder = &CancelableCallbackImpl::ForwardRepeating;
|
||||
*out = BindRepeating(forwarder, weak_ptr_factory_.GetWeakPtr());
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void MakeForwarder(OnceCallback<void(Args...)>* out) const {
|
||||
using ForwarderType = void (CancelableCallbackImpl::*)(Args...);
|
||||
ForwarderType forwarder = &CancelableCallbackImpl::ForwardOnce;
|
||||
*out = BindOnce(forwarder, weak_ptr_factory_.GetWeakPtr());
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void ForwardRepeating(Args... args) {
|
||||
callback_.Run(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void ForwardOnce(Args... args) {
|
||||
weak_ptr_factory_.InvalidateWeakPtrs();
|
||||
std::move(callback_).Run(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// The stored closure that may be cancelled.
|
||||
CallbackType callback_;
|
||||
mutable base::WeakPtrFactory<CancelableCallbackImpl> weak_ptr_factory_{this};
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
///
|
||||
/// Consider using base::WeakPtr directly instead of base::CancelableCallback
|
||||
/// for the task cancellation.
|
||||
///
|
||||
template <typename Signature>
|
||||
using CancelableOnceCallback =
|
||||
internal::CancelableCallbackImpl<OnceCallback<Signature>>;
|
||||
using CancelableOnceClosure = CancelableOnceCallback<void()>;
|
||||
|
||||
template <typename Signature>
|
||||
using CancelableRepeatingCallback =
|
||||
internal::CancelableCallbackImpl<RepeatingCallback<Signature>>;
|
||||
using CancelableRepeatingClosure = CancelableRepeatingCallback<void()>;
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_CANCELABLE_CALLBACK_H_
|
||||
382
third/cef/include/base/cef_compiler_specific.h
Normal file
382
third/cef/include/base/cef_compiler_specific.h
Normal file
@@ -0,0 +1,382 @@
|
||||
// Copyright (c) 2021 Marshall A. Greenblatt. Portions copyright (c) 2012
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_COMPILER_SPECIFIC_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_COMPILER_SPECIFIC_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/compiler_specific.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include "include/base/cef_build.h"
|
||||
|
||||
// This is a wrapper around `__has_cpp_attribute`, which can be used to test for
|
||||
// the presence of an attribute. In case the compiler does not support this
|
||||
// macro it will simply evaluate to 0.
|
||||
//
|
||||
// References:
|
||||
// https://wg21.link/sd6#testing-for-the-presence-of-an-attribute-__has_cpp_attribute
|
||||
// https://wg21.link/cpp.cond#:__has_cpp_attribute
|
||||
#if defined(__has_cpp_attribute)
|
||||
#define HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
|
||||
#else
|
||||
#define HAS_CPP_ATTRIBUTE(x) 0
|
||||
#endif
|
||||
|
||||
// A wrapper around `__has_builtin`, similar to HAS_CPP_ATTRIBUTE.
|
||||
#if defined(__has_builtin)
|
||||
#define HAS_BUILTIN(x) __has_builtin(x)
|
||||
#else
|
||||
#define HAS_BUILTIN(x) 0
|
||||
#endif
|
||||
|
||||
// __has_feature and __has_attribute don't exist for MSVC.
|
||||
#if !defined(__has_feature)
|
||||
#define __has_feature(x) 0
|
||||
#endif // !defined(__has_feature)
|
||||
|
||||
#if !defined(__has_attribute)
|
||||
#define __has_attribute(x) 0
|
||||
#endif // !defined(__has_attribute)
|
||||
|
||||
// Annotate a function indicating it should not be inlined.
|
||||
// Use like:
|
||||
// NOINLINE void DoStuff() { ... }
|
||||
#if defined(COMPILER_GCC)
|
||||
#define NOINLINE __attribute__((noinline))
|
||||
#elif defined(COMPILER_MSVC)
|
||||
#define NOINLINE __declspec(noinline)
|
||||
#else
|
||||
#define NOINLINE
|
||||
#endif
|
||||
|
||||
#if defined(COMPILER_GCC) && defined(NDEBUG)
|
||||
#define ALWAYS_INLINE inline __attribute__((__always_inline__))
|
||||
#elif defined(COMPILER_MSVC) && defined(NDEBUG)
|
||||
#define ALWAYS_INLINE __forceinline
|
||||
#else
|
||||
#define ALWAYS_INLINE inline
|
||||
#endif
|
||||
|
||||
// Annotate a function indicating it should never be tail called. Useful to make
|
||||
// sure callers of the annotated function are never omitted from call-stacks.
|
||||
// To provide the complementary behavior (prevent the annotated function from
|
||||
// being omitted) look at NOINLINE. Also note that this doesn't prevent code
|
||||
// folding of multiple identical caller functions into a single signature. To
|
||||
// prevent code folding, see NO_CODE_FOLDING() in base/debug/alias.h.
|
||||
// Use like:
|
||||
// void NOT_TAIL_CALLED FooBar();
|
||||
#if defined(__clang__) && __has_attribute(not_tail_called)
|
||||
#define NOT_TAIL_CALLED __attribute__((not_tail_called))
|
||||
#else
|
||||
#define NOT_TAIL_CALLED
|
||||
#endif
|
||||
|
||||
// Specify memory alignment for structs, classes, etc.
|
||||
// Use like:
|
||||
// class ALIGNAS(16) MyClass { ... }
|
||||
// ALIGNAS(16) int array[4];
|
||||
//
|
||||
// In most places you can use the C++11 keyword "alignas", which is preferred.
|
||||
//
|
||||
// But compilers have trouble mixing __attribute__((...)) syntax with
|
||||
// alignas(...) syntax.
|
||||
//
|
||||
// Doesn't work in clang or gcc:
|
||||
// struct alignas(16) __attribute__((packed)) S { char c; };
|
||||
// Works in clang but not gcc:
|
||||
// struct __attribute__((packed)) alignas(16) S2 { char c; };
|
||||
// Works in clang and gcc:
|
||||
// struct alignas(16) S3 { char c; } __attribute__((packed));
|
||||
//
|
||||
// There are also some attributes that must be specified *before* a class
|
||||
// definition: visibility (used for exporting functions/classes) is one of
|
||||
// these attributes. This means that it is not possible to use alignas() with a
|
||||
// class that is marked as exported.
|
||||
#if defined(COMPILER_MSVC)
|
||||
#define ALIGNAS(byte_alignment) __declspec(align(byte_alignment))
|
||||
#elif defined(COMPILER_GCC)
|
||||
#define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
|
||||
#endif
|
||||
|
||||
// In case the compiler supports it NO_UNIQUE_ADDRESS evaluates to the C++20
|
||||
// attribute [[no_unique_address]]. This allows annotating data members so that
|
||||
// they need not have an address distinct from all other non-static data members
|
||||
// of its class.
|
||||
//
|
||||
// References:
|
||||
// * https://en.cppreference.com/w/cpp/language/attributes/no_unique_address
|
||||
// * https://wg21.link/dcl.attr.nouniqueaddr
|
||||
#if HAS_CPP_ATTRIBUTE(no_unique_address)
|
||||
#define NO_UNIQUE_ADDRESS [[no_unique_address]]
|
||||
#else
|
||||
#define NO_UNIQUE_ADDRESS
|
||||
#endif
|
||||
|
||||
// Tell the compiler a function is using a printf-style format string.
|
||||
// |format_param| is the one-based index of the format string parameter;
|
||||
// |dots_param| is the one-based index of the "..." parameter.
|
||||
// For v*printf functions (which take a va_list), pass 0 for dots_param.
|
||||
// (This is undocumented but matches what the system C headers do.)
|
||||
// For member functions, the implicit this parameter counts as index 1.
|
||||
#if defined(COMPILER_GCC) || defined(__clang__)
|
||||
#define PRINTF_FORMAT(format_param, dots_param) \
|
||||
__attribute__((format(printf, format_param, dots_param)))
|
||||
#else
|
||||
#define PRINTF_FORMAT(format_param, dots_param)
|
||||
#endif
|
||||
|
||||
// WPRINTF_FORMAT is the same, but for wide format strings.
|
||||
// This doesn't appear to yet be implemented in any compiler.
|
||||
// See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 .
|
||||
#define WPRINTF_FORMAT(format_param, dots_param)
|
||||
// If available, it would look like:
|
||||
// __attribute__((format(wprintf, format_param, dots_param)))
|
||||
|
||||
// Sanitizers annotations.
|
||||
#if defined(__has_attribute)
|
||||
#if __has_attribute(no_sanitize)
|
||||
#define NO_SANITIZE(what) __attribute__((no_sanitize(what)))
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(NO_SANITIZE)
|
||||
#define NO_SANITIZE(what)
|
||||
#endif
|
||||
|
||||
// MemorySanitizer annotations.
|
||||
#if defined(MEMORY_SANITIZER) && !defined(OS_NACL)
|
||||
#include <sanitizer/msan_interface.h>
|
||||
|
||||
// Mark a memory region fully initialized.
|
||||
// Use this to annotate code that deliberately reads uninitialized data, for
|
||||
// example a GC scavenging root set pointers from the stack.
|
||||
#define MSAN_UNPOISON(p, size) __msan_unpoison(p, size)
|
||||
|
||||
// Check a memory region for initializedness, as if it was being used here.
|
||||
// If any bits are uninitialized, crash with an MSan report.
|
||||
// Use this to sanitize data which MSan won't be able to track, e.g. before
|
||||
// passing data to another process via shared memory.
|
||||
#define MSAN_CHECK_MEM_IS_INITIALIZED(p, size) \
|
||||
__msan_check_mem_is_initialized(p, size)
|
||||
#else // MEMORY_SANITIZER
|
||||
#define MSAN_UNPOISON(p, size)
|
||||
#define MSAN_CHECK_MEM_IS_INITIALIZED(p, size)
|
||||
#endif // MEMORY_SANITIZER
|
||||
|
||||
// DISABLE_CFI_PERF -- Disable Control Flow Integrity for perf reasons.
|
||||
#if !defined(DISABLE_CFI_PERF)
|
||||
#if defined(__clang__) && defined(OFFICIAL_BUILD)
|
||||
#define DISABLE_CFI_PERF __attribute__((no_sanitize("cfi")))
|
||||
#else
|
||||
#define DISABLE_CFI_PERF
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// DISABLE_CFI_ICALL -- Disable Control Flow Integrity indirect call checks.
|
||||
#if !defined(DISABLE_CFI_ICALL)
|
||||
#if defined(OS_WIN)
|
||||
// Windows also needs __declspec(guard(nocf)).
|
||||
#define DISABLE_CFI_ICALL NO_SANITIZE("cfi-icall") __declspec(guard(nocf))
|
||||
#else
|
||||
#define DISABLE_CFI_ICALL NO_SANITIZE("cfi-icall")
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(DISABLE_CFI_ICALL)
|
||||
#define DISABLE_CFI_ICALL
|
||||
#endif
|
||||
|
||||
// Macro useful for writing cross-platform function pointers.
|
||||
#if !defined(CDECL)
|
||||
#if defined(OS_WIN)
|
||||
#define CDECL __cdecl
|
||||
#else // defined(OS_WIN)
|
||||
#define CDECL
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // !defined(CDECL)
|
||||
|
||||
// Macro for hinting that an expression is likely to be false.
|
||||
#if !defined(UNLIKELY)
|
||||
#if defined(COMPILER_GCC) || defined(__clang__)
|
||||
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
|
||||
#else
|
||||
#define UNLIKELY(x) (x)
|
||||
#endif // defined(COMPILER_GCC)
|
||||
#endif // !defined(UNLIKELY)
|
||||
|
||||
#if !defined(LIKELY)
|
||||
#if defined(COMPILER_GCC) || defined(__clang__)
|
||||
#define LIKELY(x) __builtin_expect(!!(x), 1)
|
||||
#else
|
||||
#define LIKELY(x) (x)
|
||||
#endif // defined(COMPILER_GCC)
|
||||
#endif // !defined(LIKELY)
|
||||
|
||||
// Compiler feature-detection.
|
||||
// clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension
|
||||
#if defined(__has_feature)
|
||||
#define HAS_FEATURE(FEATURE) __has_feature(FEATURE)
|
||||
#else
|
||||
#define HAS_FEATURE(FEATURE) 0
|
||||
#endif
|
||||
|
||||
#if defined(COMPILER_GCC)
|
||||
#define PRETTY_FUNCTION __PRETTY_FUNCTION__
|
||||
#elif defined(COMPILER_MSVC)
|
||||
#define PRETTY_FUNCTION __FUNCSIG__
|
||||
#else
|
||||
// See https://en.cppreference.com/w/c/language/function_definition#func
|
||||
#define PRETTY_FUNCTION __func__
|
||||
#endif
|
||||
|
||||
#if !defined(CPU_ARM_NEON)
|
||||
#if defined(__arm__)
|
||||
#if !defined(__ARMEB__) && !defined(__ARM_EABI__) && !defined(__EABI__) && \
|
||||
!defined(__VFP_FP__) && !defined(_WIN32_WCE) && !defined(ANDROID)
|
||||
#error Chromium does not support middle endian architecture
|
||||
#endif
|
||||
#if defined(__ARM_NEON__)
|
||||
#define CPU_ARM_NEON 1
|
||||
#endif
|
||||
#endif // defined(__arm__)
|
||||
#endif // !defined(CPU_ARM_NEON)
|
||||
|
||||
#if !defined(HAVE_MIPS_MSA_INTRINSICS)
|
||||
#if defined(__mips_msa) && defined(__mips_isa_rev) && (__mips_isa_rev >= 5)
|
||||
#define HAVE_MIPS_MSA_INTRINSICS 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) && __has_attribute(uninitialized)
|
||||
// Attribute "uninitialized" disables -ftrivial-auto-var-init=pattern for
|
||||
// the specified variable.
|
||||
// Library-wide alternative is
|
||||
// 'configs -= [ "//build/config/compiler:default_init_stack_vars" ]' in .gn
|
||||
// file.
|
||||
//
|
||||
// See "init_stack_vars" in build/config/compiler/BUILD.gn and
|
||||
// http://crbug.com/977230
|
||||
// "init_stack_vars" is enabled for non-official builds and we hope to enable it
|
||||
// in official build in 2020 as well. The flag writes fixed pattern into
|
||||
// uninitialized parts of all local variables. In rare cases such initialization
|
||||
// is undesirable and attribute can be used:
|
||||
// 1. Degraded performance
|
||||
// In most cases compiler is able to remove additional stores. E.g. if memory is
|
||||
// never accessed or properly initialized later. Preserved stores mostly will
|
||||
// not affect program performance. However if compiler failed on some
|
||||
// performance critical code we can get a visible regression in a benchmark.
|
||||
// 2. memset, memcpy calls
|
||||
// Compiler may replaces some memory writes with memset or memcpy calls. This is
|
||||
// not -ftrivial-auto-var-init specific, but it can happen more likely with the
|
||||
// flag. It can be a problem if code is not linked with C run-time library.
|
||||
//
|
||||
// Note: The flag is security risk mitigation feature. So in future the
|
||||
// attribute uses should be avoided when possible. However to enable this
|
||||
// mitigation on the most of the code we need to be less strict now and minimize
|
||||
// number of exceptions later. So if in doubt feel free to use attribute, but
|
||||
// please document the problem for someone who is going to cleanup it later.
|
||||
// E.g. platform, bot, benchmark or test name in patch description or next to
|
||||
// the attribute.
|
||||
#define STACK_UNINITIALIZED __attribute__((uninitialized))
|
||||
#else
|
||||
#define STACK_UNINITIALIZED
|
||||
#endif
|
||||
|
||||
// The ANALYZER_ASSUME_TRUE(bool arg) macro adds compiler-specific hints
|
||||
// to Clang which control what code paths are statically analyzed,
|
||||
// and is meant to be used in conjunction with assert & assert-like functions.
|
||||
// The expression is passed straight through if analysis isn't enabled.
|
||||
//
|
||||
// ANALYZER_SKIP_THIS_PATH() suppresses static analysis for the current
|
||||
// codepath and any other branching codepaths that might follow.
|
||||
#if defined(__clang_analyzer__)
|
||||
|
||||
inline constexpr bool AnalyzerNoReturn() __attribute__((analyzer_noreturn)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
inline constexpr bool AnalyzerAssumeTrue(bool arg) {
|
||||
// AnalyzerNoReturn() is invoked and analysis is terminated if |arg| is
|
||||
// false.
|
||||
return arg || AnalyzerNoReturn();
|
||||
}
|
||||
|
||||
#define ANALYZER_ASSUME_TRUE(arg) ::AnalyzerAssumeTrue(!!(arg))
|
||||
#define ANALYZER_SKIP_THIS_PATH() static_cast<void>(::AnalyzerNoReturn())
|
||||
#define ANALYZER_ALLOW_UNUSED(var) static_cast<void>(var);
|
||||
|
||||
#else // !defined(__clang_analyzer__)
|
||||
|
||||
#define ANALYZER_ASSUME_TRUE(arg) (arg)
|
||||
#define ANALYZER_SKIP_THIS_PATH()
|
||||
#define ANALYZER_ALLOW_UNUSED(var) static_cast<void>(var);
|
||||
|
||||
#endif // defined(__clang_analyzer__)
|
||||
|
||||
// Use nomerge attribute to disable optimization of merging multiple same calls.
|
||||
#if defined(__clang__) && __has_attribute(nomerge)
|
||||
#define NOMERGE [[clang::nomerge]]
|
||||
#else
|
||||
#define NOMERGE
|
||||
#endif
|
||||
|
||||
// Marks a type as being eligible for the "trivial" ABI despite having a
|
||||
// non-trivial destructor or copy/move constructor. Such types can be relocated
|
||||
// after construction by simply copying their memory, which makes them eligible
|
||||
// to be passed in registers. The canonical example is std::unique_ptr.
|
||||
//
|
||||
// Use with caution; this has some subtle effects on constructor/destructor
|
||||
// ordering and will be very incorrect if the type relies on its address
|
||||
// remaining constant. When used as a function argument (by value), the value
|
||||
// may be constructed in the caller's stack frame, passed in a register, and
|
||||
// then used and destructed in the callee's stack frame. A similar thing can
|
||||
// occur when values are returned.
|
||||
//
|
||||
// TRIVIAL_ABI is not needed for types which have a trivial destructor and
|
||||
// copy/move constructors, such as base::TimeTicks and other POD.
|
||||
//
|
||||
// It is also not likely to be effective on types too large to be passed in one
|
||||
// or two registers on typical target ABIs.
|
||||
//
|
||||
// See also:
|
||||
// https://clang.llvm.org/docs/AttributeReference.html#trivial-abi
|
||||
// https://libcxx.llvm.org/docs/DesignDocs/UniquePtrTrivialAbi.html
|
||||
#if defined(__clang__) && __has_attribute(trivial_abi)
|
||||
#define TRIVIAL_ABI [[clang::trivial_abi]]
|
||||
#else
|
||||
#define TRIVIAL_ABI
|
||||
#endif
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
#endif // CEF_INCLUDE_BASE_CEF_COMPILER_SPECIFIC_H_
|
||||
182
third/cef/include/base/cef_lock.h
Normal file
182
third/cef/include/base/cef_lock.h
Normal file
@@ -0,0 +1,182 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_LOCK_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_LOCK_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/synchronization/lock.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include "include/base/cef_logging.h"
|
||||
#include "include/base/cef_platform_thread.h"
|
||||
#include "include/base/internal/cef_lock_impl.h"
|
||||
|
||||
namespace base {
|
||||
namespace cef_internal {
|
||||
|
||||
///
|
||||
/// A convenient wrapper for an OS specific critical section. The only real
|
||||
/// intelligence in this class is in debug mode for the support for the
|
||||
/// AssertAcquired() method.
|
||||
///
|
||||
class Lock {
|
||||
public:
|
||||
#if !DCHECK_IS_ON() // Optimized wrapper implementation
|
||||
Lock() : lock_() {}
|
||||
|
||||
Lock(const Lock&) = delete;
|
||||
Lock& operator=(const Lock&) = delete;
|
||||
|
||||
~Lock() {}
|
||||
void Acquire() { lock_.Lock(); }
|
||||
void Release() { lock_.Unlock(); }
|
||||
|
||||
///
|
||||
/// If the lock is not held, take it and return true. If the lock is already
|
||||
/// held by another thread, immediately return false. This must not be called
|
||||
/// by a thread already holding the lock (what happens is undefined and an
|
||||
/// assertion may fail).
|
||||
///
|
||||
bool Try() { return lock_.Try(); }
|
||||
|
||||
// Null implementation if not debug.
|
||||
void AssertAcquired() const {}
|
||||
#else
|
||||
Lock();
|
||||
~Lock();
|
||||
|
||||
// NOTE: Although windows critical sections support recursive locks, we do not
|
||||
// allow this, and we will commonly fire a DCHECK() if a thread attempts to
|
||||
// acquire the lock a second time (while already holding it).
|
||||
void Acquire() {
|
||||
lock_.Lock();
|
||||
CheckUnheldAndMark();
|
||||
}
|
||||
void Release() {
|
||||
CheckHeldAndUnmark();
|
||||
lock_.Unlock();
|
||||
}
|
||||
|
||||
bool Try() {
|
||||
bool rv = lock_.Try();
|
||||
if (rv) {
|
||||
CheckUnheldAndMark();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
void AssertAcquired() const;
|
||||
#endif // !DCHECK_IS_ON()
|
||||
|
||||
private:
|
||||
#if DCHECK_IS_ON()
|
||||
// Members and routines taking care of locks assertions.
|
||||
// Note that this checks for recursive locks and allows them
|
||||
// if the variable is set. This is allowed by the underlying implementation
|
||||
// on windows but not on Posix, so we're doing unneeded checks on Posix.
|
||||
// It's worth it to share the code.
|
||||
void CheckHeldAndUnmark();
|
||||
void CheckUnheldAndMark();
|
||||
|
||||
// All private data is implicitly protected by lock_.
|
||||
// Be VERY careful to only access members under that lock.
|
||||
base::PlatformThreadRef owning_thread_ref_;
|
||||
#endif // DCHECK_IS_ON()
|
||||
|
||||
// Platform specific underlying lock implementation.
|
||||
LockImpl lock_;
|
||||
};
|
||||
|
||||
///
|
||||
/// A helper class that acquires the given Lock while the AutoLock is in scope.
|
||||
///
|
||||
class AutoLock {
|
||||
public:
|
||||
struct AlreadyAcquired {};
|
||||
|
||||
explicit AutoLock(Lock& lock) : lock_(lock) { lock_.Acquire(); }
|
||||
|
||||
AutoLock(Lock& lock, const AlreadyAcquired&) : lock_(lock) {
|
||||
lock_.AssertAcquired();
|
||||
}
|
||||
|
||||
AutoLock(const AutoLock&) = delete;
|
||||
AutoLock& operator=(const AutoLock&) = delete;
|
||||
|
||||
~AutoLock() {
|
||||
lock_.AssertAcquired();
|
||||
lock_.Release();
|
||||
}
|
||||
|
||||
private:
|
||||
Lock& lock_;
|
||||
};
|
||||
|
||||
///
|
||||
/// AutoUnlock is a helper that will Release() the |lock| argument in the
|
||||
/// constructor, and re-Acquire() it in the destructor.
|
||||
///
|
||||
class AutoUnlock {
|
||||
public:
|
||||
explicit AutoUnlock(Lock& lock) : lock_(lock) {
|
||||
// We require our caller to have the lock.
|
||||
lock_.AssertAcquired();
|
||||
lock_.Release();
|
||||
}
|
||||
|
||||
AutoUnlock(const AutoUnlock&) = delete;
|
||||
AutoUnlock& operator=(const AutoUnlock&) = delete;
|
||||
|
||||
~AutoUnlock() { lock_.Acquire(); }
|
||||
|
||||
private:
|
||||
Lock& lock_;
|
||||
};
|
||||
|
||||
} // namespace cef_internal
|
||||
|
||||
// Implement classes in the cef_internal namespace and then expose them to the
|
||||
// base namespace. This avoids conflicts with the base.lib implementation when
|
||||
// linking sandbox support on Windows.
|
||||
using cef_internal::AutoLock;
|
||||
using cef_internal::AutoUnlock;
|
||||
using cef_internal::Lock;
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_LOCK_H_
|
||||
778
third/cef/include/base/cef_logging.h
Normal file
778
third/cef/include/base/cef_logging.h
Normal file
@@ -0,0 +1,778 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
///
|
||||
/// \file
|
||||
/// A bunch of macros for logging.
|
||||
///
|
||||
/// NOTE: The contents of this file are only available to applications that link
|
||||
/// against the libcef_dll_wrapper target.
|
||||
///
|
||||
/// WARNING: Logging macros should not be used in the main/browser process
|
||||
/// before calling CefInitialize or in sub-processes before calling
|
||||
/// CefExecuteProcess.
|
||||
///
|
||||
/// INSTRUCTIONS:
|
||||
///
|
||||
/// The way to log things is to stream things to LOG(<a particular severity
|
||||
/// level>). E.g.,
|
||||
///
|
||||
/// <pre>
|
||||
/// LOG(INFO) << "Found " << num_cookies << " cookies";
|
||||
/// </pre>
|
||||
///
|
||||
/// You can also do conditional logging:
|
||||
///
|
||||
/// <pre>
|
||||
/// LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
|
||||
/// </pre>
|
||||
///
|
||||
/// The CHECK(condition) macro is active in both debug and release builds and
|
||||
/// effectively performs a LOG(FATAL) which terminates the process and
|
||||
/// generates a crashdump unless a debugger is attached.
|
||||
///
|
||||
/// There are also "debug mode" logging macros like the ones above:
|
||||
///
|
||||
/// <pre>
|
||||
/// DLOG(INFO) << "Found cookies";
|
||||
///
|
||||
/// DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
|
||||
/// </pre>
|
||||
///
|
||||
/// All "debug mode" logging is compiled away to nothing for non-debug mode
|
||||
/// compiles. LOG_IF and development flags also work well together
|
||||
/// because the code can be compiled away sometimes.
|
||||
///
|
||||
/// We also have
|
||||
///
|
||||
/// <pre>
|
||||
/// LOG_ASSERT(assertion);
|
||||
/// DLOG_ASSERT(assertion);
|
||||
/// </pre>
|
||||
///
|
||||
/// which is syntactic sugar for "{,D}LOG_IF(FATAL, assert fails) << assertion;"
|
||||
///
|
||||
/// There are "verbose level" logging macros. They look like
|
||||
///
|
||||
/// <pre>
|
||||
/// VLOG(1) << "I'm printed when you run the program with --v=1 or more";
|
||||
/// VLOG(2) << "I'm printed when you run the program with --v=2 or more";
|
||||
/// </pre>
|
||||
///
|
||||
/// These always log at the INFO log level (when they log at all).
|
||||
/// The verbose logging can also be turned on module-by-module. For instance,
|
||||
/// <pre>
|
||||
/// --vmodule=profile=2,icon_loader=1,browser_*=3,*/chromeos/*=4 --v=0
|
||||
/// </pre>
|
||||
/// will cause:
|
||||
/// 1. VLOG(2) and lower messages to be printed from profile.{h,cc}
|
||||
/// 2. VLOG(1) and lower messages to be printed from icon_loader.{h,cc}
|
||||
/// 3. VLOG(3) and lower messages to be printed from files prefixed with
|
||||
/// "browser"
|
||||
/// 4. VLOG(4) and lower messages to be printed from files under a
|
||||
/// "chromeos" directory.
|
||||
/// 5. VLOG(0) and lower messages to be printed from elsewhere
|
||||
///
|
||||
/// The wildcarding functionality shown by (c) supports both '*' (match
|
||||
/// 0 or more characters) and '?' (match any single character)
|
||||
/// wildcards. Any pattern containing a forward or backward slash will
|
||||
/// be tested against the whole pathname and not just the module.
|
||||
/// E.g., "*/foo/bar/*=2" would change the logging level for all code
|
||||
/// in source files under a "foo/bar" directory.
|
||||
///
|
||||
/// There's also VLOG_IS_ON(n) "verbose level" condition macro. To be used as
|
||||
///
|
||||
/// <pre>
|
||||
/// if (VLOG_IS_ON(2)) {
|
||||
/// // do some logging preparation and logging
|
||||
/// // that can't be accomplished with just VLOG(2) << ...;
|
||||
/// }
|
||||
/// </pre>
|
||||
///
|
||||
/// There is also a VLOG_IF "verbose level" condition macro for sample
|
||||
/// cases, when some extra computation and preparation for logs is not
|
||||
/// needed.
|
||||
///
|
||||
/// <pre>
|
||||
/// VLOG_IF(1, (size > 1024))
|
||||
/// << "I'm printed when size is more than 1024 and when you run the "
|
||||
/// "program with --v=1 or more";
|
||||
/// </pre>
|
||||
///
|
||||
/// We also override the standard 'assert' to use 'DLOG_ASSERT'.
|
||||
///
|
||||
/// Lastly, there is:
|
||||
///
|
||||
/// <pre>
|
||||
/// PLOG(ERROR) << "Couldn't do foo";
|
||||
/// DPLOG(ERROR) << "Couldn't do foo";
|
||||
/// PLOG_IF(ERROR, cond) << "Couldn't do foo";
|
||||
/// DPLOG_IF(ERROR, cond) << "Couldn't do foo";
|
||||
/// PCHECK(condition) << "Couldn't do foo";
|
||||
/// DPCHECK(condition) << "Couldn't do foo";
|
||||
/// </pre>
|
||||
///
|
||||
/// which append the last system error to the message in string form (taken from
|
||||
/// GetLastError() on Windows and errno on POSIX).
|
||||
///
|
||||
/// The supported severity levels for macros that allow you to specify one
|
||||
/// are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL.
|
||||
///
|
||||
/// Very important: logging a message at the FATAL severity level causes
|
||||
/// the program to terminate (after the message is logged).
|
||||
///
|
||||
/// There is the special severity of DFATAL, which logs FATAL in debug mode,
|
||||
/// ERROR in normal mode.
|
||||
///
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_LOGGING_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_LOGGING_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/logging.h"
|
||||
#include "base/notreached.h"
|
||||
#elif defined(DCHECK)
|
||||
// Do nothing if the macros provided by this header already exist.
|
||||
// This can happen in cases where Chromium code is used directly by the
|
||||
// client application. When using Chromium code directly always include
|
||||
// the Chromium header first to avoid type conflicts.
|
||||
|
||||
// Always define the DCHECK_IS_ON macro which is used from other CEF headers.
|
||||
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
|
||||
#define DCHECK_IS_ON() false
|
||||
#else
|
||||
#define DCHECK_IS_ON() true
|
||||
#endif
|
||||
|
||||
#else // !defined(DCHECK)
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "include/base/cef_build.h"
|
||||
#include "include/internal/cef_logging_internal.h"
|
||||
|
||||
namespace cef {
|
||||
namespace logging {
|
||||
|
||||
// Gets the current log level.
|
||||
inline int GetMinLogLevel() {
|
||||
return cef_get_min_log_level();
|
||||
}
|
||||
|
||||
// Gets the current vlog level for the given file (usually taken from
|
||||
// __FILE__). Note that |N| is the size *with* the null terminator.
|
||||
template <size_t N>
|
||||
int GetVlogLevel(const char (&file)[N]) {
|
||||
return cef_get_vlog_level(file, N);
|
||||
}
|
||||
|
||||
typedef int LogSeverity;
|
||||
const LogSeverity LOG_VERBOSE = -1; // This is level 1 verbosity
|
||||
// Note: the log severities are used to index into the array of names,
|
||||
// see log_severity_names.
|
||||
const LogSeverity LOG_INFO = 0;
|
||||
const LogSeverity LOG_WARNING = 1;
|
||||
const LogSeverity LOG_ERROR = 2;
|
||||
const LogSeverity LOG_FATAL = 3;
|
||||
const LogSeverity LOG_NUM_SEVERITIES = 4;
|
||||
|
||||
// LOG_DFATAL is LOG_FATAL in debug mode, ERROR in normal mode
|
||||
#ifdef NDEBUG
|
||||
const LogSeverity LOG_DFATAL = LOG_ERROR;
|
||||
#else
|
||||
const LogSeverity LOG_DFATAL = LOG_FATAL;
|
||||
#endif
|
||||
|
||||
// A few definitions of macros that don't generate much code. These are used
|
||||
// by LOG() and LOG_IF, etc. Since these are used all over our code, it's
|
||||
// better to have compact code for these operations.
|
||||
#define COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ...) \
|
||||
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_INFO, \
|
||||
##__VA_ARGS__)
|
||||
#define COMPACT_GOOGLE_LOG_EX_WARNING(ClassName, ...) \
|
||||
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_WARNING, \
|
||||
##__VA_ARGS__)
|
||||
#define COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ...) \
|
||||
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_ERROR, \
|
||||
##__VA_ARGS__)
|
||||
#define COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ...) \
|
||||
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_FATAL, \
|
||||
##__VA_ARGS__)
|
||||
#define COMPACT_GOOGLE_LOG_EX_DFATAL(ClassName, ...) \
|
||||
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_DFATAL, \
|
||||
##__VA_ARGS__)
|
||||
|
||||
#define COMPACT_GOOGLE_LOG_INFO COMPACT_GOOGLE_LOG_EX_INFO(LogMessage)
|
||||
#define COMPACT_GOOGLE_LOG_WARNING COMPACT_GOOGLE_LOG_EX_WARNING(LogMessage)
|
||||
#define COMPACT_GOOGLE_LOG_ERROR COMPACT_GOOGLE_LOG_EX_ERROR(LogMessage)
|
||||
#define COMPACT_GOOGLE_LOG_FATAL COMPACT_GOOGLE_LOG_EX_FATAL(LogMessage)
|
||||
#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_EX_DFATAL(LogMessage)
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets
|
||||
// substituted with 0, and it expands to COMPACT_GOOGLE_LOG_0. To allow us
|
||||
// to keep using this syntax, we define this macro to do the same thing
|
||||
// as COMPACT_GOOGLE_LOG_ERROR, and also define ERROR the same way that
|
||||
// the Windows SDK does for consistency.
|
||||
#define ERROR 0
|
||||
#define COMPACT_GOOGLE_LOG_EX_0(ClassName, ...) \
|
||||
COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ##__VA_ARGS__)
|
||||
#define COMPACT_GOOGLE_LOG_0 COMPACT_GOOGLE_LOG_ERROR
|
||||
// Needed for LOG_IS_ON(ERROR).
|
||||
const LogSeverity LOG_0 = LOG_ERROR;
|
||||
#endif
|
||||
|
||||
// As special cases, we can assume that LOG_IS_ON(FATAL) always holds. Also,
|
||||
// LOG_IS_ON(DFATAL) always holds in debug mode. In particular, CHECK()s will
|
||||
// always fire if they fail.
|
||||
#define LOG_IS_ON(severity) \
|
||||
((::cef::logging::LOG_##severity) >= ::cef::logging::GetMinLogLevel())
|
||||
|
||||
// We can't do any caching tricks with VLOG_IS_ON() like the
|
||||
// google-glog version since it requires GCC extensions. This means
|
||||
// that using the v-logging functions in conjunction with --vmodule
|
||||
// may be slow.
|
||||
#define VLOG_IS_ON(verboselevel) \
|
||||
((verboselevel) <= ::cef::logging::GetVlogLevel(__FILE__))
|
||||
|
||||
// Helper macro which avoids evaluating the arguments to a stream if
|
||||
// the condition doesn't hold.
|
||||
#define LAZY_STREAM(stream, condition) \
|
||||
!(condition) ? (void)0 : ::cef::logging::LogMessageVoidify() & (stream)
|
||||
|
||||
// We use the preprocessor's merging operator, "##", so that, e.g.,
|
||||
// LOG(INFO) becomes the token COMPACT_GOOGLE_LOG_INFO. There's some funny
|
||||
// subtle difference between ostream member streaming functions (e.g.,
|
||||
// ostream::operator<<(int) and ostream non-member streaming functions
|
||||
// (e.g., ::operator<<(ostream&, string&): it turns out that it's
|
||||
// impossible to stream something like a string directly to an unnamed
|
||||
// ostream. We employ a neat hack by calling the stream() member
|
||||
// function of LogMessage which seems to avoid the problem.
|
||||
#define LOG_STREAM(severity) COMPACT_GOOGLE_LOG_##severity.stream()
|
||||
|
||||
#define LOG(severity) LAZY_STREAM(LOG_STREAM(severity), LOG_IS_ON(severity))
|
||||
#define LOG_IF(severity, condition) \
|
||||
LAZY_STREAM(LOG_STREAM(severity), LOG_IS_ON(severity) && (condition))
|
||||
|
||||
#define SYSLOG(severity) LOG(severity)
|
||||
#define SYSLOG_IF(severity, condition) LOG_IF(severity, condition)
|
||||
|
||||
// The VLOG macros log with negative verbosities.
|
||||
#define VLOG_STREAM(verbose_level) \
|
||||
cef::logging::LogMessage(__FILE__, __LINE__, -verbose_level).stream()
|
||||
|
||||
#define VLOG(verbose_level) \
|
||||
LAZY_STREAM(VLOG_STREAM(verbose_level), VLOG_IS_ON(verbose_level))
|
||||
|
||||
#define VLOG_IF(verbose_level, condition) \
|
||||
LAZY_STREAM(VLOG_STREAM(verbose_level), \
|
||||
VLOG_IS_ON(verbose_level) && (condition))
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#define VPLOG_STREAM(verbose_level) \
|
||||
cef::logging::Win32ErrorLogMessage(__FILE__, __LINE__, -verbose_level, \
|
||||
::cef::logging::GetLastSystemErrorCode()) \
|
||||
.stream()
|
||||
#elif defined(OS_POSIX)
|
||||
#define VPLOG_STREAM(verbose_level) \
|
||||
cef::logging::ErrnoLogMessage(__FILE__, __LINE__, -verbose_level, \
|
||||
::cef::logging::GetLastSystemErrorCode()) \
|
||||
.stream()
|
||||
#endif
|
||||
|
||||
#define VPLOG(verbose_level) \
|
||||
LAZY_STREAM(VPLOG_STREAM(verbose_level), VLOG_IS_ON(verbose_level))
|
||||
|
||||
#define VPLOG_IF(verbose_level, condition) \
|
||||
LAZY_STREAM(VPLOG_STREAM(verbose_level), \
|
||||
VLOG_IS_ON(verbose_level) && (condition))
|
||||
|
||||
// TODO(akalin): Add more VLOG variants, e.g. VPLOG.
|
||||
|
||||
#define LOG_ASSERT(condition) \
|
||||
LOG_IF(FATAL, !(condition)) << "Assert failed: " #condition ". "
|
||||
#define SYSLOG_ASSERT(condition) \
|
||||
SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition ". "
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#define PLOG_STREAM(severity) \
|
||||
COMPACT_GOOGLE_LOG_EX_##severity(Win32ErrorLogMessage, \
|
||||
::cef::logging::GetLastSystemErrorCode()) \
|
||||
.stream()
|
||||
#elif defined(OS_POSIX)
|
||||
#define PLOG_STREAM(severity) \
|
||||
COMPACT_GOOGLE_LOG_EX_##severity(ErrnoLogMessage, \
|
||||
::cef::logging::GetLastSystemErrorCode()) \
|
||||
.stream()
|
||||
#endif
|
||||
|
||||
#define PLOG(severity) LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity))
|
||||
|
||||
#define PLOG_IF(severity, condition) \
|
||||
LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity) && (condition))
|
||||
|
||||
// The actual stream used isn't important.
|
||||
#define EAT_STREAM_PARAMETERS \
|
||||
true ? (void)0 : ::cef::logging::LogMessageVoidify() & LOG_STREAM(FATAL)
|
||||
|
||||
// CHECK dies with a fatal error if condition is not true. It is *not*
|
||||
// controlled by NDEBUG, so the check will be executed regardless of
|
||||
// compilation mode.
|
||||
//
|
||||
// We make sure CHECK et al. always evaluates their arguments, as
|
||||
// doing CHECK(FunctionWithSideEffect()) is a common idiom.
|
||||
|
||||
#define CHECK(condition) \
|
||||
LAZY_STREAM(LOG_STREAM(FATAL), !(condition)) \
|
||||
<< "Check failed: " #condition ". "
|
||||
|
||||
#define PCHECK(condition) \
|
||||
LAZY_STREAM(PLOG_STREAM(FATAL), !(condition)) \
|
||||
<< "Check failed: " #condition ". "
|
||||
|
||||
// Helper macro for binary operators.
|
||||
// Don't use this macro directly in your code, use CHECK_EQ et al below.
|
||||
//
|
||||
// TODO(akalin): Rewrite this so that constructs like if (...)
|
||||
// CHECK_EQ(...) else { ... } work properly.
|
||||
#define CHECK_OP(name, op, val1, val2) \
|
||||
if (std::string* _result = cef::logging::Check##name##Impl( \
|
||||
(val1), (val2), #val1 " " #op " " #val2)) \
|
||||
cef::logging::LogMessage(__FILE__, __LINE__, _result).stream()
|
||||
|
||||
// Build the error message string. This is separate from the "Impl"
|
||||
// function template because it is not performance critical and so can
|
||||
// be out of line, while the "Impl" code should be inline. Caller
|
||||
// takes ownership of the returned string.
|
||||
template <class t1, class t2>
|
||||
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
|
||||
std::ostringstream ss;
|
||||
ss << names << " (" << v1 << " vs. " << v2 << ")";
|
||||
std::string* msg = new std::string(ss.str());
|
||||
return msg;
|
||||
}
|
||||
|
||||
// MSVC doesn't like complex extern templates and DLLs.
|
||||
#if !defined(COMPILER_MSVC)
|
||||
// Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated
|
||||
// in logging.cc.
|
||||
extern template std::string* MakeCheckOpString<int, int>(const int&,
|
||||
const int&,
|
||||
const char* names);
|
||||
extern template std::string* MakeCheckOpString<unsigned long, unsigned long>(
|
||||
const unsigned long&,
|
||||
const unsigned long&,
|
||||
const char* names);
|
||||
extern template std::string* MakeCheckOpString<unsigned long, unsigned int>(
|
||||
const unsigned long&,
|
||||
const unsigned int&,
|
||||
const char* names);
|
||||
extern template std::string* MakeCheckOpString<unsigned int, unsigned long>(
|
||||
const unsigned int&,
|
||||
const unsigned long&,
|
||||
const char* names);
|
||||
extern template std::string* MakeCheckOpString<std::string, std::string>(
|
||||
const std::string&,
|
||||
const std::string&,
|
||||
const char* name);
|
||||
#endif
|
||||
|
||||
// Helper functions for CHECK_OP macro.
|
||||
// The (int, int) specialization works around the issue that the compiler
|
||||
// will not instantiate the template version of the function on values of
|
||||
// unnamed enum type - see comment below.
|
||||
#define DEFINE_CHECK_OP_IMPL(name, op) \
|
||||
template <class t1, class t2> \
|
||||
inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \
|
||||
const char* names) { \
|
||||
if (v1 op v2) \
|
||||
return NULL; \
|
||||
else \
|
||||
return MakeCheckOpString(v1, v2, names); \
|
||||
} \
|
||||
inline std::string* Check##name##Impl(int v1, int v2, const char* names) { \
|
||||
if (v1 op v2) \
|
||||
return NULL; \
|
||||
else \
|
||||
return MakeCheckOpString(v1, v2, names); \
|
||||
}
|
||||
DEFINE_CHECK_OP_IMPL(EQ, ==)
|
||||
DEFINE_CHECK_OP_IMPL(NE, !=)
|
||||
DEFINE_CHECK_OP_IMPL(LE, <=)
|
||||
DEFINE_CHECK_OP_IMPL(LT, <)
|
||||
DEFINE_CHECK_OP_IMPL(GE, >=)
|
||||
DEFINE_CHECK_OP_IMPL(GT, >)
|
||||
#undef DEFINE_CHECK_OP_IMPL
|
||||
|
||||
#define CHECK_EQ(val1, val2) CHECK_OP(EQ, ==, val1, val2)
|
||||
#define CHECK_NE(val1, val2) CHECK_OP(NE, !=, val1, val2)
|
||||
#define CHECK_LE(val1, val2) CHECK_OP(LE, <=, val1, val2)
|
||||
#define CHECK_LT(val1, val2) CHECK_OP(LT, <, val1, val2)
|
||||
#define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2)
|
||||
#define CHECK_GT(val1, val2) CHECK_OP(GT, >, val1, val2)
|
||||
|
||||
#if defined(NDEBUG)
|
||||
#define ENABLE_DLOG 0
|
||||
#else
|
||||
#define ENABLE_DLOG 1
|
||||
#endif
|
||||
|
||||
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
|
||||
#define DCHECK_IS_ON() 0
|
||||
#else
|
||||
#define DCHECK_IS_ON() 1
|
||||
#endif
|
||||
|
||||
// Definitions for DLOG et al.
|
||||
|
||||
#if ENABLE_DLOG
|
||||
|
||||
#define DLOG_IS_ON(severity) LOG_IS_ON(severity)
|
||||
#define DLOG_IF(severity, condition) LOG_IF(severity, condition)
|
||||
#define DLOG_ASSERT(condition) LOG_ASSERT(condition)
|
||||
#define DPLOG_IF(severity, condition) PLOG_IF(severity, condition)
|
||||
#define DVLOG_IF(verboselevel, condition) VLOG_IF(verboselevel, condition)
|
||||
#define DVPLOG_IF(verboselevel, condition) VPLOG_IF(verboselevel, condition)
|
||||
|
||||
#else // ENABLE_DLOG
|
||||
|
||||
// If ENABLE_DLOG is off, we want to avoid emitting any references to
|
||||
// |condition| (which may reference a variable defined only if NDEBUG
|
||||
// is not defined). Contrast this with DCHECK et al., which has
|
||||
// different behavior.
|
||||
|
||||
#define DLOG_IS_ON(severity) false
|
||||
#define DLOG_IF(severity, condition) EAT_STREAM_PARAMETERS
|
||||
#define DLOG_ASSERT(condition) EAT_STREAM_PARAMETERS
|
||||
#define DPLOG_IF(severity, condition) EAT_STREAM_PARAMETERS
|
||||
#define DVLOG_IF(verboselevel, condition) EAT_STREAM_PARAMETERS
|
||||
#define DVPLOG_IF(verboselevel, condition) EAT_STREAM_PARAMETERS
|
||||
|
||||
#endif // ENABLE_DLOG
|
||||
|
||||
// DEBUG_MODE is for uses like
|
||||
// if (DEBUG_MODE) foo.CheckThatFoo();
|
||||
// instead of
|
||||
// #ifndef NDEBUG
|
||||
// foo.CheckThatFoo();
|
||||
// #endif
|
||||
//
|
||||
// We tie its state to ENABLE_DLOG.
|
||||
enum { DEBUG_MODE = ENABLE_DLOG };
|
||||
|
||||
#undef ENABLE_DLOG
|
||||
|
||||
#define DLOG(severity) LAZY_STREAM(LOG_STREAM(severity), DLOG_IS_ON(severity))
|
||||
|
||||
#define DPLOG(severity) LAZY_STREAM(PLOG_STREAM(severity), DLOG_IS_ON(severity))
|
||||
|
||||
#define DVLOG(verboselevel) DVLOG_IF(verboselevel, VLOG_IS_ON(verboselevel))
|
||||
|
||||
#define DVPLOG(verboselevel) DVPLOG_IF(verboselevel, VLOG_IS_ON(verboselevel))
|
||||
|
||||
// Definitions for DCHECK et al.
|
||||
|
||||
#if DCHECK_IS_ON()
|
||||
|
||||
#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \
|
||||
COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ##__VA_ARGS__)
|
||||
#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_FATAL
|
||||
const LogSeverity LOG_DCHECK = LOG_FATAL;
|
||||
|
||||
#else // DCHECK_IS_ON()
|
||||
|
||||
// These are just dummy values.
|
||||
#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \
|
||||
COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ##__VA_ARGS__)
|
||||
#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_INFO
|
||||
const LogSeverity LOG_DCHECK = LOG_INFO;
|
||||
|
||||
#endif // DCHECK_IS_ON()
|
||||
|
||||
// DCHECK et al. make sure to reference |condition| regardless of
|
||||
// whether DCHECKs are enabled; this is so that we don't get unused
|
||||
// variable warnings if the only use of a variable is in a DCHECK.
|
||||
// This behavior is different from DLOG_IF et al.
|
||||
|
||||
#define DCHECK(condition) \
|
||||
LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition)) \
|
||||
<< "Check failed: " #condition ". "
|
||||
|
||||
#define DPCHECK(condition) \
|
||||
LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition)) \
|
||||
<< "Check failed: " #condition ". "
|
||||
|
||||
// Helper macro for binary operators.
|
||||
// Don't use this macro directly in your code, use DCHECK_EQ et al below.
|
||||
#define DCHECK_OP(name, op, val1, val2) \
|
||||
if (DCHECK_IS_ON()) \
|
||||
if (std::string* _result = cef::logging::Check##name##Impl( \
|
||||
(val1), (val2), #val1 " " #op " " #val2)) \
|
||||
cef::logging::LogMessage(__FILE__, __LINE__, ::cef::logging::LOG_DCHECK, \
|
||||
_result) \
|
||||
.stream()
|
||||
|
||||
// Equality/Inequality checks - compare two values, and log a
|
||||
// LOG_DCHECK message including the two values when the result is not
|
||||
// as expected. The values must have operator<<(ostream, ...)
|
||||
// defined.
|
||||
//
|
||||
// You may append to the error message like so:
|
||||
// DCHECK_NE(1, 2) << ": The world must be ending!";
|
||||
//
|
||||
// We are very careful to ensure that each argument is evaluated exactly
|
||||
// once, and that anything which is legal to pass as a function argument is
|
||||
// legal here. In particular, the arguments may be temporary expressions
|
||||
// which will end up being destroyed at the end of the apparent statement,
|
||||
// for example:
|
||||
// DCHECK_EQ(string("abc")[1], 'b');
|
||||
//
|
||||
// WARNING: These may not compile correctly if one of the arguments is a pointer
|
||||
// and the other is NULL. To work around this, simply static_cast NULL to the
|
||||
// type of the desired pointer.
|
||||
|
||||
#define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2)
|
||||
#define DCHECK_NE(val1, val2) DCHECK_OP(NE, !=, val1, val2)
|
||||
#define DCHECK_LE(val1, val2) DCHECK_OP(LE, <=, val1, val2)
|
||||
#define DCHECK_LT(val1, val2) DCHECK_OP(LT, <, val1, val2)
|
||||
#define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2)
|
||||
#define DCHECK_GT(val1, val2) DCHECK_OP(GT, >, val1, val2)
|
||||
|
||||
#define NOTREACHED() DCHECK(false)
|
||||
|
||||
// Redefine the standard assert to use our nice log files
|
||||
#undef assert
|
||||
#define assert(x) DLOG_ASSERT(x)
|
||||
|
||||
// This class more or less represents a particular log message. You
|
||||
// create an instance of LogMessage and then stream stuff to it.
|
||||
// When you finish streaming to it, ~LogMessage is called and the
|
||||
// full message gets streamed to the appropriate destination.
|
||||
//
|
||||
// You shouldn't actually use LogMessage's constructor to log things,
|
||||
// though. You should use the LOG() macro (and variants thereof)
|
||||
// above.
|
||||
class LogMessage {
|
||||
public:
|
||||
// Used for LOG(severity).
|
||||
LogMessage(const char* file, int line, LogSeverity severity);
|
||||
|
||||
// Used for CHECK_EQ(), etc. Takes ownership of the given string.
|
||||
// Implied severity = LOG_FATAL.
|
||||
LogMessage(const char* file, int line, std::string* result);
|
||||
|
||||
// Used for DCHECK_EQ(), etc. Takes ownership of the given string.
|
||||
LogMessage(const char* file,
|
||||
int line,
|
||||
LogSeverity severity,
|
||||
std::string* result);
|
||||
|
||||
LogMessage(const LogMessage&) = delete;
|
||||
LogMessage& operator=(const LogMessage&) = delete;
|
||||
|
||||
~LogMessage();
|
||||
|
||||
std::ostream& stream() { return stream_; }
|
||||
|
||||
private:
|
||||
LogSeverity severity_;
|
||||
std::ostringstream stream_;
|
||||
|
||||
// The file and line information passed in to the constructor.
|
||||
const char* file_;
|
||||
const int line_;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Stores the current value of GetLastError in the constructor and restores
|
||||
// it in the destructor by calling SetLastError.
|
||||
// This is useful since the LogMessage class uses a lot of Win32 calls
|
||||
// that will lose the value of GLE and the code that called the log function
|
||||
// will have lost the thread error value when the log call returns.
|
||||
class SaveLastError {
|
||||
public:
|
||||
SaveLastError();
|
||||
~SaveLastError();
|
||||
|
||||
unsigned long get_error() const { return last_error_; }
|
||||
|
||||
protected:
|
||||
unsigned long last_error_;
|
||||
};
|
||||
|
||||
SaveLastError last_error_;
|
||||
#endif
|
||||
};
|
||||
|
||||
// A non-macro interface to the log facility; (useful
|
||||
// when the logging level is not a compile-time constant).
|
||||
inline void LogAtLevel(int const log_level, std::string const& msg) {
|
||||
LogMessage(__FILE__, __LINE__, log_level).stream() << msg;
|
||||
}
|
||||
|
||||
// This class is used to explicitly ignore values in the conditional
|
||||
// logging macros. This avoids compiler warnings like "value computed
|
||||
// is not used" and "statement has no effect".
|
||||
class LogMessageVoidify {
|
||||
public:
|
||||
LogMessageVoidify() {}
|
||||
// This has to be an operator with a precedence lower than << but
|
||||
// higher than ?:
|
||||
void operator&(std::ostream&) {}
|
||||
};
|
||||
|
||||
#if defined(OS_WIN)
|
||||
typedef unsigned long SystemErrorCode;
|
||||
#elif defined(OS_POSIX)
|
||||
typedef int SystemErrorCode;
|
||||
#endif
|
||||
|
||||
// Alias for ::GetLastError() on Windows and errno on POSIX. Avoids having to
|
||||
// pull in windows.h just for GetLastError() and DWORD.
|
||||
SystemErrorCode GetLastSystemErrorCode();
|
||||
std::string SystemErrorCodeToString(SystemErrorCode error_code);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Appends a formatted system message of the GetLastError() type.
|
||||
class Win32ErrorLogMessage {
|
||||
public:
|
||||
Win32ErrorLogMessage(const char* file,
|
||||
int line,
|
||||
LogSeverity severity,
|
||||
SystemErrorCode err);
|
||||
|
||||
Win32ErrorLogMessage(const Win32ErrorLogMessage&) = delete;
|
||||
Win32ErrorLogMessage& operator=(const Win32ErrorLogMessage&) = delete;
|
||||
|
||||
// Appends the error message before destructing the encapsulated class.
|
||||
~Win32ErrorLogMessage();
|
||||
|
||||
std::ostream& stream() { return log_message_.stream(); }
|
||||
|
||||
private:
|
||||
SystemErrorCode err_;
|
||||
LogMessage log_message_;
|
||||
};
|
||||
#elif defined(OS_POSIX)
|
||||
// Appends a formatted system message of the errno type
|
||||
class ErrnoLogMessage {
|
||||
public:
|
||||
ErrnoLogMessage(const char* file,
|
||||
int line,
|
||||
LogSeverity severity,
|
||||
SystemErrorCode err);
|
||||
|
||||
ErrnoLogMessage(const ErrnoLogMessage&) = delete;
|
||||
ErrnoLogMessage& operator=(const ErrnoLogMessage&) = delete;
|
||||
|
||||
// Appends the error message before destructing the encapsulated class.
|
||||
~ErrnoLogMessage();
|
||||
|
||||
std::ostream& stream() { return log_message_.stream(); }
|
||||
|
||||
private:
|
||||
SystemErrorCode err_;
|
||||
LogMessage log_message_;
|
||||
};
|
||||
#endif // OS_WIN
|
||||
|
||||
} // namespace logging
|
||||
} // namespace cef
|
||||
|
||||
// These functions are provided as a convenience for logging, which is where we
|
||||
// use streams (it is against Google style to use streams in other places). It
|
||||
// is designed to allow you to emit non-ASCII Unicode strings to the log file,
|
||||
// which is normally ASCII. It is relatively slow, so try not to use it for
|
||||
// common cases. Non-ASCII characters will be converted to UTF-8 by these
|
||||
// operators.
|
||||
std::ostream& operator<<(std::ostream& out, const wchar_t* wstr);
|
||||
inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) {
|
||||
return out << wstr.c_str();
|
||||
}
|
||||
|
||||
// The NOTIMPLEMENTED() macro annotates codepaths which have
|
||||
// not been implemented yet.
|
||||
//
|
||||
// The implementation of this macro is controlled by NOTIMPLEMENTED_POLICY:
|
||||
// 0 -- Do nothing (stripped by compiler)
|
||||
// 1 -- Warn at compile time
|
||||
// 2 -- Fail at compile time
|
||||
// 3 -- Fail at runtime (DCHECK)
|
||||
// 4 -- [default] LOG(ERROR) at runtime
|
||||
// 5 -- LOG(ERROR) at runtime, only once per call-site
|
||||
|
||||
#ifndef NOTIMPLEMENTED_POLICY
|
||||
#if defined(OS_ANDROID) && defined(OFFICIAL_BUILD)
|
||||
#define NOTIMPLEMENTED_POLICY 0
|
||||
#else
|
||||
// Select default policy: LOG(ERROR)
|
||||
#define NOTIMPLEMENTED_POLICY 4
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(COMPILER_GCC)
|
||||
// On Linux, with GCC, we can use __PRETTY_FUNCTION__ to get the demangled name
|
||||
// of the current function in the NOTIMPLEMENTED message.
|
||||
#define NOTIMPLEMENTED_MSG "Not implemented reached in " << __PRETTY_FUNCTION__
|
||||
#else
|
||||
#define NOTIMPLEMENTED_MSG "NOT IMPLEMENTED"
|
||||
#endif
|
||||
|
||||
#if NOTIMPLEMENTED_POLICY == 0
|
||||
#define NOTIMPLEMENTED() EAT_STREAM_PARAMETERS
|
||||
#elif NOTIMPLEMENTED_POLICY == 1
|
||||
// TODO, figure out how to generate a warning
|
||||
#define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED)
|
||||
#elif NOTIMPLEMENTED_POLICY == 2
|
||||
#define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED)
|
||||
#elif NOTIMPLEMENTED_POLICY == 3
|
||||
#define NOTIMPLEMENTED() NOTREACHED()
|
||||
#elif NOTIMPLEMENTED_POLICY == 4
|
||||
#define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG
|
||||
#elif NOTIMPLEMENTED_POLICY == 5
|
||||
#define NOTIMPLEMENTED() \
|
||||
do { \
|
||||
static bool logged_once = false; \
|
||||
LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG; \
|
||||
logged_once = true; \
|
||||
} while (0); \
|
||||
EAT_STREAM_PARAMETERS
|
||||
#endif
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_LOGGING_H_
|
||||
63
third/cef/include/base/cef_macros.h
Normal file
63
third/cef/include/base/cef_macros.h
Normal file
@@ -0,0 +1,63 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_MACROS_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_MACROS_H_
|
||||
#pragma once
|
||||
|
||||
#if !defined(USING_CHROMIUM_INCLUDES)
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
// ALL DISALLOW_xxx MACROS ARE DEPRECATED; DO NOT USE IN NEW CODE.
|
||||
// Use explicit deletions instead. For more information see
|
||||
// https://chromium.googlesource.com/chromium/src/+/lkgr/styleguide/c++/c++-dos-and-donts.md#explicitly-declare-class-copyability_movability
|
||||
|
||||
// DEPRECATED: See above. Makes a class uncopyable.
|
||||
#define DISALLOW_COPY(TypeName) TypeName(const TypeName&) = delete
|
||||
|
||||
// DEPRECATED: See above. Makes a class unassignable.
|
||||
#define DISALLOW_ASSIGN(TypeName) TypeName& operator=(const TypeName&) = delete
|
||||
|
||||
// DEPRECATED: See above. Makes a class uncopyable and unassignable.
|
||||
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||
DISALLOW_COPY(TypeName); \
|
||||
DISALLOW_ASSIGN(TypeName)
|
||||
|
||||
// DEPRECATED: See above. Disallow all implicit constructors, namely the
|
||||
// default constructor, copy constructor and operator= functions.
|
||||
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
|
||||
TypeName() = delete; \
|
||||
DISALLOW_COPY_AND_ASSIGN(TypeName)
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_MACROS_H_
|
||||
111
third/cef/include/base/cef_platform_thread.h
Normal file
111
third/cef/include/base/cef_platform_thread.h
Normal file
@@ -0,0 +1,111 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// WARNING: You should *NOT* be using this class directly. PlatformThread is
|
||||
// the low-level platform-specific abstraction to the OS's threading interface.
|
||||
// You should instead be using a message-loop driven Thread, see thread.h.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_PLATFORM_THREAD_H_
|
||||
#define CEF_INCLUDE_BASE_PLATFORM_THREAD_H_
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/threading/platform_thread.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include "include/base/cef_basictypes.h"
|
||||
#include "include/base/cef_build.h"
|
||||
#include "include/internal/cef_thread_internal.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
///
|
||||
/// Used for logging. Always an integer value.
|
||||
///
|
||||
typedef cef_platform_thread_id_t PlatformThreadId;
|
||||
|
||||
///
|
||||
/// Used for thread checking and debugging.
|
||||
/// Meant to be as fast as possible.
|
||||
/// These are produced by PlatformThread::CurrentRef(), and used to later
|
||||
/// check if we are on the same thread or not by using ==. These are safe
|
||||
/// to copy between threads, but can't be copied to another process as they
|
||||
/// have no meaning there. Also, the internal identifier can be re-used
|
||||
/// after a thread dies, so a PlatformThreadRef cannot be reliably used
|
||||
/// to distinguish a new thread from an old, dead thread.
|
||||
///
|
||||
class PlatformThreadRef {
|
||||
public:
|
||||
typedef cef_platform_thread_handle_t RefType;
|
||||
|
||||
PlatformThreadRef() : id_(0) {}
|
||||
|
||||
explicit PlatformThreadRef(RefType id) : id_(id) {}
|
||||
|
||||
bool operator==(PlatformThreadRef other) const { return id_ == other.id_; }
|
||||
|
||||
bool is_null() const { return id_ == 0; }
|
||||
|
||||
private:
|
||||
RefType id_;
|
||||
};
|
||||
|
||||
///
|
||||
/// A namespace for low-level thread functions.
|
||||
/// Chromium uses a class with static methods but CEF uses an actual namespace
|
||||
/// to avoid linker problems with the sandbox libaries on Windows.
|
||||
///
|
||||
namespace PlatformThread {
|
||||
|
||||
///
|
||||
/// Gets the current thread id, which may be useful for logging purposes.
|
||||
///
|
||||
inline PlatformThreadId CurrentId() {
|
||||
return cef_get_current_platform_thread_id();
|
||||
}
|
||||
|
||||
///
|
||||
/// Gets the current thread reference, which can be used to check if
|
||||
/// we're on the right thread quickly.
|
||||
///
|
||||
inline PlatformThreadRef CurrentRef() {
|
||||
return PlatformThreadRef(cef_get_current_platform_thread_handle());
|
||||
}
|
||||
|
||||
} // namespace PlatformThread
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_PLATFORM_THREAD_H_
|
||||
60
third/cef/include/base/cef_ptr_util.h
Normal file
60
third/cef/include/base/cef_ptr_util.h
Normal file
@@ -0,0 +1,60 @@
|
||||
// Copyright (c) 2021 Marshall A. Greenblatt. Portions copyright (c) 2015
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef INCLUDE_BASE_CEF_PTR_UTIL_H_
|
||||
#define INCLUDE_BASE_CEF_PTR_UTIL_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/memory/ptr_util.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace base {
|
||||
|
||||
///
|
||||
/// Helper to transfer ownership of a raw pointer to a std::unique_ptr<T>.
|
||||
/// Note that std::unique_ptr<T> has very different semantics from
|
||||
/// std::unique_ptr<T[]>: do not use this helper for array allocations.
|
||||
///
|
||||
template <typename T>
|
||||
std::unique_ptr<T> WrapUnique(T* ptr) {
|
||||
return std::unique_ptr<T>(ptr);
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // INCLUDE_BASE_CEF_PTR_UTIL_H_
|
||||
512
third/cef/include/base/cef_ref_counted.h
Normal file
512
third/cef/include/base/cef_ref_counted.h
Normal file
@@ -0,0 +1,512 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_REF_COUNTED_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_REF_COUNTED_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/memory/ref_counted.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "include/base/cef_atomic_ref_count.h"
|
||||
#include "include/base/cef_build.h"
|
||||
#include "include/base/cef_compiler_specific.h"
|
||||
#include "include/base/cef_logging.h"
|
||||
#include "include/base/cef_scoped_refptr.h"
|
||||
#include "include/base/cef_template_util.h"
|
||||
#include "include/base/cef_thread_checker.h"
|
||||
|
||||
namespace base {
|
||||
namespace cef_subtle {
|
||||
|
||||
class RefCountedBase {
|
||||
public:
|
||||
bool HasOneRef() const { return ref_count_ == 1; }
|
||||
bool HasAtLeastOneRef() const { return ref_count_ >= 1; }
|
||||
|
||||
protected:
|
||||
explicit RefCountedBase(StartRefCountFromZeroTag) {
|
||||
#if DCHECK_IS_ON()
|
||||
thread_checker_.DetachFromThread();
|
||||
#endif
|
||||
}
|
||||
|
||||
explicit RefCountedBase(StartRefCountFromOneTag) : ref_count_(1) {
|
||||
#if DCHECK_IS_ON()
|
||||
needs_adopt_ref_ = true;
|
||||
thread_checker_.DetachFromThread();
|
||||
#endif
|
||||
}
|
||||
|
||||
RefCountedBase(const RefCountedBase&) = delete;
|
||||
RefCountedBase& operator=(const RefCountedBase&) = delete;
|
||||
|
||||
~RefCountedBase() {
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()";
|
||||
#endif
|
||||
}
|
||||
|
||||
void AddRef() const {
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(!in_dtor_);
|
||||
DCHECK(!needs_adopt_ref_)
|
||||
<< "This RefCounted object is created with non-zero reference count."
|
||||
<< " The first reference to such a object has to be made by AdoptRef or"
|
||||
<< " MakeRefCounted.";
|
||||
if (ref_count_ >= 1) {
|
||||
DCHECK(CalledOnValidThread());
|
||||
}
|
||||
#endif
|
||||
|
||||
AddRefImpl();
|
||||
}
|
||||
|
||||
// Returns true if the object should self-delete.
|
||||
bool Release() const {
|
||||
ReleaseImpl();
|
||||
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(!in_dtor_);
|
||||
if (ref_count_ == 0) {
|
||||
in_dtor_ = true;
|
||||
}
|
||||
|
||||
if (ref_count_ >= 1) {
|
||||
DCHECK(CalledOnValidThread());
|
||||
}
|
||||
if (ref_count_ == 1) {
|
||||
thread_checker_.DetachFromThread();
|
||||
}
|
||||
#endif
|
||||
|
||||
return ref_count_ == 0;
|
||||
}
|
||||
|
||||
// Returns true if it is safe to read or write the object, from a thread
|
||||
// safety standpoint. Should be DCHECK'd from the methods of RefCounted
|
||||
// classes if there is a danger of objects being shared across threads.
|
||||
//
|
||||
// This produces fewer false positives than adding a separate ThreadChecker
|
||||
// into the subclass, because it automatically detaches from the thread when
|
||||
// the reference count is 1 (and never fails if there is only one reference).
|
||||
//
|
||||
// This means unlike a separate ThreadChecker, it will permit a singly
|
||||
// referenced object to be passed between threads (not holding a reference on
|
||||
// the sending thread), but will trap if the sending thread holds onto a
|
||||
// reference, or if the object is accessed from multiple threads
|
||||
// simultaneously.
|
||||
bool IsOnValidThread() const {
|
||||
#if DCHECK_IS_ON()
|
||||
return ref_count_ <= 1 || CalledOnValidThread();
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename U>
|
||||
friend scoped_refptr<U> base::AdoptRef(U*);
|
||||
|
||||
void Adopted() const {
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(needs_adopt_ref_);
|
||||
needs_adopt_ref_ = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(ARCH_CPU_64_BITS)
|
||||
void AddRefImpl() const;
|
||||
void ReleaseImpl() const;
|
||||
#else
|
||||
void AddRefImpl() const { ++ref_count_; }
|
||||
void ReleaseImpl() const { --ref_count_; }
|
||||
#endif
|
||||
|
||||
#if DCHECK_IS_ON()
|
||||
bool CalledOnValidThread() const;
|
||||
#endif
|
||||
|
||||
mutable uint32_t ref_count_ = 0;
|
||||
static_assert(std::is_unsigned<decltype(ref_count_)>::value,
|
||||
"ref_count_ must be an unsigned type.");
|
||||
|
||||
#if DCHECK_IS_ON()
|
||||
mutable bool needs_adopt_ref_ = false;
|
||||
mutable bool in_dtor_ = false;
|
||||
mutable ThreadChecker thread_checker_;
|
||||
#endif
|
||||
};
|
||||
|
||||
class RefCountedThreadSafeBase {
|
||||
public:
|
||||
bool HasOneRef() const;
|
||||
bool HasAtLeastOneRef() const;
|
||||
|
||||
protected:
|
||||
explicit constexpr RefCountedThreadSafeBase(StartRefCountFromZeroTag) {}
|
||||
explicit constexpr RefCountedThreadSafeBase(StartRefCountFromOneTag)
|
||||
: ref_count_(1) {
|
||||
#if DCHECK_IS_ON()
|
||||
needs_adopt_ref_ = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
RefCountedThreadSafeBase(const RefCountedThreadSafeBase&) = delete;
|
||||
RefCountedThreadSafeBase& operator=(const RefCountedThreadSafeBase&) = delete;
|
||||
|
||||
#if DCHECK_IS_ON()
|
||||
~RefCountedThreadSafeBase();
|
||||
#else
|
||||
~RefCountedThreadSafeBase() = default;
|
||||
#endif
|
||||
|
||||
// Release and AddRef are suitable for inlining on X86 because they generate
|
||||
// very small code threads. On other platforms (ARM), it causes a size
|
||||
// regression and is probably not worth it.
|
||||
#if defined(ARCH_CPU_X86_FAMILY)
|
||||
// Returns true if the object should self-delete.
|
||||
bool Release() const { return ReleaseImpl(); }
|
||||
void AddRef() const { AddRefImpl(); }
|
||||
void AddRefWithCheck() const { AddRefWithCheckImpl(); }
|
||||
#else
|
||||
// Returns true if the object should self-delete.
|
||||
bool Release() const;
|
||||
void AddRef() const;
|
||||
void AddRefWithCheck() const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
template <typename U>
|
||||
friend scoped_refptr<U> base::AdoptRef(U*);
|
||||
|
||||
void Adopted() const {
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(needs_adopt_ref_);
|
||||
needs_adopt_ref_ = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void AddRefImpl() const {
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(!in_dtor_);
|
||||
DCHECK(!needs_adopt_ref_)
|
||||
<< "This RefCounted object is created with non-zero reference count."
|
||||
<< " The first reference to such a object has to be made by AdoptRef or"
|
||||
<< " MakeRefCounted.";
|
||||
#endif
|
||||
ref_count_.Increment();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void AddRefWithCheckImpl() const {
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(!in_dtor_);
|
||||
DCHECK(!needs_adopt_ref_)
|
||||
<< "This RefCounted object is created with non-zero reference count."
|
||||
<< " The first reference to such a object has to be made by AdoptRef or"
|
||||
<< " MakeRefCounted.";
|
||||
#endif
|
||||
CHECK(ref_count_.Increment() > 0);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE bool ReleaseImpl() const {
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(!in_dtor_);
|
||||
DCHECK(!ref_count_.IsZero());
|
||||
#endif
|
||||
if (!ref_count_.Decrement()) {
|
||||
#if DCHECK_IS_ON()
|
||||
in_dtor_ = true;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
mutable AtomicRefCount ref_count_{0};
|
||||
#if DCHECK_IS_ON()
|
||||
mutable bool needs_adopt_ref_ = false;
|
||||
mutable bool in_dtor_ = false;
|
||||
#endif
|
||||
};
|
||||
|
||||
// ScopedAllowCrossThreadRefCountAccess disables the check documented on
|
||||
// RefCounted below for rare pre-existing use cases where thread-safety was
|
||||
// guaranteed through other means (e.g. explicit sequencing of calls across
|
||||
// execution threads when bouncing between threads in order). New callers
|
||||
// should refrain from using this (callsites handling thread-safety through
|
||||
// locks should use RefCountedThreadSafe per the overhead of its atomics being
|
||||
// negligible compared to locks anyways and callsites doing explicit sequencing
|
||||
// should properly std::move() the ref to avoid hitting this check).
|
||||
// TODO(tzik): Cleanup existing use cases and remove
|
||||
// ScopedAllowCrossThreadRefCountAccess.
|
||||
class ScopedAllowCrossThreadRefCountAccess final {
|
||||
public:
|
||||
#if DCHECK_IS_ON()
|
||||
ScopedAllowCrossThreadRefCountAccess();
|
||||
~ScopedAllowCrossThreadRefCountAccess();
|
||||
#else
|
||||
ScopedAllowCrossThreadRefCountAccess() {}
|
||||
~ScopedAllowCrossThreadRefCountAccess() {}
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace cef_subtle
|
||||
|
||||
using ScopedAllowCrossThreadRefCountAccess =
|
||||
cef_subtle::ScopedAllowCrossThreadRefCountAccess;
|
||||
|
||||
///
|
||||
/// The reference count starts from zero by default, and we intended to migrate
|
||||
/// to start-from-one ref count. Put REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE() to
|
||||
/// the ref counted class to opt-in.
|
||||
///
|
||||
/// If an object has start-from-one ref count, the first scoped_refptr need to
|
||||
/// be created by base::AdoptRef() or base::MakeRefCounted(). We can use
|
||||
/// base::MakeRefCounted() to create create both type of ref counted object.
|
||||
///
|
||||
/// The motivations to use start-from-one ref count are:
|
||||
/// - Start-from-one ref count doesn't need the ref count increment for the
|
||||
/// first reference.
|
||||
/// - It can detect an invalid object acquisition for a being-deleted object
|
||||
/// that has zero ref count. That tends to happen on custom deleter that
|
||||
/// delays the deletion.
|
||||
/// TODO(tzik): Implement invalid acquisition detection.
|
||||
/// - Behavior parity to Blink's WTF::RefCounted, whose count starts from one.
|
||||
/// And start-from-one ref count is a step to merge WTF::RefCounted into
|
||||
/// base::RefCounted.
|
||||
///
|
||||
#define REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE() \
|
||||
static constexpr ::base::cef_subtle::StartRefCountFromOneTag \
|
||||
kRefCountPreference = ::base::cef_subtle::kStartRefCountFromOneTag
|
||||
|
||||
template <class T, typename Traits>
|
||||
class RefCounted;
|
||||
|
||||
///
|
||||
/// Default traits for RefCounted<T>. Deletes the object when its ref count
|
||||
/// reaches 0. Overload to delete it on a different thread etc.
|
||||
///
|
||||
template <typename T>
|
||||
struct DefaultRefCountedTraits {
|
||||
static void Destruct(const T* x) {
|
||||
RefCounted<T, DefaultRefCountedTraits>::DeleteInternal(x);
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
/// A base class for reference counted classes. Otherwise, known as a cheap
|
||||
/// knock-off of WebKit's RefCounted<T> class. To use this, just extend your
|
||||
/// class from it like so:
|
||||
///
|
||||
/// <pre>
|
||||
/// class MyFoo : public base::RefCounted<MyFoo> {
|
||||
/// ...
|
||||
/// private:
|
||||
/// friend class base::RefCounted<MyFoo>;
|
||||
/// ~MyFoo();
|
||||
/// };
|
||||
/// </pre>
|
||||
///
|
||||
/// Usage Notes:
|
||||
/// 1. You should always make your destructor non-public, to avoid any code
|
||||
/// deleting the object accidentally while there are references to it.
|
||||
/// 2. You should always make the ref-counted base class a friend of your class,
|
||||
/// so that it can access the destructor.
|
||||
///
|
||||
/// The ref count manipulation to RefCounted is NOT thread safe and has DCHECKs
|
||||
/// to trap unsafe cross thread usage. A subclass instance of RefCounted can be
|
||||
/// passed to another execution thread only when its ref count is 1. If the ref
|
||||
/// count is more than 1, the RefCounted class verifies the ref updates are made
|
||||
/// on the same execution thread as the previous ones. The subclass can also
|
||||
/// manually call IsOnValidThread to trap other non-thread-safe accesses; see
|
||||
/// the documentation for that method.
|
||||
///
|
||||
template <class T, typename Traits = DefaultRefCountedTraits<T>>
|
||||
class RefCounted : public cef_subtle::RefCountedBase {
|
||||
public:
|
||||
static constexpr cef_subtle::StartRefCountFromZeroTag kRefCountPreference =
|
||||
cef_subtle::kStartRefCountFromZeroTag;
|
||||
|
||||
RefCounted() : cef_subtle::RefCountedBase(T::kRefCountPreference) {}
|
||||
|
||||
RefCounted(const RefCounted&) = delete;
|
||||
RefCounted& operator=(const RefCounted&) = delete;
|
||||
|
||||
void AddRef() const { cef_subtle::RefCountedBase::AddRef(); }
|
||||
|
||||
void Release() const {
|
||||
if (cef_subtle::RefCountedBase::Release()) {
|
||||
// Prune the code paths which the static analyzer may take to simulate
|
||||
// object destruction. Use-after-free errors aren't possible given the
|
||||
// lifetime guarantees of the refcounting system.
|
||||
ANALYZER_SKIP_THIS_PATH();
|
||||
|
||||
Traits::Destruct(static_cast<const T*>(this));
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
~RefCounted() = default;
|
||||
|
||||
private:
|
||||
friend struct DefaultRefCountedTraits<T>;
|
||||
template <typename U>
|
||||
static void DeleteInternal(const U* x) {
|
||||
delete x;
|
||||
}
|
||||
};
|
||||
|
||||
// Forward declaration.
|
||||
template <class T, typename Traits>
|
||||
class RefCountedThreadSafe;
|
||||
|
||||
///
|
||||
/// Default traits for RefCountedThreadSafe<T>. Deletes the object when its ref
|
||||
/// count reaches 0. Overload to delete it on a different thread etc.
|
||||
///
|
||||
template <typename T>
|
||||
struct DefaultRefCountedThreadSafeTraits {
|
||||
static void Destruct(const T* x) {
|
||||
// Delete through RefCountedThreadSafe to make child classes only need to be
|
||||
// friend with RefCountedThreadSafe instead of this struct, which is an
|
||||
// implementation detail.
|
||||
RefCountedThreadSafe<T, DefaultRefCountedThreadSafeTraits>::DeleteInternal(
|
||||
x);
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
/// A thread-safe variant of RefCounted<T>
|
||||
///
|
||||
/// <pre>
|
||||
/// class MyFoo : public base::RefCountedThreadSafe<MyFoo> {
|
||||
/// ...
|
||||
/// };
|
||||
/// </pre>
|
||||
///
|
||||
/// If you're using the default trait, then you should add compile time
|
||||
/// asserts that no one else is deleting your object. i.e.
|
||||
/// <pre>
|
||||
/// private:
|
||||
/// friend class base::RefCountedThreadSafe<MyFoo>;
|
||||
/// ~MyFoo();
|
||||
/// </pre>
|
||||
///
|
||||
/// We can use REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE() with RefCountedThreadSafe
|
||||
/// too. See the comment above the RefCounted definition for details.
|
||||
///
|
||||
template <class T, typename Traits = DefaultRefCountedThreadSafeTraits<T>>
|
||||
class RefCountedThreadSafe : public cef_subtle::RefCountedThreadSafeBase {
|
||||
public:
|
||||
static constexpr cef_subtle::StartRefCountFromZeroTag kRefCountPreference =
|
||||
cef_subtle::kStartRefCountFromZeroTag;
|
||||
|
||||
explicit RefCountedThreadSafe()
|
||||
: cef_subtle::RefCountedThreadSafeBase(T::kRefCountPreference) {}
|
||||
|
||||
RefCountedThreadSafe(const RefCountedThreadSafe&) = delete;
|
||||
RefCountedThreadSafe& operator=(const RefCountedThreadSafe&) = delete;
|
||||
|
||||
void AddRef() const { AddRefImpl(T::kRefCountPreference); }
|
||||
|
||||
void Release() const {
|
||||
if (cef_subtle::RefCountedThreadSafeBase::Release()) {
|
||||
ANALYZER_SKIP_THIS_PATH();
|
||||
Traits::Destruct(static_cast<const T*>(this));
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
~RefCountedThreadSafe() = default;
|
||||
|
||||
private:
|
||||
friend struct DefaultRefCountedThreadSafeTraits<T>;
|
||||
template <typename U>
|
||||
static void DeleteInternal(const U* x) {
|
||||
delete x;
|
||||
}
|
||||
|
||||
void AddRefImpl(cef_subtle::StartRefCountFromZeroTag) const {
|
||||
cef_subtle::RefCountedThreadSafeBase::AddRef();
|
||||
}
|
||||
|
||||
void AddRefImpl(cef_subtle::StartRefCountFromOneTag) const {
|
||||
cef_subtle::RefCountedThreadSafeBase::AddRefWithCheck();
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
/// A thread-safe wrapper for some piece of data so we can place other
|
||||
/// things in scoped_refptrs<>.
|
||||
///
|
||||
template <typename T>
|
||||
class RefCountedData
|
||||
: public base::RefCountedThreadSafe<base::RefCountedData<T>> {
|
||||
public:
|
||||
RefCountedData() : data() {}
|
||||
RefCountedData(const T& in_value) : data(in_value) {}
|
||||
RefCountedData(T&& in_value) : data(std::move(in_value)) {}
|
||||
template <typename... Args>
|
||||
explicit RefCountedData(in_place_t, Args&&... args)
|
||||
: data(std::forward<Args>(args)...) {}
|
||||
|
||||
T data;
|
||||
|
||||
private:
|
||||
friend class base::RefCountedThreadSafe<base::RefCountedData<T>>;
|
||||
~RefCountedData() = default;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
bool operator==(const RefCountedData<T>& lhs, const RefCountedData<T>& rhs) {
|
||||
return lhs.data == rhs.data;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator!=(const RefCountedData<T>& lhs, const RefCountedData<T>& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_REF_COUNTED_H_
|
||||
420
third/cef/include/base/cef_scoped_refptr.h
Normal file
420
third/cef/include/base/cef_scoped_refptr.h
Normal file
@@ -0,0 +1,420 @@
|
||||
// Copyright (c) 2017 Marshall A. Greenblatt. Portions copyright (c) 2011
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_SCOPED_REFPTR_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_SCOPED_REFPTR_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <iosfwd>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "include/base/cef_logging.h"
|
||||
|
||||
template <class T>
|
||||
class scoped_refptr;
|
||||
|
||||
namespace base {
|
||||
|
||||
template <class, typename>
|
||||
class RefCounted;
|
||||
template <class, typename>
|
||||
class RefCountedThreadSafe;
|
||||
class SequencedTaskRunner;
|
||||
class WrappedPromise;
|
||||
|
||||
template <typename T>
|
||||
scoped_refptr<T> AdoptRef(T* t);
|
||||
|
||||
namespace internal {
|
||||
|
||||
class BasePromise;
|
||||
|
||||
} // namespace internal
|
||||
|
||||
namespace cef_subtle {
|
||||
|
||||
enum AdoptRefTag { kAdoptRefTag };
|
||||
enum StartRefCountFromZeroTag { kStartRefCountFromZeroTag };
|
||||
enum StartRefCountFromOneTag { kStartRefCountFromOneTag };
|
||||
|
||||
template <typename T, typename U, typename V>
|
||||
constexpr bool IsRefCountPreferenceOverridden(const T*,
|
||||
const RefCounted<U, V>*) {
|
||||
return !std::is_same<std::decay_t<decltype(T::kRefCountPreference)>,
|
||||
std::decay_t<decltype(U::kRefCountPreference)>>::value;
|
||||
}
|
||||
|
||||
template <typename T, typename U, typename V>
|
||||
constexpr bool IsRefCountPreferenceOverridden(
|
||||
const T*,
|
||||
const RefCountedThreadSafe<U, V>*) {
|
||||
return !std::is_same<std::decay_t<decltype(T::kRefCountPreference)>,
|
||||
std::decay_t<decltype(U::kRefCountPreference)>>::value;
|
||||
}
|
||||
|
||||
constexpr bool IsRefCountPreferenceOverridden(...) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace cef_subtle
|
||||
|
||||
// Creates a scoped_refptr from a raw pointer without incrementing the reference
|
||||
// count. Use this only for a newly created object whose reference count starts
|
||||
// from 1 instead of 0.
|
||||
template <typename T>
|
||||
scoped_refptr<T> AdoptRef(T* obj) {
|
||||
using Tag = std::decay_t<decltype(T::kRefCountPreference)>;
|
||||
static_assert(std::is_same<cef_subtle::StartRefCountFromOneTag, Tag>::value,
|
||||
"Use AdoptRef only if the reference count starts from one.");
|
||||
|
||||
DCHECK(obj);
|
||||
DCHECK(obj->HasOneRef());
|
||||
obj->Adopted();
|
||||
return scoped_refptr<T>(obj, cef_subtle::kAdoptRefTag);
|
||||
}
|
||||
|
||||
namespace cef_subtle {
|
||||
|
||||
template <typename T>
|
||||
scoped_refptr<T> AdoptRefIfNeeded(T* obj, StartRefCountFromZeroTag) {
|
||||
return scoped_refptr<T>(obj);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
scoped_refptr<T> AdoptRefIfNeeded(T* obj, StartRefCountFromOneTag) {
|
||||
return AdoptRef(obj);
|
||||
}
|
||||
|
||||
} // namespace cef_subtle
|
||||
|
||||
// Constructs an instance of T, which is a ref counted type, and wraps the
|
||||
// object into a scoped_refptr<T>.
|
||||
template <typename T, typename... Args>
|
||||
scoped_refptr<T> MakeRefCounted(Args&&... args) {
|
||||
T* obj = new T(std::forward<Args>(args)...);
|
||||
return cef_subtle::AdoptRefIfNeeded(obj, T::kRefCountPreference);
|
||||
}
|
||||
|
||||
// Takes an instance of T, which is a ref counted type, and wraps the object
|
||||
// into a scoped_refptr<T>.
|
||||
template <typename T>
|
||||
scoped_refptr<T> WrapRefCounted(T* t) {
|
||||
return scoped_refptr<T>(t);
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
||||
///
|
||||
/// A smart pointer class for reference counted objects. Use this class instead
|
||||
/// of calling AddRef and Release manually on a reference counted object to
|
||||
/// avoid common memory leaks caused by forgetting to Release an object
|
||||
/// reference. Sample usage:
|
||||
///
|
||||
/// <pre>
|
||||
/// class MyFoo : public RefCounted<MyFoo> {
|
||||
/// ...
|
||||
/// private:
|
||||
/// friend class RefCounted<MyFoo>; // Allow destruction by RefCounted<>.
|
||||
/// ~MyFoo(); // Destructor must be
|
||||
/// private/protected.
|
||||
/// };
|
||||
///
|
||||
/// void some_function() {
|
||||
/// scoped_refptr<MyFoo> foo = MakeRefCounted<MyFoo>();
|
||||
/// foo->Method(param);
|
||||
/// // |foo| is released when this function returns
|
||||
/// }
|
||||
///
|
||||
/// void some_other_function() {
|
||||
/// scoped_refptr<MyFoo> foo = MakeRefCounted<MyFoo>();
|
||||
/// ...
|
||||
/// foo.reset(); // explicitly releases |foo|
|
||||
/// ...
|
||||
/// if (foo)
|
||||
/// foo->Method(param);
|
||||
/// }
|
||||
/// </pre>
|
||||
///
|
||||
/// The above examples show how scoped_refptr<T> acts like a pointer to T.
|
||||
/// Given two scoped_refptr<T> classes, it is also possible to exchange
|
||||
/// references between the two objects, like so:
|
||||
///
|
||||
/// <pre>
|
||||
/// {
|
||||
/// scoped_refptr<MyFoo> a = MakeRefCounted<MyFoo>();
|
||||
/// scoped_refptr<MyFoo> b;
|
||||
///
|
||||
/// b.swap(a);
|
||||
/// // now, |b| references the MyFoo object, and |a| references nullptr.
|
||||
/// }
|
||||
/// </pre>
|
||||
///
|
||||
/// To make both |a| and |b| in the above example reference the same MyFoo
|
||||
/// object, simply use the assignment operator:
|
||||
///
|
||||
/// <pre>
|
||||
/// {
|
||||
/// scoped_refptr<MyFoo> a = MakeRefCounted<MyFoo>();
|
||||
/// scoped_refptr<MyFoo> b;
|
||||
///
|
||||
/// b = a;
|
||||
/// // now, |a| and |b| each own a reference to the same MyFoo object.
|
||||
/// }
|
||||
/// </pre>
|
||||
///
|
||||
/// Also see Chromium's ownership and calling conventions:
|
||||
/// https://chromium.googlesource.com/chromium/src/+/lkgr/styleguide/c++/c++.md#object-ownership-and-calling-conventions
|
||||
/// Specifically:
|
||||
/// If the function (at least sometimes) takes a ref on a refcounted object,
|
||||
/// declare the param as scoped_refptr<T>. The caller can decide whether it
|
||||
/// wishes to transfer ownership (by calling std::move(t) when passing t) or
|
||||
/// retain its ref (by simply passing t directly).
|
||||
/// In other words, use scoped_refptr like you would a std::unique_ptr except
|
||||
/// in the odd case where it's required to hold on to a ref while handing one
|
||||
/// to another component (if a component merely needs to use t on the stack
|
||||
/// without keeping a ref: pass t as a raw T*).
|
||||
///
|
||||
template <class T>
|
||||
class TRIVIAL_ABI scoped_refptr {
|
||||
public:
|
||||
typedef T element_type;
|
||||
|
||||
constexpr scoped_refptr() = default;
|
||||
|
||||
// Allow implicit construction from nullptr.
|
||||
constexpr scoped_refptr(std::nullptr_t) {}
|
||||
|
||||
// Constructs from a raw pointer. Note that this constructor allows implicit
|
||||
// conversion from T* to scoped_refptr<T> which is strongly discouraged. If
|
||||
// you are creating a new ref-counted object please use
|
||||
// base::MakeRefCounted<T>() or base::WrapRefCounted<T>(). Otherwise you
|
||||
// should move or copy construct from an existing scoped_refptr<T> to the
|
||||
// ref-counted object.
|
||||
scoped_refptr(T* p) : ptr_(p) {
|
||||
if (ptr_) {
|
||||
AddRef(ptr_);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy constructor. This is required in addition to the copy conversion
|
||||
// constructor below.
|
||||
scoped_refptr(const scoped_refptr& r) : scoped_refptr(r.ptr_) {}
|
||||
|
||||
// Copy conversion constructor.
|
||||
template <typename U,
|
||||
typename = typename std::enable_if<
|
||||
std::is_convertible<U*, T*>::value>::type>
|
||||
scoped_refptr(const scoped_refptr<U>& r) : scoped_refptr(r.ptr_) {}
|
||||
|
||||
// Move constructor. This is required in addition to the move conversion
|
||||
// constructor below.
|
||||
scoped_refptr(scoped_refptr&& r) noexcept : ptr_(r.ptr_) { r.ptr_ = nullptr; }
|
||||
|
||||
// Move conversion constructor.
|
||||
template <typename U,
|
||||
typename = typename std::enable_if<
|
||||
std::is_convertible<U*, T*>::value>::type>
|
||||
scoped_refptr(scoped_refptr<U>&& r) noexcept : ptr_(r.ptr_) {
|
||||
r.ptr_ = nullptr;
|
||||
}
|
||||
|
||||
~scoped_refptr() {
|
||||
static_assert(!base::cef_subtle::IsRefCountPreferenceOverridden(
|
||||
static_cast<T*>(nullptr), static_cast<T*>(nullptr)),
|
||||
"It's unsafe to override the ref count preference."
|
||||
" Please remove REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE"
|
||||
" from subclasses.");
|
||||
if (ptr_) {
|
||||
Release(ptr_);
|
||||
}
|
||||
}
|
||||
|
||||
T* get() const { return ptr_; }
|
||||
|
||||
T& operator*() const {
|
||||
DCHECK(ptr_);
|
||||
return *ptr_;
|
||||
}
|
||||
|
||||
T* operator->() const {
|
||||
DCHECK(ptr_);
|
||||
return ptr_;
|
||||
}
|
||||
|
||||
scoped_refptr& operator=(std::nullptr_t) {
|
||||
reset();
|
||||
return *this;
|
||||
}
|
||||
|
||||
scoped_refptr& operator=(T* p) { return *this = scoped_refptr(p); }
|
||||
|
||||
// Unified assignment operator.
|
||||
scoped_refptr& operator=(scoped_refptr r) noexcept {
|
||||
swap(r);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Sets managed object to null and releases reference to the previous managed
|
||||
// object, if it existed.
|
||||
void reset() { scoped_refptr().swap(*this); }
|
||||
|
||||
// Returns the owned pointer (if any), releasing ownership to the caller. The
|
||||
// caller is responsible for managing the lifetime of the reference.
|
||||
[[nodiscard]] T* release();
|
||||
|
||||
void swap(scoped_refptr& r) noexcept { std::swap(ptr_, r.ptr_); }
|
||||
|
||||
explicit operator bool() const { return ptr_ != nullptr; }
|
||||
|
||||
template <typename U>
|
||||
bool operator==(const scoped_refptr<U>& rhs) const {
|
||||
return ptr_ == rhs.get();
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
bool operator!=(const scoped_refptr<U>& rhs) const {
|
||||
return !operator==(rhs);
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
bool operator<(const scoped_refptr<U>& rhs) const {
|
||||
return ptr_ < rhs.get();
|
||||
}
|
||||
|
||||
protected:
|
||||
T* ptr_ = nullptr;
|
||||
|
||||
private:
|
||||
template <typename U>
|
||||
friend scoped_refptr<U> base::AdoptRef(U*);
|
||||
friend class ::base::SequencedTaskRunner;
|
||||
|
||||
// Friend access so these classes can use the constructor below as part of a
|
||||
// binary size optimization.
|
||||
friend class ::base::internal::BasePromise;
|
||||
friend class ::base::WrappedPromise;
|
||||
|
||||
scoped_refptr(T* p, base::cef_subtle::AdoptRefTag) : ptr_(p) {}
|
||||
|
||||
// Friend required for move constructors that set r.ptr_ to null.
|
||||
template <typename U>
|
||||
friend class scoped_refptr;
|
||||
|
||||
// Non-inline helpers to allow:
|
||||
// class Opaque;
|
||||
// extern template class scoped_refptr<Opaque>;
|
||||
// Otherwise the compiler will complain that Opaque is an incomplete type.
|
||||
static void AddRef(T* ptr);
|
||||
static void Release(T* ptr);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
T* scoped_refptr<T>::release() {
|
||||
T* ptr = ptr_;
|
||||
ptr_ = nullptr;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
// static
|
||||
template <typename T>
|
||||
void scoped_refptr<T>::AddRef(T* ptr) {
|
||||
ptr->AddRef();
|
||||
}
|
||||
|
||||
// static
|
||||
template <typename T>
|
||||
void scoped_refptr<T>::Release(T* ptr) {
|
||||
ptr->Release();
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
bool operator==(const scoped_refptr<T>& lhs, const U* rhs) {
|
||||
return lhs.get() == rhs;
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
bool operator==(const T* lhs, const scoped_refptr<U>& rhs) {
|
||||
return lhs == rhs.get();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator==(const scoped_refptr<T>& lhs, std::nullptr_t null) {
|
||||
return !static_cast<bool>(lhs);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator==(std::nullptr_t null, const scoped_refptr<T>& rhs) {
|
||||
return !static_cast<bool>(rhs);
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
bool operator!=(const scoped_refptr<T>& lhs, const U* rhs) {
|
||||
return !operator==(lhs, rhs);
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
bool operator!=(const T* lhs, const scoped_refptr<U>& rhs) {
|
||||
return !operator==(lhs, rhs);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator!=(const scoped_refptr<T>& lhs, std::nullptr_t null) {
|
||||
return !operator==(lhs, null);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator!=(std::nullptr_t null, const scoped_refptr<T>& rhs) {
|
||||
return !operator==(null, rhs);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const scoped_refptr<T>& p) {
|
||||
return out << p.get();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void swap(scoped_refptr<T>& lhs, scoped_refptr<T>& rhs) noexcept {
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_SCOPED_REFPTR_H_
|
||||
417
third/cef/include/base/cef_template_util.h
Normal file
417
third/cef/include/base/cef_template_util.h
Normal file
@@ -0,0 +1,417 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_TEMPLATE_UTIL_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_TEMPLATE_UTIL_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/template_util.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <iosfwd>
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "include/base/cef_build.h"
|
||||
|
||||
// Some versions of libstdc++ have partial support for type_traits, but misses
|
||||
// a smaller subset while removing some of the older non-standard stuff. Assume
|
||||
// that all versions below 5.0 fall in this category, along with one 5.0
|
||||
// experimental release. Test for this by consulting compiler major version,
|
||||
// the only reliable option available, so theoretically this could fail should
|
||||
// you attempt to mix an earlier version of libstdc++ with >= GCC5. But
|
||||
// that's unlikely to work out, especially as GCC5 changed ABI.
|
||||
#define CR_GLIBCXX_5_0_0 20150123
|
||||
#if (defined(__GNUC__) && __GNUC__ < 5) || \
|
||||
(defined(__GLIBCXX__) && __GLIBCXX__ == CR_GLIBCXX_5_0_0)
|
||||
#define CR_USE_FALLBACKS_FOR_OLD_EXPERIMENTAL_GLIBCXX
|
||||
#endif
|
||||
|
||||
// This hacks around using gcc with libc++ which has some incompatibilies.
|
||||
// - is_trivially_* doesn't work: https://llvm.org/bugs/show_bug.cgi?id=27538
|
||||
// TODO(danakj): Remove this when android builders are all using a newer version
|
||||
// of gcc, or the android ndk is updated to a newer libc++ that works with older
|
||||
// gcc versions.
|
||||
#if !defined(__clang__) && defined(_LIBCPP_VERSION)
|
||||
#define CR_USE_FALLBACKS_FOR_GCC_WITH_LIBCXX
|
||||
#endif
|
||||
|
||||
namespace base {
|
||||
|
||||
template <class T>
|
||||
struct is_non_const_reference : std::false_type {};
|
||||
template <class T>
|
||||
struct is_non_const_reference<T&> : std::true_type {};
|
||||
template <class T>
|
||||
struct is_non_const_reference<const T&> : std::false_type {};
|
||||
|
||||
namespace internal {
|
||||
|
||||
// Implementation detail of base::void_t below.
|
||||
template <typename...>
|
||||
struct make_void {
|
||||
using type = void;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// base::void_t is an implementation of std::void_t from C++17.
|
||||
//
|
||||
// We use |base::internal::make_void| as a helper struct to avoid a C++14
|
||||
// defect:
|
||||
// http://en.cppreference.com/w/cpp/types/void_t
|
||||
// http://open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#1558
|
||||
template <typename... Ts>
|
||||
using void_t = typename ::base::internal::make_void<Ts...>::type;
|
||||
|
||||
namespace internal {
|
||||
|
||||
// Uses expression SFINAE to detect whether using operator<< would work.
|
||||
template <typename T, typename = void>
|
||||
struct SupportsOstreamOperator : std::false_type {};
|
||||
template <typename T>
|
||||
struct SupportsOstreamOperator<T,
|
||||
decltype(void(std::declval<std::ostream&>()
|
||||
<< std::declval<T>()))>
|
||||
: std::true_type {};
|
||||
|
||||
template <typename T, typename = void>
|
||||
struct SupportsToString : std::false_type {};
|
||||
template <typename T>
|
||||
struct SupportsToString<T, decltype(void(std::declval<T>().ToString()))>
|
||||
: std::true_type {};
|
||||
|
||||
// Used to detect whether the given type is an iterator. This is normally used
|
||||
// with std::enable_if to provide disambiguation for functions that take
|
||||
// templatzed iterators as input.
|
||||
template <typename T, typename = void>
|
||||
struct is_iterator : std::false_type {};
|
||||
|
||||
template <typename T>
|
||||
struct is_iterator<T,
|
||||
void_t<typename std::iterator_traits<T>::iterator_category>>
|
||||
: std::true_type {};
|
||||
|
||||
// Helper to express preferences in an overload set. If more than one overload
|
||||
// are available for a given set of parameters the overload with the higher
|
||||
// priority will be chosen.
|
||||
template <size_t I>
|
||||
struct priority_tag : priority_tag<I - 1> {};
|
||||
|
||||
template <>
|
||||
struct priority_tag<0> {};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// is_trivially_copyable is especially hard to get right.
|
||||
// - Older versions of libstdc++ will fail to have it like they do for other
|
||||
// type traits. This has become a subset of the second point, but used to be
|
||||
// handled independently.
|
||||
// - An experimental release of gcc includes most of type_traits but misses
|
||||
// is_trivially_copyable, so we still have to avoid using libstdc++ in this
|
||||
// case, which is covered by CR_USE_FALLBACKS_FOR_OLD_EXPERIMENTAL_GLIBCXX.
|
||||
// - When compiling libc++ from before r239653, with a gcc compiler, the
|
||||
// std::is_trivially_copyable can fail. So we need to work around that by not
|
||||
// using the one in libc++ in this case. This is covered by the
|
||||
// CR_USE_FALLBACKS_FOR_GCC_WITH_LIBCXX define, and is discussed in
|
||||
// https://llvm.org/bugs/show_bug.cgi?id=27538#c1 where they point out that
|
||||
// in libc++'s commit r239653 this is fixed by libc++ checking for gcc 5.1.
|
||||
// - In both of the above cases we are using the gcc compiler. When defining
|
||||
// this ourselves on compiler intrinsics, the __is_trivially_copyable()
|
||||
// intrinsic is not available on gcc before version 5.1 (see the discussion in
|
||||
// https://llvm.org/bugs/show_bug.cgi?id=27538#c1 again), so we must check for
|
||||
// that version.
|
||||
// - When __is_trivially_copyable() is not available because we are on gcc older
|
||||
// than 5.1, we need to fall back to something, so we use __has_trivial_copy()
|
||||
// instead based on what was done one-off in bit_cast() previously.
|
||||
|
||||
// TODO(crbug.com/554293): Remove this when all platforms have this in the std
|
||||
// namespace and it works with gcc as needed.
|
||||
#if defined(CR_USE_FALLBACKS_FOR_OLD_EXPERIMENTAL_GLIBCXX) || \
|
||||
defined(CR_USE_FALLBACKS_FOR_GCC_WITH_LIBCXX)
|
||||
template <typename T>
|
||||
struct is_trivially_copyable {
|
||||
// TODO(danakj): Remove this when android builders are all using a newer version
|
||||
// of gcc, or the android ndk is updated to a newer libc++ that does this for
|
||||
// us.
|
||||
#if _GNUC_VER >= 501
|
||||
static constexpr bool value = __is_trivially_copyable(T);
|
||||
#else
|
||||
static constexpr bool value =
|
||||
__has_trivial_copy(T) && __has_trivial_destructor(T);
|
||||
#endif
|
||||
};
|
||||
#else
|
||||
template <class T>
|
||||
using is_trivially_copyable = std::is_trivially_copyable<T>;
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 7
|
||||
// Workaround for g++7 and earlier family.
|
||||
// Due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80654, without this
|
||||
// Optional<std::vector<T>> where T is non-copyable causes a compile error.
|
||||
// As we know it is not trivially copy constructible, explicitly declare so.
|
||||
template <typename T>
|
||||
struct is_trivially_copy_constructible
|
||||
: std::is_trivially_copy_constructible<T> {};
|
||||
|
||||
template <typename... T>
|
||||
struct is_trivially_copy_constructible<std::vector<T...>> : std::false_type {};
|
||||
#else
|
||||
// Otherwise use std::is_trivially_copy_constructible as is.
|
||||
template <typename T>
|
||||
using is_trivially_copy_constructible = std::is_trivially_copy_constructible<T>;
|
||||
#endif
|
||||
|
||||
// base::in_place_t is an implementation of std::in_place_t from
|
||||
// C++17. A tag type used to request in-place construction in template vararg
|
||||
// constructors.
|
||||
|
||||
// Specification:
|
||||
// https://en.cppreference.com/w/cpp/utility/in_place
|
||||
struct in_place_t {};
|
||||
constexpr in_place_t in_place = {};
|
||||
|
||||
// base::in_place_type_t is an implementation of std::in_place_type_t from
|
||||
// C++17. A tag type used for in-place construction when the type to construct
|
||||
// needs to be specified, such as with base::unique_any, designed to be a
|
||||
// drop-in replacement.
|
||||
|
||||
// Specification:
|
||||
// http://en.cppreference.com/w/cpp/utility/in_place
|
||||
template <typename T>
|
||||
struct in_place_type_t {};
|
||||
|
||||
template <typename T>
|
||||
struct is_in_place_type_t {
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
|
||||
template <typename... Ts>
|
||||
struct is_in_place_type_t<in_place_type_t<Ts...>> {
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
// C++14 implementation of C++17's std::bool_constant.
|
||||
//
|
||||
// Reference: https://en.cppreference.com/w/cpp/types/integral_constant
|
||||
// Specification: https://wg21.link/meta.type.synop
|
||||
template <bool B>
|
||||
using bool_constant = std::integral_constant<bool, B>;
|
||||
|
||||
// C++14 implementation of C++17's std::conjunction.
|
||||
//
|
||||
// Reference: https://en.cppreference.com/w/cpp/types/conjunction
|
||||
// Specification: https://wg21.link/meta.logical#1.itemdecl:1
|
||||
template <typename...>
|
||||
struct conjunction : std::true_type {};
|
||||
|
||||
template <typename B1>
|
||||
struct conjunction<B1> : B1 {};
|
||||
|
||||
template <typename B1, typename... Bn>
|
||||
struct conjunction<B1, Bn...>
|
||||
: std::conditional_t<static_cast<bool>(B1::value), conjunction<Bn...>, B1> {
|
||||
};
|
||||
|
||||
// C++14 implementation of C++17's std::disjunction.
|
||||
//
|
||||
// Reference: https://en.cppreference.com/w/cpp/types/disjunction
|
||||
// Specification: https://wg21.link/meta.logical#itemdecl:2
|
||||
template <typename...>
|
||||
struct disjunction : std::false_type {};
|
||||
|
||||
template <typename B1>
|
||||
struct disjunction<B1> : B1 {};
|
||||
|
||||
template <typename B1, typename... Bn>
|
||||
struct disjunction<B1, Bn...>
|
||||
: std::conditional_t<static_cast<bool>(B1::value), B1, disjunction<Bn...>> {
|
||||
};
|
||||
|
||||
// C++14 implementation of C++17's std::negation.
|
||||
//
|
||||
// Reference: https://en.cppreference.com/w/cpp/types/negation
|
||||
// Specification: https://wg21.link/meta.logical#itemdecl:3
|
||||
template <typename B>
|
||||
struct negation : bool_constant<!static_cast<bool>(B::value)> {};
|
||||
|
||||
// Implementation of C++17's invoke_result.
|
||||
//
|
||||
// This implementation adds references to `Functor` and `Args` to work around
|
||||
// some quirks of std::result_of. See the #Notes section of [1] for details.
|
||||
//
|
||||
// References:
|
||||
// [1] https://en.cppreference.com/w/cpp/types/result_of
|
||||
// [2] https://wg21.link/meta.trans.other#lib:invoke_result
|
||||
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
|
||||
template <typename Functor, typename... Args>
|
||||
using invoke_result = std::invoke_result<Functor, Args...>;
|
||||
#else
|
||||
template <typename Functor, typename... Args>
|
||||
using invoke_result = std::result_of<Functor && (Args && ...)>;
|
||||
#endif
|
||||
|
||||
// Implementation of C++17's std::invoke_result_t.
|
||||
//
|
||||
// Reference: https://wg21.link/meta.type.synop#lib:invoke_result_t
|
||||
template <typename Functor, typename... Args>
|
||||
using invoke_result_t = typename invoke_result<Functor, Args...>::type;
|
||||
|
||||
namespace internal {
|
||||
|
||||
// Base case, `InvokeResult` does not have a nested type member. This means `F`
|
||||
// could not be invoked with `Args...` and thus is not invocable.
|
||||
template <typename InvokeResult, typename R, typename = void>
|
||||
struct IsInvocableImpl : std::false_type {};
|
||||
|
||||
// Happy case, `InvokeResult` does have a nested type member. Now check whether
|
||||
// `InvokeResult::type` is convertible to `R`. Short circuit in case
|
||||
// `std::is_void<R>`.
|
||||
template <typename InvokeResult, typename R>
|
||||
struct IsInvocableImpl<InvokeResult, R, void_t<typename InvokeResult::type>>
|
||||
: disjunction<std::is_void<R>,
|
||||
std::is_convertible<typename InvokeResult::type, R>> {};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// Implementation of C++17's std::is_invocable_r.
|
||||
//
|
||||
// Returns whether `F` can be invoked with `Args...` and the result is
|
||||
// convertible to `R`.
|
||||
//
|
||||
// Reference: https://wg21.link/meta.rel#lib:is_invocable_r
|
||||
template <typename R, typename F, typename... Args>
|
||||
struct is_invocable_r
|
||||
: internal::IsInvocableImpl<invoke_result<F, Args...>, R> {};
|
||||
|
||||
// Implementation of C++17's std::is_invocable.
|
||||
//
|
||||
// Returns whether `F` can be invoked with `Args...`.
|
||||
//
|
||||
// Reference: https://wg21.link/meta.rel#lib:is_invocable
|
||||
template <typename F, typename... Args>
|
||||
struct is_invocable : is_invocable_r<void, F, Args...> {};
|
||||
|
||||
namespace internal {
|
||||
|
||||
// The indirection with std::is_enum<T> is required, because instantiating
|
||||
// std::underlying_type_t<T> when T is not an enum is UB prior to C++20.
|
||||
template <typename T, bool = std::is_enum<T>::value>
|
||||
struct IsScopedEnumImpl : std::false_type {};
|
||||
|
||||
template <typename T>
|
||||
struct IsScopedEnumImpl<T, /*std::is_enum<T>::value=*/true>
|
||||
: negation<std::is_convertible<T, std::underlying_type_t<T>>> {};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// Implementation of C++23's std::is_scoped_enum
|
||||
//
|
||||
// Reference: https://en.cppreference.com/w/cpp/types/is_scoped_enum
|
||||
template <typename T>
|
||||
struct is_scoped_enum : internal::IsScopedEnumImpl<T> {};
|
||||
|
||||
// Implementation of C++20's std::remove_cvref.
|
||||
//
|
||||
// References:
|
||||
// - https://en.cppreference.com/w/cpp/types/remove_cvref
|
||||
// - https://wg21.link/meta.trans.other#lib:remove_cvref
|
||||
template <typename T>
|
||||
struct remove_cvref {
|
||||
using type = std::remove_cv_t<std::remove_reference_t<T>>;
|
||||
};
|
||||
|
||||
// Implementation of C++20's std::remove_cvref_t.
|
||||
//
|
||||
// References:
|
||||
// - https://en.cppreference.com/w/cpp/types/remove_cvref
|
||||
// - https://wg21.link/meta.type.synop#lib:remove_cvref_t
|
||||
template <typename T>
|
||||
using remove_cvref_t = typename remove_cvref<T>::type;
|
||||
|
||||
// Simplified implementation of C++20's std::iter_value_t.
|
||||
// As opposed to std::iter_value_t, this implementation does not restrict
|
||||
// the type of `Iter` and does not consider specializations of
|
||||
// `indirectly_readable_traits`.
|
||||
//
|
||||
// Reference: https://wg21.link/readable.traits#2
|
||||
template <typename Iter>
|
||||
using iter_value_t =
|
||||
typename std::iterator_traits<remove_cvref_t<Iter>>::value_type;
|
||||
|
||||
// Simplified implementation of C++20's std::iter_reference_t.
|
||||
// As opposed to std::iter_reference_t, this implementation does not restrict
|
||||
// the type of `Iter`.
|
||||
//
|
||||
// Reference: https://wg21.link/iterator.synopsis#:~:text=iter_reference_t
|
||||
template <typename Iter>
|
||||
using iter_reference_t = decltype(*std::declval<Iter&>());
|
||||
|
||||
// Simplified implementation of C++20's std::indirect_result_t. As opposed to
|
||||
// std::indirect_result_t, this implementation does not restrict the type of
|
||||
// `Func` and `Iters`.
|
||||
//
|
||||
// Reference: https://wg21.link/iterator.synopsis#:~:text=indirect_result_t
|
||||
template <typename Func, typename... Iters>
|
||||
using indirect_result_t = invoke_result_t<Func, iter_reference_t<Iters>...>;
|
||||
|
||||
// Simplified implementation of C++20's std::projected. As opposed to
|
||||
// std::projected, this implementation does not explicitly restrict the type of
|
||||
// `Iter` and `Proj`, but rather does so implicitly by requiring
|
||||
// `indirect_result_t<Proj, Iter>` is a valid type. This is required for SFINAE
|
||||
// friendliness.
|
||||
//
|
||||
// Reference: https://wg21.link/projected
|
||||
template <typename Iter,
|
||||
typename Proj,
|
||||
typename IndirectResultT = indirect_result_t<Proj, Iter>>
|
||||
struct projected {
|
||||
using value_type = remove_cvref_t<IndirectResultT>;
|
||||
|
||||
IndirectResultT operator*() const; // not defined
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
|
||||
#undef CR_USE_FALLBACKS_FOR_GCC_WITH_LIBCXX
|
||||
#undef CR_USE_FALLBACKS_FOR_OLD_EXPERIMENTAL_GLIBCXX
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_TEMPLATE_UTIL_H_
|
||||
125
third/cef/include/base/cef_thread_checker.h
Normal file
125
third/cef/include/base/cef_thread_checker.h
Normal file
@@ -0,0 +1,125 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_THREAD_CHECKER_H_
|
||||
#define CEF_INCLUDE_BASE_THREAD_CHECKER_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/threading/thread_checker.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include "include/base/cef_logging.h"
|
||||
#include "include/base/internal/cef_thread_checker_impl.h"
|
||||
|
||||
///
|
||||
/// Apart from debug builds, we also enable the thread checker in
|
||||
/// builds with DCHECK_ALWAYS_ON so that trybots and waterfall bots
|
||||
/// with this define will get the same level of thread checking as
|
||||
/// debug bots.
|
||||
///
|
||||
#if DCHECK_IS_ON()
|
||||
#define ENABLE_THREAD_CHECKER 1
|
||||
#else
|
||||
#define ENABLE_THREAD_CHECKER 0
|
||||
#endif
|
||||
|
||||
namespace base {
|
||||
|
||||
namespace cef_internal {
|
||||
|
||||
///
|
||||
/// Do nothing implementation, for use in release mode.
|
||||
///
|
||||
/// Note: You should almost always use the ThreadChecker class to get the
|
||||
/// right version for your build configuration.
|
||||
///
|
||||
class ThreadCheckerDoNothing {
|
||||
public:
|
||||
bool CalledOnValidThread() const { return true; }
|
||||
|
||||
void DetachFromThread() {}
|
||||
};
|
||||
|
||||
} // namespace cef_internal
|
||||
|
||||
///
|
||||
/// ThreadChecker is a helper class used to help verify that some methods of a
|
||||
/// class are called from the same thread. It provides identical functionality
|
||||
/// to base::NonThreadSafe, but it is meant to be held as a member variable,
|
||||
/// rather than inherited from base::NonThreadSafe.
|
||||
///
|
||||
/// While inheriting from base::NonThreadSafe may give a clear indication about
|
||||
/// the thread-safety of a class, it may also lead to violations of the style
|
||||
/// guide with regard to multiple inheritance. The choice between having a
|
||||
/// ThreadChecker member and inheriting from base::NonThreadSafe should be based
|
||||
/// on whether:
|
||||
/// - Derived classes need to know the thread they belong to, as opposed to
|
||||
/// having that functionality fully encapsulated in the base class.
|
||||
/// - Derived classes should be able to reassign the base class to another
|
||||
/// thread, via DetachFromThread.
|
||||
///
|
||||
/// If neither of these are true, then having a ThreadChecker member and calling
|
||||
/// CalledOnValidThread is the preferable solution.
|
||||
///
|
||||
/// Example:
|
||||
///
|
||||
/// <pre>
|
||||
/// class MyClass {
|
||||
/// public:
|
||||
/// void Foo() {
|
||||
/// DCHECK(thread_checker_.CalledOnValidThread());
|
||||
/// ... (do stuff) ...
|
||||
/// }
|
||||
///
|
||||
/// private:
|
||||
/// ThreadChecker thread_checker_;
|
||||
/// }
|
||||
/// </pre>
|
||||
///
|
||||
/// In Release mode, CalledOnValidThread will always return true.
|
||||
///
|
||||
#if ENABLE_THREAD_CHECKER
|
||||
class ThreadChecker : public cef_internal::ThreadCheckerImpl {};
|
||||
#else
|
||||
class ThreadChecker : public cef_internal::ThreadCheckerDoNothing {};
|
||||
#endif // ENABLE_THREAD_CHECKER
|
||||
|
||||
#undef ENABLE_THREAD_CHECKER
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_THREAD_CHECKER_H_
|
||||
463
third/cef/include/base/cef_trace_event.h
Normal file
463
third/cef/include/base/cef_trace_event.h
Normal file
@@ -0,0 +1,463 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
///
|
||||
/// \file
|
||||
/// Trace events are for tracking application performance and resource usage.
|
||||
/// Macros are provided to track:
|
||||
/// Begin and end of function calls
|
||||
/// Counters
|
||||
///
|
||||
/// Events are issued against categories. Whereas LOG's categories are
|
||||
/// statically defined, TRACE categories are created implicitly with a string.
|
||||
/// For example: <pre>
|
||||
/// TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent")
|
||||
/// </pre>
|
||||
///
|
||||
/// Events can be INSTANT, or can be pairs of BEGIN and END in the same scope:
|
||||
/// <pre>
|
||||
/// TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly")
|
||||
/// doSomethingCostly()
|
||||
/// TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly")
|
||||
/// </pre>
|
||||
/// Note: Our tools can't always determine the correct BEGIN/END pairs unless
|
||||
/// these are used in the same scope. Use ASYNC_BEGIN/ASYNC_END macros if you
|
||||
/// need them to be in separate scopes.
|
||||
///
|
||||
/// A common use case is to trace entire function scopes. This issues a trace
|
||||
/// BEGIN and END automatically:
|
||||
/// <pre>
|
||||
/// void doSomethingCostly() {
|
||||
/// TRACE_EVENT0("MY_SUBSYSTEM", "doSomethingCostly");
|
||||
/// ...
|
||||
/// }
|
||||
/// </pre>
|
||||
///
|
||||
/// Additional parameters can be associated with an event:
|
||||
/// <pre>
|
||||
/// void doSomethingCostly2(int howMuch) {
|
||||
/// TRACE_EVENT1("MY_SUBSYSTEM", "doSomethingCostly",
|
||||
/// "howMuch", howMuch);
|
||||
/// ...
|
||||
/// }
|
||||
/// </pre>
|
||||
///
|
||||
/// The trace system will automatically add to this information the current
|
||||
/// process id, thread id, and a timestamp in microseconds.
|
||||
///
|
||||
/// To trace an asynchronous procedure such as an IPC send/receive, use
|
||||
/// ASYNC_BEGIN and ASYNC_END:
|
||||
/// <pre>
|
||||
/// [single threaded sender code]
|
||||
/// static int send_count = 0;
|
||||
/// ++send_count;
|
||||
/// TRACE_EVENT_ASYNC_BEGIN0("ipc", "message", send_count);
|
||||
/// Send(new MyMessage(send_count));
|
||||
/// [receive code]
|
||||
/// void OnMyMessage(send_count) {
|
||||
/// TRACE_EVENT_ASYNC_END0("ipc", "message", send_count);
|
||||
/// }
|
||||
/// </pre>
|
||||
/// The third parameter is a unique ID to match ASYNC_BEGIN/ASYNC_END pairs.
|
||||
/// ASYNC_BEGIN and ASYNC_END can occur on any thread of any traced process.
|
||||
/// Pointers can be used for the ID parameter, and they will be mangled
|
||||
/// internally so that the same pointer on two different processes will not
|
||||
/// match. For example:
|
||||
/// <pre>
|
||||
/// class MyTracedClass {
|
||||
/// public:
|
||||
/// MyTracedClass() {
|
||||
/// TRACE_EVENT_ASYNC_BEGIN0("category", "MyTracedClass", this);
|
||||
/// }
|
||||
/// ~MyTracedClass() {
|
||||
/// TRACE_EVENT_ASYNC_END0("category", "MyTracedClass", this);
|
||||
/// }
|
||||
/// }
|
||||
/// </pre>
|
||||
///
|
||||
/// The trace event also supports counters, which is a way to track a quantity
|
||||
/// as it varies over time. Counters are created with the following macro:
|
||||
/// <pre>
|
||||
/// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter", g_myCounterValue);
|
||||
/// </pre>
|
||||
///
|
||||
/// Counters are process-specific. The macro itself can be issued from any
|
||||
/// thread, however.
|
||||
///
|
||||
/// Sometimes, you want to track two counters at once. You can do this with two
|
||||
/// counter macros:
|
||||
/// <pre>
|
||||
/// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter0", g_myCounterValue[0]);
|
||||
/// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter1", g_myCounterValue[1]);
|
||||
/// </pre>
|
||||
/// Or you can do it with a combined macro:
|
||||
/// <pre>
|
||||
/// TRACE_COUNTER2("MY_SUBSYSTEM", "myCounter",
|
||||
/// "bytesPinned", g_myCounterValue[0],
|
||||
/// "bytesAllocated", g_myCounterValue[1]);
|
||||
/// </pre>
|
||||
/// This indicates to the tracing UI that these counters should be displayed
|
||||
/// in a single graph, as a summed area chart.
|
||||
///
|
||||
/// Since counters are in a global namespace, you may want to disembiguate with
|
||||
/// a unique ID, by using the TRACE_COUNTER_ID* variations.
|
||||
///
|
||||
/// By default, trace collection is compiled in, but turned off at runtime.
|
||||
/// Collecting trace data is the responsibility of the embedding application. In
|
||||
/// CEF's case, calling BeginTracing will turn on tracing on all active
|
||||
/// processes.
|
||||
///
|
||||
///
|
||||
/// Memory scoping note:
|
||||
/// Tracing copies the pointers, not the string content, of the strings passed
|
||||
/// in for category, name, and arg_names. Thus, the following code will cause
|
||||
/// problems:
|
||||
/// <pre>
|
||||
/// char* str = strdup("impprtantName");
|
||||
/// TRACE_EVENT_INSTANT0("SUBSYSTEM", str); // BAD!
|
||||
/// free(str); // Trace system now has dangling pointer
|
||||
/// </pre>
|
||||
///
|
||||
/// To avoid this issue with the |name| and |arg_name| parameters, use the
|
||||
/// TRACE_EVENT_COPY_XXX overloads of the macros at additional runtime
|
||||
/// overhead.
|
||||
///
|
||||
/// Notes: The category must always be in a long-lived char* (i.e. static
|
||||
/// const). The |arg_values|, when used, are always deep copied with
|
||||
/// the _COPY macros.
|
||||
///
|
||||
///
|
||||
/// Thread Safety:
|
||||
/// All macros are thread safe and can be used from any process.
|
||||
///
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
/// When building CEF include the Chromium header directly.
|
||||
#include "base/trace_event/trace_event.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include "include/internal/cef_trace_event_internal.h"
|
||||
|
||||
///
|
||||
/// Records a pair of begin and end events called "name" for the current
|
||||
/// scope, with 0, 1 or 2 associated arguments. If the category is not
|
||||
/// enabled, then this does nothing.
|
||||
/// - category and name strings must have application lifetime (statics or
|
||||
/// literals). They may not include " chars.
|
||||
///
|
||||
#define TRACE_EVENT0(category, name) \
|
||||
cef_trace_event_begin(category, name, NULL, 0, NULL, 0, false); \
|
||||
CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name)
|
||||
#define TRACE_EVENT1(category, name, arg1_name, arg1_val) \
|
||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, false); \
|
||||
CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name)
|
||||
#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \
|
||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val, false); \
|
||||
CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name)
|
||||
|
||||
// Implementation detail: trace event macros create temporary variable names.
|
||||
// These macros give each temporary variable a unique name based on the line
|
||||
// number to prevent name collisions.
|
||||
#define CEF_INTERNAL_TRACE_EVENT_UID3(a, b) cef_trace_event_unique_##a##b
|
||||
#define CEF_INTERNAL_TRACE_EVENT_UID2(a, b) CEF_INTERNAL_TRACE_EVENT_UID3(a, b)
|
||||
#define CEF_INTERNAL_TRACE_EVENT_UID(name_prefix) \
|
||||
CEF_INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__)
|
||||
|
||||
// Implementation detail: internal macro to end end event when the scope ends.
|
||||
#define CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) \
|
||||
cef_trace_event::CefTraceEndOnScopeClose CEF_INTERNAL_TRACE_EVENT_UID( \
|
||||
profileScope)(category, name)
|
||||
|
||||
///
|
||||
/// Records a single event called "name" immediately, with 0, 1 or 2
|
||||
/// associated arguments. If the category is not enabled, then this
|
||||
/// does nothing.
|
||||
/// - category and name strings must have application lifetime (statics or
|
||||
/// literals). They may not include " chars.
|
||||
///
|
||||
#define TRACE_EVENT_INSTANT0(category, name) \
|
||||
cef_trace_event_instant(category, name, NULL, 0, NULL, 0, false)
|
||||
#define TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \
|
||||
cef_trace_event_instant(category, name, arg1_name, arg1_val, NULL, 0, false)
|
||||
#define TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val) \
|
||||
cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val, false)
|
||||
#define TRACE_EVENT_COPY_INSTANT0(category, name) \
|
||||
cef_trace_event_instant(category, name, NULL, 0, NULL, 0, true)
|
||||
#define TRACE_EVENT_COPY_INSTANT1(category, name, arg1_name, arg1_val) \
|
||||
cef_trace_event_instant(category, name, arg1_name, arg1_val, NULL, 0, true)
|
||||
#define TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val) \
|
||||
cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val, true)
|
||||
|
||||
///
|
||||
/// Records a single BEGIN event called "name" immediately, with 0, 1 or 2
|
||||
/// associated arguments. If the category is not enabled, then this
|
||||
/// does nothing.
|
||||
/// - category and name strings must have application lifetime (statics or
|
||||
/// literals). They may not include " chars.
|
||||
///
|
||||
#define TRACE_EVENT_BEGIN0(category, name) \
|
||||
cef_trace_event_begin(category, name, NULL, 0, NULL, 0, false)
|
||||
#define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \
|
||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, false)
|
||||
#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val) \
|
||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val, false)
|
||||
#define TRACE_EVENT_COPY_BEGIN0(category, name) \
|
||||
cef_trace_event_begin(category, name, NULL, 0, NULL, 0, true)
|
||||
#define TRACE_EVENT_COPY_BEGIN1(category, name, arg1_name, arg1_val) \
|
||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, true)
|
||||
#define TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val) \
|
||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val, true)
|
||||
|
||||
///
|
||||
/// Records a single END event for "name" immediately. If the category
|
||||
/// is not enabled, then this does nothing.
|
||||
/// - category and name strings must have application lifetime (statics or
|
||||
/// literals). They may not include " chars.
|
||||
///
|
||||
#define TRACE_EVENT_END0(category, name) \
|
||||
cef_trace_event_end(category, name, NULL, 0, NULL, 0, false)
|
||||
#define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \
|
||||
cef_trace_event_end(category, name, arg1_name, arg1_val, NULL, 0, false)
|
||||
#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val) \
|
||||
cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val, false)
|
||||
#define TRACE_EVENT_COPY_END0(category, name) \
|
||||
cef_trace_event_end(category, name, NULL, 0, NULL, 0, true)
|
||||
#define TRACE_EVENT_COPY_END1(category, name, arg1_name, arg1_val) \
|
||||
cef_trace_event_end(category, name, arg1_name, arg1_val, NULL, 0, true)
|
||||
#define TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val) \
|
||||
cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val, true)
|
||||
|
||||
///
|
||||
/// Records the value of a counter called "name" immediately. Value
|
||||
/// must be representable as a 32 bit integer.
|
||||
/// - category and name strings must have application lifetime (statics or
|
||||
/// literals). They may not include " chars.
|
||||
///
|
||||
#define TRACE_COUNTER1(category, name, value) \
|
||||
cef_trace_counter(category, name, NULL, value, NULL, 0, false)
|
||||
#define TRACE_COPY_COUNTER1(category, name, value) \
|
||||
cef_trace_counter(category, name, NULL, value, NULL, 0, true)
|
||||
|
||||
///
|
||||
/// Records the values of a multi-parted counter called "name" immediately.
|
||||
/// The UI will treat value1 and value2 as parts of a whole, displaying their
|
||||
/// values as a stacked-bar chart.
|
||||
/// - category and name strings must have application lifetime (statics or
|
||||
/// literals). They may not include " chars.
|
||||
///
|
||||
#define TRACE_COUNTER2(category, name, value1_name, value1_val, value2_name, \
|
||||
value2_val) \
|
||||
cef_trace_counter(category, name, value1_name, value1_val, value2_name, \
|
||||
value2_val, false)
|
||||
#define TRACE_COPY_COUNTER2(category, name, value1_name, value1_val, \
|
||||
value2_name, value2_val) \
|
||||
cef_trace_counter(category, name, value1_name, value1_val, value2_name, \
|
||||
value2_val, true)
|
||||
|
||||
///
|
||||
/// Records the value of a counter called "name" immediately. Value
|
||||
/// must be representable as a 32 bit integer.
|
||||
/// - category and name strings must have application lifetime (statics or
|
||||
/// literals). They may not include " chars.
|
||||
/// - |id| is used to disambiguate counters with the same name. It must either
|
||||
/// be a pointer or an integer value up to 64 bits. If it's a pointer, the
|
||||
/// bits will be xored with a hash of the process ID so that the same pointer
|
||||
/// on two different processes will not collide.
|
||||
///
|
||||
#define TRACE_COUNTER_ID1(category, name, id, value) \
|
||||
cef_trace_counter_id(category, name, id, NULL, value, NULL, 0, false)
|
||||
#define TRACE_COPY_COUNTER_ID1(category, name, id, value) \
|
||||
cef_trace_counter_id(category, name, id, NULL, value, NULL, 0, true)
|
||||
|
||||
///
|
||||
/// Records the values of a multi-parted counter called "name" immediately.
|
||||
/// The UI will treat value1 and value2 as parts of a whole, displaying their
|
||||
/// values as a stacked-bar chart.
|
||||
/// - category and name strings must have application lifetime (statics or
|
||||
/// literals). They may not include " chars.
|
||||
/// - |id| is used to disambiguate counters with the same name. It must either
|
||||
/// be a pointer or an integer value up to 64 bits. If it's a pointer, the
|
||||
/// bits will be xored with a hash of the process ID so that the same pointer
|
||||
/// on two different processes will not collide.
|
||||
///
|
||||
#define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \
|
||||
value2_name, value2_val) \
|
||||
cef_trace_counter_id(category, name, id, value1_name, value1_val, \
|
||||
value2_name, value2_val, false)
|
||||
#define TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, value1_val, \
|
||||
value2_name, value2_val) \
|
||||
cef_trace_counter_id(category, name, id, value1_name, value1_val, \
|
||||
value2_name, value2_val, true)
|
||||
|
||||
///
|
||||
/// Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2
|
||||
/// associated arguments. If the category is not enabled, then this
|
||||
/// does nothing.
|
||||
/// - category and name strings must have application lifetime (statics or
|
||||
/// literals). They may not include " chars.
|
||||
/// - |id| is used to match the ASYNC_BEGIN event with the ASYNC_END event.
|
||||
/// ASYNC events are considered to match if their category, name and id values
|
||||
/// all match. |id| must either be a pointer or an integer value up to 64
|
||||
/// bits. If it's a pointer, the bits will be xored with a hash of the process
|
||||
/// ID sothat the same pointer on two different processes will not collide.
|
||||
/// An asynchronous operation can consist of multiple phases. The first phase is
|
||||
/// defined by the ASYNC_BEGIN calls. Additional phases can be defined using the
|
||||
/// ASYNC_STEP_BEGIN macros. When the operation completes, call ASYNC_END.
|
||||
/// An async operation can span threads and processes, but all events in that
|
||||
/// operation must use the same |name| and |id|. Each event can have its own
|
||||
/// args.
|
||||
///
|
||||
#define TRACE_EVENT_ASYNC_BEGIN0(category, name, id) \
|
||||
cef_trace_event_async_begin(category, name, id, NULL, 0, NULL, 0, false)
|
||||
#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \
|
||||
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \
|
||||
0, false)
|
||||
#define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val) \
|
||||
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val, false)
|
||||
#define TRACE_EVENT_COPY_ASYNC_BEGIN0(category, name, id) \
|
||||
cef_trace_event_async_begin(category, name, id, NULL, 0, NULL, 0, true)
|
||||
#define TRACE_EVENT_COPY_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \
|
||||
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \
|
||||
0, true)
|
||||
#define TRACE_EVENT_COPY_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val) \
|
||||
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val, true)
|
||||
|
||||
///
|
||||
/// Records a single ASYNC_STEP_INTO event for |step| immediately. If the
|
||||
/// category is not enabled, then this does nothing. The |name| and |id| must
|
||||
/// match the ASYNC_BEGIN event above. The |step| param identifies this step
|
||||
/// within the async event. This should be called at the beginning of the next
|
||||
/// phase of an asynchronous operation. The ASYNC_BEGIN event must not have any
|
||||
/// ASYNC_STEP_PAST events.
|
||||
///
|
||||
#define TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step) \
|
||||
cef_trace_event_async_step_into(category, name, id, step, NULL, 0, false)
|
||||
#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \
|
||||
arg1_val) \
|
||||
cef_trace_event_async_step_into(category, name, id, step, arg1_name, \
|
||||
arg1_val, false)
|
||||
#define TRACE_EVENT_COPY_ASYNC_STEP_INTO0(category, name, id, step) \
|
||||
cef_trace_event_async_step_into(category, name, id, step, NULL, 0, true)
|
||||
#define TRACE_EVENT_COPY_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \
|
||||
arg1_val) \
|
||||
cef_trace_event_async_step_into(category, name, id, step, arg1_name, \
|
||||
arg1_val, true)
|
||||
|
||||
///
|
||||
/// Records a single ASYNC_STEP_PAST event for |step| immediately. If the
|
||||
/// category is not enabled, then this does nothing. The |name| and |id| must
|
||||
/// match the ASYNC_BEGIN event above. The |step| param identifies this step
|
||||
/// within the async event. This should be called at the beginning of the next
|
||||
/// phase of an asynchronous operation. The ASYNC_BEGIN event must not have any
|
||||
/// ASYNC_STEP_INTO events.
|
||||
///
|
||||
#define TRACE_EVENT_ASYNC_STEP_PAST0(category, name, id, step) \
|
||||
cef_trace_event_async_step_past(category, name, id, step, NULL, 0, false)
|
||||
#define TRACE_EVENT_ASYNC_STEP_PAST1(category, name, id, step, arg1_name, \
|
||||
arg1_val) \
|
||||
cef_trace_event_async_step_past(category, name, id, step, arg1_name, \
|
||||
arg1_val, false)
|
||||
#define TRACE_EVENT_COPY_ASYNC_STEP_PAST0(category, name, id, step) \
|
||||
cef_trace_event_async_step_past(category, name, id, step, NULL, 0, true)
|
||||
#define TRACE_EVENT_COPY_ASYNC_STEP_PAST1(category, name, id, step, arg1_name, \
|
||||
arg1_val) \
|
||||
cef_trace_event_async_step_past(category, name, id, step, arg1_name, \
|
||||
arg1_val, true)
|
||||
|
||||
///
|
||||
/// Records a single ASYNC_END event for "name" immediately. If the category
|
||||
/// is not enabled, then this does nothing.
|
||||
///
|
||||
#define TRACE_EVENT_ASYNC_END0(category, name, id) \
|
||||
cef_trace_event_async_end(category, name, id, NULL, 0, NULL, 0, false)
|
||||
#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \
|
||||
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, NULL, 0, \
|
||||
false)
|
||||
#define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val) \
|
||||
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val, false)
|
||||
#define TRACE_EVENT_COPY_ASYNC_END0(category, name, id) \
|
||||
cef_trace_event_async_end(category, name, id, NULL, 0, NULL, 0, true)
|
||||
#define TRACE_EVENT_COPY_ASYNC_END1(category, name, id, arg1_name, arg1_val) \
|
||||
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, NULL, 0, \
|
||||
true)
|
||||
#define TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val) \
|
||||
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val, true)
|
||||
|
||||
namespace cef_trace_event {
|
||||
|
||||
///
|
||||
/// Used by TRACE_EVENTx macro. Do not use directly.
|
||||
///
|
||||
class CefTraceEndOnScopeClose {
|
||||
public:
|
||||
CefTraceEndOnScopeClose(const char* category, const char* name)
|
||||
: category_(category), name_(name) {}
|
||||
~CefTraceEndOnScopeClose() {
|
||||
cef_trace_event_end(category_, name_, NULL, 0, NULL, 0, false);
|
||||
}
|
||||
|
||||
private:
|
||||
const char* category_;
|
||||
const char* name_;
|
||||
};
|
||||
|
||||
} // namespace cef_trace_event
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_
|
||||
152
third/cef/include/base/cef_tuple.h
Normal file
152
third/cef/include/base/cef_tuple.h
Normal file
@@ -0,0 +1,152 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
///
|
||||
/// \file
|
||||
/// Use std::tuple as tuple type. This file contains helper functions for
|
||||
/// working with std::tuples.
|
||||
/// The functions DispatchToMethod and DispatchToFunction take a function
|
||||
/// pointer or instance and method pointer, and unpack a tuple into arguments to
|
||||
/// the call.
|
||||
///
|
||||
/// Example usage:
|
||||
/// <pre>
|
||||
/// // These two methods of creating a Tuple are identical.
|
||||
/// std::tuple<int, const char*> tuple_a(1, "wee");
|
||||
/// std::tuple<int, const char*> tuple_b = std::make_tuple(1, "wee");
|
||||
///
|
||||
/// void SomeFunc(int a, const char* b) { }
|
||||
/// DispatchToFunction(&SomeFunc, tuple_a); // SomeFunc(1, "wee")
|
||||
/// DispatchToFunction(
|
||||
/// &SomeFunc, std::make_tuple(10, "foo")); // SomeFunc(10, "foo")
|
||||
///
|
||||
/// struct { void SomeMeth(int a, int b, int c) { } } foo;
|
||||
/// DispatchToMethod(&foo, &Foo::SomeMeth, std::make_tuple(1, 2, 3));
|
||||
/// // foo->SomeMeth(1, 2, 3);
|
||||
/// </pre>
|
||||
///
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_TUPLE_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_TUPLE_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/tuple.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
#include "include/base/cef_build.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
// Dispatchers ----------------------------------------------------------------
|
||||
//
|
||||
// Helper functions that call the given method on an object, with the unpacked
|
||||
// tuple arguments. Notice that they all have the same number of arguments,
|
||||
// so you need only write:
|
||||
// DispatchToMethod(object, &Object::method, args);
|
||||
// This is very useful for templated dispatchers, since they don't need to know
|
||||
// what type |args| is.
|
||||
|
||||
// Non-Static Dispatchers with no out params.
|
||||
|
||||
template <typename ObjT, typename Method, typename Tuple, size_t... Ns>
|
||||
inline void DispatchToMethodImpl(const ObjT& obj,
|
||||
Method method,
|
||||
Tuple&& args,
|
||||
std::index_sequence<Ns...>) {
|
||||
(obj->*method)(std::get<Ns>(std::forward<Tuple>(args))...);
|
||||
}
|
||||
|
||||
template <typename ObjT, typename Method, typename Tuple>
|
||||
inline void DispatchToMethod(const ObjT& obj, Method method, Tuple&& args) {
|
||||
constexpr size_t size = std::tuple_size<std::decay_t<Tuple>>::value;
|
||||
DispatchToMethodImpl(obj, method, std::forward<Tuple>(args),
|
||||
std::make_index_sequence<size>());
|
||||
}
|
||||
|
||||
// Static Dispatchers with no out params.
|
||||
|
||||
template <typename Function, typename Tuple, size_t... Ns>
|
||||
inline void DispatchToFunctionImpl(Function function,
|
||||
Tuple&& args,
|
||||
std::index_sequence<Ns...>) {
|
||||
(*function)(std::get<Ns>(std::forward<Tuple>(args))...);
|
||||
}
|
||||
|
||||
template <typename Function, typename Tuple>
|
||||
inline void DispatchToFunction(Function function, Tuple&& args) {
|
||||
constexpr size_t size = std::tuple_size<std::decay_t<Tuple>>::value;
|
||||
DispatchToFunctionImpl(function, std::forward<Tuple>(args),
|
||||
std::make_index_sequence<size>());
|
||||
}
|
||||
|
||||
// Dispatchers with out parameters.
|
||||
|
||||
template <typename ObjT,
|
||||
typename Method,
|
||||
typename InTuple,
|
||||
typename OutTuple,
|
||||
size_t... InNs,
|
||||
size_t... OutNs>
|
||||
inline void DispatchToMethodImpl(const ObjT& obj,
|
||||
Method method,
|
||||
InTuple&& in,
|
||||
OutTuple* out,
|
||||
std::index_sequence<InNs...>,
|
||||
std::index_sequence<OutNs...>) {
|
||||
(obj->*method)(std::get<InNs>(std::forward<InTuple>(in))...,
|
||||
&std::get<OutNs>(*out)...);
|
||||
}
|
||||
|
||||
template <typename ObjT, typename Method, typename InTuple, typename OutTuple>
|
||||
inline void DispatchToMethod(const ObjT& obj,
|
||||
Method method,
|
||||
InTuple&& in,
|
||||
OutTuple* out) {
|
||||
constexpr size_t in_size = std::tuple_size<std::decay_t<InTuple>>::value;
|
||||
constexpr size_t out_size = std::tuple_size<OutTuple>::value;
|
||||
DispatchToMethodImpl(obj, method, std::forward<InTuple>(in), out,
|
||||
std::make_index_sequence<in_size>(),
|
||||
std::make_index_sequence<out_size>());
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_TUPLE_H_
|
||||
469
third/cef/include/base/cef_weak_ptr.h
Normal file
469
third/cef/include/base/cef_weak_ptr.h
Normal file
@@ -0,0 +1,469 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
///
|
||||
/// \file
|
||||
/// Weak pointers are pointers to an object that do not affect its lifetime.
|
||||
/// They may be invalidated (i.e. reset to nullptr) by the object, or its
|
||||
/// owner, at any time, most commonly when the object is about to be deleted.
|
||||
///
|
||||
/// Weak pointers are useful when an object needs to be accessed safely by one
|
||||
/// or more objects other than its owner, and those callers can cope with the
|
||||
/// object vanishing and e.g. tasks posted to it being silently dropped.
|
||||
/// Reference-counting such an object would complicate the ownership graph and
|
||||
/// make it harder to reason about the object's lifetime.
|
||||
///
|
||||
/// EXAMPLE:
|
||||
///
|
||||
/// <pre>
|
||||
/// class Controller {
|
||||
/// public:
|
||||
/// void SpawnWorker() { Worker::StartNew(weak_factory_.GetWeakPtr()); }
|
||||
/// void WorkComplete(const Result& result) { ... }
|
||||
/// private:
|
||||
/// // Member variables should appear before the WeakPtrFactory, to ensure
|
||||
/// // that any WeakPtrs to Controller are invalidated before its members
|
||||
/// // variable's destructors are executed, rendering them invalid.
|
||||
/// WeakPtrFactory<Controller> weak_factory_{this};
|
||||
/// };
|
||||
///
|
||||
/// class Worker {
|
||||
/// public:
|
||||
/// static void StartNew(WeakPtr<Controller> controller) {
|
||||
/// Worker* worker = new Worker(std::move(controller));
|
||||
/// // Kick off asynchronous processing...
|
||||
/// }
|
||||
/// private:
|
||||
/// Worker(WeakPtr<Controller> controller)
|
||||
/// : controller_(std::move(controller)) {}
|
||||
/// void DidCompleteAsynchronousProcessing(const Result& result) {
|
||||
/// if (controller_)
|
||||
/// controller_->WorkComplete(result);
|
||||
/// }
|
||||
/// WeakPtr<Controller> controller_;
|
||||
/// };
|
||||
/// </pre>
|
||||
///
|
||||
/// With this implementation a caller may use SpawnWorker() to dispatch multiple
|
||||
/// Workers and subsequently delete the Controller, without waiting for all
|
||||
/// Workers to have completed.
|
||||
///
|
||||
/// <b>IMPORTANT: Thread-safety</b>
|
||||
///
|
||||
/// Weak pointers may be passed safely between threads, but must always be
|
||||
/// dereferenced and invalidated on the same ThreaddTaskRunner otherwise
|
||||
/// checking the pointer would be racey.
|
||||
///
|
||||
/// To ensure correct use, the first time a WeakPtr issued by a WeakPtrFactory
|
||||
/// is dereferenced, the factory and its WeakPtrs become bound to the calling
|
||||
/// thread or current ThreaddWorkerPool token, and cannot be dereferenced or
|
||||
/// invalidated on any other task runner. Bound WeakPtrs can still be handed
|
||||
/// off to other task runners, e.g. to use to post tasks back to object on the
|
||||
/// bound thread.
|
||||
///
|
||||
/// If all WeakPtr objects are destroyed or invalidated then the factory is
|
||||
/// unbound from the ThreadedTaskRunner/Thread. The WeakPtrFactory may then be
|
||||
/// destroyed, or new WeakPtr objects may be used, from a different thread.
|
||||
///
|
||||
/// Thus, at least one WeakPtr object must exist and have been dereferenced on
|
||||
/// the correct thread to enforce that other WeakPtr objects will enforce they
|
||||
/// are used on the desired thread.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_WEAK_PTR_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_WEAK_PTR_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
#include "include/base/cef_atomic_flag.h"
|
||||
#include "include/base/cef_logging.h"
|
||||
#include "include/base/cef_ref_counted.h"
|
||||
#include "include/base/cef_thread_checker.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
template <typename T>
|
||||
class SupportsWeakPtr;
|
||||
template <typename T>
|
||||
class WeakPtr;
|
||||
|
||||
namespace cef_internal {
|
||||
// These classes are part of the WeakPtr implementation.
|
||||
// DO NOT USE THESE CLASSES DIRECTLY YOURSELF.
|
||||
|
||||
class WeakReference {
|
||||
public:
|
||||
// Although Flag is bound to a specific ThreaddTaskRunner, it may be
|
||||
// deleted from another via base::WeakPtr::~WeakPtr().
|
||||
class Flag : public RefCountedThreadSafe<Flag> {
|
||||
public:
|
||||
Flag();
|
||||
|
||||
void Invalidate();
|
||||
bool IsValid() const;
|
||||
|
||||
bool MaybeValid() const;
|
||||
|
||||
void DetachFromThread();
|
||||
|
||||
private:
|
||||
friend class base::RefCountedThreadSafe<Flag>;
|
||||
|
||||
~Flag();
|
||||
|
||||
base::ThreadChecker thread_checker_;
|
||||
AtomicFlag invalidated_;
|
||||
};
|
||||
|
||||
WeakReference();
|
||||
explicit WeakReference(const scoped_refptr<Flag>& flag);
|
||||
~WeakReference();
|
||||
|
||||
WeakReference(WeakReference&& other) noexcept;
|
||||
WeakReference(const WeakReference& other);
|
||||
WeakReference& operator=(WeakReference&& other) noexcept = default;
|
||||
WeakReference& operator=(const WeakReference& other) = default;
|
||||
|
||||
bool IsValid() const;
|
||||
bool MaybeValid() const;
|
||||
|
||||
private:
|
||||
scoped_refptr<const Flag> flag_;
|
||||
};
|
||||
|
||||
class WeakReferenceOwner {
|
||||
public:
|
||||
WeakReferenceOwner();
|
||||
~WeakReferenceOwner();
|
||||
|
||||
WeakReference GetRef() const;
|
||||
|
||||
bool HasRefs() const { return !flag_->HasOneRef(); }
|
||||
|
||||
void Invalidate();
|
||||
|
||||
private:
|
||||
scoped_refptr<WeakReference::Flag> flag_;
|
||||
};
|
||||
|
||||
// This class simplifies the implementation of WeakPtr's type conversion
|
||||
// constructor by avoiding the need for a public accessor for ref_. A
|
||||
// WeakPtr<T> cannot access the private members of WeakPtr<U>, so this
|
||||
// base class gives us a way to access ref_ in a protected fashion.
|
||||
class WeakPtrBase {
|
||||
public:
|
||||
WeakPtrBase();
|
||||
~WeakPtrBase();
|
||||
|
||||
WeakPtrBase(const WeakPtrBase& other) = default;
|
||||
WeakPtrBase(WeakPtrBase&& other) noexcept = default;
|
||||
WeakPtrBase& operator=(const WeakPtrBase& other) = default;
|
||||
WeakPtrBase& operator=(WeakPtrBase&& other) noexcept = default;
|
||||
|
||||
void reset() {
|
||||
ref_ = cef_internal::WeakReference();
|
||||
ptr_ = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
WeakPtrBase(const WeakReference& ref, uintptr_t ptr);
|
||||
|
||||
WeakReference ref_;
|
||||
|
||||
// This pointer is only valid when ref_.is_valid() is true. Otherwise, its
|
||||
// value is undefined (as opposed to nullptr).
|
||||
uintptr_t ptr_;
|
||||
};
|
||||
|
||||
// This class provides a common implementation of common functions that would
|
||||
// otherwise get instantiated separately for each distinct instantiation of
|
||||
// SupportsWeakPtr<>.
|
||||
class SupportsWeakPtrBase {
|
||||
public:
|
||||
// A safe static downcast of a WeakPtr<Base> to WeakPtr<Derived>. This
|
||||
// conversion will only compile if there is exists a Base which inherits
|
||||
// from SupportsWeakPtr<Base>. See base::AsWeakPtr() below for a helper
|
||||
// function that makes calling this easier.
|
||||
//
|
||||
// Precondition: t != nullptr
|
||||
template <typename Derived>
|
||||
static WeakPtr<Derived> StaticAsWeakPtr(Derived* t) {
|
||||
static_assert(
|
||||
std::is_base_of<cef_internal::SupportsWeakPtrBase, Derived>::value,
|
||||
"AsWeakPtr argument must inherit from SupportsWeakPtr");
|
||||
return AsWeakPtrImpl<Derived>(t);
|
||||
}
|
||||
|
||||
private:
|
||||
// This template function uses type inference to find a Base of Derived
|
||||
// which is an instance of SupportsWeakPtr<Base>. We can then safely
|
||||
// static_cast the Base* to a Derived*.
|
||||
template <typename Derived, typename Base>
|
||||
static WeakPtr<Derived> AsWeakPtrImpl(SupportsWeakPtr<Base>* t) {
|
||||
WeakPtr<Base> ptr = t->AsWeakPtr();
|
||||
return WeakPtr<Derived>(
|
||||
ptr.ref_, static_cast<Derived*>(reinterpret_cast<Base*>(ptr.ptr_)));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace cef_internal
|
||||
|
||||
template <typename T>
|
||||
class WeakPtrFactory;
|
||||
|
||||
///
|
||||
/// The WeakPtr class holds a weak reference to |T*|.
|
||||
///
|
||||
/// This class is designed to be used like a normal pointer. You should always
|
||||
/// null-test an object of this class before using it or invoking a method that
|
||||
/// may result in the underlying object being destroyed.
|
||||
///
|
||||
/// EXAMPLE:
|
||||
///
|
||||
/// <pre>
|
||||
/// class Foo { ... };
|
||||
/// WeakPtr<Foo> foo;
|
||||
/// if (foo)
|
||||
/// foo->method();
|
||||
/// </pre>
|
||||
///
|
||||
template <typename T>
|
||||
class WeakPtr : public cef_internal::WeakPtrBase {
|
||||
public:
|
||||
WeakPtr() = default;
|
||||
WeakPtr(std::nullptr_t) {}
|
||||
|
||||
///
|
||||
/// Allow conversion from U to T provided U "is a" T. Note that this
|
||||
/// is separate from the (implicit) copy and move constructors.
|
||||
///
|
||||
template <typename U>
|
||||
WeakPtr(const WeakPtr<U>& other) : WeakPtrBase(other) {
|
||||
// Need to cast from U* to T* to do pointer adjustment in case of multiple
|
||||
// inheritance. This also enforces the "U is a T" rule.
|
||||
T* t = reinterpret_cast<U*>(other.ptr_);
|
||||
ptr_ = reinterpret_cast<uintptr_t>(t);
|
||||
}
|
||||
template <typename U>
|
||||
WeakPtr(WeakPtr<U>&& other) noexcept : WeakPtrBase(std::move(other)) {
|
||||
// Need to cast from U* to T* to do pointer adjustment in case of multiple
|
||||
// inheritance. This also enforces the "U is a T" rule.
|
||||
T* t = reinterpret_cast<U*>(other.ptr_);
|
||||
ptr_ = reinterpret_cast<uintptr_t>(t);
|
||||
}
|
||||
|
||||
T* get() const {
|
||||
return ref_.IsValid() ? reinterpret_cast<T*>(ptr_) : nullptr;
|
||||
}
|
||||
|
||||
T& operator*() const {
|
||||
CHECK(ref_.IsValid());
|
||||
return *get();
|
||||
}
|
||||
T* operator->() const {
|
||||
CHECK(ref_.IsValid());
|
||||
return get();
|
||||
}
|
||||
|
||||
///
|
||||
/// Allow conditionals to test validity, e.g. `if (weak_ptr) {...}`;
|
||||
///
|
||||
explicit operator bool() const { return get() != nullptr; }
|
||||
|
||||
///
|
||||
/// Returns false if the WeakPtr is confirmed to be invalid. This call is safe
|
||||
/// to make from any thread, e.g. to optimize away unnecessary work, but
|
||||
/// operator bool() must always be called, on the correct thread, before
|
||||
/// actually using the pointer.
|
||||
///
|
||||
/// Warning: as with any object, this call is only thread-safe if the WeakPtr
|
||||
/// instance isn't being re-assigned or reset() racily with this call.
|
||||
///
|
||||
bool MaybeValid() const { return ref_.MaybeValid(); }
|
||||
|
||||
///
|
||||
/// Returns whether the object |this| points to has been invalidated. This can
|
||||
/// be used to distinguish a WeakPtr to a destroyed object from one that has
|
||||
/// been explicitly set to null.
|
||||
///
|
||||
bool WasInvalidated() const { return ptr_ && !ref_.IsValid(); }
|
||||
|
||||
private:
|
||||
friend class cef_internal::SupportsWeakPtrBase;
|
||||
template <typename U>
|
||||
friend class WeakPtr;
|
||||
friend class SupportsWeakPtr<T>;
|
||||
friend class WeakPtrFactory<T>;
|
||||
|
||||
WeakPtr(const cef_internal::WeakReference& ref, T* ptr)
|
||||
: WeakPtrBase(ref, reinterpret_cast<uintptr_t>(ptr)) {}
|
||||
};
|
||||
|
||||
///
|
||||
/// Allow callers to compare WeakPtrs against nullptr to test validity.
|
||||
///
|
||||
template <class T>
|
||||
bool operator!=(const WeakPtr<T>& weak_ptr, std::nullptr_t) {
|
||||
return !(weak_ptr == nullptr);
|
||||
}
|
||||
template <class T>
|
||||
bool operator!=(std::nullptr_t, const WeakPtr<T>& weak_ptr) {
|
||||
return weak_ptr != nullptr;
|
||||
}
|
||||
template <class T>
|
||||
bool operator==(const WeakPtr<T>& weak_ptr, std::nullptr_t) {
|
||||
return weak_ptr.get() == nullptr;
|
||||
}
|
||||
template <class T>
|
||||
bool operator==(std::nullptr_t, const WeakPtr<T>& weak_ptr) {
|
||||
return weak_ptr == nullptr;
|
||||
}
|
||||
|
||||
namespace cef_internal {
|
||||
class WeakPtrFactoryBase {
|
||||
protected:
|
||||
WeakPtrFactoryBase(uintptr_t ptr);
|
||||
~WeakPtrFactoryBase();
|
||||
cef_internal::WeakReferenceOwner weak_reference_owner_;
|
||||
uintptr_t ptr_;
|
||||
};
|
||||
} // namespace cef_internal
|
||||
|
||||
///
|
||||
/// A class may be composed of a WeakPtrFactory and thereby control how it
|
||||
/// exposes weak pointers to itself. This is helpful if you only need weak
|
||||
/// pointers within the implementation of a class. This class is also useful
|
||||
/// when working with primitive types. For example, you could have a
|
||||
/// WeakPtrFactory<bool> that is used to pass around a weak reference to a
|
||||
/// bool.
|
||||
///
|
||||
template <class T>
|
||||
class WeakPtrFactory : public cef_internal::WeakPtrFactoryBase {
|
||||
public:
|
||||
WeakPtrFactory() = delete;
|
||||
|
||||
explicit WeakPtrFactory(T* ptr)
|
||||
: WeakPtrFactoryBase(reinterpret_cast<uintptr_t>(ptr)) {}
|
||||
|
||||
WeakPtrFactory(const WeakPtrFactory&) = delete;
|
||||
WeakPtrFactory& operator=(const WeakPtrFactory&) = delete;
|
||||
|
||||
~WeakPtrFactory() = default;
|
||||
|
||||
WeakPtr<T> GetWeakPtr() const {
|
||||
return WeakPtr<T>(weak_reference_owner_.GetRef(),
|
||||
reinterpret_cast<T*>(ptr_));
|
||||
}
|
||||
|
||||
///
|
||||
/// Call this method to invalidate all existing weak pointers.
|
||||
///
|
||||
void InvalidateWeakPtrs() {
|
||||
DCHECK(ptr_);
|
||||
weak_reference_owner_.Invalidate();
|
||||
}
|
||||
|
||||
///
|
||||
/// Call this method to determine if any weak pointers exist.
|
||||
///
|
||||
bool HasWeakPtrs() const {
|
||||
DCHECK(ptr_);
|
||||
return weak_reference_owner_.HasRefs();
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
/// A class may extend from SupportsWeakPtr to let others take weak pointers to
|
||||
/// it. This avoids the class itself implementing boilerplate to dispense weak
|
||||
/// pointers. However, since SupportsWeakPtr's destructor won't invalidate
|
||||
/// weak pointers to the class until after the derived class' members have been
|
||||
/// destroyed, its use can lead to subtle use-after-destroy issues.
|
||||
///
|
||||
template <class T>
|
||||
class SupportsWeakPtr : public cef_internal::SupportsWeakPtrBase {
|
||||
public:
|
||||
SupportsWeakPtr() = default;
|
||||
|
||||
SupportsWeakPtr(const SupportsWeakPtr&) = delete;
|
||||
SupportsWeakPtr& operator=(const SupportsWeakPtr&) = delete;
|
||||
|
||||
WeakPtr<T> AsWeakPtr() {
|
||||
return WeakPtr<T>(weak_reference_owner_.GetRef(), static_cast<T*>(this));
|
||||
}
|
||||
|
||||
protected:
|
||||
~SupportsWeakPtr() = default;
|
||||
|
||||
private:
|
||||
cef_internal::WeakReferenceOwner weak_reference_owner_;
|
||||
};
|
||||
|
||||
///
|
||||
/// Helper function that uses type deduction to safely return a WeakPtr<Derived>
|
||||
/// when Derived doesn't directly extend SupportsWeakPtr<Derived>, instead it
|
||||
/// extends a Base that extends SupportsWeakPtr<Base>.
|
||||
///
|
||||
/// EXAMPLE:
|
||||
/// <pre>
|
||||
/// class Base : public base::SupportsWeakPtr<Producer> {};
|
||||
/// class Derived : public Base {};
|
||||
///
|
||||
/// Derived derived;
|
||||
/// base::WeakPtr<Derived> ptr = base::AsWeakPtr(&derived);
|
||||
/// </pre>
|
||||
///
|
||||
/// Note that the following doesn't work (invalid type conversion) since
|
||||
/// Derived::AsWeakPtr() is WeakPtr<Base> SupportsWeakPtr<Base>::AsWeakPtr(),
|
||||
/// and there's no way to safely cast WeakPtr<Base> to WeakPtr<Derived> at
|
||||
/// the caller.
|
||||
///
|
||||
/// <pre>
|
||||
/// base::WeakPtr<Derived> ptr = derived.AsWeakPtr(); // Fails.
|
||||
/// </pre>
|
||||
///
|
||||
template <typename Derived>
|
||||
WeakPtr<Derived> AsWeakPtr(Derived* t) {
|
||||
return cef_internal::SupportsWeakPtrBase::StaticAsWeakPtr<Derived>(t);
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_WEAK_PTR_H_
|
||||
6
third/cef/include/base/internal/README-TRANSFER.txt
Normal file
6
third/cef/include/base/internal/README-TRANSFER.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
Files in this directory have been copied from other locations in the Chromium
|
||||
source tree. They have been modified only to the extent necessary to work in
|
||||
the CEF Binary Distribution directory structure. Below is a listing of the
|
||||
original file locations.
|
||||
|
||||
../net/base/net_error_list.h
|
||||
1415
third/cef/include/base/internal/cef_bind_internal.h
Normal file
1415
third/cef/include/base/internal/cef_bind_internal.h
Normal file
File diff suppressed because it is too large
Load Diff
275
third/cef/include/base/internal/cef_callback_internal.h
Normal file
275
third/cef/include/base/internal/cef_callback_internal.h
Normal file
@@ -0,0 +1,275 @@
|
||||
// Copyright (c) 2012 Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Do not include this header file directly. Use base/cef_bind.h or
|
||||
// base/cef_callback.h instead.
|
||||
|
||||
// This file contains utility functions and classes that help the
|
||||
// implementation, and management of the Callback objects.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_
|
||||
#define CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_
|
||||
|
||||
#include "include/base/cef_callback_forward.h"
|
||||
#include "include/base/cef_ref_counted.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
struct FakeBindState;
|
||||
|
||||
namespace cef_internal {
|
||||
|
||||
class BindStateBase;
|
||||
class FinallyExecutorCommon;
|
||||
class ThenAndCatchExecutorCommon;
|
||||
|
||||
template <typename ReturnType>
|
||||
class PostTaskExecutor;
|
||||
|
||||
template <typename Functor, typename... BoundArgs>
|
||||
struct BindState;
|
||||
|
||||
class CallbackBase;
|
||||
class CallbackBaseCopyable;
|
||||
|
||||
struct BindStateBaseRefCountTraits {
|
||||
static void Destruct(const BindStateBase*);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using PassingType = std::conditional_t<std::is_scalar<T>::value, T, T&&>;
|
||||
|
||||
// BindStateBase is used to provide an opaque handle that the Callback
|
||||
// class can use to represent a function object with bound arguments. It
|
||||
// behaves as an existential type that is used by a corresponding
|
||||
// DoInvoke function to perform the function execution. This allows
|
||||
// us to shield the Callback class from the types of the bound argument via
|
||||
// "type erasure."
|
||||
// At the base level, the only task is to add reference counting data. Avoid
|
||||
// using or inheriting any virtual functions. Creating a vtable for every
|
||||
// BindState template instantiation results in a lot of bloat. Its only task is
|
||||
// to call the destructor which can be done with a function pointer.
|
||||
class BindStateBase
|
||||
: public RefCountedThreadSafe<BindStateBase, BindStateBaseRefCountTraits> {
|
||||
public:
|
||||
REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE();
|
||||
|
||||
enum CancellationQueryMode {
|
||||
IS_CANCELLED,
|
||||
MAYBE_VALID,
|
||||
};
|
||||
|
||||
using InvokeFuncStorage = void (*)();
|
||||
|
||||
BindStateBase(const BindStateBase&) = delete;
|
||||
BindStateBase& operator=(const BindStateBase&) = delete;
|
||||
|
||||
private:
|
||||
BindStateBase(InvokeFuncStorage polymorphic_invoke,
|
||||
void (*destructor)(const BindStateBase*));
|
||||
BindStateBase(InvokeFuncStorage polymorphic_invoke,
|
||||
void (*destructor)(const BindStateBase*),
|
||||
bool (*query_cancellation_traits)(const BindStateBase*,
|
||||
CancellationQueryMode mode));
|
||||
|
||||
~BindStateBase() = default;
|
||||
|
||||
friend struct BindStateBaseRefCountTraits;
|
||||
friend class RefCountedThreadSafe<BindStateBase, BindStateBaseRefCountTraits>;
|
||||
|
||||
friend class CallbackBase;
|
||||
friend class CallbackBaseCopyable;
|
||||
|
||||
// Allowlist subclasses that access the destructor of BindStateBase.
|
||||
template <typename Functor, typename... BoundArgs>
|
||||
friend struct BindState;
|
||||
friend struct ::base::FakeBindState;
|
||||
|
||||
bool IsCancelled() const {
|
||||
return query_cancellation_traits_(this, IS_CANCELLED);
|
||||
}
|
||||
|
||||
bool MaybeValid() const {
|
||||
return query_cancellation_traits_(this, MAYBE_VALID);
|
||||
}
|
||||
|
||||
// In C++, it is safe to cast function pointers to function pointers of
|
||||
// another type. It is not okay to use void*. We create a InvokeFuncStorage
|
||||
// that that can store our function pointer, and then cast it back to
|
||||
// the original type on usage.
|
||||
InvokeFuncStorage polymorphic_invoke_;
|
||||
|
||||
// Pointer to a function that will properly destroy |this|.
|
||||
void (*destructor_)(const BindStateBase*);
|
||||
bool (*query_cancellation_traits_)(const BindStateBase*,
|
||||
CancellationQueryMode mode);
|
||||
};
|
||||
|
||||
// Holds the Callback methods that don't require specialization to reduce
|
||||
// template bloat.
|
||||
// CallbackBase<MoveOnly> is a direct base class of MoveOnly callbacks, and
|
||||
// CallbackBase<Copyable> uses CallbackBase<MoveOnly> for its implementation.
|
||||
class CallbackBase {
|
||||
public:
|
||||
inline CallbackBase(CallbackBase&& c) noexcept;
|
||||
CallbackBase& operator=(CallbackBase&& c) noexcept;
|
||||
|
||||
explicit CallbackBase(const CallbackBaseCopyable& c);
|
||||
CallbackBase& operator=(const CallbackBaseCopyable& c);
|
||||
|
||||
explicit CallbackBase(CallbackBaseCopyable&& c) noexcept;
|
||||
CallbackBase& operator=(CallbackBaseCopyable&& c) noexcept;
|
||||
|
||||
// Returns true if Callback is null (doesn't refer to anything).
|
||||
bool is_null() const { return !bind_state_; }
|
||||
explicit operator bool() const { return !is_null(); }
|
||||
|
||||
// Returns true if the callback invocation will be nop due to an cancellation.
|
||||
// It's invalid to call this on uninitialized callback.
|
||||
//
|
||||
// Must be called on the Callback's destination sequence.
|
||||
bool IsCancelled() const;
|
||||
|
||||
// If this returns false, the callback invocation will be a nop due to a
|
||||
// cancellation. This may(!) still return true, even on a cancelled callback.
|
||||
//
|
||||
// This function is thread-safe.
|
||||
bool MaybeValid() const;
|
||||
|
||||
// Returns the Callback into an uninitialized state.
|
||||
void Reset();
|
||||
|
||||
protected:
|
||||
friend class FinallyExecutorCommon;
|
||||
friend class ThenAndCatchExecutorCommon;
|
||||
|
||||
template <typename ReturnType>
|
||||
friend class PostTaskExecutor;
|
||||
|
||||
using InvokeFuncStorage = BindStateBase::InvokeFuncStorage;
|
||||
|
||||
// Returns true if this callback equals |other|. |other| may be null.
|
||||
bool EqualsInternal(const CallbackBase& other) const;
|
||||
|
||||
constexpr inline CallbackBase();
|
||||
|
||||
// Allow initializing of |bind_state_| via the constructor to avoid default
|
||||
// initialization of the scoped_refptr.
|
||||
explicit inline CallbackBase(BindStateBase* bind_state);
|
||||
|
||||
InvokeFuncStorage polymorphic_invoke() const {
|
||||
return bind_state_->polymorphic_invoke_;
|
||||
}
|
||||
|
||||
// Force the destructor to be instantiated inside this translation unit so
|
||||
// that our subclasses will not get inlined versions. Avoids more template
|
||||
// bloat.
|
||||
~CallbackBase();
|
||||
|
||||
scoped_refptr<BindStateBase> bind_state_;
|
||||
};
|
||||
|
||||
constexpr CallbackBase::CallbackBase() = default;
|
||||
CallbackBase::CallbackBase(CallbackBase&&) noexcept = default;
|
||||
CallbackBase::CallbackBase(BindStateBase* bind_state)
|
||||
: bind_state_(AdoptRef(bind_state)) {}
|
||||
|
||||
// CallbackBase<Copyable> is a direct base class of Copyable Callbacks.
|
||||
class CallbackBaseCopyable : public CallbackBase {
|
||||
public:
|
||||
CallbackBaseCopyable(const CallbackBaseCopyable& c);
|
||||
CallbackBaseCopyable(CallbackBaseCopyable&& c) noexcept = default;
|
||||
CallbackBaseCopyable& operator=(const CallbackBaseCopyable& c);
|
||||
CallbackBaseCopyable& operator=(CallbackBaseCopyable&& c) noexcept;
|
||||
|
||||
protected:
|
||||
constexpr CallbackBaseCopyable() = default;
|
||||
explicit CallbackBaseCopyable(BindStateBase* bind_state)
|
||||
: CallbackBase(bind_state) {}
|
||||
~CallbackBaseCopyable() = default;
|
||||
};
|
||||
|
||||
// Helpers for the `Then()` implementation.
|
||||
template <typename OriginalCallback, typename ThenCallback>
|
||||
struct ThenHelper;
|
||||
|
||||
// Specialization when original callback returns `void`.
|
||||
template <template <typename> class OriginalCallback,
|
||||
template <typename>
|
||||
class ThenCallback,
|
||||
typename... OriginalArgs,
|
||||
typename ThenR,
|
||||
typename... ThenArgs>
|
||||
struct ThenHelper<OriginalCallback<void(OriginalArgs...)>,
|
||||
ThenCallback<ThenR(ThenArgs...)>> {
|
||||
static_assert(sizeof...(ThenArgs) == 0,
|
||||
"|then| callback cannot accept parameters if |this| has a "
|
||||
"void return type.");
|
||||
|
||||
static auto CreateTrampoline() {
|
||||
return [](OriginalCallback<void(OriginalArgs...)> c1,
|
||||
ThenCallback<ThenR(ThenArgs...)> c2, OriginalArgs... c1_args) {
|
||||
std::move(c1).Run(std::forward<OriginalArgs>(c1_args)...);
|
||||
return std::move(c2).Run();
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
// Specialization when original callback returns a non-void type.
|
||||
template <template <typename> class OriginalCallback,
|
||||
template <typename>
|
||||
class ThenCallback,
|
||||
typename OriginalR,
|
||||
typename... OriginalArgs,
|
||||
typename ThenR,
|
||||
typename... ThenArgs>
|
||||
struct ThenHelper<OriginalCallback<OriginalR(OriginalArgs...)>,
|
||||
ThenCallback<ThenR(ThenArgs...)>> {
|
||||
static_assert(sizeof...(ThenArgs) == 1,
|
||||
"|then| callback must accept exactly one parameter if |this| "
|
||||
"has a non-void return type.");
|
||||
// TODO(dcheng): This should probably check is_convertible as well (same with
|
||||
// `AssertBindArgsValidity`).
|
||||
static_assert(std::is_constructible<ThenArgs..., OriginalR&&>::value,
|
||||
"|then| callback's parameter must be constructible from "
|
||||
"return type of |this|.");
|
||||
|
||||
static auto CreateTrampoline() {
|
||||
return [](OriginalCallback<OriginalR(OriginalArgs...)> c1,
|
||||
ThenCallback<ThenR(ThenArgs...)> c2, OriginalArgs... c1_args) {
|
||||
return std::move(c2).Run(
|
||||
std::move(c1).Run(std::forward<OriginalArgs>(c1_args)...));
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace cef_internal
|
||||
} // namespace base
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_
|
||||
87
third/cef/include/base/internal/cef_lock_impl.h
Normal file
87
third/cef/include/base/internal/cef_lock_impl.h
Normal file
@@ -0,0 +1,87 @@
|
||||
// Copyright (c) 2011 Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Do not include this header file directly. Use base/cef_lock.h instead.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_LOCK_IMPL_H_
|
||||
#define CEF_INCLUDE_BASE_INTERNAL_CEF_LOCK_IMPL_H_
|
||||
|
||||
#include "include/base/cef_build.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h>
|
||||
#elif defined(OS_POSIX)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
namespace base {
|
||||
namespace cef_internal {
|
||||
|
||||
// This class implements the underlying platform-specific spin-lock mechanism
|
||||
// used for the Lock class. Most users should not use LockImpl directly, but
|
||||
// should instead use Lock.
|
||||
class LockImpl {
|
||||
public:
|
||||
#if defined(OS_WIN)
|
||||
typedef CRITICAL_SECTION NativeHandle;
|
||||
#elif defined(OS_POSIX)
|
||||
typedef pthread_mutex_t NativeHandle;
|
||||
#endif
|
||||
|
||||
LockImpl();
|
||||
|
||||
LockImpl(const LockImpl&) = delete;
|
||||
LockImpl& operator=(const LockImpl&) = delete;
|
||||
|
||||
~LockImpl();
|
||||
|
||||
// If the lock is not held, take it and return true. If the lock is already
|
||||
// held by something else, immediately return false.
|
||||
bool Try();
|
||||
|
||||
// Take the lock, blocking until it is available if necessary.
|
||||
void Lock();
|
||||
|
||||
// Release the lock. This must only be called by the lock's holder: after
|
||||
// a successful call to Try, or a call to Lock.
|
||||
void Unlock();
|
||||
|
||||
// Return the native underlying lock.
|
||||
// TODO(awalker): refactor lock and condition variables so that this is
|
||||
// unnecessary.
|
||||
NativeHandle* native_handle() { return &native_handle_; }
|
||||
|
||||
private:
|
||||
NativeHandle native_handle_;
|
||||
};
|
||||
|
||||
} // namespace cef_internal
|
||||
} // namespace base
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_LOCK_IMPL_H_
|
||||
1031
third/cef/include/base/internal/cef_net_error_list.h
Normal file
1031
third/cef/include/base/internal/cef_net_error_list.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,75 @@
|
||||
// Copyright (c) 2011 Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Do not include this header file directly. Use base/cef_callback.h instead.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_
|
||||
#define CEF_INCLUDE_BASE_INTERNAL_CEF_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "include/base/cef_template_util.h"
|
||||
|
||||
// It is dangerous to post a task with a T* argument where T is a subtype of
|
||||
// RefCounted(Base|ThreadSafeBase), since by the time the parameter is used, the
|
||||
// object may already have been deleted since it was not held with a
|
||||
// scoped_refptr. Example: http://crbug.com/27191
|
||||
// The following set of traits are designed to generate a compile error
|
||||
// whenever this antipattern is attempted.
|
||||
|
||||
namespace base {
|
||||
|
||||
// This is a base internal implementation file used by task.h and callback.h.
|
||||
// Not for public consumption, so we wrap it in namespace internal.
|
||||
namespace cef_internal {
|
||||
|
||||
template <typename T, typename = void>
|
||||
struct IsRefCountedType : std::false_type {};
|
||||
|
||||
template <typename T>
|
||||
struct IsRefCountedType<T,
|
||||
void_t<decltype(std::declval<T*>()->AddRef()),
|
||||
decltype(std::declval<T*>()->Release())>>
|
||||
: std::true_type {};
|
||||
|
||||
// Human readable translation: you needed to be a scoped_refptr if you are a raw
|
||||
// pointer type and are convertible to a RefCounted(Base|ThreadSafeBase) type.
|
||||
template <typename T>
|
||||
struct NeedsScopedRefptrButGetsRawPtr
|
||||
: conjunction<std::is_pointer<T>,
|
||||
IsRefCountedType<std::remove_pointer_t<T>>> {
|
||||
static_assert(!std::is_reference<T>::value,
|
||||
"NeedsScopedRefptrButGetsRawPtr requires non-reference type.");
|
||||
};
|
||||
|
||||
} // namespace cef_internal
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_
|
||||
53
third/cef/include/base/internal/cef_scoped_policy.h
Normal file
53
third/cef/include/base/internal/cef_scoped_policy.h
Normal file
@@ -0,0 +1,53 @@
|
||||
// Copyright (c) 2012 Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Do not include this header file directly. Use base/memory/scoped_policy.h
|
||||
// instead.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_SCOPED_POLICY_H_
|
||||
#define CEF_INCLUDE_BASE_INTERNAL_CEF_SCOPED_POLICY_H_
|
||||
|
||||
namespace base {
|
||||
namespace scoped_policy {
|
||||
|
||||
// Defines the ownership policy for a scoped object.
|
||||
enum OwnershipPolicy {
|
||||
// The scoped object takes ownership of an object by taking over an existing
|
||||
// ownership claim.
|
||||
ASSUME,
|
||||
|
||||
// The scoped object will retain the object and any initial ownership is
|
||||
// not changed.
|
||||
RETAIN
|
||||
};
|
||||
|
||||
} // namespace scoped_policy
|
||||
} // namespace base
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_SCOPED_POLICY_H_
|
||||
72
third/cef/include/base/internal/cef_thread_checker_impl.h
Normal file
72
third/cef/include/base/internal/cef_thread_checker_impl.h
Normal file
@@ -0,0 +1,72 @@
|
||||
// Copyright (c) 2011 Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Do not include this header file directly. Use base/cef_thread_checker.h
|
||||
// instead.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_THREAD_CHECKER_IMPL_H_
|
||||
#define CEF_INCLUDE_BASE_INTERNAL_THREAD_CHECKER_IMPL_H_
|
||||
|
||||
#include "include/base/cef_lock.h"
|
||||
#include "include/base/cef_platform_thread.h"
|
||||
|
||||
namespace base {
|
||||
namespace cef_internal {
|
||||
|
||||
// Real implementation of ThreadChecker, for use in debug mode, or
|
||||
// for temporary use in release mode (e.g. to CHECK on a threading issue
|
||||
// seen only in the wild).
|
||||
//
|
||||
// Note: You should almost always use the ThreadChecker class to get the
|
||||
// right version for your build configuration.
|
||||
class ThreadCheckerImpl {
|
||||
public:
|
||||
ThreadCheckerImpl();
|
||||
~ThreadCheckerImpl();
|
||||
|
||||
bool CalledOnValidThread() const;
|
||||
|
||||
// Changes the thread that is checked for in CalledOnValidThread. This may
|
||||
// be useful when an object may be created on one thread and then used
|
||||
// exclusively on another thread.
|
||||
void DetachFromThread();
|
||||
|
||||
private:
|
||||
void EnsureThreadIdAssigned() const;
|
||||
|
||||
mutable base::Lock lock_;
|
||||
// This is mutable so that CalledOnValidThread can set it.
|
||||
// It's guarded by |lock_|.
|
||||
mutable PlatformThreadRef valid_thread_id_;
|
||||
};
|
||||
|
||||
} // namespace cef_internal
|
||||
} // namespace base
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_INTERNAL_THREAD_CHECKER_IMPL_H_
|
||||
81
third/cef/include/capi/cef_accessibility_handler_capi.h
Normal file
81
third/cef/include/capi/cef_accessibility_handler_capi.h
Normal file
@@ -0,0 +1,81 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=0ac3c8ca887778a840c65108d56038d4d776e073$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_ACCESSIBILITY_HANDLER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_ACCESSIBILITY_HANDLER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Implement this structure to receive accessibility notification when
|
||||
/// accessibility events have been registered. The functions of this structure
|
||||
/// will be called on the UI thread.
|
||||
///
|
||||
typedef struct _cef_accessibility_handler_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Called after renderer process sends accessibility tree changes to the
|
||||
/// browser process.
|
||||
///
|
||||
void(CEF_CALLBACK* on_accessibility_tree_change)(
|
||||
struct _cef_accessibility_handler_t* self,
|
||||
struct _cef_value_t* value);
|
||||
|
||||
///
|
||||
/// Called after renderer process sends accessibility location changes to the
|
||||
/// browser process.
|
||||
///
|
||||
void(CEF_CALLBACK* on_accessibility_location_change)(
|
||||
struct _cef_accessibility_handler_t* self,
|
||||
struct _cef_value_t* value);
|
||||
} cef_accessibility_handler_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_ACCESSIBILITY_HANDLER_CAPI_H_
|
||||
190
third/cef/include/capi/cef_app_capi.h
Normal file
190
third/cef/include/capi/cef_app_capi.h
Normal file
@@ -0,0 +1,190 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=9b523fbf312a8a0cb1c743a3c8aca7bc9cc22bbc$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_browser_process_handler_capi.h"
|
||||
#include "include/capi/cef_command_line_capi.h"
|
||||
#include "include/capi/cef_render_process_handler_capi.h"
|
||||
#include "include/capi/cef_resource_bundle_handler_capi.h"
|
||||
#include "include/capi/cef_scheme_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _cef_app_t;
|
||||
|
||||
///
|
||||
/// Implement this structure to provide handler implementations. Methods will be
|
||||
/// called by the process and/or thread indicated.
|
||||
///
|
||||
typedef struct _cef_app_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Provides an opportunity to view and/or modify command-line arguments
|
||||
/// before processing by CEF and Chromium. The |process_type| value will be
|
||||
/// NULL for the browser process. Do not keep a reference to the
|
||||
/// cef_command_line_t object passed to this function. The
|
||||
/// cef_settings_t.command_line_args_disabled value can be used to start with
|
||||
/// an NULL command-line object. Any values specified in CefSettings that
|
||||
/// equate to command-line arguments will be set before this function is
|
||||
/// called. Be cautious when using this function to modify command-line
|
||||
/// arguments for non-browser processes as this may result in undefined
|
||||
/// behavior including crashes.
|
||||
///
|
||||
void(CEF_CALLBACK* on_before_command_line_processing)(
|
||||
struct _cef_app_t* self,
|
||||
const cef_string_t* process_type,
|
||||
struct _cef_command_line_t* command_line);
|
||||
|
||||
///
|
||||
/// Provides an opportunity to register custom schemes. Do not keep a
|
||||
/// reference to the |registrar| object. This function is called on the main
|
||||
/// thread for each process and the registered schemes should be the same
|
||||
/// across all processes.
|
||||
///
|
||||
void(CEF_CALLBACK* on_register_custom_schemes)(
|
||||
struct _cef_app_t* self,
|
||||
struct _cef_scheme_registrar_t* registrar);
|
||||
|
||||
///
|
||||
/// Return the handler for resource bundle events. If
|
||||
/// cef_settings_t.pack_loading_disabled is true (1) a handler must be
|
||||
/// returned. If no handler is returned resources will be loaded from pack
|
||||
/// files. This function is called by the browser and render processes on
|
||||
/// multiple threads.
|
||||
///
|
||||
struct _cef_resource_bundle_handler_t*(
|
||||
CEF_CALLBACK* get_resource_bundle_handler)(struct _cef_app_t* self);
|
||||
|
||||
///
|
||||
/// Return the handler for functionality specific to the browser process. This
|
||||
/// function is called on multiple threads in the browser process.
|
||||
///
|
||||
struct _cef_browser_process_handler_t*(
|
||||
CEF_CALLBACK* get_browser_process_handler)(struct _cef_app_t* self);
|
||||
|
||||
///
|
||||
/// Return the handler for functionality specific to the render process. This
|
||||
/// function is called on the render process main thread.
|
||||
///
|
||||
struct _cef_render_process_handler_t*(
|
||||
CEF_CALLBACK* get_render_process_handler)(struct _cef_app_t* self);
|
||||
} cef_app_t;
|
||||
|
||||
///
|
||||
/// This function should be called from the application entry point function to
|
||||
/// execute a secondary process. It can be used to run secondary processes from
|
||||
/// the browser client executable (default behavior) or from a separate
|
||||
/// executable specified by the cef_settings_t.browser_subprocess_path value. If
|
||||
/// called for the browser process (identified by no "type" command-line value)
|
||||
/// it will return immediately with a value of -1. If called for a recognized
|
||||
/// secondary process it will block until the process should exit and then
|
||||
/// return the process exit code. The |application| parameter may be NULL. The
|
||||
/// |windows_sandbox_info| parameter is only used on Windows and may be NULL
|
||||
/// (see cef_sandbox_win.h for details).
|
||||
///
|
||||
CEF_EXPORT int cef_execute_process(const cef_main_args_t* args,
|
||||
cef_app_t* application,
|
||||
void* windows_sandbox_info);
|
||||
|
||||
///
|
||||
/// This function should be called on the main application thread to initialize
|
||||
/// the CEF browser process. The |application| parameter may be NULL. A return
|
||||
/// value of true (1) indicates that it succeeded and false (0) indicates that
|
||||
/// it failed. The |windows_sandbox_info| parameter is only used on Windows and
|
||||
/// may be NULL (see cef_sandbox_win.h for details).
|
||||
///
|
||||
CEF_EXPORT int cef_initialize(const cef_main_args_t* args,
|
||||
const struct _cef_settings_t* settings,
|
||||
cef_app_t* application,
|
||||
void* windows_sandbox_info);
|
||||
|
||||
///
|
||||
/// This function should be called on the main application thread to shut down
|
||||
/// the CEF browser process before the application exits.
|
||||
///
|
||||
CEF_EXPORT void cef_shutdown(void);
|
||||
|
||||
///
|
||||
/// Perform a single iteration of CEF message loop processing. This function is
|
||||
/// provided for cases where the CEF message loop must be integrated into an
|
||||
/// existing application message loop. Use of this function is not recommended
|
||||
/// for most users; use either the cef_run_message_loop() function or
|
||||
/// cef_settings_t.multi_threaded_message_loop if possible. When using this
|
||||
/// function care must be taken to balance performance against excessive CPU
|
||||
/// usage. It is recommended to enable the cef_settings_t.external_message_pump
|
||||
/// option when using this function so that
|
||||
/// cef_browser_process_handler_t::on_schedule_message_pump_work() callbacks can
|
||||
/// facilitate the scheduling process. This function should only be called on
|
||||
/// the main application thread and only if cef_initialize() is called with a
|
||||
/// cef_settings_t.multi_threaded_message_loop value of false (0). This function
|
||||
/// will not block.
|
||||
///
|
||||
CEF_EXPORT void cef_do_message_loop_work(void);
|
||||
|
||||
///
|
||||
/// Run the CEF message loop. Use this function instead of an application-
|
||||
/// provided message loop to get the best balance between performance and CPU
|
||||
/// usage. This function should only be called on the main application thread
|
||||
/// and only if cef_initialize() is called with a
|
||||
/// cef_settings_t.multi_threaded_message_loop value of false (0). This function
|
||||
/// will block until a quit message is received by the system.
|
||||
///
|
||||
CEF_EXPORT void cef_run_message_loop(void);
|
||||
|
||||
///
|
||||
/// Quit the CEF message loop that was started by calling
|
||||
/// cef_run_message_loop(). This function should only be called on the main
|
||||
/// application thread and only if cef_run_message_loop() was used.
|
||||
///
|
||||
CEF_EXPORT void cef_quit_message_loop(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_
|
||||
121
third/cef/include/capi/cef_audio_handler_capi.h
Normal file
121
third/cef/include/capi/cef_audio_handler_capi.h
Normal file
@@ -0,0 +1,121 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=936274d5539f225ff7adb7e0acba517fd9a8e2f8$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_AUDIO_HANDLER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_AUDIO_HANDLER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Implement this structure to handle audio events.
|
||||
///
|
||||
typedef struct _cef_audio_handler_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Called on the UI thread to allow configuration of audio stream parameters.
|
||||
/// Return true (1) to proceed with audio stream capture, or false (0) to
|
||||
/// cancel it. All members of |params| can optionally be configured here, but
|
||||
/// they are also pre-filled with some sensible defaults.
|
||||
///
|
||||
int(CEF_CALLBACK* get_audio_parameters)(struct _cef_audio_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
cef_audio_parameters_t* params);
|
||||
|
||||
///
|
||||
/// Called on a browser audio capture thread when the browser starts streaming
|
||||
/// audio. OnAudioStreamStopped will always be called after
|
||||
/// OnAudioStreamStarted; both functions may be called multiple times for the
|
||||
/// same browser. |params| contains the audio parameters like sample rate and
|
||||
/// channel layout. |channels| is the number of channels.
|
||||
///
|
||||
void(CEF_CALLBACK* on_audio_stream_started)(
|
||||
struct _cef_audio_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
const cef_audio_parameters_t* params,
|
||||
int channels);
|
||||
|
||||
///
|
||||
/// Called on the audio stream thread when a PCM packet is received for the
|
||||
/// stream. |data| is an array representing the raw PCM data as a floating
|
||||
/// point type, i.e. 4-byte value(s). |frames| is the number of frames in the
|
||||
/// PCM packet. |pts| is the presentation timestamp (in milliseconds since the
|
||||
/// Unix Epoch) and represents the time at which the decompressed packet
|
||||
/// should be presented to the user. Based on |frames| and the
|
||||
/// |channel_layout| value passed to OnAudioStreamStarted you can calculate
|
||||
/// the size of the |data| array in bytes.
|
||||
///
|
||||
void(CEF_CALLBACK* on_audio_stream_packet)(struct _cef_audio_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
const float** data,
|
||||
int frames,
|
||||
int64 pts);
|
||||
|
||||
///
|
||||
/// Called on the UI thread when the stream has stopped. OnAudioSteamStopped
|
||||
/// will always be called after OnAudioStreamStarted; both functions may be
|
||||
/// called multiple times for the same stream.
|
||||
///
|
||||
void(CEF_CALLBACK* on_audio_stream_stopped)(struct _cef_audio_handler_t* self,
|
||||
struct _cef_browser_t* browser);
|
||||
|
||||
///
|
||||
/// Called on the UI or audio stream thread when an error occurred. During the
|
||||
/// stream creation phase this callback will be called on the UI thread while
|
||||
/// in the capturing phase it will be called on the audio stream thread. The
|
||||
/// stream will be stopped immediately.
|
||||
///
|
||||
void(CEF_CALLBACK* on_audio_stream_error)(struct _cef_audio_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
const cef_string_t* message);
|
||||
} cef_audio_handler_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_AUDIO_HANDLER_CAPI_H_
|
||||
76
third/cef/include/capi/cef_auth_callback_capi.h
Normal file
76
third/cef/include/capi/cef_auth_callback_capi.h
Normal file
@@ -0,0 +1,76 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=4b9c31ef9a23f899c6d8cd3da49934a41f1bd231$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_AUTH_CALLBACK_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_AUTH_CALLBACK_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Callback structure used for asynchronous continuation of authentication
|
||||
/// requests.
|
||||
///
|
||||
typedef struct _cef_auth_callback_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Continue the authentication request.
|
||||
///
|
||||
void(CEF_CALLBACK* cont)(struct _cef_auth_callback_t* self,
|
||||
const cef_string_t* username,
|
||||
const cef_string_t* password);
|
||||
|
||||
///
|
||||
/// Cancel the authentication request.
|
||||
///
|
||||
void(CEF_CALLBACK* cancel)(struct _cef_auth_callback_t* self);
|
||||
} cef_auth_callback_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_AUTH_CALLBACK_CAPI_H_
|
||||
107
third/cef/include/capi/cef_base_capi.h
Normal file
107
third/cef/include/capi/cef_base_capi.h
Normal file
@@ -0,0 +1,107 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_BASE_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_BASE_CAPI_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "include/internal/cef_export.h"
|
||||
#include "include/internal/cef_string.h"
|
||||
#include "include/internal/cef_string_list.h"
|
||||
#include "include/internal/cef_string_map.h"
|
||||
#include "include/internal/cef_string_multimap.h"
|
||||
#include "include/internal/cef_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
// All ref-counted framework structures must include this structure first.
|
||||
///
|
||||
typedef struct _cef_base_ref_counted_t {
|
||||
///
|
||||
// Size of the data structure.
|
||||
///
|
||||
size_t size;
|
||||
|
||||
///
|
||||
// Called to increment the reference count for the object. Should be called
|
||||
// for every new copy of a pointer to a given object.
|
||||
///
|
||||
void(CEF_CALLBACK* add_ref)(struct _cef_base_ref_counted_t* self);
|
||||
|
||||
///
|
||||
// Called to decrement the reference count for the object. If the reference
|
||||
// count falls to 0 the object should self-delete. Returns true (1) if the
|
||||
// resulting reference count is 0.
|
||||
///
|
||||
int(CEF_CALLBACK* release)(struct _cef_base_ref_counted_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if the current reference count is 1.
|
||||
///
|
||||
int(CEF_CALLBACK* has_one_ref)(struct _cef_base_ref_counted_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if the current reference count is at least 1.
|
||||
///
|
||||
int(CEF_CALLBACK* has_at_least_one_ref)(struct _cef_base_ref_counted_t* self);
|
||||
} cef_base_ref_counted_t;
|
||||
|
||||
///
|
||||
// All scoped framework structures must include this structure first.
|
||||
///
|
||||
typedef struct _cef_base_scoped_t {
|
||||
///
|
||||
// Size of the data structure.
|
||||
///
|
||||
size_t size;
|
||||
|
||||
///
|
||||
// Called to delete this object. May be NULL if the object is not owned.
|
||||
///
|
||||
void(CEF_CALLBACK* del)(struct _cef_base_scoped_t* self);
|
||||
|
||||
} cef_base_scoped_t;
|
||||
|
||||
// Check that the structure |s|, which is defined with a size_t member at the
|
||||
// top, is large enough to contain the specified member |f|.
|
||||
#define CEF_MEMBER_EXISTS(s, f) \
|
||||
((intptr_t) & \
|
||||
((s)->f) - (intptr_t)(s) + sizeof((s)->f) <= *reinterpret_cast<size_t*>(s))
|
||||
|
||||
#define CEF_MEMBER_MISSING(s, f) (!CEF_MEMBER_EXISTS(s, f) || !((s)->f))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_BASE_CAPI_H_
|
||||
952
third/cef/include/capi/cef_browser_capi.h
Normal file
952
third/cef/include/capi/cef_browser_capi.h
Normal file
@@ -0,0 +1,952 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=7254c050cd7db2ff7d40a1f54c99e941dc592692$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_devtools_message_observer_capi.h"
|
||||
#include "include/capi/cef_drag_data_capi.h"
|
||||
#include "include/capi/cef_frame_capi.h"
|
||||
#include "include/capi/cef_image_capi.h"
|
||||
#include "include/capi/cef_navigation_entry_capi.h"
|
||||
#include "include/capi/cef_registration_capi.h"
|
||||
#include "include/capi/cef_request_context_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _cef_browser_host_t;
|
||||
struct _cef_client_t;
|
||||
|
||||
///
|
||||
/// Structure used to represent a browser. When used in the browser process the
|
||||
/// functions of this structure may be called on any thread unless otherwise
|
||||
/// indicated in the comments. When used in the render process the functions of
|
||||
/// this structure may only be called on the main thread.
|
||||
///
|
||||
typedef struct _cef_browser_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// True if this object is currently valid. This will return false (0) after
|
||||
/// cef_life_span_handler_t::OnBeforeClose is called.
|
||||
///
|
||||
int(CEF_CALLBACK* is_valid)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
/// Returns the browser host object. This function can only be called in the
|
||||
/// browser process.
|
||||
///
|
||||
struct _cef_browser_host_t*(CEF_CALLBACK* get_host)(
|
||||
struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the browser can navigate backwards.
|
||||
///
|
||||
int(CEF_CALLBACK* can_go_back)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
/// Navigate backwards.
|
||||
///
|
||||
void(CEF_CALLBACK* go_back)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the browser can navigate forwards.
|
||||
///
|
||||
int(CEF_CALLBACK* can_go_forward)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
/// Navigate forwards.
|
||||
///
|
||||
void(CEF_CALLBACK* go_forward)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the browser is currently loading.
|
||||
///
|
||||
int(CEF_CALLBACK* is_loading)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
/// Reload the current page.
|
||||
///
|
||||
void(CEF_CALLBACK* reload)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
/// Reload the current page ignoring any cached data.
|
||||
///
|
||||
void(CEF_CALLBACK* reload_ignore_cache)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
/// Stop loading the page.
|
||||
///
|
||||
void(CEF_CALLBACK* stop_load)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
/// Returns the globally unique identifier for this browser. This value is
|
||||
/// also used as the tabId for extension APIs.
|
||||
///
|
||||
int(CEF_CALLBACK* get_identifier)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if this object is pointing to the same handle as |that|
|
||||
/// object.
|
||||
///
|
||||
int(CEF_CALLBACK* is_same)(struct _cef_browser_t* self,
|
||||
struct _cef_browser_t* that);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the browser is a popup.
|
||||
///
|
||||
int(CEF_CALLBACK* is_popup)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if a document has been loaded in the browser.
|
||||
///
|
||||
int(CEF_CALLBACK* has_document)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
/// Returns the main (top-level) frame for the browser. In the browser process
|
||||
/// this will return a valid object until after
|
||||
/// cef_life_span_handler_t::OnBeforeClose is called. In the renderer process
|
||||
/// this will return NULL if the main frame is hosted in a different renderer
|
||||
/// process (e.g. for cross-origin sub-frames). The main frame object will
|
||||
/// change during cross-origin navigation or re-navigation after renderer
|
||||
/// process termination (due to crashes, etc).
|
||||
///
|
||||
struct _cef_frame_t*(CEF_CALLBACK* get_main_frame)(
|
||||
struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
/// Returns the focused frame for the browser.
|
||||
///
|
||||
struct _cef_frame_t*(CEF_CALLBACK* get_focused_frame)(
|
||||
struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
/// Returns the frame with the specified identifier, or NULL if not found.
|
||||
///
|
||||
struct _cef_frame_t*(CEF_CALLBACK* get_frame_byident)(
|
||||
struct _cef_browser_t* self,
|
||||
int64 identifier);
|
||||
|
||||
///
|
||||
/// Returns the frame with the specified name, or NULL if not found.
|
||||
///
|
||||
struct _cef_frame_t*(CEF_CALLBACK* get_frame)(struct _cef_browser_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Returns the number of frames that currently exist.
|
||||
///
|
||||
size_t(CEF_CALLBACK* get_frame_count)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
/// Returns the identifiers of all existing frames.
|
||||
///
|
||||
void(CEF_CALLBACK* get_frame_identifiers)(struct _cef_browser_t* self,
|
||||
size_t* identifiersCount,
|
||||
int64* identifiers);
|
||||
|
||||
///
|
||||
/// Returns the names of all existing frames.
|
||||
///
|
||||
void(CEF_CALLBACK* get_frame_names)(struct _cef_browser_t* self,
|
||||
cef_string_list_t names);
|
||||
} cef_browser_t;
|
||||
|
||||
///
|
||||
/// Callback structure for cef_browser_host_t::RunFileDialog. The functions of
|
||||
/// this structure will be called on the browser process UI thread.
|
||||
///
|
||||
typedef struct _cef_run_file_dialog_callback_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Called asynchronously after the file dialog is dismissed. |file_paths|
|
||||
/// will be a single value or a list of values depending on the dialog mode.
|
||||
/// If the selection was cancelled |file_paths| will be NULL.
|
||||
///
|
||||
void(CEF_CALLBACK* on_file_dialog_dismissed)(
|
||||
struct _cef_run_file_dialog_callback_t* self,
|
||||
cef_string_list_t file_paths);
|
||||
} cef_run_file_dialog_callback_t;
|
||||
|
||||
///
|
||||
/// Callback structure for cef_browser_host_t::GetNavigationEntries. The
|
||||
/// functions of this structure will be called on the browser process UI thread.
|
||||
///
|
||||
typedef struct _cef_navigation_entry_visitor_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Method that will be executed. Do not keep a reference to |entry| outside
|
||||
/// of this callback. Return true (1) to continue visiting entries or false
|
||||
/// (0) to stop. |current| is true (1) if this entry is the currently loaded
|
||||
/// navigation entry. |index| is the 0-based index of this entry and |total|
|
||||
/// is the total number of entries.
|
||||
///
|
||||
int(CEF_CALLBACK* visit)(struct _cef_navigation_entry_visitor_t* self,
|
||||
struct _cef_navigation_entry_t* entry,
|
||||
int current,
|
||||
int index,
|
||||
int total);
|
||||
} cef_navigation_entry_visitor_t;
|
||||
|
||||
///
|
||||
/// Callback structure for cef_browser_host_t::PrintToPDF. The functions of this
|
||||
/// structure will be called on the browser process UI thread.
|
||||
///
|
||||
typedef struct _cef_pdf_print_callback_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Method that will be executed when the PDF printing has completed. |path|
|
||||
/// is the output path. |ok| will be true (1) if the printing completed
|
||||
/// successfully or false (0) otherwise.
|
||||
///
|
||||
void(CEF_CALLBACK* on_pdf_print_finished)(
|
||||
struct _cef_pdf_print_callback_t* self,
|
||||
const cef_string_t* path,
|
||||
int ok);
|
||||
} cef_pdf_print_callback_t;
|
||||
|
||||
///
|
||||
/// Callback structure for cef_browser_host_t::DownloadImage. The functions of
|
||||
/// this structure will be called on the browser process UI thread.
|
||||
///
|
||||
typedef struct _cef_download_image_callback_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Method that will be executed when the image download has completed.
|
||||
/// |image_url| is the URL that was downloaded and |http_status_code| is the
|
||||
/// resulting HTTP status code. |image| is the resulting image, possibly at
|
||||
/// multiple scale factors, or NULL if the download failed.
|
||||
///
|
||||
void(CEF_CALLBACK* on_download_image_finished)(
|
||||
struct _cef_download_image_callback_t* self,
|
||||
const cef_string_t* image_url,
|
||||
int http_status_code,
|
||||
struct _cef_image_t* image);
|
||||
} cef_download_image_callback_t;
|
||||
|
||||
///
|
||||
/// Structure used to represent the browser process aspects of a browser. The
|
||||
/// functions of this structure can only be called in the browser process. They
|
||||
/// may be called on any thread in that process unless otherwise indicated in
|
||||
/// the comments.
|
||||
///
|
||||
typedef struct _cef_browser_host_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Returns the hosted browser object.
|
||||
///
|
||||
struct _cef_browser_t*(CEF_CALLBACK* get_browser)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Request that the browser close. The JavaScript 'onbeforeunload' event will
|
||||
/// be fired. If |force_close| is false (0) the event handler, if any, will be
|
||||
/// allowed to prompt the user and the user can optionally cancel the close.
|
||||
/// If |force_close| is true (1) the prompt will not be displayed and the
|
||||
/// close will proceed. Results in a call to
|
||||
/// cef_life_span_handler_t::do_close() if the event handler allows the close
|
||||
/// or if |force_close| is true (1). See cef_life_span_handler_t::do_close()
|
||||
/// documentation for additional usage information.
|
||||
///
|
||||
void(CEF_CALLBACK* close_browser)(struct _cef_browser_host_t* self,
|
||||
int force_close);
|
||||
|
||||
///
|
||||
/// Helper for closing a browser. Call this function from the top-level window
|
||||
/// close handler (if any). Internally this calls CloseBrowser(false (0)) if
|
||||
/// the close has not yet been initiated. This function returns false (0)
|
||||
/// while the close is pending and true (1) after the close has completed. See
|
||||
/// close_browser() and cef_life_span_handler_t::do_close() documentation for
|
||||
/// additional usage information. This function must be called on the browser
|
||||
/// process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* try_close_browser)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Set whether the browser is focused.
|
||||
///
|
||||
void(CEF_CALLBACK* set_focus)(struct _cef_browser_host_t* self, int focus);
|
||||
|
||||
///
|
||||
/// Retrieve the window handle (if any) for this browser. If this browser is
|
||||
/// wrapped in a cef_browser_view_t this function should be called on the
|
||||
/// browser process UI thread and it will return the handle for the top-level
|
||||
/// native window.
|
||||
///
|
||||
cef_window_handle_t(CEF_CALLBACK* get_window_handle)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Retrieve the window handle (if any) of the browser that opened this
|
||||
/// browser. Will return NULL for non-popup browsers or if this browser is
|
||||
/// wrapped in a cef_browser_view_t. This function can be used in combination
|
||||
/// with custom handling of modal windows.
|
||||
///
|
||||
cef_window_handle_t(CEF_CALLBACK* get_opener_window_handle)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if this browser is wrapped in a cef_browser_view_t.
|
||||
///
|
||||
int(CEF_CALLBACK* has_view)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Returns the client for this browser.
|
||||
///
|
||||
struct _cef_client_t*(CEF_CALLBACK* get_client)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Returns the request context for this browser.
|
||||
///
|
||||
struct _cef_request_context_t*(CEF_CALLBACK* get_request_context)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Get the current zoom level. The default zoom level is 0.0. This function
|
||||
/// can only be called on the UI thread.
|
||||
///
|
||||
double(CEF_CALLBACK* get_zoom_level)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Change the zoom level to the specified value. Specify 0.0 to reset the
|
||||
/// zoom level. If called on the UI thread the change will be applied
|
||||
/// immediately. Otherwise, the change will be applied asynchronously on the
|
||||
/// UI thread.
|
||||
///
|
||||
void(CEF_CALLBACK* set_zoom_level)(struct _cef_browser_host_t* self,
|
||||
double zoomLevel);
|
||||
|
||||
///
|
||||
/// Call to run a file chooser dialog. Only a single file chooser dialog may
|
||||
/// be pending at any given time. |mode| represents the type of dialog to
|
||||
/// display. |title| to the title to be used for the dialog and may be NULL to
|
||||
/// show the default title ("Open" or "Save" depending on the mode).
|
||||
/// |default_file_path| is the path with optional directory and/or file name
|
||||
/// component that will be initially selected in the dialog. |accept_filters|
|
||||
/// are used to restrict the selectable file types and may any combination of
|
||||
/// (a) valid lower-cased MIME types (e.g. "text/*" or "image/*"), (b)
|
||||
/// individual file extensions (e.g. ".txt" or ".png"), or (c) combined
|
||||
/// description and file extension delimited using "|" and ";" (e.g. "Image
|
||||
/// Types|.png;.gif;.jpg"). |callback| will be executed after the dialog is
|
||||
/// dismissed or immediately if another dialog is already pending. The dialog
|
||||
/// will be initiated asynchronously on the UI thread.
|
||||
///
|
||||
void(CEF_CALLBACK* run_file_dialog)(
|
||||
struct _cef_browser_host_t* self,
|
||||
cef_file_dialog_mode_t mode,
|
||||
const cef_string_t* title,
|
||||
const cef_string_t* default_file_path,
|
||||
cef_string_list_t accept_filters,
|
||||
struct _cef_run_file_dialog_callback_t* callback);
|
||||
|
||||
///
|
||||
/// Download the file at |url| using cef_download_handler_t.
|
||||
///
|
||||
void(CEF_CALLBACK* start_download)(struct _cef_browser_host_t* self,
|
||||
const cef_string_t* url);
|
||||
|
||||
///
|
||||
/// Download |image_url| and execute |callback| on completion with the images
|
||||
/// received from the renderer. If |is_favicon| is true (1) then cookies are
|
||||
/// not sent and not accepted during download. Images with density independent
|
||||
/// pixel (DIP) sizes larger than |max_image_size| are filtered out from the
|
||||
/// image results. Versions of the image at different scale factors may be
|
||||
/// downloaded up to the maximum scale factor supported by the system. If
|
||||
/// there are no image results <= |max_image_size| then the smallest image is
|
||||
/// resized to |max_image_size| and is the only result. A |max_image_size| of
|
||||
/// 0 means unlimited. If |bypass_cache| is true (1) then |image_url| is
|
||||
/// requested from the server even if it is present in the browser cache.
|
||||
///
|
||||
void(CEF_CALLBACK* download_image)(
|
||||
struct _cef_browser_host_t* self,
|
||||
const cef_string_t* image_url,
|
||||
int is_favicon,
|
||||
uint32 max_image_size,
|
||||
int bypass_cache,
|
||||
struct _cef_download_image_callback_t* callback);
|
||||
|
||||
///
|
||||
/// Print the current browser contents.
|
||||
///
|
||||
void(CEF_CALLBACK* print)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Print the current browser contents to the PDF file specified by |path| and
|
||||
/// execute |callback| on completion. The caller is responsible for deleting
|
||||
/// |path| when done. For PDF printing to work on Linux you must implement the
|
||||
/// cef_print_handler_t::GetPdfPaperSize function.
|
||||
///
|
||||
void(CEF_CALLBACK* print_to_pdf)(
|
||||
struct _cef_browser_host_t* self,
|
||||
const cef_string_t* path,
|
||||
const struct _cef_pdf_print_settings_t* settings,
|
||||
struct _cef_pdf_print_callback_t* callback);
|
||||
|
||||
///
|
||||
/// Search for |searchText|. |forward| indicates whether to search forward or
|
||||
/// backward within the page. |matchCase| indicates whether the search should
|
||||
/// be case-sensitive. |findNext| indicates whether this is the first request
|
||||
/// or a follow-up. The search will be restarted if |searchText| or
|
||||
/// |matchCase| change. The search will be stopped if |searchText| is NULL.
|
||||
/// The cef_find_handler_t instance, if any, returned via
|
||||
/// cef_client_t::GetFindHandler will be called to report find results.
|
||||
///
|
||||
void(CEF_CALLBACK* find)(struct _cef_browser_host_t* self,
|
||||
const cef_string_t* searchText,
|
||||
int forward,
|
||||
int matchCase,
|
||||
int findNext);
|
||||
|
||||
///
|
||||
/// Cancel all searches that are currently going on.
|
||||
///
|
||||
void(CEF_CALLBACK* stop_finding)(struct _cef_browser_host_t* self,
|
||||
int clearSelection);
|
||||
|
||||
///
|
||||
/// Open developer tools (DevTools) in its own browser. The DevTools browser
|
||||
/// will remain associated with this browser. If the DevTools browser is
|
||||
/// already open then it will be focused, in which case the |windowInfo|,
|
||||
/// |client| and |settings| parameters will be ignored. If
|
||||
/// |inspect_element_at| is non-NULL then the element at the specified (x,y)
|
||||
/// location will be inspected. The |windowInfo| parameter will be ignored if
|
||||
/// this browser is wrapped in a cef_browser_view_t.
|
||||
///
|
||||
void(CEF_CALLBACK* show_dev_tools)(
|
||||
struct _cef_browser_host_t* self,
|
||||
const struct _cef_window_info_t* windowInfo,
|
||||
struct _cef_client_t* client,
|
||||
const struct _cef_browser_settings_t* settings,
|
||||
const cef_point_t* inspect_element_at);
|
||||
|
||||
///
|
||||
/// Explicitly close the associated DevTools browser, if any.
|
||||
///
|
||||
void(CEF_CALLBACK* close_dev_tools)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if this browser currently has an associated DevTools
|
||||
/// browser. Must be called on the browser process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* has_dev_tools)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Send a function call message over the DevTools protocol. |message| must be
|
||||
/// a UTF8-encoded JSON dictionary that contains "id" (int), "function"
|
||||
/// (string) and "params" (dictionary, optional) values. See the DevTools
|
||||
/// protocol documentation at https://chromedevtools.github.io/devtools-
|
||||
/// protocol/ for details of supported functions and the expected "params"
|
||||
/// dictionary contents. |message| will be copied if necessary. This function
|
||||
/// will return true (1) if called on the UI thread and the message was
|
||||
/// successfully submitted for validation, otherwise false (0). Validation
|
||||
/// will be applied asynchronously and any messages that fail due to
|
||||
/// formatting errors or missing parameters may be discarded without
|
||||
/// notification. Prefer ExecuteDevToolsMethod if a more structured approach
|
||||
/// to message formatting is desired.
|
||||
///
|
||||
/// Every valid function call will result in an asynchronous function result
|
||||
/// or error message that references the sent message "id". Event messages are
|
||||
/// received while notifications are enabled (for example, between function
|
||||
/// calls for "Page.enable" and "Page.disable"). All received messages will be
|
||||
/// delivered to the observer(s) registered with AddDevToolsMessageObserver.
|
||||
/// See cef_dev_tools_message_observer_t::OnDevToolsMessage documentation for
|
||||
/// details of received message contents.
|
||||
///
|
||||
/// Usage of the SendDevToolsMessage, ExecuteDevToolsMethod and
|
||||
/// AddDevToolsMessageObserver functions does not require an active DevTools
|
||||
/// front-end or remote-debugging session. Other active DevTools sessions will
|
||||
/// continue to function independently. However, any modification of global
|
||||
/// browser state by one session may not be reflected in the UI of other
|
||||
/// sessions.
|
||||
///
|
||||
/// Communication with the DevTools front-end (when displayed) can be logged
|
||||
/// for development purposes by passing the `--devtools-protocol-log-
|
||||
/// file=<path>` command-line flag.
|
||||
///
|
||||
int(CEF_CALLBACK* send_dev_tools_message)(struct _cef_browser_host_t* self,
|
||||
const void* message,
|
||||
size_t message_size);
|
||||
|
||||
///
|
||||
/// Execute a function call over the DevTools protocol. This is a more
|
||||
/// structured version of SendDevToolsMessage. |message_id| is an incremental
|
||||
/// number that uniquely identifies the message (pass 0 to have the next
|
||||
/// number assigned automatically based on previous values). |function| is the
|
||||
/// function name. |params| are the function parameters, which may be NULL.
|
||||
/// See the DevTools protocol documentation (linked above) for details of
|
||||
/// supported functions and the expected |params| dictionary contents. This
|
||||
/// function will return the assigned message ID if called on the UI thread
|
||||
/// and the message was successfully submitted for validation, otherwise 0.
|
||||
/// See the SendDevToolsMessage documentation for additional usage
|
||||
/// information.
|
||||
///
|
||||
int(CEF_CALLBACK* execute_dev_tools_method)(
|
||||
struct _cef_browser_host_t* self,
|
||||
int message_id,
|
||||
const cef_string_t* method,
|
||||
struct _cef_dictionary_value_t* params);
|
||||
|
||||
///
|
||||
/// Add an observer for DevTools protocol messages (function results and
|
||||
/// events). The observer will remain registered until the returned
|
||||
/// Registration object is destroyed. See the SendDevToolsMessage
|
||||
/// documentation for additional usage information.
|
||||
///
|
||||
struct _cef_registration_t*(CEF_CALLBACK* add_dev_tools_message_observer)(
|
||||
struct _cef_browser_host_t* self,
|
||||
struct _cef_dev_tools_message_observer_t* observer);
|
||||
|
||||
///
|
||||
/// Retrieve a snapshot of current navigation entries as values sent to the
|
||||
/// specified visitor. If |current_only| is true (1) only the current
|
||||
/// navigation entry will be sent, otherwise all navigation entries will be
|
||||
/// sent.
|
||||
///
|
||||
void(CEF_CALLBACK* get_navigation_entries)(
|
||||
struct _cef_browser_host_t* self,
|
||||
struct _cef_navigation_entry_visitor_t* visitor,
|
||||
int current_only);
|
||||
|
||||
///
|
||||
/// If a misspelled word is currently selected in an editable node calling
|
||||
/// this function will replace it with the specified |word|.
|
||||
///
|
||||
void(CEF_CALLBACK* replace_misspelling)(struct _cef_browser_host_t* self,
|
||||
const cef_string_t* word);
|
||||
|
||||
///
|
||||
/// Add the specified |word| to the spelling dictionary.
|
||||
///
|
||||
void(CEF_CALLBACK* add_word_to_dictionary)(struct _cef_browser_host_t* self,
|
||||
const cef_string_t* word);
|
||||
|
||||
///
|
||||
/// Returns true (1) if window rendering is disabled.
|
||||
///
|
||||
int(CEF_CALLBACK* is_window_rendering_disabled)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Notify the browser that the widget has been resized. The browser will
|
||||
/// first call cef_render_handler_t::GetViewRect to get the new size and then
|
||||
/// call cef_render_handler_t::OnPaint asynchronously with the updated
|
||||
/// regions. This function is only used when window rendering is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* was_resized)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Notify the browser that it has been hidden or shown. Layouting and
|
||||
/// cef_render_handler_t::OnPaint notification will stop when the browser is
|
||||
/// hidden. This function is only used when window rendering is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* was_hidden)(struct _cef_browser_host_t* self, int hidden);
|
||||
|
||||
///
|
||||
/// Send a notification to the browser that the screen info has changed. The
|
||||
/// browser will then call cef_render_handler_t::GetScreenInfo to update the
|
||||
/// screen information with the new values. This simulates moving the webview
|
||||
/// window from one display to another, or changing the properties of the
|
||||
/// current display. This function is only used when window rendering is
|
||||
/// disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* notify_screen_info_changed)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Invalidate the view. The browser will call cef_render_handler_t::OnPaint
|
||||
/// asynchronously. This function is only used when window rendering is
|
||||
/// disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* invalidate)(struct _cef_browser_host_t* self,
|
||||
cef_paint_element_type_t type);
|
||||
|
||||
///
|
||||
/// Issue a BeginFrame request to Chromium. Only valid when
|
||||
/// cef_window_tInfo::external_begin_frame_enabled is set to true (1).
|
||||
///
|
||||
void(CEF_CALLBACK* send_external_begin_frame)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Send a key event to the browser.
|
||||
///
|
||||
void(CEF_CALLBACK* send_key_event)(struct _cef_browser_host_t* self,
|
||||
const cef_key_event_t* event);
|
||||
|
||||
///
|
||||
/// Send a mouse click event to the browser. The |x| and |y| coordinates are
|
||||
/// relative to the upper-left corner of the view.
|
||||
///
|
||||
void(CEF_CALLBACK* send_mouse_click_event)(struct _cef_browser_host_t* self,
|
||||
const cef_mouse_event_t* event,
|
||||
cef_mouse_button_type_t type,
|
||||
int mouseUp,
|
||||
int clickCount);
|
||||
|
||||
///
|
||||
/// Send a mouse move event to the browser. The |x| and |y| coordinates are
|
||||
/// relative to the upper-left corner of the view.
|
||||
///
|
||||
void(CEF_CALLBACK* send_mouse_move_event)(struct _cef_browser_host_t* self,
|
||||
const cef_mouse_event_t* event,
|
||||
int mouseLeave);
|
||||
|
||||
///
|
||||
/// Send a mouse wheel event to the browser. The |x| and |y| coordinates are
|
||||
/// relative to the upper-left corner of the view. The |deltaX| and |deltaY|
|
||||
/// values represent the movement delta in the X and Y directions
|
||||
/// respectively. In order to scroll inside select popups with window
|
||||
/// rendering disabled cef_render_handler_t::GetScreenPoint should be
|
||||
/// implemented properly.
|
||||
///
|
||||
void(CEF_CALLBACK* send_mouse_wheel_event)(struct _cef_browser_host_t* self,
|
||||
const cef_mouse_event_t* event,
|
||||
int deltaX,
|
||||
int deltaY);
|
||||
|
||||
///
|
||||
/// Send a touch event to the browser for a windowless browser.
|
||||
///
|
||||
void(CEF_CALLBACK* send_touch_event)(struct _cef_browser_host_t* self,
|
||||
const cef_touch_event_t* event);
|
||||
|
||||
///
|
||||
/// Send a capture lost event to the browser.
|
||||
///
|
||||
void(CEF_CALLBACK* send_capture_lost_event)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Notify the browser that the window hosting it is about to be moved or
|
||||
/// resized. This function is only used on Windows and Linux.
|
||||
///
|
||||
void(CEF_CALLBACK* notify_move_or_resize_started)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Returns the maximum rate in frames per second (fps) that
|
||||
/// cef_render_handler_t::OnPaint will be called for a windowless browser. The
|
||||
/// actual fps may be lower if the browser cannot generate frames at the
|
||||
/// requested rate. The minimum value is 1 and the maximum value is 60
|
||||
/// (default 30). This function can only be called on the UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* get_windowless_frame_rate)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Set the maximum rate in frames per second (fps) that
|
||||
/// cef_render_handler_t:: OnPaint will be called for a windowless browser.
|
||||
/// The actual fps may be lower if the browser cannot generate frames at the
|
||||
/// requested rate. The minimum value is 1 and the maximum value is 60
|
||||
/// (default 30). Can also be set at browser creation via
|
||||
/// cef_browser_tSettings.windowless_frame_rate.
|
||||
///
|
||||
void(CEF_CALLBACK* set_windowless_frame_rate)(
|
||||
struct _cef_browser_host_t* self,
|
||||
int frame_rate);
|
||||
|
||||
///
|
||||
/// Begins a new composition or updates the existing composition. Blink has a
|
||||
/// special node (a composition node) that allows the input function to change
|
||||
/// text without affecting other DOM nodes. |text| is the optional text that
|
||||
/// will be inserted into the composition node. |underlines| is an optional
|
||||
/// set of ranges that will be underlined in the resulting text.
|
||||
/// |replacement_range| is an optional range of the existing text that will be
|
||||
/// replaced. |selection_range| is an optional range of the resulting text
|
||||
/// that will be selected after insertion or replacement. The
|
||||
/// |replacement_range| value is only used on OS X.
|
||||
///
|
||||
/// This function may be called multiple times as the composition changes.
|
||||
/// When the client is done making changes the composition should either be
|
||||
/// canceled or completed. To cancel the composition call
|
||||
/// ImeCancelComposition. To complete the composition call either
|
||||
/// ImeCommitText or ImeFinishComposingText. Completion is usually signaled
|
||||
/// when:
|
||||
///
|
||||
/// 1. The client receives a WM_IME_COMPOSITION message with a GCS_RESULTSTR
|
||||
/// flag (on Windows), or;
|
||||
/// 2. The client receives a "commit" signal of GtkIMContext (on Linux), or;
|
||||
/// 3. insertText of NSTextInput is called (on Mac).
|
||||
///
|
||||
/// This function is only used when window rendering is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* ime_set_composition)(
|
||||
struct _cef_browser_host_t* self,
|
||||
const cef_string_t* text,
|
||||
size_t underlinesCount,
|
||||
cef_composition_underline_t const* underlines,
|
||||
const cef_range_t* replacement_range,
|
||||
const cef_range_t* selection_range);
|
||||
|
||||
///
|
||||
/// Completes the existing composition by optionally inserting the specified
|
||||
/// |text| into the composition node. |replacement_range| is an optional range
|
||||
/// of the existing text that will be replaced. |relative_cursor_pos| is where
|
||||
/// the cursor will be positioned relative to the current cursor position. See
|
||||
/// comments on ImeSetComposition for usage. The |replacement_range| and
|
||||
/// |relative_cursor_pos| values are only used on OS X. This function is only
|
||||
/// used when window rendering is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* ime_commit_text)(struct _cef_browser_host_t* self,
|
||||
const cef_string_t* text,
|
||||
const cef_range_t* replacement_range,
|
||||
int relative_cursor_pos);
|
||||
|
||||
///
|
||||
/// Completes the existing composition by applying the current composition
|
||||
/// node contents. If |keep_selection| is false (0) the current selection, if
|
||||
/// any, will be discarded. See comments on ImeSetComposition for usage. This
|
||||
/// function is only used when window rendering is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* ime_finish_composing_text)(
|
||||
struct _cef_browser_host_t* self,
|
||||
int keep_selection);
|
||||
|
||||
///
|
||||
/// Cancels the existing composition and discards the composition node
|
||||
/// contents without applying them. See comments on ImeSetComposition for
|
||||
/// usage. This function is only used when window rendering is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* ime_cancel_composition)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Call this function when the user drags the mouse into the web view (before
|
||||
/// calling DragTargetDragOver/DragTargetLeave/DragTargetDrop). |drag_data|
|
||||
/// should not contain file contents as this type of data is not allowed to be
|
||||
/// dragged into the web view. File contents can be removed using
|
||||
/// cef_drag_data_t::ResetFileContents (for example, if |drag_data| comes from
|
||||
/// cef_render_handler_t::StartDragging). This function is only used when
|
||||
/// window rendering is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* drag_target_drag_enter)(
|
||||
struct _cef_browser_host_t* self,
|
||||
struct _cef_drag_data_t* drag_data,
|
||||
const cef_mouse_event_t* event,
|
||||
cef_drag_operations_mask_t allowed_ops);
|
||||
|
||||
///
|
||||
/// Call this function each time the mouse is moved across the web view during
|
||||
/// a drag operation (after calling DragTargetDragEnter and before calling
|
||||
/// DragTargetDragLeave/DragTargetDrop). This function is only used when
|
||||
/// window rendering is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* drag_target_drag_over)(
|
||||
struct _cef_browser_host_t* self,
|
||||
const cef_mouse_event_t* event,
|
||||
cef_drag_operations_mask_t allowed_ops);
|
||||
|
||||
///
|
||||
/// Call this function when the user drags the mouse out of the web view
|
||||
/// (after calling DragTargetDragEnter). This function is only used when
|
||||
/// window rendering is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* drag_target_drag_leave)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Call this function when the user completes the drag operation by dropping
|
||||
/// the object onto the web view (after calling DragTargetDragEnter). The
|
||||
/// object being dropped is |drag_data|, given as an argument to the previous
|
||||
/// DragTargetDragEnter call. This function is only used when window rendering
|
||||
/// is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* drag_target_drop)(struct _cef_browser_host_t* self,
|
||||
const cef_mouse_event_t* event);
|
||||
|
||||
///
|
||||
/// Call this function when the drag operation started by a
|
||||
/// cef_render_handler_t::StartDragging call has ended either in a drop or by
|
||||
/// being cancelled. |x| and |y| are mouse coordinates relative to the upper-
|
||||
/// left corner of the view. If the web view is both the drag source and the
|
||||
/// drag target then all DragTarget* functions should be called before
|
||||
/// DragSource* mthods. This function is only used when window rendering is
|
||||
/// disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* drag_source_ended_at)(struct _cef_browser_host_t* self,
|
||||
int x,
|
||||
int y,
|
||||
cef_drag_operations_mask_t op);
|
||||
|
||||
///
|
||||
/// Call this function when the drag operation started by a
|
||||
/// cef_render_handler_t::StartDragging call has completed. This function may
|
||||
/// be called immediately without first calling DragSourceEndedAt to cancel a
|
||||
/// drag operation. If the web view is both the drag source and the drag
|
||||
/// target then all DragTarget* functions should be called before DragSource*
|
||||
/// mthods. This function is only used when window rendering is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* drag_source_system_drag_ended)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Returns the current visible navigation entry for this browser. This
|
||||
/// function can only be called on the UI thread.
|
||||
///
|
||||
struct _cef_navigation_entry_t*(CEF_CALLBACK* get_visible_navigation_entry)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Set accessibility state for all frames. |accessibility_state| may be
|
||||
/// default, enabled or disabled. If |accessibility_state| is STATE_DEFAULT
|
||||
/// then accessibility will be disabled by default and the state may be
|
||||
/// further controlled with the "force-renderer-accessibility" and "disable-
|
||||
/// renderer-accessibility" command-line switches. If |accessibility_state| is
|
||||
/// STATE_ENABLED then accessibility will be enabled. If |accessibility_state|
|
||||
/// is STATE_DISABLED then accessibility will be completely disabled.
|
||||
///
|
||||
/// For windowed browsers accessibility will be enabled in Complete mode
|
||||
/// (which corresponds to kAccessibilityModeComplete in Chromium). In this
|
||||
/// mode all platform accessibility objects will be created and managed by
|
||||
/// Chromium's internal implementation. The client needs only to detect the
|
||||
/// screen reader and call this function appropriately. For example, on macOS
|
||||
/// the client can handle the @"AXEnhancedUserStructure" accessibility
|
||||
/// attribute to detect VoiceOver state changes and on Windows the client can
|
||||
/// handle WM_GETOBJECT with OBJID_CLIENT to detect accessibility readers.
|
||||
///
|
||||
/// For windowless browsers accessibility will be enabled in TreeOnly mode
|
||||
/// (which corresponds to kAccessibilityModeWebContentsOnly in Chromium). In
|
||||
/// this mode renderer accessibility is enabled, the full tree is computed,
|
||||
/// and events are passed to CefAccessibiltyHandler, but platform
|
||||
/// accessibility objects are not created. The client may implement platform
|
||||
/// accessibility objects using CefAccessibiltyHandler callbacks if desired.
|
||||
///
|
||||
void(CEF_CALLBACK* set_accessibility_state)(struct _cef_browser_host_t* self,
|
||||
cef_state_t accessibility_state);
|
||||
|
||||
///
|
||||
/// Enable notifications of auto resize via
|
||||
/// cef_display_handler_t::OnAutoResize. Notifications are disabled by
|
||||
/// default. |min_size| and |max_size| define the range of allowed sizes.
|
||||
///
|
||||
void(CEF_CALLBACK* set_auto_resize_enabled)(struct _cef_browser_host_t* self,
|
||||
int enabled,
|
||||
const cef_size_t* min_size,
|
||||
const cef_size_t* max_size);
|
||||
|
||||
///
|
||||
/// Returns the extension hosted in this browser or NULL if no extension is
|
||||
/// hosted. See cef_request_context_t::LoadExtension for details.
|
||||
///
|
||||
struct _cef_extension_t*(CEF_CALLBACK* get_extension)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if this browser is hosting an extension background
|
||||
/// script. Background hosts do not have a window and are not displayable. See
|
||||
/// cef_request_context_t::LoadExtension for details.
|
||||
///
|
||||
int(CEF_CALLBACK* is_background_host)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Set whether the browser's audio is muted.
|
||||
///
|
||||
void(CEF_CALLBACK* set_audio_muted)(struct _cef_browser_host_t* self,
|
||||
int mute);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the browser's audio is muted. This function can only
|
||||
/// be called on the UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* is_audio_muted)(struct _cef_browser_host_t* self);
|
||||
} cef_browser_host_t;
|
||||
|
||||
///
|
||||
/// Create a new browser using the window parameters specified by |windowInfo|.
|
||||
/// All values will be copied internally and the actual window (if any) will be
|
||||
/// created on the UI thread. If |request_context| is NULL the global request
|
||||
/// context will be used. This function can be called on any browser process
|
||||
/// thread and will not block. The optional |extra_info| parameter provides an
|
||||
/// opportunity to specify extra information specific to the created browser
|
||||
/// that will be passed to cef_render_process_handler_t::on_browser_created() in
|
||||
/// the render process.
|
||||
///
|
||||
CEF_EXPORT int cef_browser_host_create_browser(
|
||||
const cef_window_info_t* windowInfo,
|
||||
struct _cef_client_t* client,
|
||||
const cef_string_t* url,
|
||||
const struct _cef_browser_settings_t* settings,
|
||||
struct _cef_dictionary_value_t* extra_info,
|
||||
struct _cef_request_context_t* request_context);
|
||||
|
||||
///
|
||||
/// Create a new browser using the window parameters specified by |windowInfo|.
|
||||
/// If |request_context| is NULL the global request context will be used. This
|
||||
/// function can only be called on the browser process UI thread. The optional
|
||||
/// |extra_info| parameter provides an opportunity to specify extra information
|
||||
/// specific to the created browser that will be passed to
|
||||
/// cef_render_process_handler_t::on_browser_created() in the render process.
|
||||
///
|
||||
CEF_EXPORT cef_browser_t* cef_browser_host_create_browser_sync(
|
||||
const cef_window_info_t* windowInfo,
|
||||
struct _cef_client_t* client,
|
||||
const cef_string_t* url,
|
||||
const struct _cef_browser_settings_t* settings,
|
||||
struct _cef_dictionary_value_t* extra_info,
|
||||
struct _cef_request_context_t* request_context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
|
||||
141
third/cef/include/capi/cef_browser_process_handler_capi.h
Normal file
141
third/cef/include/capi/cef_browser_process_handler_capi.h
Normal file
@@ -0,0 +1,141 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=4ef8b73a5218531b370fdd76c23153a1f83b7f7b$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_client_capi.h"
|
||||
#include "include/capi/cef_command_line_capi.h"
|
||||
#include "include/capi/cef_preference_capi.h"
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Structure used to implement browser process callbacks. The functions of this
|
||||
/// structure will be called on the browser process main thread unless otherwise
|
||||
/// indicated.
|
||||
///
|
||||
typedef struct _cef_browser_process_handler_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Provides an opportunity to register custom preferences prior to global and
|
||||
/// request context initialization.
|
||||
///
|
||||
/// If |type| is CEF_PREFERENCES_TYPE_GLOBAL the registered preferences can be
|
||||
/// accessed via cef_preference_manager_t::GetGlobalPreferences after
|
||||
/// OnContextInitialized is called. Global preferences are registered a single
|
||||
/// time at application startup. See related cef_settings_t.cache_path and
|
||||
/// cef_settings_t.persist_user_preferences configuration.
|
||||
///
|
||||
/// If |type| is CEF_PREFERENCES_TYPE_REQUEST_CONTEXT the preferences can be
|
||||
/// accessed via the cef_request_context_t after
|
||||
/// cef_request_context_handler_t::OnRequestContextInitialized is called.
|
||||
/// Request context preferences are registered each time a new
|
||||
/// cef_request_context_t is created. It is intended but not required that all
|
||||
/// request contexts have the same registered preferences. See related
|
||||
/// cef_request_context_settings_t.cache_path and
|
||||
/// cef_request_context_settings_t.persist_user_preferences configuration.
|
||||
///
|
||||
/// Do not keep a reference to the |registrar| object. This function is called
|
||||
/// on the browser process UI thread.
|
||||
///
|
||||
void(CEF_CALLBACK* on_register_custom_preferences)(
|
||||
struct _cef_browser_process_handler_t* self,
|
||||
cef_preferences_type_t type,
|
||||
struct _cef_preference_registrar_t* registrar);
|
||||
|
||||
///
|
||||
/// Called on the browser process UI thread immediately after the CEF context
|
||||
/// has been initialized.
|
||||
///
|
||||
void(CEF_CALLBACK* on_context_initialized)(
|
||||
struct _cef_browser_process_handler_t* self);
|
||||
|
||||
///
|
||||
/// Called before a child process is launched. Will be called on the browser
|
||||
/// process UI thread when launching a render process and on the browser
|
||||
/// process IO thread when launching a GPU process. Provides an opportunity to
|
||||
/// modify the child process command line. Do not keep a reference to
|
||||
/// |command_line| outside of this function.
|
||||
///
|
||||
void(CEF_CALLBACK* on_before_child_process_launch)(
|
||||
struct _cef_browser_process_handler_t* self,
|
||||
struct _cef_command_line_t* command_line);
|
||||
|
||||
///
|
||||
/// Called from any thread when work has been scheduled for the browser
|
||||
/// process main (UI) thread. This callback is used in combination with
|
||||
/// cef_settings_t.external_message_pump and cef_do_message_loop_work() in
|
||||
/// cases where the CEF message loop must be integrated into an existing
|
||||
/// application message loop (see additional comments and warnings on
|
||||
/// CefDoMessageLoopWork). This callback should schedule a
|
||||
/// cef_do_message_loop_work() call to happen on the main (UI) thread.
|
||||
/// |delay_ms| is the requested delay in milliseconds. If |delay_ms| is <= 0
|
||||
/// then the call should happen reasonably soon. If |delay_ms| is > 0 then the
|
||||
/// call should be scheduled to happen after the specified delay and any
|
||||
/// currently pending scheduled call should be cancelled.
|
||||
///
|
||||
void(CEF_CALLBACK* on_schedule_message_pump_work)(
|
||||
struct _cef_browser_process_handler_t* self,
|
||||
int64 delay_ms);
|
||||
|
||||
///
|
||||
/// Return the default client for use with a newly created browser window. If
|
||||
/// null is returned the browser will be unmanaged (no callbacks will be
|
||||
/// executed for that browser) and application shutdown will be blocked until
|
||||
/// the browser window is closed manually. This function is currently only
|
||||
/// used with the chrome runtime.
|
||||
///
|
||||
struct _cef_client_t*(CEF_CALLBACK* get_default_client)(
|
||||
struct _cef_browser_process_handler_t* self);
|
||||
} cef_browser_process_handler_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
||||
88
third/cef/include/capi/cef_callback_capi.h
Normal file
88
third/cef/include/capi/cef_callback_capi.h
Normal file
@@ -0,0 +1,88 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=4fd98ff68ecb42677c3344b75e26d4787161b0d2$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_CALLBACK_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_CALLBACK_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Generic callback structure used for asynchronous continuation.
|
||||
///
|
||||
typedef struct _cef_callback_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Continue processing.
|
||||
///
|
||||
void(CEF_CALLBACK* cont)(struct _cef_callback_t* self);
|
||||
|
||||
///
|
||||
/// Cancel processing.
|
||||
///
|
||||
void(CEF_CALLBACK* cancel)(struct _cef_callback_t* self);
|
||||
} cef_callback_t;
|
||||
|
||||
///
|
||||
/// Generic callback structure used for asynchronous completion.
|
||||
///
|
||||
typedef struct _cef_completion_callback_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Method that will be called once the task is complete.
|
||||
///
|
||||
void(CEF_CALLBACK* on_complete)(struct _cef_completion_callback_t* self);
|
||||
} cef_completion_callback_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_CALLBACK_CAPI_H_
|
||||
210
third/cef/include/capi/cef_client_capi.h
Normal file
210
third/cef/include/capi/cef_client_capi.h
Normal file
@@ -0,0 +1,210 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=eb9dcb574252483dfab12834af93ba14138d4089$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_audio_handler_capi.h"
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_command_handler_capi.h"
|
||||
#include "include/capi/cef_context_menu_handler_capi.h"
|
||||
#include "include/capi/cef_dialog_handler_capi.h"
|
||||
#include "include/capi/cef_display_handler_capi.h"
|
||||
#include "include/capi/cef_download_handler_capi.h"
|
||||
#include "include/capi/cef_drag_handler_capi.h"
|
||||
#include "include/capi/cef_find_handler_capi.h"
|
||||
#include "include/capi/cef_focus_handler_capi.h"
|
||||
#include "include/capi/cef_frame_handler_capi.h"
|
||||
#include "include/capi/cef_jsdialog_handler_capi.h"
|
||||
#include "include/capi/cef_keyboard_handler_capi.h"
|
||||
#include "include/capi/cef_life_span_handler_capi.h"
|
||||
#include "include/capi/cef_load_handler_capi.h"
|
||||
#include "include/capi/cef_permission_handler_capi.h"
|
||||
#include "include/capi/cef_print_handler_capi.h"
|
||||
#include "include/capi/cef_process_message_capi.h"
|
||||
#include "include/capi/cef_render_handler_capi.h"
|
||||
#include "include/capi/cef_request_handler_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Implement this structure to provide handler implementations.
|
||||
///
|
||||
typedef struct _cef_client_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Return the handler for audio rendering events.
|
||||
///
|
||||
struct _cef_audio_handler_t*(CEF_CALLBACK* get_audio_handler)(
|
||||
struct _cef_client_t* self);
|
||||
|
||||
///
|
||||
/// Return the handler for commands. If no handler is provided the default
|
||||
/// implementation will be used.
|
||||
///
|
||||
struct _cef_command_handler_t*(CEF_CALLBACK* get_command_handler)(
|
||||
struct _cef_client_t* self);
|
||||
|
||||
///
|
||||
/// Return the handler for context menus. If no handler is provided the
|
||||
/// default implementation will be used.
|
||||
///
|
||||
struct _cef_context_menu_handler_t*(CEF_CALLBACK* get_context_menu_handler)(
|
||||
struct _cef_client_t* self);
|
||||
|
||||
///
|
||||
/// Return the handler for dialogs. If no handler is provided the default
|
||||
/// implementation will be used.
|
||||
///
|
||||
struct _cef_dialog_handler_t*(CEF_CALLBACK* get_dialog_handler)(
|
||||
struct _cef_client_t* self);
|
||||
|
||||
///
|
||||
/// Return the handler for browser display state events.
|
||||
///
|
||||
struct _cef_display_handler_t*(CEF_CALLBACK* get_display_handler)(
|
||||
struct _cef_client_t* self);
|
||||
|
||||
///
|
||||
/// Return the handler for download events. If no handler is returned
|
||||
/// downloads will not be allowed.
|
||||
///
|
||||
struct _cef_download_handler_t*(CEF_CALLBACK* get_download_handler)(
|
||||
struct _cef_client_t* self);
|
||||
|
||||
///
|
||||
/// Return the handler for drag events.
|
||||
///
|
||||
struct _cef_drag_handler_t*(CEF_CALLBACK* get_drag_handler)(
|
||||
struct _cef_client_t* self);
|
||||
|
||||
///
|
||||
/// Return the handler for find result events.
|
||||
///
|
||||
struct _cef_find_handler_t*(CEF_CALLBACK* get_find_handler)(
|
||||
struct _cef_client_t* self);
|
||||
|
||||
///
|
||||
/// Return the handler for focus events.
|
||||
///
|
||||
struct _cef_focus_handler_t*(CEF_CALLBACK* get_focus_handler)(
|
||||
struct _cef_client_t* self);
|
||||
|
||||
///
|
||||
/// Return the handler for events related to cef_frame_t lifespan. This
|
||||
/// function will be called once during cef_browser_t creation and the result
|
||||
/// will be cached for performance reasons.
|
||||
///
|
||||
struct _cef_frame_handler_t*(CEF_CALLBACK* get_frame_handler)(
|
||||
struct _cef_client_t* self);
|
||||
|
||||
///
|
||||
/// Return the handler for permission requests.
|
||||
///
|
||||
struct _cef_permission_handler_t*(CEF_CALLBACK* get_permission_handler)(
|
||||
struct _cef_client_t* self);
|
||||
|
||||
///
|
||||
/// Return the handler for JavaScript dialogs. If no handler is provided the
|
||||
/// default implementation will be used.
|
||||
///
|
||||
struct _cef_jsdialog_handler_t*(CEF_CALLBACK* get_jsdialog_handler)(
|
||||
struct _cef_client_t* self);
|
||||
|
||||
///
|
||||
/// Return the handler for keyboard events.
|
||||
///
|
||||
struct _cef_keyboard_handler_t*(CEF_CALLBACK* get_keyboard_handler)(
|
||||
struct _cef_client_t* self);
|
||||
|
||||
///
|
||||
/// Return the handler for browser life span events.
|
||||
///
|
||||
struct _cef_life_span_handler_t*(CEF_CALLBACK* get_life_span_handler)(
|
||||
struct _cef_client_t* self);
|
||||
|
||||
///
|
||||
/// Return the handler for browser load status events.
|
||||
///
|
||||
struct _cef_load_handler_t*(CEF_CALLBACK* get_load_handler)(
|
||||
struct _cef_client_t* self);
|
||||
|
||||
///
|
||||
/// Return the handler for printing on Linux. If a print handler is not
|
||||
/// provided then printing will not be supported on the Linux platform.
|
||||
///
|
||||
struct _cef_print_handler_t*(CEF_CALLBACK* get_print_handler)(
|
||||
struct _cef_client_t* self);
|
||||
|
||||
///
|
||||
/// Return the handler for off-screen rendering events.
|
||||
///
|
||||
struct _cef_render_handler_t*(CEF_CALLBACK* get_render_handler)(
|
||||
struct _cef_client_t* self);
|
||||
|
||||
///
|
||||
/// Return the handler for browser request events.
|
||||
///
|
||||
struct _cef_request_handler_t*(CEF_CALLBACK* get_request_handler)(
|
||||
struct _cef_client_t* self);
|
||||
|
||||
///
|
||||
/// Called when a new message is received from a different process. Return
|
||||
/// true (1) if the message was handled or false (0) otherwise. It is safe to
|
||||
/// keep a reference to |message| outside of this callback.
|
||||
///
|
||||
int(CEF_CALLBACK* on_process_message_received)(
|
||||
struct _cef_client_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame,
|
||||
cef_process_id_t source_process,
|
||||
struct _cef_process_message_t* message);
|
||||
} cef_client_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
|
||||
120
third/cef/include/capi/cef_command_handler_capi.h
Normal file
120
third/cef/include/capi/cef_command_handler_capi.h
Normal file
@@ -0,0 +1,120 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=0cbb756a64d2aca1075480b5188b36cae533864d$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_COMMAND_HANDLER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_COMMAND_HANDLER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Implement this structure to handle events related to commands. The functions
|
||||
/// of this structure will be called on the UI thread.
|
||||
///
|
||||
typedef struct _cef_command_handler_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Called to execute a Chrome command triggered via menu selection or
|
||||
/// keyboard shortcut. Values for |command_id| can be found in the
|
||||
/// cef_command_ids.h file. |disposition| provides information about the
|
||||
/// intended command target. Return true (1) if the command was handled or
|
||||
/// false (0) for the default implementation. For context menu commands this
|
||||
/// will be called after cef_context_menu_handler_t::OnContextMenuCommand.
|
||||
/// Only used with the Chrome runtime.
|
||||
///
|
||||
int(CEF_CALLBACK* on_chrome_command)(
|
||||
struct _cef_command_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
int command_id,
|
||||
cef_window_open_disposition_t disposition);
|
||||
|
||||
///
|
||||
/// Called to check if a Chrome app menu item should be visible. Values for
|
||||
/// |command_id| can be found in the cef_command_ids.h file. Only called for
|
||||
/// menu items that would be visible by default. Only used with the Chrome
|
||||
/// runtime.
|
||||
///
|
||||
int(CEF_CALLBACK* is_chrome_app_menu_item_visible)(
|
||||
struct _cef_command_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
int command_id);
|
||||
|
||||
///
|
||||
/// Called to check if a Chrome app menu item should be enabled. Values for
|
||||
/// |command_id| can be found in the cef_command_ids.h file. Only called for
|
||||
/// menu items that would be enabled by default. Only used with the Chrome
|
||||
/// runtime.
|
||||
///
|
||||
int(CEF_CALLBACK* is_chrome_app_menu_item_enabled)(
|
||||
struct _cef_command_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
int command_id);
|
||||
|
||||
///
|
||||
/// Called during browser creation to check if a Chrome page action icon
|
||||
/// should be visible. Only called for icons that would be visible by default.
|
||||
/// Only used with the Chrome runtime.
|
||||
///
|
||||
int(CEF_CALLBACK* is_chrome_page_action_icon_visible)(
|
||||
struct _cef_command_handler_t* self,
|
||||
cef_chrome_page_action_icon_type_t icon_type);
|
||||
|
||||
///
|
||||
/// Called during browser creation to check if a Chrome toolbar button should
|
||||
/// be visible. Only called for buttons that would be visible by default. Only
|
||||
/// used with the Chrome runtime.
|
||||
///
|
||||
int(CEF_CALLBACK* is_chrome_toolbar_button_visible)(
|
||||
struct _cef_command_handler_t* self,
|
||||
cef_chrome_toolbar_button_type_t button_type);
|
||||
} cef_command_handler_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_COMMAND_HANDLER_CAPI_H_
|
||||
215
third/cef/include/capi/cef_command_line_capi.h
Normal file
215
third/cef/include/capi/cef_command_line_capi.h
Normal file
@@ -0,0 +1,215 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=ac8fd3a7da20cff1fe2f20a75b045bf27c0312f2$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_COMMAND_LINE_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_COMMAND_LINE_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Structure used to create and/or parse command line arguments. Arguments with
|
||||
/// "--", "-" and, on Windows, "/" prefixes are considered switches. Switches
|
||||
/// will always precede any arguments without switch prefixes. Switches can
|
||||
/// optionally have a value specified using the "=" delimiter (e.g.
|
||||
/// "-switch=value"). An argument of "--" will terminate switch parsing with all
|
||||
/// subsequent tokens, regardless of prefix, being interpreted as non-switch
|
||||
/// arguments. Switch names should be lowercase ASCII and will be converted to
|
||||
/// such if necessary. Switch values will retain the original case and UTF8
|
||||
/// encoding. This structure can be used before cef_initialize() is called.
|
||||
///
|
||||
typedef struct _cef_command_line_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Returns true (1) if this object is valid. Do not call any other functions
|
||||
/// if this function returns false (0).
|
||||
///
|
||||
int(CEF_CALLBACK* is_valid)(struct _cef_command_line_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the values of this object are read-only. Some APIs may
|
||||
/// expose read-only objects.
|
||||
///
|
||||
int(CEF_CALLBACK* is_read_only)(struct _cef_command_line_t* self);
|
||||
|
||||
///
|
||||
/// Returns a writable copy of this object.
|
||||
///
|
||||
struct _cef_command_line_t*(CEF_CALLBACK* copy)(
|
||||
struct _cef_command_line_t* self);
|
||||
|
||||
///
|
||||
/// Initialize the command line with the specified |argc| and |argv| values.
|
||||
/// The first argument must be the name of the program. This function is only
|
||||
/// supported on non-Windows platforms.
|
||||
///
|
||||
void(CEF_CALLBACK* init_from_argv)(struct _cef_command_line_t* self,
|
||||
int argc,
|
||||
const char* const* argv);
|
||||
|
||||
///
|
||||
/// Initialize the command line with the string returned by calling
|
||||
/// GetCommandLineW(). This function is only supported on Windows.
|
||||
///
|
||||
void(CEF_CALLBACK* init_from_string)(struct _cef_command_line_t* self,
|
||||
const cef_string_t* command_line);
|
||||
|
||||
///
|
||||
/// Reset the command-line switches and arguments but leave the program
|
||||
/// component unchanged.
|
||||
///
|
||||
void(CEF_CALLBACK* reset)(struct _cef_command_line_t* self);
|
||||
|
||||
///
|
||||
/// Retrieve the original command line string as a vector of strings. The argv
|
||||
/// array: `{ program, [(--|-|/)switch[=value]]*, [--], [argument]* }`
|
||||
///
|
||||
void(CEF_CALLBACK* get_argv)(struct _cef_command_line_t* self,
|
||||
cef_string_list_t argv);
|
||||
|
||||
///
|
||||
/// Constructs and returns the represented command line string. Use this
|
||||
/// function cautiously because quoting behavior is unclear.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_command_line_string)(
|
||||
struct _cef_command_line_t* self);
|
||||
|
||||
///
|
||||
/// Get the program part of the command line string (the first item).
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_program)(
|
||||
struct _cef_command_line_t* self);
|
||||
|
||||
///
|
||||
/// Set the program part of the command line string (the first item).
|
||||
///
|
||||
void(CEF_CALLBACK* set_program)(struct _cef_command_line_t* self,
|
||||
const cef_string_t* program);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the command line has switches.
|
||||
///
|
||||
int(CEF_CALLBACK* has_switches)(struct _cef_command_line_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the command line contains the given switch.
|
||||
///
|
||||
int(CEF_CALLBACK* has_switch)(struct _cef_command_line_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Returns the value associated with the given switch. If the switch has no
|
||||
/// value or isn't present this function returns the NULL string.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_switch_value)(
|
||||
struct _cef_command_line_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Returns the map of switch names and values. If a switch has no value an
|
||||
/// NULL string is returned.
|
||||
///
|
||||
void(CEF_CALLBACK* get_switches)(struct _cef_command_line_t* self,
|
||||
cef_string_map_t switches);
|
||||
|
||||
///
|
||||
/// Add a switch to the end of the command line.
|
||||
///
|
||||
void(CEF_CALLBACK* append_switch)(struct _cef_command_line_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Add a switch with the specified value to the end of the command line. If
|
||||
/// the switch has no value pass an NULL value string.
|
||||
///
|
||||
void(CEF_CALLBACK* append_switch_with_value)(struct _cef_command_line_t* self,
|
||||
const cef_string_t* name,
|
||||
const cef_string_t* value);
|
||||
|
||||
///
|
||||
/// True if there are remaining command line arguments.
|
||||
///
|
||||
int(CEF_CALLBACK* has_arguments)(struct _cef_command_line_t* self);
|
||||
|
||||
///
|
||||
/// Get the remaining command line arguments.
|
||||
///
|
||||
void(CEF_CALLBACK* get_arguments)(struct _cef_command_line_t* self,
|
||||
cef_string_list_t arguments);
|
||||
|
||||
///
|
||||
/// Add an argument to the end of the command line.
|
||||
///
|
||||
void(CEF_CALLBACK* append_argument)(struct _cef_command_line_t* self,
|
||||
const cef_string_t* argument);
|
||||
|
||||
///
|
||||
/// Insert a command before the current command. Common for debuggers, like
|
||||
/// "valgrind" or "gdb --args".
|
||||
///
|
||||
void(CEF_CALLBACK* prepend_wrapper)(struct _cef_command_line_t* self,
|
||||
const cef_string_t* wrapper);
|
||||
} cef_command_line_t;
|
||||
|
||||
///
|
||||
/// Create a new cef_command_line_t instance.
|
||||
///
|
||||
CEF_EXPORT cef_command_line_t* cef_command_line_create(void);
|
||||
|
||||
///
|
||||
/// Returns the singleton global cef_command_line_t object. The returned object
|
||||
/// will be read-only.
|
||||
///
|
||||
CEF_EXPORT cef_command_line_t* cef_command_line_get_global(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_COMMAND_LINE_CAPI_H_
|
||||
367
third/cef/include/capi/cef_context_menu_handler_capi.h
Normal file
367
third/cef/include/capi/cef_context_menu_handler_capi.h
Normal file
@@ -0,0 +1,367 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=c82f41d81f5afa5ed6995693e012c13d2a609f88$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
#include "include/capi/cef_frame_capi.h"
|
||||
#include "include/capi/cef_menu_model_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _cef_context_menu_params_t;
|
||||
|
||||
///
|
||||
/// Callback structure used for continuation of custom context menu display.
|
||||
///
|
||||
typedef struct _cef_run_context_menu_callback_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Complete context menu display by selecting the specified |command_id| and
|
||||
/// |event_flags|.
|
||||
///
|
||||
void(CEF_CALLBACK* cont)(struct _cef_run_context_menu_callback_t* self,
|
||||
int command_id,
|
||||
cef_event_flags_t event_flags);
|
||||
|
||||
///
|
||||
/// Cancel context menu display.
|
||||
///
|
||||
void(CEF_CALLBACK* cancel)(struct _cef_run_context_menu_callback_t* self);
|
||||
} cef_run_context_menu_callback_t;
|
||||
|
||||
///
|
||||
/// Callback structure used for continuation of custom quick menu display.
|
||||
///
|
||||
typedef struct _cef_run_quick_menu_callback_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Complete quick menu display by selecting the specified |command_id| and
|
||||
/// |event_flags|.
|
||||
///
|
||||
void(CEF_CALLBACK* cont)(struct _cef_run_quick_menu_callback_t* self,
|
||||
int command_id,
|
||||
cef_event_flags_t event_flags);
|
||||
|
||||
///
|
||||
/// Cancel quick menu display.
|
||||
///
|
||||
void(CEF_CALLBACK* cancel)(struct _cef_run_quick_menu_callback_t* self);
|
||||
} cef_run_quick_menu_callback_t;
|
||||
|
||||
///
|
||||
/// Implement this structure to handle context menu events. The functions of
|
||||
/// this structure will be called on the UI thread.
|
||||
///
|
||||
typedef struct _cef_context_menu_handler_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Called before a context menu is displayed. |params| provides information
|
||||
/// about the context menu state. |model| initially contains the default
|
||||
/// context menu. The |model| can be cleared to show no context menu or
|
||||
/// modified to show a custom menu. Do not keep references to |params| or
|
||||
/// |model| outside of this callback.
|
||||
///
|
||||
void(CEF_CALLBACK* on_before_context_menu)(
|
||||
struct _cef_context_menu_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame,
|
||||
struct _cef_context_menu_params_t* params,
|
||||
struct _cef_menu_model_t* model);
|
||||
|
||||
///
|
||||
/// Called to allow custom display of the context menu. |params| provides
|
||||
/// information about the context menu state. |model| contains the context
|
||||
/// menu model resulting from OnBeforeContextMenu. For custom display return
|
||||
/// true (1) and execute |callback| either synchronously or asynchronously
|
||||
/// with the selected command ID. For default display return false (0). Do not
|
||||
/// keep references to |params| or |model| outside of this callback.
|
||||
///
|
||||
int(CEF_CALLBACK* run_context_menu)(
|
||||
struct _cef_context_menu_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame,
|
||||
struct _cef_context_menu_params_t* params,
|
||||
struct _cef_menu_model_t* model,
|
||||
struct _cef_run_context_menu_callback_t* callback);
|
||||
|
||||
///
|
||||
/// Called to execute a command selected from the context menu. Return true
|
||||
/// (1) if the command was handled or false (0) for the default
|
||||
/// implementation. See cef_menu_id_t for the command ids that have default
|
||||
/// implementations. All user-defined command ids should be between
|
||||
/// MENU_ID_USER_FIRST and MENU_ID_USER_LAST. |params| will have the same
|
||||
/// values as what was passed to on_before_context_menu(). Do not keep a
|
||||
/// reference to |params| outside of this callback.
|
||||
///
|
||||
int(CEF_CALLBACK* on_context_menu_command)(
|
||||
struct _cef_context_menu_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame,
|
||||
struct _cef_context_menu_params_t* params,
|
||||
int command_id,
|
||||
cef_event_flags_t event_flags);
|
||||
|
||||
///
|
||||
/// Called when the context menu is dismissed irregardless of whether the menu
|
||||
/// was canceled or a command was selected.
|
||||
///
|
||||
void(CEF_CALLBACK* on_context_menu_dismissed)(
|
||||
struct _cef_context_menu_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame);
|
||||
|
||||
///
|
||||
/// Called to allow custom display of the quick menu for a windowless browser.
|
||||
/// |location| is the top left corner of the selected region. |size| is the
|
||||
/// size of the selected region. |edit_state_flags| is a combination of flags
|
||||
/// that represent the state of the quick menu. Return true (1) if the menu
|
||||
/// will be handled and execute |callback| either synchronously or
|
||||
/// asynchronously with the selected command ID. Return false (0) to cancel
|
||||
/// the menu.
|
||||
///
|
||||
int(CEF_CALLBACK* run_quick_menu)(
|
||||
struct _cef_context_menu_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame,
|
||||
const cef_point_t* location,
|
||||
const cef_size_t* size,
|
||||
cef_quick_menu_edit_state_flags_t edit_state_flags,
|
||||
struct _cef_run_quick_menu_callback_t* callback);
|
||||
|
||||
///
|
||||
/// Called to execute a command selected from the quick menu for a windowless
|
||||
/// browser. Return true (1) if the command was handled or false (0) for the
|
||||
/// default implementation. See cef_menu_id_t for command IDs that have
|
||||
/// default implementations.
|
||||
///
|
||||
int(CEF_CALLBACK* on_quick_menu_command)(
|
||||
struct _cef_context_menu_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame,
|
||||
int command_id,
|
||||
cef_event_flags_t event_flags);
|
||||
|
||||
///
|
||||
/// Called when the quick menu for a windowless browser is dismissed
|
||||
/// irregardless of whether the menu was canceled or a command was selected.
|
||||
///
|
||||
void(CEF_CALLBACK* on_quick_menu_dismissed)(
|
||||
struct _cef_context_menu_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame);
|
||||
} cef_context_menu_handler_t;
|
||||
|
||||
///
|
||||
/// Provides information about the context menu state. The functions of this
|
||||
/// structure can only be accessed on browser process the UI thread.
|
||||
///
|
||||
typedef struct _cef_context_menu_params_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Returns the X coordinate of the mouse where the context menu was invoked.
|
||||
/// Coords are relative to the associated RenderView's origin.
|
||||
///
|
||||
int(CEF_CALLBACK* get_xcoord)(struct _cef_context_menu_params_t* self);
|
||||
|
||||
///
|
||||
/// Returns the Y coordinate of the mouse where the context menu was invoked.
|
||||
/// Coords are relative to the associated RenderView's origin.
|
||||
///
|
||||
int(CEF_CALLBACK* get_ycoord)(struct _cef_context_menu_params_t* self);
|
||||
|
||||
///
|
||||
/// Returns flags representing the type of node that the context menu was
|
||||
/// invoked on.
|
||||
///
|
||||
cef_context_menu_type_flags_t(CEF_CALLBACK* get_type_flags)(
|
||||
struct _cef_context_menu_params_t* self);
|
||||
|
||||
///
|
||||
/// Returns the URL of the link, if any, that encloses the node that the
|
||||
/// context menu was invoked on.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_link_url)(
|
||||
struct _cef_context_menu_params_t* self);
|
||||
|
||||
///
|
||||
/// Returns the link URL, if any, to be used ONLY for "copy link address". We
|
||||
/// don't validate this field in the frontend process.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_unfiltered_link_url)(
|
||||
struct _cef_context_menu_params_t* self);
|
||||
|
||||
///
|
||||
/// Returns the source URL, if any, for the element that the context menu was
|
||||
/// invoked on. Example of elements with source URLs are img, audio, and
|
||||
/// video.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_source_url)(
|
||||
struct _cef_context_menu_params_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the context menu was invoked on an image which has
|
||||
/// non-NULL contents.
|
||||
///
|
||||
int(CEF_CALLBACK* has_image_contents)(
|
||||
struct _cef_context_menu_params_t* self);
|
||||
|
||||
///
|
||||
/// Returns the title text or the alt text if the context menu was invoked on
|
||||
/// an image.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_title_text)(
|
||||
struct _cef_context_menu_params_t* self);
|
||||
|
||||
///
|
||||
/// Returns the URL of the top level page that the context menu was invoked
|
||||
/// on.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_page_url)(
|
||||
struct _cef_context_menu_params_t* self);
|
||||
|
||||
///
|
||||
/// Returns the URL of the subframe that the context menu was invoked on.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_frame_url)(
|
||||
struct _cef_context_menu_params_t* self);
|
||||
|
||||
///
|
||||
/// Returns the character encoding of the subframe that the context menu was
|
||||
/// invoked on.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_frame_charset)(
|
||||
struct _cef_context_menu_params_t* self);
|
||||
|
||||
///
|
||||
/// Returns the type of context node that the context menu was invoked on.
|
||||
///
|
||||
cef_context_menu_media_type_t(CEF_CALLBACK* get_media_type)(
|
||||
struct _cef_context_menu_params_t* self);
|
||||
|
||||
///
|
||||
/// Returns flags representing the actions supported by the media element, if
|
||||
/// any, that the context menu was invoked on.
|
||||
///
|
||||
cef_context_menu_media_state_flags_t(CEF_CALLBACK* get_media_state_flags)(
|
||||
struct _cef_context_menu_params_t* self);
|
||||
|
||||
///
|
||||
/// Returns the text of the selection, if any, that the context menu was
|
||||
/// invoked on.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_selection_text)(
|
||||
struct _cef_context_menu_params_t* self);
|
||||
|
||||
///
|
||||
/// Returns the text of the misspelled word, if any, that the context menu was
|
||||
/// invoked on.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_misspelled_word)(
|
||||
struct _cef_context_menu_params_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if suggestions exist, false (0) otherwise. Fills in
|
||||
/// |suggestions| from the spell check service for the misspelled word if
|
||||
/// there is one.
|
||||
///
|
||||
int(CEF_CALLBACK* get_dictionary_suggestions)(
|
||||
struct _cef_context_menu_params_t* self,
|
||||
cef_string_list_t suggestions);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the context menu was invoked on an editable node.
|
||||
///
|
||||
int(CEF_CALLBACK* is_editable)(struct _cef_context_menu_params_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the context menu was invoked on an editable node where
|
||||
/// spell-check is enabled.
|
||||
///
|
||||
int(CEF_CALLBACK* is_spell_check_enabled)(
|
||||
struct _cef_context_menu_params_t* self);
|
||||
|
||||
///
|
||||
/// Returns flags representing the actions supported by the editable node, if
|
||||
/// any, that the context menu was invoked on.
|
||||
///
|
||||
cef_context_menu_edit_state_flags_t(CEF_CALLBACK* get_edit_state_flags)(
|
||||
struct _cef_context_menu_params_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the context menu contains items specified by the
|
||||
/// renderer process.
|
||||
///
|
||||
int(CEF_CALLBACK* is_custom_menu)(struct _cef_context_menu_params_t* self);
|
||||
} cef_context_menu_params_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_
|
||||
199
third/cef/include/capi/cef_cookie_capi.h
Normal file
199
third/cef/include/capi/cef_cookie_capi.h
Normal file
@@ -0,0 +1,199 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=598c6f530b2e2553197d8c6a72ad9e2bf72b5443$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_callback_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _cef_cookie_visitor_t;
|
||||
struct _cef_delete_cookies_callback_t;
|
||||
struct _cef_set_cookie_callback_t;
|
||||
|
||||
///
|
||||
/// Structure used for managing cookies. The functions of this structure may be
|
||||
/// called on any thread unless otherwise indicated.
|
||||
///
|
||||
typedef struct _cef_cookie_manager_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Visit all cookies on the UI thread. The returned cookies are ordered by
|
||||
/// longest path, then by earliest creation date. Returns false (0) if cookies
|
||||
/// cannot be accessed.
|
||||
///
|
||||
int(CEF_CALLBACK* visit_all_cookies)(struct _cef_cookie_manager_t* self,
|
||||
struct _cef_cookie_visitor_t* visitor);
|
||||
|
||||
///
|
||||
/// Visit a subset of cookies on the UI thread. The results are filtered by
|
||||
/// the given url scheme, host, domain and path. If |includeHttpOnly| is true
|
||||
/// (1) HTTP-only cookies will also be included in the results. The returned
|
||||
/// cookies are ordered by longest path, then by earliest creation date.
|
||||
/// Returns false (0) if cookies cannot be accessed.
|
||||
///
|
||||
int(CEF_CALLBACK* visit_url_cookies)(struct _cef_cookie_manager_t* self,
|
||||
const cef_string_t* url,
|
||||
int includeHttpOnly,
|
||||
struct _cef_cookie_visitor_t* visitor);
|
||||
|
||||
///
|
||||
/// Sets a cookie given a valid URL and explicit user-provided cookie
|
||||
/// attributes. This function expects each attribute to be well-formed. It
|
||||
/// will check for disallowed characters (e.g. the ';' character is disallowed
|
||||
/// within the cookie value attribute) and fail without setting the cookie if
|
||||
/// such characters are found. If |callback| is non-NULL it will be executed
|
||||
/// asnychronously on the UI thread after the cookie has been set. Returns
|
||||
/// false (0) if an invalid URL is specified or if cookies cannot be accessed.
|
||||
///
|
||||
int(CEF_CALLBACK* set_cookie)(struct _cef_cookie_manager_t* self,
|
||||
const cef_string_t* url,
|
||||
const struct _cef_cookie_t* cookie,
|
||||
struct _cef_set_cookie_callback_t* callback);
|
||||
|
||||
///
|
||||
/// Delete all cookies that match the specified parameters. If both |url| and
|
||||
/// |cookie_name| values are specified all host and domain cookies matching
|
||||
/// both will be deleted. If only |url| is specified all host cookies (but not
|
||||
/// domain cookies) irrespective of path will be deleted. If |url| is NULL all
|
||||
/// cookies for all hosts and domains will be deleted. If |callback| is non-
|
||||
/// NULL it will be executed asnychronously on the UI thread after the cookies
|
||||
/// have been deleted. Returns false (0) if a non-NULL invalid URL is
|
||||
/// specified or if cookies cannot be accessed. Cookies can alternately be
|
||||
/// deleted using the Visit*Cookies() functions.
|
||||
///
|
||||
int(CEF_CALLBACK* delete_cookies)(
|
||||
struct _cef_cookie_manager_t* self,
|
||||
const cef_string_t* url,
|
||||
const cef_string_t* cookie_name,
|
||||
struct _cef_delete_cookies_callback_t* callback);
|
||||
|
||||
///
|
||||
/// Flush the backing store (if any) to disk. If |callback| is non-NULL it
|
||||
/// will be executed asnychronously on the UI thread after the flush is
|
||||
/// complete. Returns false (0) if cookies cannot be accessed.
|
||||
///
|
||||
int(CEF_CALLBACK* flush_store)(struct _cef_cookie_manager_t* self,
|
||||
struct _cef_completion_callback_t* callback);
|
||||
} cef_cookie_manager_t;
|
||||
|
||||
///
|
||||
/// Returns the global cookie manager. By default data will be stored at
|
||||
/// cef_settings_t.cache_path if specified or in memory otherwise. If |callback|
|
||||
/// is non-NULL it will be executed asnychronously on the UI thread after the
|
||||
/// manager's storage has been initialized. Using this function is equivalent to
|
||||
/// calling cef_request_context_t::cef_request_context_get_global_context()->Get
|
||||
/// DefaultCookieManager().
|
||||
///
|
||||
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager(
|
||||
struct _cef_completion_callback_t* callback);
|
||||
|
||||
///
|
||||
/// Structure to implement for visiting cookie values. The functions of this
|
||||
/// structure will always be called on the UI thread.
|
||||
///
|
||||
typedef struct _cef_cookie_visitor_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Method that will be called once for each cookie. |count| is the 0-based
|
||||
/// index for the current cookie. |total| is the total number of cookies. Set
|
||||
/// |deleteCookie| to true (1) to delete the cookie currently being visited.
|
||||
/// Return false (0) to stop visiting cookies. This function may never be
|
||||
/// called if no cookies are found.
|
||||
///
|
||||
int(CEF_CALLBACK* visit)(struct _cef_cookie_visitor_t* self,
|
||||
const struct _cef_cookie_t* cookie,
|
||||
int count,
|
||||
int total,
|
||||
int* deleteCookie);
|
||||
} cef_cookie_visitor_t;
|
||||
|
||||
///
|
||||
/// Structure to implement to be notified of asynchronous completion via
|
||||
/// cef_cookie_manager_t::set_cookie().
|
||||
///
|
||||
typedef struct _cef_set_cookie_callback_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Method that will be called upon completion. |success| will be true (1) if
|
||||
/// the cookie was set successfully.
|
||||
///
|
||||
void(CEF_CALLBACK* on_complete)(struct _cef_set_cookie_callback_t* self,
|
||||
int success);
|
||||
} cef_set_cookie_callback_t;
|
||||
|
||||
///
|
||||
/// Structure to implement to be notified of asynchronous completion via
|
||||
/// cef_cookie_manager_t::delete_cookies().
|
||||
///
|
||||
typedef struct _cef_delete_cookies_callback_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Method that will be called upon completion. |num_deleted| will be the
|
||||
/// number of cookies that were deleted.
|
||||
///
|
||||
void(CEF_CALLBACK* on_complete)(struct _cef_delete_cookies_callback_t* self,
|
||||
int num_deleted);
|
||||
} cef_delete_cookies_callback_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_
|
||||
154
third/cef/include/capi/cef_crash_util_capi.h
Normal file
154
third/cef/include/capi/cef_crash_util_capi.h
Normal file
@@ -0,0 +1,154 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=5c6e0b9e37b8103a182f200fccdf5973104fcd70$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_CRASH_UTIL_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_CRASH_UTIL_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Crash reporting is configured using an INI-style config file named
|
||||
/// "crash_reporter.cfg". On Windows and Linux this file must be placed next to
|
||||
/// the main application executable. On macOS this file must be placed in the
|
||||
/// top-level app bundle Resources directory (e.g.
|
||||
/// "<appname>.app/Contents/Resources"). File contents are as follows:
|
||||
///
|
||||
/// <pre>
|
||||
/// # Comments start with a hash character and must be on their own line.
|
||||
///
|
||||
/// [Config]
|
||||
/// ProductName=<Value of the "prod" crash key; defaults to "cef">
|
||||
/// ProductVersion=<Value of the "ver" crash key; defaults to the CEF version>
|
||||
/// AppName=<Windows only; App-specific folder name component for storing crash
|
||||
/// information; default to "CEF">
|
||||
/// ExternalHandler=<Windows only; Name of the external handler exe to use
|
||||
/// instead of re-launching the main exe; default to empty>
|
||||
/// BrowserCrashForwardingEnabled=<macOS only; True if browser process crashes
|
||||
/// should be forwarded to the system crash
|
||||
/// reporter; default to false>
|
||||
/// ServerURL=<crash server URL; default to empty>
|
||||
/// RateLimitEnabled=<True if uploads should be rate limited; default to true>
|
||||
/// MaxUploadsPerDay=<Max uploads per 24 hours, used if rate limit is enabled;
|
||||
/// default to 5>
|
||||
/// MaxDatabaseSizeInMb=<Total crash report disk usage greater than this value
|
||||
/// will cause older reports to be deleted; default to 20>
|
||||
/// MaxDatabaseAgeInDays=<Crash reports older than this value will be deleted;
|
||||
/// default to 5>
|
||||
///
|
||||
/// [CrashKeys]
|
||||
/// my_key1=<small|medium|large>
|
||||
/// my_key2=<small|medium|large>
|
||||
/// </pre>
|
||||
///
|
||||
/// <b>Config section:</b>
|
||||
///
|
||||
/// If "ProductName" and/or "ProductVersion" are set then the specified values
|
||||
/// will be included in the crash dump metadata. On macOS if these values are
|
||||
/// set to NULL then they will be retrieved from the Info.plist file using the
|
||||
/// "CFBundleName" and "CFBundleShortVersionString" keys respectively.
|
||||
///
|
||||
/// If "AppName" is set on Windows then crash report information (metrics,
|
||||
/// database and dumps) will be stored locally on disk under the
|
||||
/// "C:\Users\[CurrentUser]\AppData\Local\[AppName]\User Data" folder. On other
|
||||
/// platforms the cef_settings_t.user_data_path value will be used.
|
||||
///
|
||||
/// If "ExternalHandler" is set on Windows then the specified exe will be
|
||||
/// launched as the crashpad-handler instead of re-launching the main process
|
||||
/// exe. The value can be an absolute path or a path relative to the main exe
|
||||
/// directory. On Linux the cef_settings_t.browser_subprocess_path value will be
|
||||
/// used. On macOS the existing subprocess app bundle will be used.
|
||||
///
|
||||
/// If "BrowserCrashForwardingEnabled" is set to true (1) on macOS then browser
|
||||
/// process crashes will be forwarded to the system crash reporter. This results
|
||||
/// in the crash UI dialog being displayed to the user and crash reports being
|
||||
/// logged under "~/Library/Logs/DiagnosticReports". Forwarding of crash reports
|
||||
/// from non-browser processes and Debug builds is always disabled.
|
||||
///
|
||||
/// If "ServerURL" is set then crashes will be uploaded as a multi-part POST
|
||||
/// request to the specified URL. Otherwise, reports will only be stored locally
|
||||
/// on disk.
|
||||
///
|
||||
/// If "RateLimitEnabled" is set to true (1) then crash report uploads will be
|
||||
/// rate limited as follows:
|
||||
/// 1. If "MaxUploadsPerDay" is set to a positive value then at most the
|
||||
/// specified number of crashes will be uploaded in each 24 hour period.
|
||||
/// 2. If crash upload fails due to a network or server error then an
|
||||
/// incremental backoff delay up to a maximum of 24 hours will be applied
|
||||
/// for retries.
|
||||
/// 3. If a backoff delay is applied and "MaxUploadsPerDay" is > 1 then the
|
||||
/// "MaxUploadsPerDay" value will be reduced to 1 until the client is
|
||||
/// restarted. This helps to avoid an upload flood when the network or
|
||||
/// server error is resolved.
|
||||
/// Rate limiting is not supported on Linux.
|
||||
///
|
||||
/// If "MaxDatabaseSizeInMb" is set to a positive value then crash report
|
||||
/// storage on disk will be limited to that size in megabytes. For example, on
|
||||
/// Windows each dump is about 600KB so a "MaxDatabaseSizeInMb" value of 20
|
||||
/// equates to about 34 crash reports stored on disk. Not supported on Linux.
|
||||
///
|
||||
/// If "MaxDatabaseAgeInDays" is set to a positive value then crash reports
|
||||
/// older than the specified age in days will be deleted. Not supported on
|
||||
/// Linux.
|
||||
///
|
||||
/// <b>CrashKeys section:</b>
|
||||
///
|
||||
/// A maximum of 26 crash keys of each size can be specified for use by the
|
||||
/// application. Crash key values will be truncated based on the specified size
|
||||
/// (small = 64 bytes, medium = 256 bytes, large = 1024 bytes). The value of
|
||||
/// crash keys can be set from any thread or process using the
|
||||
/// CefSetCrashKeyValue function. These key/value pairs will be sent to the
|
||||
/// crash server along with the crash dump file.
|
||||
///
|
||||
CEF_EXPORT int cef_crash_reporting_enabled(void);
|
||||
|
||||
///
|
||||
/// Sets or clears a specific key-value pair from the crash metadata.
|
||||
///
|
||||
CEF_EXPORT void cef_set_crash_key_value(const cef_string_t* key,
|
||||
const cef_string_t* value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_CRASH_UTIL_CAPI_H_
|
||||
148
third/cef/include/capi/cef_devtools_message_observer_capi.h
Normal file
148
third/cef/include/capi/cef_devtools_message_observer_capi.h
Normal file
@@ -0,0 +1,148 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=777485120b9a9df0f890579ee698d33f273819c5$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_DEVTOOLS_MESSAGE_OBSERVER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_DEVTOOLS_MESSAGE_OBSERVER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _cef_browser_t;
|
||||
|
||||
///
|
||||
/// Callback structure for cef_browser_host_t::AddDevToolsMessageObserver. The
|
||||
/// functions of this structure will be called on the browser process UI thread.
|
||||
///
|
||||
typedef struct _cef_dev_tools_message_observer_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Method that will be called on receipt of a DevTools protocol message.
|
||||
/// |browser| is the originating browser instance. |message| is a UTF8-encoded
|
||||
/// JSON dictionary representing either a function result or an event.
|
||||
/// |message| is only valid for the scope of this callback and should be
|
||||
/// copied if necessary. Return true (1) if the message was handled or false
|
||||
/// (0) if the message should be further processed and passed to the
|
||||
/// OnDevToolsMethodResult or OnDevToolsEvent functions as appropriate.
|
||||
///
|
||||
/// Method result dictionaries include an "id" (int) value that identifies the
|
||||
/// orginating function call sent from
|
||||
/// cef_browser_host_t::SendDevToolsMessage, and optionally either a "result"
|
||||
/// (dictionary) or "error" (dictionary) value. The "error" dictionary will
|
||||
/// contain "code" (int) and "message" (string) values. Event dictionaries
|
||||
/// include a "function" (string) value and optionally a "params" (dictionary)
|
||||
/// value. See the DevTools protocol documentation at
|
||||
/// https://chromedevtools.github.io/devtools-protocol/ for details of
|
||||
/// supported function calls and the expected "result" or "params" dictionary
|
||||
/// contents. JSON dictionaries can be parsed using the CefParseJSON function
|
||||
/// if desired, however be aware of performance considerations when parsing
|
||||
/// large messages (some of which may exceed 1MB in size).
|
||||
///
|
||||
int(CEF_CALLBACK* on_dev_tools_message)(
|
||||
struct _cef_dev_tools_message_observer_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
const void* message,
|
||||
size_t message_size);
|
||||
|
||||
///
|
||||
/// Method that will be called after attempted execution of a DevTools
|
||||
/// protocol function. |browser| is the originating browser instance.
|
||||
/// |message_id| is the "id" value that identifies the originating function
|
||||
/// call message. If the function succeeded |success| will be true (1) and
|
||||
/// |result| will be the UTF8-encoded JSON "result" dictionary value (which
|
||||
/// may be NULL). If the function failed |success| will be false (0) and
|
||||
/// |result| will be the UTF8-encoded JSON "error" dictionary value. |result|
|
||||
/// is only valid for the scope of this callback and should be copied if
|
||||
/// necessary. See the OnDevToolsMessage documentation for additional details
|
||||
/// on |result| contents.
|
||||
///
|
||||
void(CEF_CALLBACK* on_dev_tools_method_result)(
|
||||
struct _cef_dev_tools_message_observer_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
int message_id,
|
||||
int success,
|
||||
const void* result,
|
||||
size_t result_size);
|
||||
|
||||
///
|
||||
/// Method that will be called on receipt of a DevTools protocol event.
|
||||
/// |browser| is the originating browser instance. |function| is the
|
||||
/// "function" value. |params| is the UTF8-encoded JSON "params" dictionary
|
||||
/// value (which may be NULL). |params| is only valid for the scope of this
|
||||
/// callback and should be copied if necessary. See the OnDevToolsMessage
|
||||
/// documentation for additional details on |params| contents.
|
||||
///
|
||||
void(CEF_CALLBACK* on_dev_tools_event)(
|
||||
struct _cef_dev_tools_message_observer_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
const cef_string_t* method,
|
||||
const void* params,
|
||||
size_t params_size);
|
||||
|
||||
///
|
||||
/// Method that will be called when the DevTools agent has attached. |browser|
|
||||
/// is the originating browser instance. This will generally occur in response
|
||||
/// to the first message sent while the agent is detached.
|
||||
///
|
||||
void(CEF_CALLBACK* on_dev_tools_agent_attached)(
|
||||
struct _cef_dev_tools_message_observer_t* self,
|
||||
struct _cef_browser_t* browser);
|
||||
|
||||
///
|
||||
/// Method that will be called when the DevTools agent has detached. |browser|
|
||||
/// is the originating browser instance. Any function results that were
|
||||
/// pending before the agent became detached will not be delivered, and any
|
||||
/// active event subscriptions will be canceled.
|
||||
///
|
||||
void(CEF_CALLBACK* on_dev_tools_agent_detached)(
|
||||
struct _cef_dev_tools_message_observer_t* self,
|
||||
struct _cef_browser_t* browser);
|
||||
} cef_dev_tools_message_observer_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_DEVTOOLS_MESSAGE_OBSERVER_CAPI_H_
|
||||
111
third/cef/include/capi/cef_dialog_handler_capi.h
Normal file
111
third/cef/include/capi/cef_dialog_handler_capi.h
Normal file
@@ -0,0 +1,111 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=69545645f079f4593d9cbb6d8a36535c209245f7$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_DIALOG_HANDLER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_DIALOG_HANDLER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Callback structure for asynchronous continuation of file dialog requests.
|
||||
///
|
||||
typedef struct _cef_file_dialog_callback_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Continue the file selection. |file_paths| should be a single value or a
|
||||
/// list of values depending on the dialog mode. An NULL |file_paths| value is
|
||||
/// treated the same as calling cancel().
|
||||
///
|
||||
void(CEF_CALLBACK* cont)(struct _cef_file_dialog_callback_t* self,
|
||||
cef_string_list_t file_paths);
|
||||
|
||||
///
|
||||
/// Cancel the file selection.
|
||||
///
|
||||
void(CEF_CALLBACK* cancel)(struct _cef_file_dialog_callback_t* self);
|
||||
} cef_file_dialog_callback_t;
|
||||
|
||||
///
|
||||
/// Implement this structure to handle dialog events. The functions of this
|
||||
/// structure will be called on the browser process UI thread.
|
||||
///
|
||||
typedef struct _cef_dialog_handler_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Called to run a file chooser dialog. |mode| represents the type of dialog
|
||||
/// to display. |title| to the title to be used for the dialog and may be NULL
|
||||
/// to show the default title ("Open" or "Save" depending on the mode).
|
||||
/// |default_file_path| is the path with optional directory and/or file name
|
||||
/// component that should be initially selected in the dialog.
|
||||
/// |accept_filters| are used to restrict the selectable file types and may
|
||||
/// any combination of (a) valid lower-cased MIME types (e.g. "text/*" or
|
||||
/// "image/*"), (b) individual file extensions (e.g. ".txt" or ".png"), or (c)
|
||||
/// combined description and file extension delimited using "|" and ";" (e.g.
|
||||
/// "Image Types|.png;.gif;.jpg"). To display a custom dialog return true (1)
|
||||
/// and execute |callback| either inline or at a later time. To display the
|
||||
/// default dialog return false (0).
|
||||
///
|
||||
int(CEF_CALLBACK* on_file_dialog)(
|
||||
struct _cef_dialog_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
cef_file_dialog_mode_t mode,
|
||||
const cef_string_t* title,
|
||||
const cef_string_t* default_file_path,
|
||||
cef_string_list_t accept_filters,
|
||||
struct _cef_file_dialog_callback_t* callback);
|
||||
} cef_dialog_handler_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_DIALOG_HANDLER_CAPI_H_
|
||||
173
third/cef/include/capi/cef_display_handler_capi.h
Normal file
173
third/cef/include/capi/cef_display_handler_capi.h
Normal file
@@ -0,0 +1,173 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=1de3354bd0a042cc28199f1f56753b1df9e279a2$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
#include "include/capi/cef_frame_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Implement this structure to handle events related to browser display state.
|
||||
/// The functions of this structure will be called on the UI thread.
|
||||
///
|
||||
typedef struct _cef_display_handler_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Called when a frame's address has changed.
|
||||
///
|
||||
void(CEF_CALLBACK* on_address_change)(struct _cef_display_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame,
|
||||
const cef_string_t* url);
|
||||
|
||||
///
|
||||
/// Called when the page title changes.
|
||||
///
|
||||
void(CEF_CALLBACK* on_title_change)(struct _cef_display_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
const cef_string_t* title);
|
||||
|
||||
///
|
||||
/// Called when the page icon changes.
|
||||
///
|
||||
void(CEF_CALLBACK* on_favicon_urlchange)(struct _cef_display_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
cef_string_list_t icon_urls);
|
||||
|
||||
///
|
||||
/// Called when web content in the page has toggled fullscreen mode. If
|
||||
/// |fullscreen| is true (1) the content will automatically be sized to fill
|
||||
/// the browser content area. If |fullscreen| is false (0) the content will
|
||||
/// automatically return to its original size and position. The client is
|
||||
/// responsible for resizing the browser if desired.
|
||||
///
|
||||
void(CEF_CALLBACK* on_fullscreen_mode_change)(
|
||||
struct _cef_display_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
int fullscreen);
|
||||
|
||||
///
|
||||
/// Called when the browser is about to display a tooltip. |text| contains the
|
||||
/// text that will be displayed in the tooltip. To handle the display of the
|
||||
/// tooltip yourself return true (1). Otherwise, you can optionally modify
|
||||
/// |text| and then return false (0) to allow the browser to display the
|
||||
/// tooltip. When window rendering is disabled the application is responsible
|
||||
/// for drawing tooltips and the return value is ignored.
|
||||
///
|
||||
int(CEF_CALLBACK* on_tooltip)(struct _cef_display_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
cef_string_t* text);
|
||||
|
||||
///
|
||||
/// Called when the browser receives a status message. |value| contains the
|
||||
/// text that will be displayed in the status message.
|
||||
///
|
||||
void(CEF_CALLBACK* on_status_message)(struct _cef_display_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
const cef_string_t* value);
|
||||
|
||||
///
|
||||
/// Called to display a console message. Return true (1) to stop the message
|
||||
/// from being output to the console.
|
||||
///
|
||||
int(CEF_CALLBACK* on_console_message)(struct _cef_display_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
cef_log_severity_t level,
|
||||
const cef_string_t* message,
|
||||
const cef_string_t* source,
|
||||
int line);
|
||||
|
||||
///
|
||||
/// Called when auto-resize is enabled via
|
||||
/// cef_browser_host_t::SetAutoResizeEnabled and the contents have auto-
|
||||
/// resized. |new_size| will be the desired size in view coordinates. Return
|
||||
/// true (1) if the resize was handled or false (0) for default handling.
|
||||
///
|
||||
int(CEF_CALLBACK* on_auto_resize)(struct _cef_display_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
const cef_size_t* new_size);
|
||||
|
||||
///
|
||||
/// Called when the overall page loading progress has changed. |progress|
|
||||
/// ranges from 0.0 to 1.0.
|
||||
///
|
||||
void(CEF_CALLBACK* on_loading_progress_change)(
|
||||
struct _cef_display_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
double progress);
|
||||
|
||||
///
|
||||
/// Called when the browser's cursor has changed. If |type| is CT_CUSTOM then
|
||||
/// |custom_cursor_info| will be populated with the custom cursor information.
|
||||
/// Return true (1) if the cursor change was handled or false (0) for default
|
||||
/// handling.
|
||||
///
|
||||
int(CEF_CALLBACK* on_cursor_change)(
|
||||
struct _cef_display_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
cef_cursor_handle_t cursor,
|
||||
cef_cursor_type_t type,
|
||||
const cef_cursor_info_t* custom_cursor_info);
|
||||
|
||||
///
|
||||
/// Called when the browser's access to an audio and/or video source has
|
||||
/// changed.
|
||||
///
|
||||
void(CEF_CALLBACK* on_media_access_change)(
|
||||
struct _cef_display_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
int has_video_access,
|
||||
int has_audio_access);
|
||||
} cef_display_handler_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_
|
||||
346
third/cef/include/capi/cef_dom_capi.h
Normal file
346
third/cef/include/capi/cef_dom_capi.h
Normal file
@@ -0,0 +1,346 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=d703b8af664ed9dfac8ad935616ef43fafc062e2$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_DOM_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_DOM_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _cef_domdocument_t;
|
||||
struct _cef_domnode_t;
|
||||
|
||||
///
|
||||
/// Structure to implement for visiting the DOM. The functions of this structure
|
||||
/// will be called on the render process main thread.
|
||||
///
|
||||
typedef struct _cef_domvisitor_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Method executed for visiting the DOM. The document object passed to this
|
||||
/// function represents a snapshot of the DOM at the time this function is
|
||||
/// executed. DOM objects are only valid for the scope of this function. Do
|
||||
/// not keep references to or attempt to access any DOM objects outside the
|
||||
/// scope of this function.
|
||||
///
|
||||
void(CEF_CALLBACK* visit)(struct _cef_domvisitor_t* self,
|
||||
struct _cef_domdocument_t* document);
|
||||
} cef_domvisitor_t;
|
||||
|
||||
///
|
||||
/// Structure used to represent a DOM document. The functions of this structure
|
||||
/// should only be called on the render process main thread thread.
|
||||
///
|
||||
typedef struct _cef_domdocument_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Returns the document type.
|
||||
///
|
||||
cef_dom_document_type_t(CEF_CALLBACK* get_type)(
|
||||
struct _cef_domdocument_t* self);
|
||||
|
||||
///
|
||||
/// Returns the root document node.
|
||||
///
|
||||
struct _cef_domnode_t*(CEF_CALLBACK* get_document)(
|
||||
struct _cef_domdocument_t* self);
|
||||
|
||||
///
|
||||
/// Returns the BODY node of an HTML document.
|
||||
///
|
||||
struct _cef_domnode_t*(CEF_CALLBACK* get_body)(
|
||||
struct _cef_domdocument_t* self);
|
||||
|
||||
///
|
||||
/// Returns the HEAD node of an HTML document.
|
||||
///
|
||||
struct _cef_domnode_t*(CEF_CALLBACK* get_head)(
|
||||
struct _cef_domdocument_t* self);
|
||||
|
||||
///
|
||||
/// Returns the title of an HTML document.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_title)(
|
||||
struct _cef_domdocument_t* self);
|
||||
|
||||
///
|
||||
/// Returns the document element with the specified ID value.
|
||||
///
|
||||
struct _cef_domnode_t*(CEF_CALLBACK* get_element_by_id)(
|
||||
struct _cef_domdocument_t* self,
|
||||
const cef_string_t* id);
|
||||
|
||||
///
|
||||
/// Returns the node that currently has keyboard focus.
|
||||
///
|
||||
struct _cef_domnode_t*(CEF_CALLBACK* get_focused_node)(
|
||||
struct _cef_domdocument_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if a portion of the document is selected.
|
||||
///
|
||||
int(CEF_CALLBACK* has_selection)(struct _cef_domdocument_t* self);
|
||||
|
||||
///
|
||||
/// Returns the selection offset within the start node.
|
||||
///
|
||||
int(CEF_CALLBACK* get_selection_start_offset)(
|
||||
struct _cef_domdocument_t* self);
|
||||
|
||||
///
|
||||
/// Returns the selection offset within the end node.
|
||||
///
|
||||
int(CEF_CALLBACK* get_selection_end_offset)(struct _cef_domdocument_t* self);
|
||||
|
||||
///
|
||||
/// Returns the contents of this selection as markup.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_selection_as_markup)(
|
||||
struct _cef_domdocument_t* self);
|
||||
|
||||
///
|
||||
/// Returns the contents of this selection as text.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_selection_as_text)(
|
||||
struct _cef_domdocument_t* self);
|
||||
|
||||
///
|
||||
/// Returns the base URL for the document.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_base_url)(
|
||||
struct _cef_domdocument_t* self);
|
||||
|
||||
///
|
||||
/// Returns a complete URL based on the document base URL and the specified
|
||||
/// partial URL.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_complete_url)(
|
||||
struct _cef_domdocument_t* self,
|
||||
const cef_string_t* partialURL);
|
||||
} cef_domdocument_t;
|
||||
|
||||
///
|
||||
/// Structure used to represent a DOM node. The functions of this structure
|
||||
/// should only be called on the render process main thread.
|
||||
///
|
||||
typedef struct _cef_domnode_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Returns the type for this node.
|
||||
///
|
||||
cef_dom_node_type_t(CEF_CALLBACK* get_type)(struct _cef_domnode_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if this is a text node.
|
||||
///
|
||||
int(CEF_CALLBACK* is_text)(struct _cef_domnode_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if this is an element node.
|
||||
///
|
||||
int(CEF_CALLBACK* is_element)(struct _cef_domnode_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if this is an editable node.
|
||||
///
|
||||
int(CEF_CALLBACK* is_editable)(struct _cef_domnode_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if this is a form control element node.
|
||||
///
|
||||
int(CEF_CALLBACK* is_form_control_element)(struct _cef_domnode_t* self);
|
||||
|
||||
///
|
||||
/// Returns the type of this form control element node.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_form_control_element_type)(
|
||||
struct _cef_domnode_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if this object is pointing to the same handle as |that|
|
||||
/// object.
|
||||
///
|
||||
int(CEF_CALLBACK* is_same)(struct _cef_domnode_t* self,
|
||||
struct _cef_domnode_t* that);
|
||||
|
||||
///
|
||||
/// Returns the name of this node.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_name)(struct _cef_domnode_t* self);
|
||||
|
||||
///
|
||||
/// Returns the value of this node.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_value)(struct _cef_domnode_t* self);
|
||||
|
||||
///
|
||||
/// Set the value of this node. Returns true (1) on success.
|
||||
///
|
||||
int(CEF_CALLBACK* set_value)(struct _cef_domnode_t* self,
|
||||
const cef_string_t* value);
|
||||
|
||||
///
|
||||
/// Returns the contents of this node as markup.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_as_markup)(
|
||||
struct _cef_domnode_t* self);
|
||||
|
||||
///
|
||||
/// Returns the document associated with this node.
|
||||
///
|
||||
struct _cef_domdocument_t*(CEF_CALLBACK* get_document)(
|
||||
struct _cef_domnode_t* self);
|
||||
|
||||
///
|
||||
/// Returns the parent node.
|
||||
///
|
||||
struct _cef_domnode_t*(CEF_CALLBACK* get_parent)(struct _cef_domnode_t* self);
|
||||
|
||||
///
|
||||
/// Returns the previous sibling node.
|
||||
///
|
||||
struct _cef_domnode_t*(CEF_CALLBACK* get_previous_sibling)(
|
||||
struct _cef_domnode_t* self);
|
||||
|
||||
///
|
||||
/// Returns the next sibling node.
|
||||
///
|
||||
struct _cef_domnode_t*(CEF_CALLBACK* get_next_sibling)(
|
||||
struct _cef_domnode_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if this node has child nodes.
|
||||
///
|
||||
int(CEF_CALLBACK* has_children)(struct _cef_domnode_t* self);
|
||||
|
||||
///
|
||||
/// Return the first child node.
|
||||
///
|
||||
struct _cef_domnode_t*(CEF_CALLBACK* get_first_child)(
|
||||
struct _cef_domnode_t* self);
|
||||
|
||||
///
|
||||
/// Returns the last child node.
|
||||
///
|
||||
struct _cef_domnode_t*(CEF_CALLBACK* get_last_child)(
|
||||
struct _cef_domnode_t* self);
|
||||
|
||||
///
|
||||
/// Returns the tag name of this element.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_element_tag_name)(
|
||||
struct _cef_domnode_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if this element has attributes.
|
||||
///
|
||||
int(CEF_CALLBACK* has_element_attributes)(struct _cef_domnode_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if this element has an attribute named |attrName|.
|
||||
///
|
||||
int(CEF_CALLBACK* has_element_attribute)(struct _cef_domnode_t* self,
|
||||
const cef_string_t* attrName);
|
||||
|
||||
///
|
||||
/// Returns the element attribute named |attrName|.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_element_attribute)(
|
||||
struct _cef_domnode_t* self,
|
||||
const cef_string_t* attrName);
|
||||
|
||||
///
|
||||
/// Returns a map of all element attributes.
|
||||
///
|
||||
void(CEF_CALLBACK* get_element_attributes)(struct _cef_domnode_t* self,
|
||||
cef_string_map_t attrMap);
|
||||
|
||||
///
|
||||
/// Set the value for the element attribute named |attrName|. Returns true (1)
|
||||
/// on success.
|
||||
///
|
||||
int(CEF_CALLBACK* set_element_attribute)(struct _cef_domnode_t* self,
|
||||
const cef_string_t* attrName,
|
||||
const cef_string_t* value);
|
||||
|
||||
///
|
||||
/// Returns the inner text of the element.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_element_inner_text)(
|
||||
struct _cef_domnode_t* self);
|
||||
|
||||
///
|
||||
/// Returns the bounds of the element in device pixels. Use
|
||||
/// "window.devicePixelRatio" to convert to/from CSS pixels.
|
||||
///
|
||||
cef_rect_t(CEF_CALLBACK* get_element_bounds)(struct _cef_domnode_t* self);
|
||||
} cef_domnode_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_DOM_CAPI_H_
|
||||
150
third/cef/include/capi/cef_download_handler_capi.h
Normal file
150
third/cef/include/capi/cef_download_handler_capi.h
Normal file
@@ -0,0 +1,150 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=f1f6a110a7ce15611a7062b3d7fe8b5c630f2980$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_DOWNLOAD_HANDLER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_DOWNLOAD_HANDLER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
#include "include/capi/cef_download_item_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Callback structure used to asynchronously continue a download.
|
||||
///
|
||||
typedef struct _cef_before_download_callback_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Call to continue the download. Set |download_path| to the full file path
|
||||
/// for the download including the file name or leave blank to use the
|
||||
/// suggested name and the default temp directory. Set |show_dialog| to true
|
||||
/// (1) if you do wish to show the default "Save As" dialog.
|
||||
///
|
||||
void(CEF_CALLBACK* cont)(struct _cef_before_download_callback_t* self,
|
||||
const cef_string_t* download_path,
|
||||
int show_dialog);
|
||||
} cef_before_download_callback_t;
|
||||
|
||||
///
|
||||
/// Callback structure used to asynchronously cancel a download.
|
||||
///
|
||||
typedef struct _cef_download_item_callback_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Call to cancel the download.
|
||||
///
|
||||
void(CEF_CALLBACK* cancel)(struct _cef_download_item_callback_t* self);
|
||||
|
||||
///
|
||||
/// Call to pause the download.
|
||||
///
|
||||
void(CEF_CALLBACK* pause)(struct _cef_download_item_callback_t* self);
|
||||
|
||||
///
|
||||
/// Call to resume the download.
|
||||
///
|
||||
void(CEF_CALLBACK* resume)(struct _cef_download_item_callback_t* self);
|
||||
} cef_download_item_callback_t;
|
||||
|
||||
///
|
||||
/// Structure used to handle file downloads. The functions of this structure
|
||||
/// will called on the browser process UI thread.
|
||||
///
|
||||
typedef struct _cef_download_handler_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Called before a download begins in response to a user-initiated action
|
||||
/// (e.g. alt + link click or link click that returns a `Content-Disposition:
|
||||
/// attachment` response from the server). |url| is the target download URL
|
||||
/// and |request_function| is the target function (GET, POST, etc). Return
|
||||
/// true (1) to proceed with the download or false (0) to cancel the download.
|
||||
///
|
||||
int(CEF_CALLBACK* can_download)(struct _cef_download_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
const cef_string_t* url,
|
||||
const cef_string_t* request_method);
|
||||
|
||||
///
|
||||
/// Called before a download begins. |suggested_name| is the suggested name
|
||||
/// for the download file. By default the download will be canceled. Execute
|
||||
/// |callback| either asynchronously or in this function to continue the
|
||||
/// download if desired. Do not keep a reference to |download_item| outside of
|
||||
/// this function.
|
||||
///
|
||||
void(CEF_CALLBACK* on_before_download)(
|
||||
struct _cef_download_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
struct _cef_download_item_t* download_item,
|
||||
const cef_string_t* suggested_name,
|
||||
struct _cef_before_download_callback_t* callback);
|
||||
|
||||
///
|
||||
/// Called when a download's status or progress information has been updated.
|
||||
/// This may be called multiple times before and after on_before_download().
|
||||
/// Execute |callback| either asynchronously or in this function to cancel the
|
||||
/// download if desired. Do not keep a reference to |download_item| outside of
|
||||
/// this function.
|
||||
///
|
||||
void(CEF_CALLBACK* on_download_updated)(
|
||||
struct _cef_download_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
struct _cef_download_item_t* download_item,
|
||||
struct _cef_download_item_callback_t* callback);
|
||||
} cef_download_handler_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_DOWNLOAD_HANDLER_CAPI_H_
|
||||
174
third/cef/include/capi/cef_download_item_capi.h
Normal file
174
third/cef/include/capi/cef_download_item_capi.h
Normal file
@@ -0,0 +1,174 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=d9e9f4b914ae2d3b1ed83ae0d9e2e46e9e736af5$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_DOWNLOAD_ITEM_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_DOWNLOAD_ITEM_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Structure used to represent a download item.
|
||||
///
|
||||
typedef struct _cef_download_item_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Returns true (1) if this object is valid. Do not call any other functions
|
||||
/// if this function returns false (0).
|
||||
///
|
||||
int(CEF_CALLBACK* is_valid)(struct _cef_download_item_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the download is in progress.
|
||||
///
|
||||
int(CEF_CALLBACK* is_in_progress)(struct _cef_download_item_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the download is complete.
|
||||
///
|
||||
int(CEF_CALLBACK* is_complete)(struct _cef_download_item_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the download has been canceled.
|
||||
///
|
||||
int(CEF_CALLBACK* is_canceled)(struct _cef_download_item_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the download has been interrupted.
|
||||
///
|
||||
int(CEF_CALLBACK* is_interrupted)(struct _cef_download_item_t* self);
|
||||
|
||||
///
|
||||
/// Returns the most recent interrupt reason.
|
||||
///
|
||||
cef_download_interrupt_reason_t(CEF_CALLBACK* get_interrupt_reason)(
|
||||
struct _cef_download_item_t* self);
|
||||
|
||||
///
|
||||
/// Returns a simple speed estimate in bytes/s.
|
||||
///
|
||||
int64(CEF_CALLBACK* get_current_speed)(struct _cef_download_item_t* self);
|
||||
|
||||
///
|
||||
/// Returns the rough percent complete or -1 if the receive total size is
|
||||
/// unknown.
|
||||
///
|
||||
int(CEF_CALLBACK* get_percent_complete)(struct _cef_download_item_t* self);
|
||||
|
||||
///
|
||||
/// Returns the total number of bytes.
|
||||
///
|
||||
int64(CEF_CALLBACK* get_total_bytes)(struct _cef_download_item_t* self);
|
||||
|
||||
///
|
||||
/// Returns the number of received bytes.
|
||||
///
|
||||
int64(CEF_CALLBACK* get_received_bytes)(struct _cef_download_item_t* self);
|
||||
|
||||
///
|
||||
/// Returns the time that the download started.
|
||||
///
|
||||
cef_basetime_t(CEF_CALLBACK* get_start_time)(
|
||||
struct _cef_download_item_t* self);
|
||||
|
||||
///
|
||||
/// Returns the time that the download ended.
|
||||
///
|
||||
cef_basetime_t(CEF_CALLBACK* get_end_time)(struct _cef_download_item_t* self);
|
||||
|
||||
///
|
||||
/// Returns the full path to the downloaded or downloading file.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_full_path)(
|
||||
struct _cef_download_item_t* self);
|
||||
|
||||
///
|
||||
/// Returns the unique identifier for this download.
|
||||
///
|
||||
uint32(CEF_CALLBACK* get_id)(struct _cef_download_item_t* self);
|
||||
|
||||
///
|
||||
/// Returns the URL.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_url)(
|
||||
struct _cef_download_item_t* self);
|
||||
|
||||
///
|
||||
/// Returns the original URL before any redirections.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_original_url)(
|
||||
struct _cef_download_item_t* self);
|
||||
|
||||
///
|
||||
/// Returns the suggested file name.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_suggested_file_name)(
|
||||
struct _cef_download_item_t* self);
|
||||
|
||||
///
|
||||
/// Returns the content disposition.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_content_disposition)(
|
||||
struct _cef_download_item_t* self);
|
||||
|
||||
///
|
||||
/// Returns the mime type.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_mime_type)(
|
||||
struct _cef_download_item_t* self);
|
||||
} cef_download_item_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_DOWNLOAD_ITEM_CAPI_H_
|
||||
233
third/cef/include/capi/cef_drag_data_capi.h
Normal file
233
third/cef/include/capi/cef_drag_data_capi.h
Normal file
@@ -0,0 +1,233 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=a1ce746f0dd97d21973d4c80d8ef46391c0fd463$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_DRAG_DATA_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_DRAG_DATA_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_image_capi.h"
|
||||
#include "include/capi/cef_stream_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Structure used to represent drag data. The functions of this structure may
|
||||
/// be called on any thread.
|
||||
///
|
||||
typedef struct _cef_drag_data_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Returns a copy of the current object.
|
||||
///
|
||||
struct _cef_drag_data_t*(CEF_CALLBACK* clone)(struct _cef_drag_data_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if this object is read-only.
|
||||
///
|
||||
int(CEF_CALLBACK* is_read_only)(struct _cef_drag_data_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the drag data is a link.
|
||||
///
|
||||
int(CEF_CALLBACK* is_link)(struct _cef_drag_data_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the drag data is a text or html fragment.
|
||||
///
|
||||
int(CEF_CALLBACK* is_fragment)(struct _cef_drag_data_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the drag data is a file.
|
||||
///
|
||||
int(CEF_CALLBACK* is_file)(struct _cef_drag_data_t* self);
|
||||
|
||||
///
|
||||
/// Return the link URL that is being dragged.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_link_url)(
|
||||
struct _cef_drag_data_t* self);
|
||||
|
||||
///
|
||||
/// Return the title associated with the link being dragged.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_link_title)(
|
||||
struct _cef_drag_data_t* self);
|
||||
|
||||
///
|
||||
/// Return the metadata, if any, associated with the link being dragged.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_link_metadata)(
|
||||
struct _cef_drag_data_t* self);
|
||||
|
||||
///
|
||||
/// Return the plain text fragment that is being dragged.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_fragment_text)(
|
||||
struct _cef_drag_data_t* self);
|
||||
|
||||
///
|
||||
/// Return the text/html fragment that is being dragged.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_fragment_html)(
|
||||
struct _cef_drag_data_t* self);
|
||||
|
||||
///
|
||||
/// Return the base URL that the fragment came from. This value is used for
|
||||
/// resolving relative URLs and may be NULL.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_fragment_base_url)(
|
||||
struct _cef_drag_data_t* self);
|
||||
|
||||
///
|
||||
/// Return the name of the file being dragged out of the browser window.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_file_name)(
|
||||
struct _cef_drag_data_t* self);
|
||||
|
||||
///
|
||||
/// Write the contents of the file being dragged out of the web view into
|
||||
/// |writer|. Returns the number of bytes sent to |writer|. If |writer| is
|
||||
/// NULL this function will return the size of the file contents in bytes.
|
||||
/// Call get_file_name() to get a suggested name for the file.
|
||||
///
|
||||
size_t(CEF_CALLBACK* get_file_contents)(struct _cef_drag_data_t* self,
|
||||
struct _cef_stream_writer_t* writer);
|
||||
|
||||
///
|
||||
/// Retrieve the list of file names that are being dragged into the browser
|
||||
/// window.
|
||||
///
|
||||
int(CEF_CALLBACK* get_file_names)(struct _cef_drag_data_t* self,
|
||||
cef_string_list_t names);
|
||||
|
||||
///
|
||||
/// Set the link URL that is being dragged.
|
||||
///
|
||||
void(CEF_CALLBACK* set_link_url)(struct _cef_drag_data_t* self,
|
||||
const cef_string_t* url);
|
||||
|
||||
///
|
||||
/// Set the title associated with the link being dragged.
|
||||
///
|
||||
void(CEF_CALLBACK* set_link_title)(struct _cef_drag_data_t* self,
|
||||
const cef_string_t* title);
|
||||
|
||||
///
|
||||
/// Set the metadata associated with the link being dragged.
|
||||
///
|
||||
void(CEF_CALLBACK* set_link_metadata)(struct _cef_drag_data_t* self,
|
||||
const cef_string_t* data);
|
||||
|
||||
///
|
||||
/// Set the plain text fragment that is being dragged.
|
||||
///
|
||||
void(CEF_CALLBACK* set_fragment_text)(struct _cef_drag_data_t* self,
|
||||
const cef_string_t* text);
|
||||
|
||||
///
|
||||
/// Set the text/html fragment that is being dragged.
|
||||
///
|
||||
void(CEF_CALLBACK* set_fragment_html)(struct _cef_drag_data_t* self,
|
||||
const cef_string_t* html);
|
||||
|
||||
///
|
||||
/// Set the base URL that the fragment came from.
|
||||
///
|
||||
void(CEF_CALLBACK* set_fragment_base_url)(struct _cef_drag_data_t* self,
|
||||
const cef_string_t* base_url);
|
||||
|
||||
///
|
||||
/// Reset the file contents. You should do this before calling
|
||||
/// cef_browser_host_t::DragTargetDragEnter as the web view does not allow us
|
||||
/// to drag in this kind of data.
|
||||
///
|
||||
void(CEF_CALLBACK* reset_file_contents)(struct _cef_drag_data_t* self);
|
||||
|
||||
///
|
||||
/// Add a file that is being dragged into the webview.
|
||||
///
|
||||
void(CEF_CALLBACK* add_file)(struct _cef_drag_data_t* self,
|
||||
const cef_string_t* path,
|
||||
const cef_string_t* display_name);
|
||||
|
||||
///
|
||||
/// Clear list of filenames.
|
||||
///
|
||||
void(CEF_CALLBACK* clear_filenames)(struct _cef_drag_data_t* self);
|
||||
|
||||
///
|
||||
/// Get the image representation of drag data. May return NULL if no image
|
||||
/// representation is available.
|
||||
///
|
||||
struct _cef_image_t*(CEF_CALLBACK* get_image)(struct _cef_drag_data_t* self);
|
||||
|
||||
///
|
||||
/// Get the image hotspot (drag start location relative to image dimensions).
|
||||
///
|
||||
cef_point_t(CEF_CALLBACK* get_image_hotspot)(struct _cef_drag_data_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if an image representation of drag data is available.
|
||||
///
|
||||
int(CEF_CALLBACK* has_image)(struct _cef_drag_data_t* self);
|
||||
} cef_drag_data_t;
|
||||
|
||||
///
|
||||
/// Create a new cef_drag_data_t object.
|
||||
///
|
||||
CEF_EXPORT cef_drag_data_t* cef_drag_data_create(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_DRAG_DATA_CAPI_H_
|
||||
92
third/cef/include/capi/cef_drag_handler_capi.h
Normal file
92
third/cef/include/capi/cef_drag_handler_capi.h
Normal file
@@ -0,0 +1,92 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=ad16b0f4320d7b363efb152a65e3ce142882b9d9$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_DRAG_HANDLER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_DRAG_HANDLER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
#include "include/capi/cef_drag_data_capi.h"
|
||||
#include "include/capi/cef_frame_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Implement this structure to handle events related to dragging. The functions
|
||||
/// of this structure will be called on the UI thread.
|
||||
///
|
||||
typedef struct _cef_drag_handler_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Called when an external drag event enters the browser window. |dragData|
|
||||
/// contains the drag event data and |mask| represents the type of drag
|
||||
/// operation. Return false (0) for default drag handling behavior or true (1)
|
||||
/// to cancel the drag event.
|
||||
///
|
||||
int(CEF_CALLBACK* on_drag_enter)(struct _cef_drag_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
struct _cef_drag_data_t* dragData,
|
||||
cef_drag_operations_mask_t mask);
|
||||
|
||||
///
|
||||
/// Called whenever draggable regions for the browser window change. These can
|
||||
/// be specified using the '-webkit-app-region: drag/no-drag' CSS-property. If
|
||||
/// draggable regions are never defined in a document this function will also
|
||||
/// never be called. If the last draggable region is removed from a document
|
||||
/// this function will be called with an NULL vector.
|
||||
///
|
||||
void(CEF_CALLBACK* on_draggable_regions_changed)(
|
||||
struct _cef_drag_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame,
|
||||
size_t regionsCount,
|
||||
cef_draggable_region_t const* regions);
|
||||
} cef_drag_handler_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_DRAG_HANDLER_CAPI_H_
|
||||
130
third/cef/include/capi/cef_extension_capi.h
Normal file
130
third/cef/include/capi/cef_extension_capi.h
Normal file
@@ -0,0 +1,130 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=c81a74622b987483e5fcd2c508aec5c13e12389b$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_EXTENSION_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_EXTENSION_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _cef_extension_handler_t;
|
||||
struct _cef_request_context_t;
|
||||
|
||||
///
|
||||
/// Object representing an extension. Methods may be called on any thread unless
|
||||
/// otherwise indicated.
|
||||
///
|
||||
typedef struct _cef_extension_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Returns the unique extension identifier. This is calculated based on the
|
||||
/// extension public key, if available, or on the extension path. See
|
||||
/// https://developer.chrome.com/extensions/manifest/key for details.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_identifier)(
|
||||
struct _cef_extension_t* self);
|
||||
|
||||
///
|
||||
/// Returns the absolute path to the extension directory on disk. This value
|
||||
/// will be prefixed with PK_DIR_RESOURCES if a relative path was passed to
|
||||
/// cef_request_context_t::LoadExtension.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_path)(struct _cef_extension_t* self);
|
||||
|
||||
///
|
||||
/// Returns the extension manifest contents as a cef_dictionary_value_t
|
||||
/// object. See https://developer.chrome.com/extensions/manifest for details.
|
||||
///
|
||||
struct _cef_dictionary_value_t*(CEF_CALLBACK* get_manifest)(
|
||||
struct _cef_extension_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if this object is the same extension as |that| object.
|
||||
/// Extensions are considered the same if identifier, path and loader context
|
||||
/// match.
|
||||
///
|
||||
int(CEF_CALLBACK* is_same)(struct _cef_extension_t* self,
|
||||
struct _cef_extension_t* that);
|
||||
|
||||
///
|
||||
/// Returns the handler for this extension. Will return NULL for internal
|
||||
/// extensions or if no handler was passed to
|
||||
/// cef_request_context_t::LoadExtension.
|
||||
///
|
||||
struct _cef_extension_handler_t*(CEF_CALLBACK* get_handler)(
|
||||
struct _cef_extension_t* self);
|
||||
|
||||
///
|
||||
/// Returns the request context that loaded this extension. Will return NULL
|
||||
/// for internal extensions or if the extension has been unloaded. See the
|
||||
/// cef_request_context_t::LoadExtension documentation for more information
|
||||
/// about loader contexts. Must be called on the browser process UI thread.
|
||||
///
|
||||
struct _cef_request_context_t*(CEF_CALLBACK* get_loader_context)(
|
||||
struct _cef_extension_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if this extension is currently loaded. Must be called on
|
||||
/// the browser process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* is_loaded)(struct _cef_extension_t* self);
|
||||
|
||||
///
|
||||
/// Unload this extension if it is not an internal extension and is currently
|
||||
/// loaded. Will result in a call to
|
||||
/// cef_extension_handler_t::OnExtensionUnloaded on success.
|
||||
///
|
||||
void(CEF_CALLBACK* unload)(struct _cef_extension_t* self);
|
||||
} cef_extension_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_EXTENSION_CAPI_H_
|
||||
212
third/cef/include/capi/cef_extension_handler_capi.h
Normal file
212
third/cef/include/capi/cef_extension_handler_capi.h
Normal file
@@ -0,0 +1,212 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=ad6d3845b150f22b88a71dafa601ef01c9579824$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
#include "include/capi/cef_extension_capi.h"
|
||||
#include "include/capi/cef_stream_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _cef_client_t;
|
||||
|
||||
///
|
||||
/// Callback structure used for asynchronous continuation of
|
||||
/// cef_extension_handler_t::GetExtensionResource.
|
||||
///
|
||||
typedef struct _cef_get_extension_resource_callback_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Continue the request. Read the resource contents from |stream|.
|
||||
///
|
||||
void(CEF_CALLBACK* cont)(struct _cef_get_extension_resource_callback_t* self,
|
||||
struct _cef_stream_reader_t* stream);
|
||||
|
||||
///
|
||||
/// Cancel the request.
|
||||
///
|
||||
void(CEF_CALLBACK* cancel)(
|
||||
struct _cef_get_extension_resource_callback_t* self);
|
||||
} cef_get_extension_resource_callback_t;
|
||||
|
||||
///
|
||||
/// Implement this structure to handle events related to browser extensions. The
|
||||
/// functions of this structure will be called on the UI thread. See
|
||||
/// cef_request_context_t::LoadExtension for information about extension
|
||||
/// loading.
|
||||
///
|
||||
typedef struct _cef_extension_handler_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Called if the cef_request_context_t::LoadExtension request fails. |result|
|
||||
/// will be the error code.
|
||||
///
|
||||
void(CEF_CALLBACK* on_extension_load_failed)(
|
||||
struct _cef_extension_handler_t* self,
|
||||
cef_errorcode_t result);
|
||||
|
||||
///
|
||||
/// Called if the cef_request_context_t::LoadExtension request succeeds.
|
||||
/// |extension| is the loaded extension.
|
||||
///
|
||||
void(CEF_CALLBACK* on_extension_loaded)(struct _cef_extension_handler_t* self,
|
||||
struct _cef_extension_t* extension);
|
||||
|
||||
///
|
||||
/// Called after the cef_extension_t::Unload request has completed.
|
||||
///
|
||||
void(CEF_CALLBACK* on_extension_unloaded)(
|
||||
struct _cef_extension_handler_t* self,
|
||||
struct _cef_extension_t* extension);
|
||||
|
||||
///
|
||||
/// Called when an extension needs a browser to host a background script
|
||||
/// specified via the "background" manifest key. The browser will have no
|
||||
/// visible window and cannot be displayed. |extension| is the extension that
|
||||
/// is loading the background script. |url| is an internally generated
|
||||
/// reference to an HTML page that will be used to load the background script
|
||||
/// via a "<script>" src attribute. To allow creation of the browser
|
||||
/// optionally modify |client| and |settings| and return false (0). To cancel
|
||||
/// creation of the browser (and consequently cancel load of the background
|
||||
/// script) return true (1). Successful creation will be indicated by a call
|
||||
/// to cef_life_span_handler_t::OnAfterCreated, and
|
||||
/// cef_browser_host_t::IsBackgroundHost will return true (1) for the
|
||||
/// resulting browser. See https://developer.chrome.com/extensions/event_pages
|
||||
/// for more information about extension background script usage.
|
||||
///
|
||||
int(CEF_CALLBACK* on_before_background_browser)(
|
||||
struct _cef_extension_handler_t* self,
|
||||
struct _cef_extension_t* extension,
|
||||
const cef_string_t* url,
|
||||
struct _cef_client_t** client,
|
||||
struct _cef_browser_settings_t* settings);
|
||||
|
||||
///
|
||||
/// Called when an extension API (e.g. chrome.tabs.create) requests creation
|
||||
/// of a new browser. |extension| and |browser| are the source of the API
|
||||
/// call. |active_browser| may optionally be specified via the windowId
|
||||
/// property or returned via the get_active_browser() callback and provides
|
||||
/// the default |client| and |settings| values for the new browser. |index| is
|
||||
/// the position value optionally specified via the index property. |url| is
|
||||
/// the URL that will be loaded in the browser. |active| is true (1) if the
|
||||
/// new browser should be active when opened. To allow creation of the
|
||||
/// browser optionally modify |windowInfo|, |client| and |settings| and return
|
||||
/// false (0). To cancel creation of the browser return true (1). Successful
|
||||
/// creation will be indicated by a call to
|
||||
/// cef_life_span_handler_t::OnAfterCreated. Any modifications to |windowInfo|
|
||||
/// will be ignored if |active_browser| is wrapped in a cef_browser_view_t.
|
||||
///
|
||||
int(CEF_CALLBACK* on_before_browser)(
|
||||
struct _cef_extension_handler_t* self,
|
||||
struct _cef_extension_t* extension,
|
||||
struct _cef_browser_t* browser,
|
||||
struct _cef_browser_t* active_browser,
|
||||
int index,
|
||||
const cef_string_t* url,
|
||||
int active,
|
||||
struct _cef_window_info_t* windowInfo,
|
||||
struct _cef_client_t** client,
|
||||
struct _cef_browser_settings_t* settings);
|
||||
|
||||
///
|
||||
/// Called when no tabId is specified to an extension API call that accepts a
|
||||
/// tabId parameter (e.g. chrome.tabs.*). |extension| and |browser| are the
|
||||
/// source of the API call. Return the browser that will be acted on by the
|
||||
/// API call or return NULL to act on |browser|. The returned browser must
|
||||
/// share the same cef_request_context_t as |browser|. Incognito browsers
|
||||
/// should not be considered unless the source extension has incognito access
|
||||
/// enabled, in which case |include_incognito| will be true (1).
|
||||
///
|
||||
struct _cef_browser_t*(CEF_CALLBACK* get_active_browser)(
|
||||
struct _cef_extension_handler_t* self,
|
||||
struct _cef_extension_t* extension,
|
||||
struct _cef_browser_t* browser,
|
||||
int include_incognito);
|
||||
|
||||
///
|
||||
/// Called when the tabId associated with |target_browser| is specified to an
|
||||
/// extension API call that accepts a tabId parameter (e.g. chrome.tabs.*).
|
||||
/// |extension| and |browser| are the source of the API call. Return true (1)
|
||||
/// to allow access of false (0) to deny access. Access to incognito browsers
|
||||
/// should not be allowed unless the source extension has incognito access
|
||||
/// enabled, in which case |include_incognito| will be true (1).
|
||||
///
|
||||
int(CEF_CALLBACK* can_access_browser)(struct _cef_extension_handler_t* self,
|
||||
struct _cef_extension_t* extension,
|
||||
struct _cef_browser_t* browser,
|
||||
int include_incognito,
|
||||
struct _cef_browser_t* target_browser);
|
||||
|
||||
///
|
||||
/// Called to retrieve an extension resource that would normally be loaded
|
||||
/// from disk (e.g. if a file parameter is specified to
|
||||
/// chrome.tabs.executeScript). |extension| and |browser| are the source of
|
||||
/// the resource request. |file| is the requested relative file path. To
|
||||
/// handle the resource request return true (1) and execute |callback| either
|
||||
/// synchronously or asynchronously. For the default behavior which reads the
|
||||
/// resource from the extension directory on disk return false (0).
|
||||
/// Localization substitutions will not be applied to resources handled via
|
||||
/// this function.
|
||||
///
|
||||
int(CEF_CALLBACK* get_extension_resource)(
|
||||
struct _cef_extension_handler_t* self,
|
||||
struct _cef_extension_t* extension,
|
||||
struct _cef_browser_t* browser,
|
||||
const cef_string_t* file,
|
||||
struct _cef_get_extension_resource_callback_t* callback);
|
||||
} cef_extension_handler_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_
|
||||
132
third/cef/include/capi/cef_file_util_capi.h
Normal file
132
third/cef/include/capi/cef_file_util_capi.h
Normal file
@@ -0,0 +1,132 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=4e0e0abcb72327998df950e618b147b196e76b60$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_FILE_UTIL_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_FILE_UTIL_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Creates a directory and all parent directories if they don't already exist.
|
||||
/// Returns true (1) on successful creation or if the directory already exists.
|
||||
/// The directory is only readable by the current user. Calling this function on
|
||||
/// the browser process UI or IO threads is not allowed.
|
||||
///
|
||||
CEF_EXPORT int cef_create_directory(const cef_string_t* full_path);
|
||||
|
||||
///
|
||||
/// Get the temporary directory provided by the system.
|
||||
///
|
||||
/// WARNING: In general, you should use the temp directory variants below
|
||||
/// instead of this function. Those variants will ensure that the proper
|
||||
/// permissions are set so that other users on the system can't edit them while
|
||||
/// they're open (which could lead to security issues).
|
||||
///
|
||||
CEF_EXPORT int cef_get_temp_directory(cef_string_t* temp_dir);
|
||||
|
||||
///
|
||||
/// Creates a new directory. On Windows if |prefix| is provided the new
|
||||
/// directory name is in the format of "prefixyyyy". Returns true (1) on success
|
||||
/// and sets |new_temp_path| to the full path of the directory that was created.
|
||||
/// The directory is only readable by the current user. Calling this function on
|
||||
/// the browser process UI or IO threads is not allowed.
|
||||
///
|
||||
CEF_EXPORT int cef_create_new_temp_directory(const cef_string_t* prefix,
|
||||
cef_string_t* new_temp_path);
|
||||
|
||||
///
|
||||
/// Creates a directory within another directory. Extra characters will be
|
||||
/// appended to |prefix| to ensure that the new directory does not have the same
|
||||
/// name as an existing directory. Returns true (1) on success and sets
|
||||
/// |new_dir| to the full path of the directory that was created. The directory
|
||||
/// is only readable by the current user. Calling this function on the browser
|
||||
/// process UI or IO threads is not allowed.
|
||||
///
|
||||
CEF_EXPORT int cef_create_temp_directory_in_directory(
|
||||
const cef_string_t* base_dir,
|
||||
const cef_string_t* prefix,
|
||||
cef_string_t* new_dir);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the given path exists and is a directory. Calling this
|
||||
/// function on the browser process UI or IO threads is not allowed.
|
||||
///
|
||||
CEF_EXPORT int cef_directory_exists(const cef_string_t* path);
|
||||
|
||||
///
|
||||
/// Deletes the given path whether it's a file or a directory. If |path| is a
|
||||
/// directory all contents will be deleted. If |recursive| is true (1) any sub-
|
||||
/// directories and their contents will also be deleted (equivalent to executing
|
||||
/// "rm -rf", so use with caution). On POSIX environments if |path| is a
|
||||
/// symbolic link then only the symlink will be deleted. Returns true (1) on
|
||||
/// successful deletion or if |path| does not exist. Calling this function on
|
||||
/// the browser process UI or IO threads is not allowed.
|
||||
///
|
||||
CEF_EXPORT int cef_delete_file(const cef_string_t* path, int recursive);
|
||||
|
||||
///
|
||||
/// Writes the contents of |src_dir| into a zip archive at |dest_file|. If
|
||||
/// |include_hidden_files| is true (1) files starting with "." will be included.
|
||||
/// Returns true (1) on success. Calling this function on the browser process
|
||||
/// UI or IO threads is not allowed.
|
||||
///
|
||||
CEF_EXPORT int cef_zip_directory(const cef_string_t* src_dir,
|
||||
const cef_string_t* dest_file,
|
||||
int include_hidden_files);
|
||||
|
||||
///
|
||||
/// Loads the existing "Certificate Revocation Lists" file that is managed by
|
||||
/// Google Chrome. This file can generally be found in Chrome's User Data
|
||||
/// directory (e.g. "C:\Users\[User]\AppData\Local\Google\Chrome\User Data\" on
|
||||
/// Windows) and is updated periodically by Chrome's component updater service.
|
||||
/// Must be called in the browser process after the context has been
|
||||
/// initialized. See https://dev.chromium.org/Home/chromium-security/crlsets for
|
||||
/// background.
|
||||
///
|
||||
CEF_EXPORT void cef_load_crlsets_file(const cef_string_t* path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_FILE_UTIL_CAPI_H_
|
||||
82
third/cef/include/capi/cef_find_handler_capi.h
Normal file
82
third/cef/include/capi/cef_find_handler_capi.h
Normal file
@@ -0,0 +1,82 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=8149c82dd6671d676ee62cb6749bf30b32a5832c$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_FIND_HANDLER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_FIND_HANDLER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Implement this structure to handle events related to find results. The
|
||||
/// functions of this structure will be called on the UI thread.
|
||||
///
|
||||
typedef struct _cef_find_handler_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Called to report find results returned by cef_browser_host_t::find().
|
||||
/// |identifer| is a unique incremental identifier for the currently active
|
||||
/// search, |count| is the number of matches currently identified,
|
||||
/// |selectionRect| is the location of where the match was found (in window
|
||||
/// coordinates), |activeMatchOrdinal| is the current position in the search
|
||||
/// results, and |finalUpdate| is true (1) if this is the last find
|
||||
/// notification.
|
||||
///
|
||||
void(CEF_CALLBACK* on_find_result)(struct _cef_find_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
int identifier,
|
||||
int count,
|
||||
const cef_rect_t* selectionRect,
|
||||
int activeMatchOrdinal,
|
||||
int finalUpdate);
|
||||
} cef_find_handler_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_FIND_HANDLER_CAPI_H_
|
||||
93
third/cef/include/capi/cef_focus_handler_capi.h
Normal file
93
third/cef/include/capi/cef_focus_handler_capi.h
Normal file
@@ -0,0 +1,93 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=53ec33c8937c735f646f9e0a14a416218e32887c$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_FOCUS_HANDLER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_FOCUS_HANDLER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
#include "include/capi/cef_dom_capi.h"
|
||||
#include "include/capi/cef_frame_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Implement this structure to handle events related to focus. The functions of
|
||||
/// this structure will be called on the UI thread.
|
||||
///
|
||||
typedef struct _cef_focus_handler_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Called when the browser component is about to loose focus. For instance,
|
||||
/// if focus was on the last HTML element and the user pressed the TAB key.
|
||||
/// |next| will be true (1) if the browser is giving focus to the next
|
||||
/// component and false (0) if the browser is giving focus to the previous
|
||||
/// component.
|
||||
///
|
||||
void(CEF_CALLBACK* on_take_focus)(struct _cef_focus_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
int next);
|
||||
|
||||
///
|
||||
/// Called when the browser component is requesting focus. |source| indicates
|
||||
/// where the focus request is originating from. Return false (0) to allow the
|
||||
/// focus to be set or true (1) to cancel setting the focus.
|
||||
///
|
||||
int(CEF_CALLBACK* on_set_focus)(struct _cef_focus_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
cef_focus_source_t source);
|
||||
|
||||
///
|
||||
/// Called when the browser component has received focus.
|
||||
///
|
||||
void(CEF_CALLBACK* on_got_focus)(struct _cef_focus_handler_t* self,
|
||||
struct _cef_browser_t* browser);
|
||||
} cef_focus_handler_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_FOCUS_HANDLER_CAPI_H_
|
||||
255
third/cef/include/capi/cef_frame_capi.h
Normal file
255
third/cef/include/capi/cef_frame_capi.h
Normal file
@@ -0,0 +1,255 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=5bed8359f09a821f4b5ec8ebfad0aa5720bf39f9$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_FRAME_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_FRAME_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_dom_capi.h"
|
||||
#include "include/capi/cef_process_message_capi.h"
|
||||
#include "include/capi/cef_request_capi.h"
|
||||
#include "include/capi/cef_stream_capi.h"
|
||||
#include "include/capi/cef_string_visitor_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _cef_browser_t;
|
||||
struct _cef_urlrequest_client_t;
|
||||
struct _cef_urlrequest_t;
|
||||
struct _cef_v8context_t;
|
||||
|
||||
///
|
||||
/// Structure used to represent a frame in the browser window. When used in the
|
||||
/// browser process the functions of this structure may be called on any thread
|
||||
/// unless otherwise indicated in the comments. When used in the render process
|
||||
/// the functions of this structure may only be called on the main thread.
|
||||
///
|
||||
typedef struct _cef_frame_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// True if this object is currently attached to a valid frame.
|
||||
///
|
||||
int(CEF_CALLBACK* is_valid)(struct _cef_frame_t* self);
|
||||
|
||||
///
|
||||
/// Execute undo in this frame.
|
||||
///
|
||||
void(CEF_CALLBACK* undo)(struct _cef_frame_t* self);
|
||||
|
||||
///
|
||||
/// Execute redo in this frame.
|
||||
///
|
||||
void(CEF_CALLBACK* redo)(struct _cef_frame_t* self);
|
||||
|
||||
///
|
||||
/// Execute cut in this frame.
|
||||
///
|
||||
void(CEF_CALLBACK* cut)(struct _cef_frame_t* self);
|
||||
|
||||
///
|
||||
/// Execute copy in this frame.
|
||||
///
|
||||
void(CEF_CALLBACK* copy)(struct _cef_frame_t* self);
|
||||
|
||||
///
|
||||
/// Execute paste in this frame.
|
||||
///
|
||||
void(CEF_CALLBACK* paste)(struct _cef_frame_t* self);
|
||||
|
||||
///
|
||||
/// Execute delete in this frame.
|
||||
///
|
||||
void(CEF_CALLBACK* del)(struct _cef_frame_t* self);
|
||||
|
||||
///
|
||||
/// Execute select all in this frame.
|
||||
///
|
||||
void(CEF_CALLBACK* select_all)(struct _cef_frame_t* self);
|
||||
|
||||
///
|
||||
/// Save this frame's HTML source to a temporary file and open it in the
|
||||
/// default text viewing application. This function can only be called from
|
||||
/// the browser process.
|
||||
///
|
||||
void(CEF_CALLBACK* view_source)(struct _cef_frame_t* self);
|
||||
|
||||
///
|
||||
/// Retrieve this frame's HTML source as a string sent to the specified
|
||||
/// visitor.
|
||||
///
|
||||
void(CEF_CALLBACK* get_source)(struct _cef_frame_t* self,
|
||||
struct _cef_string_visitor_t* visitor);
|
||||
|
||||
///
|
||||
/// Retrieve this frame's display text as a string sent to the specified
|
||||
/// visitor.
|
||||
///
|
||||
void(CEF_CALLBACK* get_text)(struct _cef_frame_t* self,
|
||||
struct _cef_string_visitor_t* visitor);
|
||||
|
||||
///
|
||||
/// Load the request represented by the |request| object.
|
||||
///
|
||||
/// WARNING: This function will fail with "bad IPC message" reason
|
||||
/// INVALID_INITIATOR_ORIGIN (213) unless you first navigate to the request
|
||||
/// origin using some other mechanism (LoadURL, link click, etc).
|
||||
///
|
||||
void(CEF_CALLBACK* load_request)(struct _cef_frame_t* self,
|
||||
struct _cef_request_t* request);
|
||||
|
||||
///
|
||||
/// Load the specified |url|.
|
||||
///
|
||||
void(CEF_CALLBACK* load_url)(struct _cef_frame_t* self,
|
||||
const cef_string_t* url);
|
||||
|
||||
///
|
||||
/// Execute a string of JavaScript code in this frame. The |script_url|
|
||||
/// parameter is the URL where the script in question can be found, if any.
|
||||
/// The renderer may request this URL to show the developer the source of the
|
||||
/// error. The |start_line| parameter is the base line number to use for
|
||||
/// error reporting.
|
||||
///
|
||||
void(CEF_CALLBACK* execute_java_script)(struct _cef_frame_t* self,
|
||||
const cef_string_t* code,
|
||||
const cef_string_t* script_url,
|
||||
int start_line);
|
||||
|
||||
///
|
||||
/// Returns true (1) if this is the main (top-level) frame.
|
||||
///
|
||||
int(CEF_CALLBACK* is_main)(struct _cef_frame_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if this is the focused frame.
|
||||
///
|
||||
int(CEF_CALLBACK* is_focused)(struct _cef_frame_t* self);
|
||||
|
||||
///
|
||||
/// Returns the name for this frame. If the frame has an assigned name (for
|
||||
/// example, set via the iframe "name" attribute) then that value will be
|
||||
/// returned. Otherwise a unique name will be constructed based on the frame
|
||||
/// parent hierarchy. The main (top-level) frame will always have an NULL name
|
||||
/// value.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_name)(struct _cef_frame_t* self);
|
||||
|
||||
///
|
||||
/// Returns the globally unique identifier for this frame or < 0 if the
|
||||
/// underlying frame does not yet exist.
|
||||
///
|
||||
int64(CEF_CALLBACK* get_identifier)(struct _cef_frame_t* self);
|
||||
|
||||
///
|
||||
/// Returns the parent of this frame or NULL if this is the main (top-level)
|
||||
/// frame.
|
||||
///
|
||||
struct _cef_frame_t*(CEF_CALLBACK* get_parent)(struct _cef_frame_t* self);
|
||||
|
||||
///
|
||||
/// Returns the URL currently loaded in this frame.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_url)(struct _cef_frame_t* self);
|
||||
|
||||
///
|
||||
/// Returns the browser that this frame belongs to.
|
||||
///
|
||||
struct _cef_browser_t*(CEF_CALLBACK* get_browser)(struct _cef_frame_t* self);
|
||||
|
||||
///
|
||||
/// Get the V8 context associated with the frame. This function can only be
|
||||
/// called from the render process.
|
||||
///
|
||||
struct _cef_v8context_t*(CEF_CALLBACK* get_v8context)(
|
||||
struct _cef_frame_t* self);
|
||||
|
||||
///
|
||||
/// Visit the DOM document. This function can only be called from the render
|
||||
/// process.
|
||||
///
|
||||
void(CEF_CALLBACK* visit_dom)(struct _cef_frame_t* self,
|
||||
struct _cef_domvisitor_t* visitor);
|
||||
|
||||
///
|
||||
/// Create a new URL request that will be treated as originating from this
|
||||
/// frame and the associated browser. Use cef_urlrequest_t::Create instead if
|
||||
/// you do not want the request to have this association, in which case it may
|
||||
/// be handled differently (see documentation on that function). A request
|
||||
/// created with this function may only originate from the browser process,
|
||||
/// and will behave as follows:
|
||||
/// - It may be intercepted by the client via CefResourceRequestHandler or
|
||||
/// CefSchemeHandlerFactory.
|
||||
/// - POST data may only contain a single element of type PDE_TYPE_FILE or
|
||||
/// PDE_TYPE_BYTES.
|
||||
///
|
||||
/// The |request| object will be marked as read-only after calling this
|
||||
/// function.
|
||||
///
|
||||
struct _cef_urlrequest_t*(CEF_CALLBACK* create_urlrequest)(
|
||||
struct _cef_frame_t* self,
|
||||
struct _cef_request_t* request,
|
||||
struct _cef_urlrequest_client_t* client);
|
||||
|
||||
///
|
||||
/// Send a message to the specified |target_process|. Ownership of the message
|
||||
/// contents will be transferred and the |message| reference will be
|
||||
/// invalidated. Message delivery is not guaranteed in all cases (for example,
|
||||
/// if the browser is closing, navigating, or if the target process crashes).
|
||||
/// Send an ACK message back from the target process if confirmation is
|
||||
/// required.
|
||||
///
|
||||
void(CEF_CALLBACK* send_process_message)(
|
||||
struct _cef_frame_t* self,
|
||||
cef_process_id_t target_process,
|
||||
struct _cef_process_message_t* message);
|
||||
} cef_frame_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_FRAME_CAPI_H_
|
||||
202
third/cef/include/capi/cef_frame_handler_capi.h
Normal file
202
third/cef/include/capi/cef_frame_handler_capi.h
Normal file
@@ -0,0 +1,202 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=4cdadeb6439415d60ec32249c3a0b6457dd586f7$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_FRAME_HANDLER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_FRAME_HANDLER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
#include "include/capi/cef_frame_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Implement this structure to handle events related to cef_frame_t life span.
|
||||
/// The order of callbacks is:
|
||||
///
|
||||
/// (1) During initial cef_browser_host_t creation and navigation of the main
|
||||
/// frame: - cef_frame_handler_t::OnFrameCreated => The initial main frame
|
||||
/// object has been
|
||||
/// created. Any commands will be queued until the frame is attached.
|
||||
/// - cef_frame_handler_t::OnMainFrameChanged => The initial main frame object
|
||||
/// has
|
||||
/// been assigned to the browser.
|
||||
/// - cef_life_span_handler_t::OnAfterCreated => The browser is now valid and
|
||||
/// can be
|
||||
/// used.
|
||||
/// - cef_frame_handler_t::OnFrameAttached => The initial main frame object is
|
||||
/// now
|
||||
/// connected to its peer in the renderer process. Commands can be routed.
|
||||
///
|
||||
/// (2) During further cef_browser_host_t navigation/loading of the main frame
|
||||
/// and/or sub-frames:
|
||||
/// - cef_frame_handler_t::OnFrameCreated => A new main frame or sub-frame
|
||||
/// object
|
||||
/// has been created. Any commands will be queued until the frame is attached.
|
||||
/// - cef_frame_handler_t::OnFrameAttached => A new main frame or sub-frame
|
||||
/// object
|
||||
/// is now connected to its peer in the renderer process. Commands can be
|
||||
/// routed.
|
||||
/// - cef_frame_handler_t::OnFrameDetached => An existing main frame or sub-
|
||||
/// frame
|
||||
/// object has lost its connection to the renderer process. If multiple
|
||||
/// objects are detached at the same time then notifications will be sent for
|
||||
/// any sub-frame objects before the main frame object. Commands can no longer
|
||||
/// be routed and will be discarded.
|
||||
/// - cef_frame_handler_t::OnMainFrameChanged => A new main frame object has
|
||||
/// been
|
||||
/// assigned to the browser. This will only occur with cross-origin navigation
|
||||
/// or re-navigation after renderer process termination (due to crashes, etc).
|
||||
///
|
||||
/// (3) During final cef_browser_host_t destruction of the main frame: -
|
||||
/// cef_frame_handler_t::OnFrameDetached => Any sub-frame objects have lost
|
||||
/// their
|
||||
/// connection to the renderer process. Commands can no longer be routed and
|
||||
/// will be discarded.
|
||||
/// - cef_life_span_handler_t::OnBeforeClose => The browser has been destroyed.
|
||||
/// - cef_frame_handler_t::OnFrameDetached => The main frame object have lost
|
||||
/// its
|
||||
/// connection to the renderer process. Notifications will be sent for any
|
||||
/// sub-frame objects before the main frame object. Commands can no longer be
|
||||
/// routed and will be discarded.
|
||||
/// - cef_frame_handler_t::OnMainFrameChanged => The final main frame object has
|
||||
/// been removed from the browser.
|
||||
///
|
||||
/// Cross-origin navigation and/or loading receives special handling.
|
||||
///
|
||||
/// When the main frame navigates to a different origin the OnMainFrameChanged
|
||||
/// callback (2) will be executed with the old and new main frame objects.
|
||||
///
|
||||
/// When a new sub-frame is loaded in, or an existing sub-frame is navigated to,
|
||||
/// a different origin from the parent frame, a temporary sub-frame object will
|
||||
/// first be created in the parent's renderer process. That temporary sub-frame
|
||||
/// will then be discarded after the real cross-origin sub-frame is created in
|
||||
/// the new/target renderer process. The client will receive cross-origin
|
||||
/// navigation callbacks (2) for the transition from the temporary sub-frame to
|
||||
/// the real sub-frame. The temporary sub-frame will not recieve or execute
|
||||
/// commands during this transitional period (any sent commands will be
|
||||
/// discarded).
|
||||
///
|
||||
/// When a new popup browser is created in a different origin from the parent
|
||||
/// browser, a temporary main frame object for the popup will first be created
|
||||
/// in the parent's renderer process. That temporary main frame will then be
|
||||
/// discarded after the real cross-origin main frame is created in the
|
||||
/// new/target renderer process. The client will recieve creation and initial
|
||||
/// navigation callbacks (1) for the temporary main frame, followed by cross-
|
||||
/// origin navigation callbacks (2) for the transition from the temporary main
|
||||
/// frame to the real main frame. The temporary main frame may receive and
|
||||
/// execute commands during this transitional period (any sent commands may be
|
||||
/// executed, but the behavior is potentially undesirable since they execute in
|
||||
/// the parent browser's renderer process and not the new/target renderer
|
||||
/// process).
|
||||
///
|
||||
/// Callbacks will not be executed for placeholders that may be created during
|
||||
/// pre-commit navigation for sub-frames that do not yet exist in the renderer
|
||||
/// process. Placeholders will have cef_frame_t::get_identifier() == -4.
|
||||
///
|
||||
/// The functions of this structure will be called on the UI thread unless
|
||||
/// otherwise indicated.
|
||||
///
|
||||
typedef struct _cef_frame_handler_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Called when a new frame is created. This will be the first notification
|
||||
/// that references |frame|. Any commands that require transport to the
|
||||
/// associated renderer process (LoadRequest, SendProcessMessage, GetSource,
|
||||
/// etc.) will be queued until OnFrameAttached is called for |frame|.
|
||||
///
|
||||
void(CEF_CALLBACK* on_frame_created)(struct _cef_frame_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame);
|
||||
|
||||
///
|
||||
/// Called when a frame can begin routing commands to/from the associated
|
||||
/// renderer process. |reattached| will be true (1) if the frame was re-
|
||||
/// attached after exiting the BackForwardCache. Any commands that were queued
|
||||
/// have now been dispatched.
|
||||
///
|
||||
void(CEF_CALLBACK* on_frame_attached)(struct _cef_frame_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame,
|
||||
int reattached);
|
||||
|
||||
///
|
||||
/// Called when a frame loses its connection to the renderer process and will
|
||||
/// be destroyed. Any pending or future commands will be discarded and
|
||||
/// cef_frame_t::is_valid() will now return false (0) for |frame|. If called
|
||||
/// after cef_life_span_handler_t::on_before_close() during browser
|
||||
/// destruction then cef_browser_t::is_valid() will return false (0) for
|
||||
/// |browser|.
|
||||
///
|
||||
void(CEF_CALLBACK* on_frame_detached)(struct _cef_frame_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame);
|
||||
|
||||
///
|
||||
/// Called when the main frame changes due to (a) initial browser creation,
|
||||
/// (b) final browser destruction, (c) cross-origin navigation or (d) re-
|
||||
/// navigation after renderer process termination (due to crashes, etc).
|
||||
/// |old_frame| will be NULL and |new_frame| will be non-NULL when a main
|
||||
/// frame is assigned to |browser| for the first time. |old_frame| will be
|
||||
/// non-NULL and |new_frame| will be NULL and when a main frame is removed
|
||||
/// from |browser| for the last time. Both |old_frame| and |new_frame| will be
|
||||
/// non-NULL for cross-origin navigations or re-navigation after renderer
|
||||
/// process termination. This function will be called after on_frame_created()
|
||||
/// for |new_frame| and/or after on_frame_detached() for |old_frame|. If
|
||||
/// called after cef_life_span_handler_t::on_before_close() during browser
|
||||
/// destruction then cef_browser_t::is_valid() will return false (0) for
|
||||
/// |browser|.
|
||||
///
|
||||
void(CEF_CALLBACK* on_main_frame_changed)(struct _cef_frame_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* old_frame,
|
||||
struct _cef_frame_t* new_frame);
|
||||
} cef_frame_handler_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_FRAME_HANDLER_CAPI_H_
|
||||
58
third/cef/include/capi/cef_i18n_util_capi.h
Normal file
58
third/cef/include/capi/cef_i18n_util_capi.h
Normal file
@@ -0,0 +1,58 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=c564ee1f32a0ef05fe49fc779af5bc0b0e1b36d6$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_I18N_UTIL_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_I18N_UTIL_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Returns true (1) if the application text direction is right-to-left.
|
||||
///
|
||||
CEF_EXPORT int cef_is_rtl(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_I18N_UTIL_CAPI_H_
|
||||
206
third/cef/include/capi/cef_image_capi.h
Normal file
206
third/cef/include/capi/cef_image_capi.h
Normal file
@@ -0,0 +1,206 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=99c94b208f9b184985220493bba4ea08e6786046$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_IMAGE_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_IMAGE_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Container for a single image represented at different scale factors. All
|
||||
/// image representations should be the same size in density independent pixel
|
||||
/// (DIP) units. For example, if the image at scale factor 1.0 is 100x100 pixels
|
||||
/// then the image at scale factor 2.0 should be 200x200 pixels -- both images
|
||||
/// will display with a DIP size of 100x100 units. The functions of this
|
||||
/// structure can be called on any browser process thread.
|
||||
///
|
||||
typedef struct _cef_image_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Returns true (1) if this Image is NULL.
|
||||
///
|
||||
int(CEF_CALLBACK* is_empty)(struct _cef_image_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if this Image and |that| Image share the same underlying
|
||||
/// storage. Will also return true (1) if both images are NULL.
|
||||
///
|
||||
int(CEF_CALLBACK* is_same)(struct _cef_image_t* self,
|
||||
struct _cef_image_t* that);
|
||||
|
||||
///
|
||||
/// Add a bitmap image representation for |scale_factor|. Only 32-bit
|
||||
/// RGBA/BGRA formats are supported. |pixel_width| and |pixel_height| are the
|
||||
/// bitmap representation size in pixel coordinates. |pixel_data| is the array
|
||||
/// of pixel data and should be |pixel_width| x |pixel_height| x 4 bytes in
|
||||
/// size. |color_type| and |alpha_type| values specify the pixel format.
|
||||
///
|
||||
int(CEF_CALLBACK* add_bitmap)(struct _cef_image_t* self,
|
||||
float scale_factor,
|
||||
int pixel_width,
|
||||
int pixel_height,
|
||||
cef_color_type_t color_type,
|
||||
cef_alpha_type_t alpha_type,
|
||||
const void* pixel_data,
|
||||
size_t pixel_data_size);
|
||||
|
||||
///
|
||||
/// Add a PNG image representation for |scale_factor|. |png_data| is the image
|
||||
/// data of size |png_data_size|. Any alpha transparency in the PNG data will
|
||||
/// be maintained.
|
||||
///
|
||||
int(CEF_CALLBACK* add_png)(struct _cef_image_t* self,
|
||||
float scale_factor,
|
||||
const void* png_data,
|
||||
size_t png_data_size);
|
||||
|
||||
///
|
||||
/// Create a JPEG image representation for |scale_factor|. |jpeg_data| is the
|
||||
/// image data of size |jpeg_data_size|. The JPEG format does not support
|
||||
/// transparency so the alpha byte will be set to 0xFF for all pixels.
|
||||
///
|
||||
int(CEF_CALLBACK* add_jpeg)(struct _cef_image_t* self,
|
||||
float scale_factor,
|
||||
const void* jpeg_data,
|
||||
size_t jpeg_data_size);
|
||||
|
||||
///
|
||||
/// Returns the image width in density independent pixel (DIP) units.
|
||||
///
|
||||
size_t(CEF_CALLBACK* get_width)(struct _cef_image_t* self);
|
||||
|
||||
///
|
||||
/// Returns the image height in density independent pixel (DIP) units.
|
||||
///
|
||||
size_t(CEF_CALLBACK* get_height)(struct _cef_image_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if this image contains a representation for
|
||||
/// |scale_factor|.
|
||||
///
|
||||
int(CEF_CALLBACK* has_representation)(struct _cef_image_t* self,
|
||||
float scale_factor);
|
||||
|
||||
///
|
||||
/// Removes the representation for |scale_factor|. Returns true (1) on
|
||||
/// success.
|
||||
///
|
||||
int(CEF_CALLBACK* remove_representation)(struct _cef_image_t* self,
|
||||
float scale_factor);
|
||||
|
||||
///
|
||||
/// Returns information for the representation that most closely matches
|
||||
/// |scale_factor|. |actual_scale_factor| is the actual scale factor for the
|
||||
/// representation. |pixel_width| and |pixel_height| are the representation
|
||||
/// size in pixel coordinates. Returns true (1) on success.
|
||||
///
|
||||
int(CEF_CALLBACK* get_representation_info)(struct _cef_image_t* self,
|
||||
float scale_factor,
|
||||
float* actual_scale_factor,
|
||||
int* pixel_width,
|
||||
int* pixel_height);
|
||||
|
||||
///
|
||||
/// Returns the bitmap representation that most closely matches
|
||||
/// |scale_factor|. Only 32-bit RGBA/BGRA formats are supported. |color_type|
|
||||
/// and |alpha_type| values specify the desired output pixel format.
|
||||
/// |pixel_width| and |pixel_height| are the output representation size in
|
||||
/// pixel coordinates. Returns a cef_binary_value_t containing the pixel data
|
||||
/// on success or NULL on failure.
|
||||
///
|
||||
struct _cef_binary_value_t*(CEF_CALLBACK* get_as_bitmap)(
|
||||
struct _cef_image_t* self,
|
||||
float scale_factor,
|
||||
cef_color_type_t color_type,
|
||||
cef_alpha_type_t alpha_type,
|
||||
int* pixel_width,
|
||||
int* pixel_height);
|
||||
|
||||
///
|
||||
/// Returns the PNG representation that most closely matches |scale_factor|.
|
||||
/// If |with_transparency| is true (1) any alpha transparency in the image
|
||||
/// will be represented in the resulting PNG data. |pixel_width| and
|
||||
/// |pixel_height| are the output representation size in pixel coordinates.
|
||||
/// Returns a cef_binary_value_t containing the PNG image data on success or
|
||||
/// NULL on failure.
|
||||
///
|
||||
struct _cef_binary_value_t*(CEF_CALLBACK* get_as_png)(
|
||||
struct _cef_image_t* self,
|
||||
float scale_factor,
|
||||
int with_transparency,
|
||||
int* pixel_width,
|
||||
int* pixel_height);
|
||||
|
||||
///
|
||||
/// Returns the JPEG representation that most closely matches |scale_factor|.
|
||||
/// |quality| determines the compression level with 0 == lowest and 100 ==
|
||||
/// highest. The JPEG format does not support alpha transparency and the alpha
|
||||
/// channel, if any, will be discarded. |pixel_width| and |pixel_height| are
|
||||
/// the output representation size in pixel coordinates. Returns a
|
||||
/// cef_binary_value_t containing the JPEG image data on success or NULL on
|
||||
/// failure.
|
||||
///
|
||||
struct _cef_binary_value_t*(CEF_CALLBACK* get_as_jpeg)(
|
||||
struct _cef_image_t* self,
|
||||
float scale_factor,
|
||||
int quality,
|
||||
int* pixel_width,
|
||||
int* pixel_height);
|
||||
} cef_image_t;
|
||||
|
||||
///
|
||||
/// Create a new cef_image_t. It will initially be NULL. Use the Add*()
|
||||
/// functions to add representations at different scale factors.
|
||||
///
|
||||
CEF_EXPORT cef_image_t* cef_image_create(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_IMAGE_CAPI_H_
|
||||
141
third/cef/include/capi/cef_jsdialog_handler_capi.h
Normal file
141
third/cef/include/capi/cef_jsdialog_handler_capi.h
Normal file
@@ -0,0 +1,141 @@
|
||||
// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=e9fb0354243611f3a4de508923a4e01dab42f82d$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_JSDIALOG_HANDLER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_JSDIALOG_HANDLER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Callback structure used for asynchronous continuation of JavaScript dialog
|
||||
/// requests.
|
||||
///
|
||||
typedef struct _cef_jsdialog_callback_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Continue the JS dialog request. Set |success| to true (1) if the OK button
|
||||
/// was pressed. The |user_input| value should be specified for prompt
|
||||
/// dialogs.
|
||||
///
|
||||
void(CEF_CALLBACK* cont)(struct _cef_jsdialog_callback_t* self,
|
||||
int success,
|
||||
const cef_string_t* user_input);
|
||||
} cef_jsdialog_callback_t;
|
||||
|
||||
///
|
||||
/// Implement this structure to handle events related to JavaScript dialogs. The
|
||||
/// functions of this structure will be called on the UI thread.
|
||||
///
|
||||
typedef struct _cef_jsdialog_handler_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Called to run a JavaScript dialog. If |origin_url| is non-NULL it can be
|
||||
/// passed to the CefFormatUrlForSecurityDisplay function to retrieve a secure
|
||||
/// and user-friendly display string. The |default_prompt_text| value will be
|
||||
/// specified for prompt dialogs only. Set |suppress_message| to true (1) and
|
||||
/// return false (0) to suppress the message (suppressing messages is
|
||||
/// preferable to immediately executing the callback as this is used to detect
|
||||
/// presumably malicious behavior like spamming alert messages in
|
||||
/// onbeforeunload). Set |suppress_message| to false (0) and return false (0)
|
||||
/// to use the default implementation (the default implementation will show
|
||||
/// one modal dialog at a time and suppress any additional dialog requests
|
||||
/// until the displayed dialog is dismissed). Return true (1) if the
|
||||
/// application will use a custom dialog or if the callback has been executed
|
||||
/// immediately. Custom dialogs may be either modal or modeless. If a custom
|
||||
/// dialog is used the application must execute |callback| once the custom
|
||||
/// dialog is dismissed.
|
||||
///
|
||||
int(CEF_CALLBACK* on_jsdialog)(struct _cef_jsdialog_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
const cef_string_t* origin_url,
|
||||
cef_jsdialog_type_t dialog_type,
|
||||
const cef_string_t* message_text,
|
||||
const cef_string_t* default_prompt_text,
|
||||
struct _cef_jsdialog_callback_t* callback,
|
||||
int* suppress_message);
|
||||
|
||||
///
|
||||
/// Called to run a dialog asking the user if they want to leave a page.
|
||||
/// Return false (0) to use the default dialog implementation. Return true (1)
|
||||
/// if the application will use a custom dialog or if the callback has been
|
||||
/// executed immediately. Custom dialogs may be either modal or modeless. If a
|
||||
/// custom dialog is used the application must execute |callback| once the
|
||||
/// custom dialog is dismissed.
|
||||
///
|
||||
int(CEF_CALLBACK* on_before_unload_dialog)(
|
||||
struct _cef_jsdialog_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
const cef_string_t* message_text,
|
||||
int is_reload,
|
||||
struct _cef_jsdialog_callback_t* callback);
|
||||
|
||||
///
|
||||
/// Called to cancel any pending dialogs and reset any saved dialog state.
|
||||
/// Will be called due to events like page navigation irregardless of whether
|
||||
/// any dialogs are currently pending.
|
||||
///
|
||||
void(CEF_CALLBACK* on_reset_dialog_state)(
|
||||
struct _cef_jsdialog_handler_t* self,
|
||||
struct _cef_browser_t* browser);
|
||||
|
||||
///
|
||||
/// Called when the dialog is closed.
|
||||
///
|
||||
void(CEF_CALLBACK* on_dialog_closed)(struct _cef_jsdialog_handler_t* self,
|
||||
struct _cef_browser_t* browser);
|
||||
} cef_jsdialog_handler_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_JSDIALOG_HANDLER_CAPI_H_
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user