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:
Marshall Greenblatt
2020-06-12 20:54:08 -04:00
parent a9aef28966
commit 39aed35644
46 changed files with 2824 additions and 146 deletions

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=bf82965f02cafae5a1afc80ab0c976436be9712e$
// $hash=66b734973339eb27399083e978844f7d5a6a6c44$
//
#include <dlfcn.h>
@@ -139,6 +139,8 @@ typedef cef_string_userfree_t (*cef_uridecode_ptr)(const cef_string_t*,
cef_uri_unescape_rule_t);
typedef struct _cef_value_t* (*cef_parse_json_ptr)(const cef_string_t*,
cef_json_parser_options_t);
typedef struct _cef_value_t* (
*cef_parse_json_buffer_ptr)(const void*, size_t, cef_json_parser_options_t);
typedef struct _cef_value_t* (*cef_parse_jsonand_return_error_ptr)(
const cef_string_t*,
cef_json_parser_options_t,
@@ -547,6 +549,7 @@ struct libcef_pointers {
cef_uriencode_ptr cef_uriencode;
cef_uridecode_ptr cef_uridecode;
cef_parse_json_ptr cef_parse_json;
cef_parse_json_buffer_ptr cef_parse_json_buffer;
cef_parse_jsonand_return_error_ptr cef_parse_jsonand_return_error;
cef_write_json_ptr cef_write_json;
cef_get_path_ptr cef_get_path;
@@ -763,6 +766,7 @@ int libcef_init_pointers(const char* path) {
INIT_ENTRY(cef_uriencode);
INIT_ENTRY(cef_uridecode);
INIT_ENTRY(cef_parse_json);
INIT_ENTRY(cef_parse_json_buffer);
INIT_ENTRY(cef_parse_jsonand_return_error);
INIT_ENTRY(cef_write_json);
INIT_ENTRY(cef_get_path);
@@ -1134,6 +1138,13 @@ struct _cef_value_t* cef_parse_json(const cef_string_t* json_string,
return g_libcef_pointers.cef_parse_json(json_string, options);
}
NO_SANITIZE("cfi-icall")
struct _cef_value_t* cef_parse_json_buffer(const void* json,
size_t json_size,
cef_json_parser_options_t options) {
return g_libcef_pointers.cef_parse_json_buffer(json, json_size, options);
}
NO_SANITIZE("cfi-icall")
struct _cef_value_t* cef_parse_jsonand_return_error(
const cef_string_t* json_string,