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:
@ -9,7 +9,7 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=a84451b4f759f2a4a0fe673d90be1fb5053bfd1a$
|
||||
// $hash=516b55b7ea53e2de2b096e85ba0eb83f2a2693f3$
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/browser_host_cpptoc.h"
|
||||
@ -18,8 +18,10 @@
|
||||
#include "libcef_dll/cpptoc/drag_data_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/extension_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/navigation_entry_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/registration_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/request_context_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/client_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/dev_tools_message_observer_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/download_image_callback_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/navigation_entry_visitor_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/pdf_print_callback_ctocpp.h"
|
||||
@ -522,6 +524,81 @@ int CEF_CALLBACK browser_host_has_dev_tools(struct _cef_browser_host_t* self) {
|
||||
return _retval;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK
|
||||
browser_host_send_dev_tools_message(struct _cef_browser_host_t* self,
|
||||
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: message; type: simple_byaddr
|
||||
DCHECK(message);
|
||||
if (!message)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefBrowserHostCppToC::Get(self)->SendDevToolsMessage(
|
||||
message, message_size);
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK
|
||||
browser_host_execute_dev_tools_method(struct _cef_browser_host_t* self,
|
||||
int message_id,
|
||||
const cef_string_t* method,
|
||||
struct _cef_dictionary_value_t* params) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
// Verify param: method; type: string_byref_const
|
||||
DCHECK(method);
|
||||
if (!method)
|
||||
return 0;
|
||||
// Unverified params: params
|
||||
|
||||
// Execute
|
||||
int _retval = CefBrowserHostCppToC::Get(self)->ExecuteDevToolsMethod(
|
||||
message_id, CefString(method), CefDictionaryValueCppToC::Unwrap(params));
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
struct _cef_registration_t* CEF_CALLBACK
|
||||
browser_host_add_dev_tools_message_observer(
|
||||
struct _cef_browser_host_t* self,
|
||||
struct _cef_dev_tools_message_observer_t* observer) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
// Verify param: observer; type: refptr_diff
|
||||
DCHECK(observer);
|
||||
if (!observer)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefRegistration> _retval =
|
||||
CefBrowserHostCppToC::Get(self)->AddDevToolsMessageObserver(
|
||||
CefDevToolsMessageObserverCToCpp::Wrap(observer));
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefRegistrationCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK
|
||||
browser_host_get_navigation_entries(struct _cef_browser_host_t* self,
|
||||
cef_navigation_entry_visitor_t* visitor,
|
||||
@ -1285,6 +1362,10 @@ CefBrowserHostCppToC::CefBrowserHostCppToC() {
|
||||
GetStruct()->show_dev_tools = browser_host_show_dev_tools;
|
||||
GetStruct()->close_dev_tools = browser_host_close_dev_tools;
|
||||
GetStruct()->has_dev_tools = browser_host_has_dev_tools;
|
||||
GetStruct()->send_dev_tools_message = browser_host_send_dev_tools_message;
|
||||
GetStruct()->execute_dev_tools_method = browser_host_execute_dev_tools_method;
|
||||
GetStruct()->add_dev_tools_message_observer =
|
||||
browser_host_add_dev_tools_message_observer;
|
||||
GetStruct()->get_navigation_entries = browser_host_get_navigation_entries;
|
||||
GetStruct()->set_mouse_cursor_change_disabled =
|
||||
browser_host_set_mouse_cursor_change_disabled;
|
||||
|
Reference in New Issue
Block a user