cef/libcef_dll/cpptoc/dev_tools_message_observer_...

185 lines
5.3 KiB
C++
Raw Normal View History

// Copyright (c) 2021 The Chromium Embedded Framework Authors. All rights
Add support for direct DevTools protocol messaging (fixes issue #2961). This change allows the client to directly send and receive DevTools protocol messages (send method calls, and receive method results and events) without requiring a DevTools front-end or remote-debugging session. This change includes additional supporting changes: - Add a new CefRequestHandler::OnDocumentAvailableInMainFrame callback (see issue #1454). - Add a CefParseJSON variant that accepts a UTF8-encoded buffer. - Add a `--devtools-protocol-log-file=<path>` command-line flag for logging protocol messages sent to/from the DevTools front-end while it is displayed. This is useful for understanding existing DevTools protocol usage. - Add a new "libcef_static_unittests" executable target to support light-weight unit tests of libcef_static internals (e.g. without requiring exposure via the CEF API). Files to be unittested are placed in the new "libcef_static_unittested" source_set which is then included by both the existing libcef_static library and the new unittests executable target. - Linux: Remove use_bundled_fontconfig=false, which is no longer required and causes unittest build errors (see issue #2424). This change also adds a cefclient demo for configuring offline mode using the DevTools protocol (fixes issue #245). This is controlled by the "Offline mode" context menu option and the `--offline` command-line switch which will launch cefclient in offline mode. When cefclient is offline all network requests will fail with ERR_INTERNET_DISCONNECTED and navigator.onLine will return false when called from JavaScript in any frame. This mode is per-browser so newly created browser windows will have the default mode. Note that configuring offline mode in this way will not update the Network tab UI ("Throtting" option) in a displayed DevTools front-end instance.
2020-06-13 02:54:08 +02:00
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=d675fee9716fb6801ed17dea7d57a7c427c4ba5f$
Add support for direct DevTools protocol messaging (fixes issue #2961). This change allows the client to directly send and receive DevTools protocol messages (send method calls, and receive method results and events) without requiring a DevTools front-end or remote-debugging session. This change includes additional supporting changes: - Add a new CefRequestHandler::OnDocumentAvailableInMainFrame callback (see issue #1454). - Add a CefParseJSON variant that accepts a UTF8-encoded buffer. - Add a `--devtools-protocol-log-file=<path>` command-line flag for logging protocol messages sent to/from the DevTools front-end while it is displayed. This is useful for understanding existing DevTools protocol usage. - Add a new "libcef_static_unittests" executable target to support light-weight unit tests of libcef_static internals (e.g. without requiring exposure via the CEF API). Files to be unittested are placed in the new "libcef_static_unittested" source_set which is then included by both the existing libcef_static library and the new unittests executable target. - Linux: Remove use_bundled_fontconfig=false, which is no longer required and causes unittest build errors (see issue #2424). This change also adds a cefclient demo for configuring offline mode using the DevTools protocol (fixes issue #245). This is controlled by the "Offline mode" context menu option and the `--offline` command-line switch which will launch cefclient in offline mode. When cefclient is offline all network requests will fail with ERR_INTERNET_DISCONNECTED and navigator.onLine will return false when called from JavaScript in any frame. This mode is per-browser so newly created browser windows will have the default mode. Note that configuring offline mode in this way will not update the Network tab UI ("Throtting" option) in a displayed DevTools front-end instance.
2020-06-13 02:54:08 +02:00
//
#include "libcef_dll/cpptoc/dev_tools_message_observer_cpptoc.h"
#include "libcef_dll/ctocpp/browser_ctocpp.h"
#include "libcef_dll/shutdown_checker.h"
namespace {
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK dev_tools_message_observer_on_dev_tools_message(
struct _cef_dev_tools_message_observer_t* self,
cef_browser_t* browser,
const void* message,
size_t message_size) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return 0;
// Verify param: message; type: simple_byaddr
DCHECK(message);
if (!message)
return 0;
// Execute
bool _retval = CefDevToolsMessageObserverCppToC::Get(self)->OnDevToolsMessage(
CefBrowserCToCpp::Wrap(browser), message, message_size);
// Return type: bool
return _retval;
}
void CEF_CALLBACK dev_tools_message_observer_on_dev_tools_method_result(
struct _cef_dev_tools_message_observer_t* self,
cef_browser_t* browser,
int message_id,
int success,
const void* result,
size_t result_size) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Unverified params: result
// Execute
CefDevToolsMessageObserverCppToC::Get(self)->OnDevToolsMethodResult(
CefBrowserCToCpp::Wrap(browser), message_id, success ? true : false,
result, result_size);
}
void CEF_CALLBACK dev_tools_message_observer_on_dev_tools_event(
struct _cef_dev_tools_message_observer_t* self,
cef_browser_t* browser,
const cef_string_t* method,
const void* params,
size_t params_size) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Verify param: method; type: string_byref_const
DCHECK(method);
if (!method)
return;
// Unverified params: params
// Execute
CefDevToolsMessageObserverCppToC::Get(self)->OnDevToolsEvent(
CefBrowserCToCpp::Wrap(browser), CefString(method), params, params_size);
}
void CEF_CALLBACK dev_tools_message_observer_on_dev_tools_agent_attached(
struct _cef_dev_tools_message_observer_t* self,
cef_browser_t* browser) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Execute
CefDevToolsMessageObserverCppToC::Get(self)->OnDevToolsAgentAttached(
CefBrowserCToCpp::Wrap(browser));
}
void CEF_CALLBACK dev_tools_message_observer_on_dev_tools_agent_detached(
struct _cef_dev_tools_message_observer_t* self,
cef_browser_t* browser) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Execute
CefDevToolsMessageObserverCppToC::Get(self)->OnDevToolsAgentDetached(
CefBrowserCToCpp::Wrap(browser));
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
CefDevToolsMessageObserverCppToC::CefDevToolsMessageObserverCppToC() {
GetStruct()->on_dev_tools_message =
dev_tools_message_observer_on_dev_tools_message;
GetStruct()->on_dev_tools_method_result =
dev_tools_message_observer_on_dev_tools_method_result;
GetStruct()->on_dev_tools_event =
dev_tools_message_observer_on_dev_tools_event;
GetStruct()->on_dev_tools_agent_attached =
dev_tools_message_observer_on_dev_tools_agent_attached;
GetStruct()->on_dev_tools_agent_detached =
dev_tools_message_observer_on_dev_tools_agent_detached;
}
// DESTRUCTOR - Do not edit by hand.
CefDevToolsMessageObserverCppToC::~CefDevToolsMessageObserverCppToC() {
shutdown_checker::AssertNotShutdown();
}
template <>
CefRefPtr<CefDevToolsMessageObserver>
CefCppToCRefCounted<CefDevToolsMessageObserverCppToC,
CefDevToolsMessageObserver,
cef_dev_tools_message_observer_t>::
UnwrapDerived(CefWrapperType type, cef_dev_tools_message_observer_t* s) {
NOTREACHED() << "Unexpected class type: " << type;
return nullptr;
}
template <>
CefWrapperType
CefCppToCRefCounted<CefDevToolsMessageObserverCppToC,
CefDevToolsMessageObserver,
cef_dev_tools_message_observer_t>::kWrapperType =
WT_DEV_TOOLS_MESSAGE_OBSERVER;