mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
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.
This commit is contained in:
174
libcef_dll/ctocpp/dev_tools_message_observer_ctocpp.cc
Normal file
174
libcef_dll/ctocpp/dev_tools_message_observer_ctocpp.cc
Normal file
@@ -0,0 +1,174 @@
|
||||
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
|
||||
// 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=e8d1eaf4b8cdfd79a260de33fb3be05a2948c81e$
|
||||
//
|
||||
|
||||
#include "libcef_dll/ctocpp/dev_tools_message_observer_ctocpp.h"
|
||||
#include "libcef_dll/cpptoc/browser_cpptoc.h"
|
||||
#include "libcef_dll/shutdown_checker.h"
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
bool CefDevToolsMessageObserverCToCpp::OnDevToolsMessage(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
const void* message,
|
||||
size_t message_size) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
cef_dev_tools_message_observer_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, on_dev_tools_message))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser.get());
|
||||
if (!browser.get())
|
||||
return false;
|
||||
// Verify param: message; type: simple_byaddr
|
||||
DCHECK(message);
|
||||
if (!message)
|
||||
return false;
|
||||
|
||||
// Execute
|
||||
int _retval = _struct->on_dev_tools_message(
|
||||
_struct, CefBrowserCppToC::Wrap(browser), message, message_size);
|
||||
|
||||
// Return type: bool
|
||||
return _retval ? true : false;
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
void CefDevToolsMessageObserverCToCpp::OnDevToolsMethodResult(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
int message_id,
|
||||
bool success,
|
||||
const void* result,
|
||||
size_t result_size) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
cef_dev_tools_message_observer_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, on_dev_tools_method_result))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser.get());
|
||||
if (!browser.get())
|
||||
return;
|
||||
// Unverified params: result
|
||||
|
||||
// Execute
|
||||
_struct->on_dev_tools_method_result(_struct, CefBrowserCppToC::Wrap(browser),
|
||||
message_id, success, result, result_size);
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
void CefDevToolsMessageObserverCToCpp::OnDevToolsEvent(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
const CefString& method,
|
||||
const void* params,
|
||||
size_t params_size) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
cef_dev_tools_message_observer_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, on_dev_tools_event))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser.get());
|
||||
if (!browser.get())
|
||||
return;
|
||||
// Verify param: method; type: string_byref_const
|
||||
DCHECK(!method.empty());
|
||||
if (method.empty())
|
||||
return;
|
||||
// Unverified params: params
|
||||
|
||||
// Execute
|
||||
_struct->on_dev_tools_event(_struct, CefBrowserCppToC::Wrap(browser),
|
||||
method.GetStruct(), params, params_size);
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
void CefDevToolsMessageObserverCToCpp::OnDevToolsAgentAttached(
|
||||
CefRefPtr<CefBrowser> browser) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
cef_dev_tools_message_observer_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, on_dev_tools_agent_attached))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser.get());
|
||||
if (!browser.get())
|
||||
return;
|
||||
|
||||
// Execute
|
||||
_struct->on_dev_tools_agent_attached(_struct,
|
||||
CefBrowserCppToC::Wrap(browser));
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
void CefDevToolsMessageObserverCToCpp::OnDevToolsAgentDetached(
|
||||
CefRefPtr<CefBrowser> browser) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
cef_dev_tools_message_observer_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, on_dev_tools_agent_detached))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser.get());
|
||||
if (!browser.get())
|
||||
return;
|
||||
|
||||
// Execute
|
||||
_struct->on_dev_tools_agent_detached(_struct,
|
||||
CefBrowserCppToC::Wrap(browser));
|
||||
}
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefDevToolsMessageObserverCToCpp::CefDevToolsMessageObserverCToCpp() {}
|
||||
|
||||
// DESTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefDevToolsMessageObserverCToCpp::~CefDevToolsMessageObserverCToCpp() {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
}
|
||||
|
||||
template <>
|
||||
cef_dev_tools_message_observer_t* CefCToCppRefCounted<
|
||||
CefDevToolsMessageObserverCToCpp,
|
||||
CefDevToolsMessageObserver,
|
||||
cef_dev_tools_message_observer_t>::UnwrapDerived(CefWrapperType type,
|
||||
CefDevToolsMessageObserver*
|
||||
c) {
|
||||
NOTREACHED() << "Unexpected class type: " << type;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
CefWrapperType
|
||||
CefCToCppRefCounted<CefDevToolsMessageObserverCToCpp,
|
||||
CefDevToolsMessageObserver,
|
||||
cef_dev_tools_message_observer_t>::kWrapperType =
|
||||
WT_DEV_TOOLS_MESSAGE_OBSERVER;
|
Reference in New Issue
Block a user