Compare commits

..

12 Commits
5112 ... 5060

Author SHA1 Message Date
Marshall Greenblatt
8eb56c7914 Update to Chromium version 103.0.5060.134 2022-07-20 15:35:40 +00:00
Marshall Greenblatt
b1e93e1fd8 alloy: win: Focus the browser after dismissal of a modal dialog (fixes issue #3361) 2022-07-15 14:08:59 +03:00
Marshall Greenblatt
a5c79bb989 Increase frame reconnect timeout to 10 seconds (see issue #3260) 2022-07-13 12:19:32 +03:00
Marshall Greenblatt
d0bbcbb6bc Update to Chromium version 103.0.5060.114 2022-07-05 07:20:56 +00:00
Marshall Greenblatt
444ebe74e5 Update to Chromium version 103.0.5060.66 2022-06-29 10:39:34 +00:00
Marshall Greenblatt
8963d1e62c Windows: Fix AssertBlockingAllowed failure in GetAzureADJoinStateStorage (fixes issue #3342) 2022-06-23 14:03:48 +03:00
Marshall Greenblatt
e38efd51d1 Update to Chromium version 103.0.5060.53 2022-06-16 07:29:04 +00:00
Marshall Greenblatt
9e8dba7e03 Update to Chromium version 103.0.5060.42 2022-06-15 21:20:24 +03:00
Marshall Greenblatt
3ae256f4ba Update to Chromium version 103.0.5060.24 2022-05-27 07:39:38 +00:00
Marshall Greenblatt
4a6a16d4ef Call OnResourceRedirect for internal network service redirects (fixes issue #3336) 2022-05-25 16:46:59 +03:00
Marshall Greenblatt
6c10101ae4 ceftests: Minor code cleanup 2022-05-25 16:46:53 +03:00
Marshall Greenblatt
5788b1a1eb Update to Chromium version 103.0.5060.13 2022-05-23 13:05:05 +03:00
286 changed files with 3300 additions and 12438 deletions

View File

@@ -373,8 +373,6 @@ source_set("libcef_static_unittested") {
sources = [
"libcef/browser/devtools/devtools_util.cc",
"libcef/browser/devtools/devtools_util.h",
"libcef/browser/screen_util.h",
"libcef/browser/screen_util.cc",
]
deps = [
@@ -391,7 +389,6 @@ source_set("libcef_static_unittested") {
test("libcef_static_unittests") {
sources = [
"libcef/browser/devtools/devtools_util_unittest.cc",
"libcef/browser/screen_util_unittest.cc",
]
deps = [
@@ -419,16 +416,8 @@ static_library("libcef_static") {
"libcef/browser/alloy/alloy_content_browser_client.h",
"libcef/browser/alloy/alloy_download_util.cc",
"libcef/browser/alloy/alloy_download_util.h",
"libcef/browser/alloy/alloy_web_contents_view_delegate.cc",
"libcef/browser/alloy/alloy_web_contents_view_delegate.h",
"libcef/browser/alloy/browser_platform_delegate_alloy.cc",
"libcef/browser/alloy/browser_platform_delegate_alloy.h",
"libcef/browser/alloy/dialogs/alloy_constrained_window_views_client.cc",
"libcef/browser/alloy/dialogs/alloy_constrained_window_views_client.h",
"libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.cc",
"libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.h",
"libcef/browser/alloy/dialogs/alloy_web_contents_dialog_helper.cc",
"libcef/browser/alloy/dialogs/alloy_web_contents_dialog_helper.h",
"libcef/browser/alloy/chrome_browser_process_alloy.cc",
"libcef/browser/alloy/chrome_browser_process_alloy.h",
"libcef/browser/alloy/chrome_profile_manager_alloy.cc",
@@ -575,8 +564,6 @@ static_library("libcef_static") {
"libcef/browser/javascript_dialog_manager.h",
"libcef/browser/main_runner.cc",
"libcef/browser/main_runner.h",
"libcef/browser/media_access_query.cc",
"libcef/browser/media_access_query.h",
"libcef/browser/media_capture_devices_dispatcher.cc",
"libcef/browser/media_capture_devices_dispatcher.h",
"libcef/browser/media_router/media_route_impl.cc",
@@ -589,8 +576,6 @@ static_library("libcef_static") {
"libcef/browser/media_router/media_sink_impl.h",
"libcef/browser/media_router/media_source_impl.cc",
"libcef/browser/media_router/media_source_impl.h",
"libcef/browser/media_stream_registrar.cc",
"libcef/browser/media_stream_registrar.h",
"libcef/browser/menu_manager.cc",
"libcef/browser/menu_manager.h",
"libcef/browser/menu_model_impl.cc",
@@ -651,17 +636,11 @@ static_library("libcef_static") {
"libcef/browser/osr/render_widget_host_view_osr.h",
"libcef/browser/osr/synthetic_gesture_target_osr.cc",
"libcef/browser/osr/synthetic_gesture_target_osr.h",
"libcef/browser/osr/touch_handle_drawable_osr.cc",
"libcef/browser/osr/touch_handle_drawable_osr.h",
"libcef/browser/osr/touch_selection_controller_client_osr.cc",
"libcef/browser/osr/touch_selection_controller_client_osr.h",
"libcef/browser/osr/video_consumer_osr.cc",
"libcef/browser/osr/video_consumer_osr.h",
"libcef/browser/osr/web_contents_view_osr.cc",
"libcef/browser/osr/web_contents_view_osr.h",
"libcef/browser/path_util_impl.cc",
"libcef/browser/permission_prompt.cc",
"libcef/browser/permission_prompt.h",
"libcef/browser/prefs/browser_prefs.cc",
"libcef/browser/prefs/browser_prefs.h",
"libcef/browser/prefs/pref_store.cc",
@@ -670,6 +649,8 @@ static_library("libcef_static") {
"libcef/browser/prefs/renderer_prefs.h",
"libcef/browser/print_settings_impl.cc",
"libcef/browser/print_settings_impl.h",
"libcef/browser/printing/constrained_window_views_client.cc",
"libcef/browser/printing/constrained_window_views_client.h",
"libcef/browser/printing/print_view_manager.cc",
"libcef/browser/printing/print_view_manager.h",
"libcef/browser/process_util_impl.cc",
@@ -753,6 +734,8 @@ static_library("libcef_static") {
"libcef/browser/views/window_impl.h",
"libcef/browser/views/window_view.cc",
"libcef/browser/views/window_view.h",
"libcef/browser/web_contents_dialog_helper.cc",
"libcef/browser/web_contents_dialog_helper.h",
"libcef/browser/x509_certificate_impl.cc",
"libcef/browser/x509_certificate_impl.h",
"libcef/browser/x509_cert_principal_impl.cc",
@@ -814,8 +797,6 @@ static_library("libcef_static") {
"libcef/common/parser_impl.cc",
"libcef/common/process_message_impl.cc",
"libcef/common/process_message_impl.h",
"libcef/common/process_message_smr_impl.cc",
"libcef/common/process_message_smr_impl.h",
"libcef/common/request_impl.cc",
"libcef/common/request_impl.h",
"libcef/common/resource_bundle_delegate.cc",
@@ -1039,6 +1020,8 @@ static_library("libcef_static") {
"libcef/browser/native/browser_platform_delegate_native_win.cc",
"libcef/browser/native/browser_platform_delegate_native_win.h",
"libcef/browser/native/cursor_util_win.cc",
"libcef/browser/native/javascript_dialog_runner_win.cc",
"libcef/browser/native/javascript_dialog_runner_win.h",
"libcef/browser/osr/browser_platform_delegate_osr_win.cc",
"libcef/browser/osr/browser_platform_delegate_osr_win.h",
]
@@ -1656,7 +1639,7 @@ if (is_mac) {
"libcef_dll/libcef_dll.rc",
]
deps += [
deps += [
# Bring in ui_unscaled_resources.rc which contains custom cursors.
# TODO(cef): Remove this once custom cursors can be loaded via
# ResourceBundle. See crbug.com/147663.
@@ -2260,7 +2243,7 @@ if (is_mac) {
#
# ceftests targets.
#
if (is_linux) {
copy("copy_ceftests_files") {
sources = gypi_paths2.shared_sources_resources

View File

@@ -7,6 +7,6 @@
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
{
'chromium_checkout': 'refs/tags/104.0.5112.102',
'depot_tools_checkout': '350d210871'
'chromium_checkout': 'refs/tags/103.0.5060.134',
'depot_tools_checkout': '964f8124b6'
}

View File

@@ -8,7 +8,7 @@
# by hand. See the translator.README.txt file in the tools directory for
# more information.
#
# $hash=3ed1afd1b5f881884e6cfd0186fe41bb7b19fd38$
# $hash=5f2e9bf79ec768c0eb978ff5e1dd0178701dcc21$
#
{
@@ -55,7 +55,6 @@
'include/cef_origin_whitelist.h',
'include/cef_parser.h',
'include/cef_path_util.h',
'include/cef_permission_handler.h',
'include/cef_print_handler.h',
'include/cef_print_settings.h',
'include/cef_process_message.h',
@@ -75,8 +74,6 @@
'include/cef_response_filter.h',
'include/cef_scheme.h',
'include/cef_server.h',
'include/cef_shared_memory_region.h',
'include/cef_shared_process_message_builder.h',
'include/cef_ssl_info.h',
'include/cef_ssl_status.h',
'include/cef_stream.h',
@@ -157,7 +154,6 @@
'include/capi/cef_origin_whitelist_capi.h',
'include/capi/cef_parser_capi.h',
'include/capi/cef_path_util_capi.h',
'include/capi/cef_permission_handler_capi.h',
'include/capi/cef_print_handler_capi.h',
'include/capi/cef_print_settings_capi.h',
'include/capi/cef_process_message_capi.h',
@@ -177,8 +173,6 @@
'include/capi/cef_response_filter_capi.h',
'include/capi/cef_scheme_capi.h',
'include/capi/cef_server_capi.h',
'include/capi/cef_shared_memory_region_capi.h',
'include/capi/cef_shared_process_message_builder_capi.h',
'include/capi/cef_ssl_info_capi.h',
'include/capi/cef_ssl_status_capi.h',
'include/capi/cef_stream_capi.h',
@@ -334,8 +328,6 @@
'libcef_dll/cpptoc/list_value_cpptoc.h',
'libcef_dll/ctocpp/load_handler_ctocpp.cc',
'libcef_dll/ctocpp/load_handler_ctocpp.h',
'libcef_dll/cpptoc/media_access_callback_cpptoc.cc',
'libcef_dll/cpptoc/media_access_callback_cpptoc.h',
'libcef_dll/ctocpp/media_observer_ctocpp.cc',
'libcef_dll/ctocpp/media_observer_ctocpp.h',
'libcef_dll/cpptoc/media_route_cpptoc.cc',
@@ -372,10 +364,6 @@
'libcef_dll/ctocpp/views/panel_delegate_ctocpp.h',
'libcef_dll/ctocpp/pdf_print_callback_ctocpp.cc',
'libcef_dll/ctocpp/pdf_print_callback_ctocpp.h',
'libcef_dll/ctocpp/permission_handler_ctocpp.cc',
'libcef_dll/ctocpp/permission_handler_ctocpp.h',
'libcef_dll/cpptoc/permission_prompt_callback_cpptoc.cc',
'libcef_dll/cpptoc/permission_prompt_callback_cpptoc.h',
'libcef_dll/cpptoc/post_data_cpptoc.cc',
'libcef_dll/cpptoc/post_data_cpptoc.h',
'libcef_dll/cpptoc/post_data_element_cpptoc.cc',
@@ -428,8 +416,6 @@
'libcef_dll/cpptoc/run_context_menu_callback_cpptoc.h',
'libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.cc',
'libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h',
'libcef_dll/cpptoc/run_quick_menu_callback_cpptoc.cc',
'libcef_dll/cpptoc/run_quick_menu_callback_cpptoc.h',
'libcef_dll/cpptoc/sslinfo_cpptoc.cc',
'libcef_dll/cpptoc/sslinfo_cpptoc.h',
'libcef_dll/cpptoc/sslstatus_cpptoc.cc',
@@ -448,10 +434,6 @@
'libcef_dll/ctocpp/server_handler_ctocpp.h',
'libcef_dll/ctocpp/set_cookie_callback_ctocpp.cc',
'libcef_dll/ctocpp/set_cookie_callback_ctocpp.h',
'libcef_dll/cpptoc/shared_memory_region_cpptoc.cc',
'libcef_dll/cpptoc/shared_memory_region_cpptoc.h',
'libcef_dll/cpptoc/shared_process_message_builder_cpptoc.cc',
'libcef_dll/cpptoc/shared_process_message_builder_cpptoc.h',
'libcef_dll/cpptoc/stream_reader_cpptoc.cc',
'libcef_dll/cpptoc/stream_reader_cpptoc.h',
'libcef_dll/cpptoc/stream_writer_cpptoc.cc',
@@ -652,8 +634,6 @@
'libcef_dll/ctocpp/list_value_ctocpp.h',
'libcef_dll/cpptoc/load_handler_cpptoc.cc',
'libcef_dll/cpptoc/load_handler_cpptoc.h',
'libcef_dll/ctocpp/media_access_callback_ctocpp.cc',
'libcef_dll/ctocpp/media_access_callback_ctocpp.h',
'libcef_dll/cpptoc/media_observer_cpptoc.cc',
'libcef_dll/cpptoc/media_observer_cpptoc.h',
'libcef_dll/ctocpp/media_route_ctocpp.cc',
@@ -690,10 +670,6 @@
'libcef_dll/cpptoc/views/panel_delegate_cpptoc.h',
'libcef_dll/cpptoc/pdf_print_callback_cpptoc.cc',
'libcef_dll/cpptoc/pdf_print_callback_cpptoc.h',
'libcef_dll/cpptoc/permission_handler_cpptoc.cc',
'libcef_dll/cpptoc/permission_handler_cpptoc.h',
'libcef_dll/ctocpp/permission_prompt_callback_ctocpp.cc',
'libcef_dll/ctocpp/permission_prompt_callback_ctocpp.h',
'libcef_dll/ctocpp/post_data_ctocpp.cc',
'libcef_dll/ctocpp/post_data_ctocpp.h',
'libcef_dll/ctocpp/post_data_element_ctocpp.cc',
@@ -746,8 +722,6 @@
'libcef_dll/ctocpp/run_context_menu_callback_ctocpp.h',
'libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.cc',
'libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h',
'libcef_dll/ctocpp/run_quick_menu_callback_ctocpp.cc',
'libcef_dll/ctocpp/run_quick_menu_callback_ctocpp.h',
'libcef_dll/ctocpp/sslinfo_ctocpp.cc',
'libcef_dll/ctocpp/sslinfo_ctocpp.h',
'libcef_dll/ctocpp/sslstatus_ctocpp.cc',
@@ -766,10 +740,6 @@
'libcef_dll/cpptoc/server_handler_cpptoc.h',
'libcef_dll/cpptoc/set_cookie_callback_cpptoc.cc',
'libcef_dll/cpptoc/set_cookie_callback_cpptoc.h',
'libcef_dll/ctocpp/shared_memory_region_ctocpp.cc',
'libcef_dll/ctocpp/shared_memory_region_ctocpp.h',
'libcef_dll/ctocpp/shared_process_message_builder_ctocpp.cc',
'libcef_dll/ctocpp/shared_process_message_builder_ctocpp.h',
'libcef_dll/ctocpp/stream_reader_ctocpp.cc',
'libcef_dll/ctocpp/stream_reader_ctocpp.h',
'libcef_dll/ctocpp/stream_writer_ctocpp.cc',

View File

@@ -177,8 +177,6 @@
'tests/shared/browser/resource_util.h',
],
'shared_sources_common': [
'tests/shared/common/binary_value_utils.cc',
'tests/shared/common/binary_value_utils.h',
'tests/shared/common/client_app.cc',
'tests/shared/common/client_app.h',
'tests/shared/common/client_app_other.cc',
@@ -291,8 +289,6 @@
'tests/cefclient/renderer/client_app_delegates_renderer.cc',
'tests/cefclient/renderer/client_renderer.cc',
'tests/cefclient/renderer/client_renderer.h',
'tests/cefclient/renderer/ipc_performance_test.cc',
'tests/cefclient/renderer/ipc_performance_test.h',
'tests/cefclient/renderer/performance_test.cc',
'tests/cefclient/renderer/performance_test.h',
'tests/cefclient/renderer/performance_test_setup.h',
@@ -302,7 +298,6 @@
'tests/cefclient/resources/binding.html',
'tests/cefclient/resources/dialogs.html',
'tests/cefclient/resources/draggable.html',
'tests/cefclient/resources/ipc_performance.html',
'tests/cefclient/resources/localstorage.html',
'tests/cefclient/resources/logo.png',
'tests/cefclient/resources/media_router.html',
@@ -480,20 +475,13 @@
'tests/ceftests/image_util.h',
'tests/ceftests/jsdialog_unittest.cc',
'tests/ceftests/life_span_unittest.cc',
'tests/ceftests/media_access_unittest.cc',
'tests/ceftests/message_router_harness_unittest.cc',
'tests/ceftests/message_router_multi_query_unittest.cc',
'tests/ceftests/message_router_single_query_unittest.cc',
'tests/ceftests/message_router_threshold_unittest.cc',
'tests/ceftests/message_router_unittest_utils.cc',
'tests/ceftests/message_router_unittest_utils.h',
'tests/ceftests/message_router_unittest.cc',
'tests/ceftests/navigation_unittest.cc',
'tests/ceftests/os_rendering_unittest.cc',
'tests/ceftests/osr_accessibility_unittest.cc',
'tests/ceftests/osr_display_unittest.cc',
'tests/ceftests/parser_unittest.cc',
'tests/ceftests/pdf_viewer_unittest.cc',
'tests/ceftests/permission_prompt_unittest.cc',
'tests/ceftests/preference_unittest.cc',
'tests/ceftests/print_unittest.cc',
'tests/ceftests/process_message_unittest.cc',
@@ -510,8 +498,6 @@
'tests/ceftests/scheme_handler_unittest.cc',
'tests/ceftests/scoped_temp_dir_unittest.cc',
'tests/ceftests/server_unittest.cc',
'tests/ceftests/send_shared_process_message_unittest.cc',
"tests/ceftests/shared_process_message_unittest.cc",
'tests/ceftests/stream_unittest.cc',
'tests/ceftests/stream_resource_handler_unittest.cc',
'tests/ceftests/string_unittest.cc',
@@ -576,16 +562,9 @@
'tests/ceftests/cors_unittest.cc',
'tests/ceftests/dom_unittest.cc',
'tests/ceftests/frame_unittest.cc',
'tests/ceftests/media_access_unittest.cc',
'tests/ceftests/message_router_harness_unittest.cc',
'tests/ceftests/message_router_multi_query_unittest.cc',
'tests/ceftests/message_router_single_query_unittest.cc',
'tests/ceftests/message_router_threshold_unittest.cc',
'tests/ceftests/message_router_unittest_utils.cc',
'tests/ceftests/message_router_unittest_utils.h',
'tests/ceftests/message_router_unittest.cc',
'tests/ceftests/navigation_unittest.cc',
'tests/ceftests/pdf_viewer_unittest.cc',
'tests/ceftests/permission_prompt_unittest.cc',
'tests/ceftests/preference_unittest.cc',
'tests/ceftests/process_message_unittest.cc',
'tests/ceftests/request_handler_unittest.cc',
@@ -595,8 +574,6 @@
'tests/ceftests/routing_test_handler.cc',
'tests/ceftests/routing_test_handler.h',
'tests/ceftests/scheme_handler_unittest.cc',
'tests/ceftests/send_shared_process_message_unittest.cc',
"tests/ceftests/shared_process_message_unittest.cc",
'tests/ceftests/urlrequest_unittest.cc',
'tests/ceftests/test_handler.cc',
'tests/ceftests/test_handler.h',

View File

@@ -314,7 +314,7 @@ if(OS_MAC)
# Find the newest available base SDK.
execute_process(COMMAND xcode-select --print-path OUTPUT_VARIABLE XCODE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
foreach(OS_VERSION 10.15 10.14 10.13)
foreach(OS_VERSION 10.15 10.14 10.13 10.12 10.11)
set(SDK "${XCODE_PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${OS_VERSION}.sdk")
if(NOT "${CMAKE_OSX_SYSROOT}" AND EXISTS "${SDK}" AND IS_DIRECTORY "${SDK}")
set(CMAKE_OSX_SYSROOT ${SDK})
@@ -322,7 +322,7 @@ if(OS_MAC)
endforeach()
# Target SDK.
set(CEF_TARGET_SDK "10.13")
set(CEF_TARGET_SDK "10.11")
list(APPEND CEF_COMPILER_FLAGS
-mmacosx-version-min=${CEF_TARGET_SDK}
)

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=03ae4ba9762510e2b0c19ea29322c20ebaf2e683$
// $hash=7df3c13b75072c2ad5061cd3a344811222798903$
//
#ifndef CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
@@ -55,7 +55,6 @@
#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"
@@ -140,12 +139,6 @@ typedef struct _cef_client_t {
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.

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=d9498ae2e32ec124df3dd2c3017bcf415d4205f8$
// $hash=d007b3dc26f3f049bf67623da8fae59dc75a193b$
//
#ifndef CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_
@@ -74,29 +74,6 @@ typedef struct _cef_run_context_menu_callback_t {
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.
@@ -156,56 +133,16 @@ typedef struct _cef_context_menu_handler_t {
///
// Called when the context menu is dismissed irregardless of whether the menu
// was canceled or a command was selected.
// was NULL 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
// Provides information about the context menu state. The ethods of this
// structure can only be accessed on browser process the UI thread.
///
typedef struct _cef_context_menu_params_t {

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=5e52ae520b7eda3595683d428aa578bbc776956b$
// $hash=142637539a094a03adc71d2f3f5b711ba64918b1$
//
#ifndef CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_
@@ -154,16 +154,6 @@ typedef struct _cef_display_handler_t {
cef_cursor_handle_t cursor,
cef_cursor_type_t type,
const struct _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

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=ddff4ad975fc26d0abfe05799aedb597b8274ffd$
// $hash=c6de3fb4d64a2b2ad06a4b9c5e9d7625d40b5bb6$
//
#ifndef CEF_INCLUDE_CAPI_CEF_DOM_CAPI_H_
@@ -335,8 +335,7 @@ typedef struct _cef_domnode_t {
struct _cef_domnode_t* self);
///
// Returns the bounds of the element in device pixels. Use
// "window.devicePixelRatio" to convert to/from CSS pixels.
// Returns the bounds of the element.
///
cef_rect_t(CEF_CALLBACK* get_element_bounds)(struct _cef_domnode_t* self);
} cef_domnode_t;

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=942579315e4b8c0819cd2b06becb93670310cd09$
// $hash=c68332a779bab425aa2e6a858d20a43448631890$
//
#ifndef CEF_INCLUDE_CAPI_CEF_JSDIALOG_HANDLER_CAPI_H_
@@ -127,7 +127,7 @@ typedef struct _cef_jsdialog_handler_t {
struct _cef_browser_t* browser);
///
// Called when the dialog is closed.
// Called when the default implementation dialog is closed.
///
void(CEF_CALLBACK* on_dialog_closed)(struct _cef_jsdialog_handler_t* self,
struct _cef_browser_t* browser);

View File

@@ -1,108 +0,0 @@
// Copyright (c) 2022 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=91101808168ec0faf1f39b1924579e31478a6616$
//
#ifndef CEF_INCLUDE_CAPI_CEF_MEDIA_ACCESS_HANDLER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_MEDIA_ACCESS_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 media access
// permission requests.
///
typedef struct _cef_media_access_callback_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Call to allow or deny media access. If this callback was initiated in
// response to a getUserMedia (indicated by
// CEF_MEDIA_PERMISSION_DEVICE_AUDIO_CAPTURE and/or
// CEF_MEDIA_PERMISSION_DEVICE_VIDEO_CAPTURE being set) the
// |allowed_permissions| are required to match those given in
// |required_permissions| in the OnRequestMediaAccessPermission.
///
void(CEF_CALLBACK* cont)(struct _cef_media_access_callback_t* self,
int allowed_permissions);
///
// Cancel the media access request.
///
void(CEF_CALLBACK* cancel)(struct _cef_media_access_callback_t* self);
} cef_media_access_callback_t;
///
// Implement this structure to handle events related to media access permission
// requests. The functions of this structure will be called on the browser
// process UI thread.
///
typedef struct _cef_media_access_handler_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Called when a page requests permission to access media. |requesting_url| is
// the URL requesting permission. Return true (1) and call
// cef_media_access_callback_t::cont() either in this function or at a later
// time to continue or cancel the request. Return false (0) to cancel the
// request immediately.
///
int(CEF_CALLBACK* on_request_media_access_permission)(
struct _cef_media_access_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
const cef_string_t* requesting_url,
int32_t requested_permissions,
struct _cef_media_access_callback_t* callback);
} cef_media_access_handler_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_MEDIA_ACCESS_HANDLER_CAPI_H_

View File

@@ -1,162 +0,0 @@
// Copyright (c) 2022 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=e902fe011f8667b64989e57ad9e72aec74b22015$
//
#ifndef CEF_INCLUDE_CAPI_CEF_PERMISSION_HANDLER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_PERMISSION_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 media access
// permission requests.
///
typedef struct _cef_media_access_callback_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Call to allow or deny media access. If this callback was initiated in
// response to a getUserMedia (indicated by
// CEF_MEDIA_PERMISSION_DEVICE_AUDIO_CAPTURE and/or
// CEF_MEDIA_PERMISSION_DEVICE_VIDEO_CAPTURE being set) then
// |allowed_permissions| must match |required_permissions| passed to
// OnRequestMediaAccessPermission.
///
void(CEF_CALLBACK* cont)(struct _cef_media_access_callback_t* self,
uint32 allowed_permissions);
///
// Cancel the media access request.
///
void(CEF_CALLBACK* cancel)(struct _cef_media_access_callback_t* self);
} cef_media_access_callback_t;
///
// Callback structure used for asynchronous continuation of permission prompts.
///
typedef struct _cef_permission_prompt_callback_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Complete the permissions request with the specified |result|.
///
void(CEF_CALLBACK* cont)(struct _cef_permission_prompt_callback_t* self,
cef_permission_request_result_t result);
} cef_permission_prompt_callback_t;
///
// Implement this structure to handle events related to permission requests. The
// functions of this structure will be called on the browser process UI thread.
///
typedef struct _cef_permission_handler_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Called when a page requests permission to access media. |requesting_origin|
// is the URL origin requesting permission. |requested_permissions| is a
// combination of values from cef_media_access_permission_types_t that
// represent the requested permissions. Return true (1) and call
// cef_media_access_callback_t functions either in this function or at a later
// time to continue or cancel the request. Return false (0) to proceed with
// default handling. With the Chrome runtime, default handling will display
// the permission request UI. With the Alloy runtime, default handling will
// deny the request. This function will not be called if the "--enable-media-
// stream" command-line switch is used to grant all permissions.
///
int(CEF_CALLBACK* on_request_media_access_permission)(
struct _cef_permission_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
const cef_string_t* requesting_origin,
uint32 requested_permissions,
struct _cef_media_access_callback_t* callback);
///
// Called when a page should show a permission prompt. |prompt_id| uniquely
// identifies the prompt. |requesting_origin| is the URL origin requesting
// permission. |requested_permissions| is a combination of values from
// cef_permission_request_types_t that represent the requested permissions.
// Return true (1) and call cef_permission_prompt_callback_t::Continue either
// in this function or at a later time to continue or cancel the request.
// Return false (0) to proceed with default handling. With the Chrome runtime,
// default handling will display the permission prompt UI. With the Alloy
// runtime, default handling is CEF_PERMISSION_RESULT_IGNORE.
///
int(CEF_CALLBACK* on_show_permission_prompt)(
struct _cef_permission_handler_t* self,
struct _cef_browser_t* browser,
uint64 prompt_id,
const cef_string_t* requesting_origin,
uint32 requested_permissions,
struct _cef_permission_prompt_callback_t* callback);
///
// Called when a permission prompt handled via OnShowPermissionPrompt is
// dismissed. |prompt_id| will match the value that was passed to
// OnShowPermissionPrompt. |result| will be the value passed to
// cef_permission_prompt_callback_t::Continue or CEF_PERMISSION_RESULT_IGNORE
// if the dialog was dismissed for other reasons such as navigation, browser
// closure, etc. This function will not be called if OnShowPermissionPrompt
// returned false (0) for |prompt_id|.
///
void(CEF_CALLBACK* on_dismiss_permission_prompt)(
struct _cef_permission_handler_t* self,
struct _cef_browser_t* browser,
uint64 prompt_id,
cef_permission_request_result_t result);
} cef_permission_handler_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_PERMISSION_HANDLER_CAPI_H_

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=026a7f827962222a1df8b62a8e7bdfbf4dce27e0$
// $hash=2549ea10cd3a41bc04ab81bad24eb12787de68b9$
//
#ifndef CEF_INCLUDE_CAPI_CEF_PROCESS_MESSAGE_CAPI_H_
@@ -41,7 +41,6 @@
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_shared_memory_region_capi.h"
#include "include/capi/cef_values_capi.h"
#ifdef __cplusplus
@@ -70,8 +69,7 @@ typedef struct _cef_process_message_t {
int(CEF_CALLBACK* is_read_only)(struct _cef_process_message_t* self);
///
// Returns a writable copy of this object. Returns nullptr when message
// contains a shared memory region.
// Returns a writable copy of this object.
///
struct _cef_process_message_t*(CEF_CALLBACK* copy)(
struct _cef_process_message_t* self);
@@ -84,18 +82,10 @@ typedef struct _cef_process_message_t {
struct _cef_process_message_t* self);
///
// Returns the list of arguments. Returns nullptr when message contains a
// shared memory region.
// Returns the list of arguments.
///
struct _cef_list_value_t*(CEF_CALLBACK* get_argument_list)(
struct _cef_process_message_t* self);
///
// Returns the shared memory region. Returns nullptr when message contains an
// argument list.
///
struct _cef_shared_memory_region_t*(CEF_CALLBACK* get_shared_memory_region)(
struct _cef_process_message_t* self);
} cef_process_message_t;
///

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=b0688a7d24b67b74a62841be60217a8e48c7228e$
// $hash=7fc75c41ce47a5e715471b9bb82c848d6cf25472$
//
#ifndef CEF_INCLUDE_CAPI_CEF_RENDER_HANDLER_CAPI_H_
@@ -161,25 +161,6 @@ typedef struct _cef_render_handler_t {
cef_rect_t const* dirtyRects,
void* shared_handle);
///
// Called to retrieve the size of the touch handle for the specified
// |orientation|.
///
void(CEF_CALLBACK* get_touch_handle_size)(
struct _cef_render_handler_t* self,
struct _cef_browser_t* browser,
cef_horizontal_alignment_t orientation,
cef_size_t* size);
///
// Called when touch handle state is updated. The client is responsible for
// rendering the touch handles.
///
void(CEF_CALLBACK* on_touch_handle_state_changed)(
struct _cef_render_handler_t* self,
struct _cef_browser_t* browser,
const struct _cef_touch_handle_state_t* state);
///
// Called when the user starts dragging content in the web view. Contextual
// information about the dragged content is supplied by |drag_data|. (|x|,

View File

@@ -1,79 +0,0 @@
// Copyright (c) 2022 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=212f13ac6baeeefb86f1648d1e18ccba95fd5f79$
//
#ifndef CEF_INCLUDE_CAPI_CEF_SHARED_MEMORY_REGION_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_SHARED_MEMORY_REGION_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
///
// Structure that wraps platform-dependent share memory region mapping.
///
typedef struct _cef_shared_memory_region_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Returns true (1) if the mapping is valid.
///
int(CEF_CALLBACK* is_valid)(struct _cef_shared_memory_region_t* self);
///
// Returns the size of the mapping in bytes. Returns 0 for invalid instances.
///
size_t(CEF_CALLBACK* size)(struct _cef_shared_memory_region_t* self);
///
// Returns the pointer to the memory. Returns nullptr for invalid instances.
// The returned pointer is only valid for the life span of this object.
///
const void*(CEF_CALLBACK* memory)(struct _cef_shared_memory_region_t* self);
} cef_shared_memory_region_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_SHARED_MEMORY_REGION_CAPI_H_

View File

@@ -1,101 +0,0 @@
// Copyright (c) 2022 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=0ed88d26dab045ebef0f4f4ae209e7f11206a242$
//
#ifndef CEF_INCLUDE_CAPI_CEF_SHARED_PROCESS_MESSAGE_BUILDER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_SHARED_PROCESS_MESSAGE_BUILDER_CAPI_H_
#pragma once
#include "include/capi/cef_process_message_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
///
// Structure that builds a cef_process_message_t containing a shared memory
// region. This structure is not thread-safe but may be used exclusively on a
// different thread from the one which constructed it.
///
typedef struct _cef_shared_process_message_builder_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Returns true (1) if the builder is valid.
///
int(CEF_CALLBACK* is_valid)(
struct _cef_shared_process_message_builder_t* self);
///
// Returns the size of the shared memory region in bytes. Returns 0 for
// invalid instances.
///
size_t(CEF_CALLBACK* size)(
struct _cef_shared_process_message_builder_t* self);
///
// Returns the pointer to the writable memory. Returns nullptr for invalid
// instances. The returned pointer is only valid for the life span of this
// object.
///
void*(CEF_CALLBACK* memory)(
struct _cef_shared_process_message_builder_t* self);
///
// Creates a new cef_process_message_t from the data provided to the builder.
// Returns nullptr for invalid instances. Invalidates the builder instance.
///
struct _cef_process_message_t*(CEF_CALLBACK* build)(
struct _cef_shared_process_message_builder_t* self);
} cef_shared_process_message_builder_t;
///
// Creates a new cef_shared_process_message_builder_t with the specified |name|
// and shared memory region of specified |byte_size|.
///
CEF_EXPORT cef_shared_process_message_builder_t*
cef_shared_process_message_builder_create(const cef_string_t* name,
size_t byte_size);
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_SHARED_PROCESS_MESSAGE_BUILDER_CAPI_H_

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=a75487288913e4646f67ee8aded4bc9ef328bb79$
// $hash=6a8166eca76513b59a4f6355f4f765dc1d77e4ee$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_DELEGATE_CAPI_H_
@@ -49,10 +49,9 @@ extern "C" {
struct _cef_view_t;
///
// Implement this structure to handle view events. All size and position values
// are in density independent pixels (DIP) unless otherwise indicated. The
// functions of this structure will be called on the browser process UI thread
// unless otherwise indicated.
// Implement this structure to handle view events. The functions of this
// structure will be called on the browser process UI thread unless otherwise
// indicated.
///
typedef struct _cef_view_delegate_t {
///

View File

@@ -42,13 +42,13 @@
// way that may cause binary incompatibility with other builds. The universal
// hash value will change if any platform is affected whereas the platform hash
// values will change only if that particular platform is affected.
#define CEF_API_HASH_UNIVERSAL "1f35577ebd00c5e6cc03a172bb41e3c0d820f3d1"
#define CEF_API_HASH_UNIVERSAL "b6255e15aa977a7214cf28e4e1a2372b454838d4"
#if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "99f91193dce6b93011526269c4dc5d0c32569b70"
#define CEF_API_HASH_PLATFORM "b262c3a2cbd2632de1bfed887da8b8114c9ecbf5"
#elif defined(OS_MAC)
#define CEF_API_HASH_PLATFORM "316e120c0bf151de8145ee3b45ef3451e1ff60dc"
#define CEF_API_HASH_PLATFORM "fd6d3d83442fe31ad26d5648755e0cf2e14a7fc7"
#elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "e061aecbfbf09b9068391bdfcd80c9d5ed1faece"
#define CEF_API_HASH_PLATFORM "d686964de5e01eed900d78d5f8a7da9f8fc3a777"
#endif
#ifdef __cplusplus

View File

@@ -53,7 +53,6 @@
#include "include/cef_keyboard_handler.h"
#include "include/cef_life_span_handler.h"
#include "include/cef_load_handler.h"
#include "include/cef_permission_handler.h"
#include "include/cef_print_handler.h"
#include "include/cef_process_message.h"
#include "include/cef_render_handler.h"
@@ -133,14 +132,6 @@ class CefClient : public virtual CefBaseRefCounted {
/*--cef()--*/
virtual CefRefPtr<CefFrameHandler> GetFrameHandler() { return nullptr; }
///
// Return the handler for permission requests.
///
/*--cef()--*/
virtual CefRefPtr<CefPermissionHandler> GetPermissionHandler() {
return nullptr;
}
///
// Return the handler for JavaScript dialogs. If no handler is provided the
// default implementation will be used.

View File

@@ -51,12 +51,14 @@ class CefContextMenuParams;
/*--cef(source=library)--*/
class CefRunContextMenuCallback : public virtual CefBaseRefCounted {
public:
typedef cef_event_flags_t EventFlags;
///
// Complete context menu display by selecting the specified |command_id| and
// |event_flags|.
///
/*--cef(capi_name=cont)--*/
virtual void Continue(int command_id, cef_event_flags_t event_flags) = 0;
virtual void Continue(int command_id, EventFlags event_flags) = 0;
///
// Cancel context menu display.
@@ -65,26 +67,6 @@ class CefRunContextMenuCallback : public virtual CefBaseRefCounted {
virtual void Cancel() = 0;
};
///
// Callback interface used for continuation of custom quick menu display.
///
/*--cef(source=library)--*/
class CefRunQuickMenuCallback : public virtual CefBaseRefCounted {
public:
///
// Complete quick menu display by selecting the specified |command_id| and
// |event_flags|.
///
/*--cef(capi_name=cont)--*/
virtual void Continue(int command_id, cef_event_flags_t event_flags) = 0;
///
// Cancel quick menu display.
///
/*--cef()--*/
virtual void Cancel() = 0;
};
///
// Implement this interface to handle context menu events. The methods of this
// class will be called on the UI thread.
@@ -93,7 +75,6 @@ class CefRunQuickMenuCallback : public virtual CefBaseRefCounted {
class CefContextMenuHandler : public virtual CefBaseRefCounted {
public:
typedef cef_event_flags_t EventFlags;
typedef cef_quick_menu_edit_state_flags_t QuickMenuEditStateFlags;
///
// Called before a context menu is displayed. |params| provides information
@@ -145,55 +126,15 @@ class CefContextMenuHandler : public virtual CefBaseRefCounted {
///
// Called when the context menu is dismissed irregardless of whether the menu
// was canceled or a command was selected.
// was empty or a command was selected.
///
/*--cef()--*/
virtual void OnContextMenuDismissed(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> 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 if the menu will be
// handled and execute |callback| either synchronously or asynchronously with
// the selected command ID. Return false to cancel the menu.
///
/*--cef()--*/
virtual bool RunQuickMenu(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefPoint& location,
const CefSize& size,
QuickMenuEditStateFlags edit_state_flags,
CefRefPtr<CefRunQuickMenuCallback> callback) {
return false;
}
///
// Called to execute a command selected from the quick menu for a windowless
// browser. Return true if the command was handled or false for the default
// implementation. See cef_menu_id_t for command IDs that have default
// implementations.
///
/*--cef()--*/
virtual bool OnQuickMenuCommand(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
int command_id,
EventFlags event_flags) {
return false;
}
///
// Called when the quick menu for a windowless browser is dismissed
// irregardless of whether the menu was canceled or a command was selected.
///
/*--cef()--*/
virtual void OnQuickMenuDismissed(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame) {}
};
///
// Provides information about the context menu state. The methods of this class
// Provides information about the context menu state. The ethods of this class
// can only be accessed on browser process the UI thread.
///
/*--cef(source=library)--*/

View File

@@ -148,15 +148,6 @@ class CefDisplayHandler : public virtual CefBaseRefCounted {
const CefCursorInfo& custom_cursor_info) {
return false;
}
///
// Called when the browser's access to an audio and/or video source has
// changed.
///
/*--cef()--*/
virtual void OnMediaAccessChange(CefRefPtr<CefBrowser> browser,
bool has_video_access,
bool has_audio_access) {}
};
#endif // CEF_INCLUDE_CEF_DISPLAY_HANDLER_H_

View File

@@ -323,8 +323,7 @@ class CefDOMNode : public virtual CefBaseRefCounted {
virtual CefString GetElementInnerText() = 0;
///
// Returns the bounds of the element in device pixels. Use
// "window.devicePixelRatio" to convert to/from CSS pixels.
// Returns the bounds of the element.
///
/*--cef()--*/
virtual CefRect GetElementBounds() = 0;

View File

@@ -118,7 +118,7 @@ class CefJSDialogHandler : public virtual CefBaseRefCounted {
virtual void OnResetDialogState(CefRefPtr<CefBrowser> browser) {}
///
// Called when the dialog is closed.
// Called when the default implementation dialog is closed.
///
/*--cef()--*/
virtual void OnDialogClosed(CefRefPtr<CefBrowser> browser) {}

View File

@@ -1,148 +0,0 @@
// Copyright (c) 2022 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.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_PERMISSION_HANDLER_H_
#define CEF_INCLUDE_CEF_PERMISSION_HANDLER_H_
#pragma once
#include "include/cef_base.h"
#include "include/cef_browser.h"
///
// Callback interface used for asynchronous continuation of media access
// permission requests.
///
/*--cef(source=library)--*/
class CefMediaAccessCallback : public virtual CefBaseRefCounted {
public:
///
// Call to allow or deny media access. If this callback was initiated in
// response to a getUserMedia (indicated by
// CEF_MEDIA_PERMISSION_DEVICE_AUDIO_CAPTURE and/or
// CEF_MEDIA_PERMISSION_DEVICE_VIDEO_CAPTURE being set) then
// |allowed_permissions| must match |required_permissions| passed to
// OnRequestMediaAccessPermission.
///
/*--cef(capi_name=cont)--*/
virtual void Continue(uint32 allowed_permissions) = 0;
///
// Cancel the media access request.
///
/*--cef()--*/
virtual void Cancel() = 0;
};
///
// Callback interface used for asynchronous continuation of permission prompts.
///
/*--cef(source=library)--*/
class CefPermissionPromptCallback : public virtual CefBaseRefCounted {
public:
///
// Complete the permissions request with the specified |result|.
///
/*--cef(capi_name=cont)--*/
virtual void Continue(cef_permission_request_result_t result) = 0;
};
///
// Implement this interface to handle events related to permission requests. The
// methods of this class will be called on the browser process UI thread.
///
/*--cef(source=client)--*/
class CefPermissionHandler : public virtual CefBaseRefCounted {
public:
///
// Called when a page requests permission to access media. |requesting_origin|
// is the URL origin requesting permission. |requested_permissions| is a
// combination of values from cef_media_access_permission_types_t that
// represent the requested permissions. Return true and call
// CefMediaAccessCallback methods either in this method or at a later time to
// continue or cancel the request. Return false to proceed with default
// handling. With the Chrome runtime, default handling will display the
// permission request UI. With the Alloy runtime, default handling will deny
// the request. This method will not be called if the "--enable-media-stream"
// command-line switch is used to grant all permissions.
///
/*--cef()--*/
virtual bool OnRequestMediaAccessPermission(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& requesting_origin,
uint32 requested_permissions,
CefRefPtr<CefMediaAccessCallback> callback) {
return false;
}
///
// Called when a page should show a permission prompt. |prompt_id| uniquely
// identifies the prompt. |requesting_origin| is the URL origin requesting
// permission. |requested_permissions| is a combination of values from
// cef_permission_request_types_t that represent the requested permissions.
// Return true and call CefPermissionPromptCallback::Continue either in this
// method or at a later time to continue or cancel the request. Return false
// to proceed with default handling. With the Chrome runtime, default handling
// will display the permission prompt UI. With the Alloy runtime, default
// handling is CEF_PERMISSION_RESULT_IGNORE.
///
/*--cef()--*/
virtual bool OnShowPermissionPrompt(
CefRefPtr<CefBrowser> browser,
uint64 prompt_id,
const CefString& requesting_origin,
uint32 requested_permissions,
CefRefPtr<CefPermissionPromptCallback> callback) {
return false;
}
///
// Called when a permission prompt handled via OnShowPermissionPrompt is
// dismissed. |prompt_id| will match the value that was passed to
// OnShowPermissionPrompt. |result| will be the value passed to
// CefPermissionPromptCallback::Continue or CEF_PERMISSION_RESULT_IGNORE if
// the dialog was dismissed for other reasons such as navigation, browser
// closure, etc. This method will not be called if OnShowPermissionPrompt
// returned false for |prompt_id|.
///
/*--cef()--*/
virtual void OnDismissPermissionPrompt(
CefRefPtr<CefBrowser> browser,
uint64 prompt_id,
cef_permission_request_result_t result) {}
};
#endif // CEF_INCLUDE_CEF_PERMISSION_HANDLER_H_

View File

@@ -39,7 +39,6 @@
#pragma once
#include "include/cef_base.h"
#include "include/cef_shared_memory_region.h"
#include "include/cef_values.h"
typedef cef_process_id_t CefProcessId;
@@ -72,7 +71,6 @@ class CefProcessMessage : public virtual CefBaseRefCounted {
///
// Returns a writable copy of this object.
// Returns nullptr when message contains a shared memory region.
///
/*--cef()--*/
virtual CefRefPtr<CefProcessMessage> Copy() = 0;
@@ -85,17 +83,9 @@ class CefProcessMessage : public virtual CefBaseRefCounted {
///
// Returns the list of arguments.
// Returns nullptr when message contains a shared memory region.
///
/*--cef()--*/
virtual CefRefPtr<CefListValue> GetArgumentList() = 0;
///
// Returns the shared memory region.
// Returns nullptr when message contains an argument list.
///
/*--cef()--*/
virtual CefRefPtr<CefSharedMemoryRegion> GetSharedMemoryRegion() = 0;
};
#endif // CEF_INCLUDE_CEF_MESSAGE_H_

View File

@@ -163,23 +163,6 @@ class CefRenderHandler : public virtual CefBaseRefCounted {
const RectList& dirtyRects,
void* shared_handle) {}
///
// Called to retrieve the size of the touch handle for the specified
// |orientation|.
///
/*--cef()--*/
virtual void GetTouchHandleSize(CefRefPtr<CefBrowser> browser,
cef_horizontal_alignment_t orientation,
CefSize& size) {}
///
// Called when touch handle state is updated. The client is responsible for
// rendering the touch handles.
///
/*--cef()--*/
virtual void OnTouchHandleStateChanged(CefRefPtr<CefBrowser> browser,
const CefTouchHandleState& state) {}
///
// Called when the user starts dragging content in the web view. Contextual
// information about the dragged content is supplied by |drag_data|.

View File

@@ -1,69 +0,0 @@
// Copyright (c) 2022 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.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_SHARED_MEMORY_REGION_H_
#define CEF_INCLUDE_CEF_SHARED_MEMORY_REGION_H_
#pragma once
#include "include/cef_base.h"
///
// Class that wraps platform-dependent share memory region mapping.
///
/*--cef(source=library)--*/
class CefSharedMemoryRegion : public virtual CefBaseRefCounted {
public:
///
// Returns true if the mapping is valid.
///
/*--cef()--*/
virtual bool IsValid() = 0;
///
// Returns the size of the mapping in bytes. Returns 0 for invalid instances.
///
/*--cef()--*/
virtual size_t Size() = 0;
///
// Returns the pointer to the memory. Returns nullptr for invalid instances.
// The returned pointer is only valid for the life span of this object.
///
/*--cef()--*/
virtual const void* Memory() = 0;
};
#endif // CEF_INCLUDE_CEF_SHARED_MEMORY_REGION_H_

View File

@@ -1,87 +0,0 @@
// Copyright (c) 2022 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.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_SHARED_PROCESS_MESSAGE_BUILDER_H_
#define CEF_INCLUDE_CEF_SHARED_PROCESS_MESSAGE_BUILDER_H_
#pragma once
#include "include/cef_process_message.h"
///
// Class that builds a CefProcessMessage containing a shared memory region.
// This class is not thread-safe but may be used exclusively on a different
// thread from the one which constructed it.
///
/*--cef(source=library)--*/
class CefSharedProcessMessageBuilder : public virtual CefBaseRefCounted {
public:
///
// Creates a new CefSharedProcessMessageBuilder with the specified |name| and
// shared memory region of specified |byte_size|.
///
/*--cef()--*/
static CefRefPtr<CefSharedProcessMessageBuilder> Create(const CefString& name,
size_t byte_size);
///
// Returns true if the builder is valid.
///
/*--cef()--*/
virtual bool IsValid() = 0;
///
// Returns the size of the shared memory region in bytes. Returns 0 for
// invalid instances.
///
/*--cef()--*/
virtual size_t Size() = 0;
///
// Returns the pointer to the writable memory. Returns nullptr for invalid
// instances. The returned pointer is only valid for the life span of this
// object.
///
/*--cef()--*/
virtual void* Memory() = 0;
///
// Creates a new CefProcessMessage from the data provided to the builder.
// Returns nullptr for invalid instances. Invalidates the builder instance.
///
/*--cef()--*/
virtual CefRefPtr<CefProcessMessage> Build() = 0;
};
#endif // CEF_INCLUDE_CEF_SHARED_PROCESS_MESSAGE_BUILDER_H_

View File

@@ -1996,17 +1996,6 @@ typedef enum {
CM_EDITFLAG_CAN_EDIT_RICHLY = 1 << 8,
} cef_context_menu_edit_state_flags_t;
///
// Supported quick menu state bit flags.
///
typedef enum {
QM_EDITFLAG_NONE = 0,
QM_EDITFLAG_CAN_ELLIPSIS = 1 << 0,
QM_EDITFLAG_CAN_CUT = 1 << 1,
QM_EDITFLAG_CAN_COPY = 1 << 2,
QM_EDITFLAG_CAN_PASTE = 1 << 3,
} cef_quick_menu_edit_state_flags_t;
///
// Key event types.
///
@@ -3241,138 +3230,6 @@ typedef enum {
CEF_SHOW_STATE_FULLSCREEN,
} cef_show_state_t;
///
// Values indicating what state of the touch handle is set.
///
typedef enum {
CEF_THS_FLAG_NONE = 0,
CEF_THS_FLAG_ENABLED = 1 << 0,
CEF_THS_FLAG_ORIENTATION = 1 << 1,
CEF_THS_FLAG_ORIGIN = 1 << 2,
CEF_THS_FLAG_ALPHA = 1 << 3,
} cef_touch_handle_state_flags_t;
typedef struct _cef_touch_handle_state_t {
///
// Touch handle id. Increments for each new touch handle.
///
int touch_handle_id;
///
// Combination of cef_touch_handle_state_flags_t values indicating what state
// is set.
///
uint32 flags;
///
// Enabled state. Only set if |flags| contains CEF_THS_FLAG_ENABLED.
///
int enabled;
///
// Orientation state. Only set if |flags| contains CEF_THS_FLAG_ORIENTATION.
///
cef_horizontal_alignment_t orientation;
int mirror_vertical;
int mirror_horizontal;
///
// Origin state. Only set if |flags| contains CEF_THS_FLAG_ORIGIN.
///
cef_point_t origin;
///
// Alpha state. Only set if |flags| contains CEF_THS_FLAG_ALPHA.
///
float alpha;
} cef_touch_handle_state_t;
///
// Media access permissions used by OnRequestMediaAccessPermission.
///
typedef enum {
///
// No permission.
///
CEF_MEDIA_PERMISSION_NONE = 0,
///
// Device audio capture permission.
///
CEF_MEDIA_PERMISSION_DEVICE_AUDIO_CAPTURE = 1 << 0,
///
// Device video capture permission.
///
CEF_MEDIA_PERMISSION_DEVICE_VIDEO_CAPTURE = 1 << 1,
///
// Desktop audio capture permission.
///
CEF_MEDIA_PERMISSION_DESKTOP_AUDIO_CAPTURE = 1 << 2,
///
// Desktop video capture permission.
///
CEF_MEDIA_PERMISSION_DESKTOP_VIDEO_CAPTURE = 1 << 3,
} cef_media_access_permission_types_t;
///
// Permission types used with OnShowPermissionPrompt. Some types are
// platform-specific or only supported with the Chrome runtime. Should be kept
// in sync with Chromium's permissions::RequestType type.
///
typedef enum {
CEF_PERMISSION_TYPE_NONE = 0,
CEF_PERMISSION_TYPE_ACCESSIBILITY_EVENTS = 1 << 0,
CEF_PERMISSION_TYPE_AR_SESSION = 1 << 1,
CEF_PERMISSION_TYPE_CAMERA_PAN_TILT_ZOOM = 1 << 2,
CEF_PERMISSION_TYPE_CAMERA_STREAM = 1 << 3,
CEF_PERMISSION_TYPE_CLIPBOARD = 1 << 4,
CEF_PERMISSION_TYPE_DISK_QUOTA = 1 << 5,
CEF_PERMISSION_TYPE_LOCAL_FONTS = 1 << 6,
CEF_PERMISSION_TYPE_GEOLOCATION = 1 << 7,
CEF_PERMISSION_TYPE_IDLE_DETECTION = 1 << 8,
CEF_PERMISSION_TYPE_MIC_STREAM = 1 << 9,
CEF_PERMISSION_TYPE_MIDI_SYSEX = 1 << 10,
CEF_PERMISSION_TYPE_MULTIPLE_DOWNLOADS = 1 << 11,
CEF_PERMISSION_TYPE_NOTIFICATIONS = 1 << 12,
CEF_PERMISSION_TYPE_PROTECTED_MEDIA_IDENTIFIER = 1 << 13,
CEF_PERMISSION_TYPE_REGISTER_PROTOCOL_HANDLER = 1 << 14,
CEF_PERMISSION_TYPE_SECURITY_ATTESTATION = 1 << 15,
CEF_PERMISSION_TYPE_STORAGE_ACCESS = 1 << 16,
CEF_PERMISSION_TYPE_U2F_API_REQUEST = 1 << 17,
CEF_PERMISSION_TYPE_VR_SESSION = 1 << 18,
CEF_PERMISSION_TYPE_WINDOW_PLACEMENT = 1 << 19,
} cef_permission_request_types_t;
///
// Permission request results.
///
typedef enum {
///
// Accept the permission request as an explicit user action.
///
CEF_PERMISSION_RESULT_ACCEPT,
///
// Deny the permission request as an explicit user action.
///
CEF_PERMISSION_RESULT_DENY,
///
// Dismiss the permission request as an explicit user action.
///
CEF_PERMISSION_RESULT_DISMISS,
///
// Ignore the permission request. If the prompt remains unhandled (e.g.
// OnShowPermissionPrompt returns false and there is no default permissions
// UI) then any related promises may remain unresolved.
///
CEF_PERMISSION_RESULT_IGNORE,
} cef_permission_request_result_t;
#ifdef __cplusplus
}
#endif

View File

@@ -820,25 +820,6 @@ class CefTime : public CefStructBase<CefTimeTraits> {
}
};
struct CefTouchHandleStateTraits {
typedef cef_touch_handle_state_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src,
struct_type* target,
bool copy) {
*target = *src;
}
};
///
// Class representing the state of a touch handle.
///
typedef CefStructBase<CefTouchHandleStateTraits> CefTouchHandleState;
struct CefCookieTraits {
typedef cef_cookie_t struct_type;

View File

@@ -43,10 +43,8 @@
class CefView;
///
// Implement this interface to handle view events. All size and position values
// are in density independent pixels (DIP) unless otherwise indicated. The
// methods of this class will be called on the browser process UI thread unless
// otherwise indicated.
// Implement this interface to handle view events. The methods of this class
// will be called on the browser process UI thread unless otherwise indicated.
///
/*--cef(source=client)--*/
class CefViewDelegate : public virtual CefBaseRefCounted {

View File

@@ -207,10 +207,6 @@ struct CefMessageRouterConfig {
// Name of the JavaScript function that will be added to the 'window' object
// for canceling a pending query. The default value is "cefQueryCancel".
CefString js_cancel_function;
// Messages of size (in bytes) larger than this threshold will be sent via
// shared memory region.
size_t message_size_threshold;
};
///

View File

@@ -22,7 +22,6 @@
#include "base/strings/string_util.h"
#include "chrome/browser/font_family_cache.h"
#include "chrome/browser/media/media_device_id_salt.h"
#include "chrome/browser/permissions/permission_manager_factory.h"
#include "chrome/browser/plugins/chrome_plugin_service_filter.h"
#include "chrome/browser/profiles/profile_key.h"
#include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
@@ -31,7 +30,6 @@
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/keyed_service/core/simple_dependency_manager.h"
#include "components/keyed_service/core/simple_key_map.h"
#include "components/permissions/permission_manager.h"
#include "components/prefs/pref_service.h"
#include "components/proxy_config/pref_proxy_config_tracker_impl.h"
#include "components/user_prefs/user_prefs.h"
@@ -382,7 +380,7 @@ content::SSLHostStateDelegate* AlloyBrowserContext::GetSSLHostStateDelegate() {
content::PermissionControllerDelegate*
AlloyBrowserContext::GetPermissionControllerDelegate() {
return PermissionManagerFactory::GetForProfile(this);
return nullptr;
}
content::BackgroundFetchDelegate*

View File

@@ -17,7 +17,7 @@
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/context.h"
#include "libcef/browser/devtools/devtools_manager.h"
#include "libcef/browser/media_access_query.h"
#include "libcef/browser/media_capture_devices_dispatcher.h"
#include "libcef/browser/osr/osr_util.h"
#include "libcef/browser/request_context_impl.h"
#include "libcef/browser/thread_util.h"
@@ -51,6 +51,7 @@
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "net/base/net_errors.h"
#include "third_party/blink/public/mojom/mediastream/media_stream.mojom.h"
#include "ui/events/base_event_utils.h"
using content::KeyboardEventProcessingResult;
@@ -617,14 +618,6 @@ bool AlloyBrowserHostImpl::IsWindowless() const {
return is_windowless_;
}
bool AlloyBrowserHostImpl::IsVisible() const {
CEF_REQUIRE_UIT();
if (IsWindowless() && platform_delegate_) {
return !platform_delegate_->IsHidden();
}
return CefBrowserHostBase::IsVisible();
}
bool AlloyBrowserHostImpl::IsPictureInPictureSupported() const {
// Not currently supported with OSR.
return !IsWindowless();
@@ -637,11 +630,6 @@ void AlloyBrowserHostImpl::WindowDestroyed() {
CloseBrowser(true);
}
bool AlloyBrowserHostImpl::WillBeDestroyed() const {
CEF_REQUIRE_UIT();
return destruction_state_ >= DESTRUCTION_STATE_ACCEPTED;
}
void AlloyBrowserHostImpl::DestroyBrowser() {
CEF_REQUIRE_UIT();
@@ -1131,6 +1119,12 @@ bool AlloyBrowserHostImpl::TakeFocus(content::WebContents* source,
return false;
}
bool AlloyBrowserHostImpl::HandleContextMenu(
content::RenderFrameHost& render_frame_host,
const content::ContextMenuParams& params) {
return HandleContextMenu(web_contents(), params);
}
void AlloyBrowserHostImpl::CanDownload(
const GURL& url,
const std::string& request_method,
@@ -1245,8 +1239,9 @@ void AlloyBrowserHostImpl::DidNavigatePrimaryMainFramePostCommit(
content::JavaScriptDialogManager*
AlloyBrowserHostImpl::GetJavaScriptDialogManager(content::WebContents* source) {
if (!javascript_dialog_manager_) {
javascript_dialog_manager_.reset(new CefJavaScriptDialogManager(this));
if (!javascript_dialog_manager_.get() && platform_delegate_) {
javascript_dialog_manager_.reset(new CefJavaScriptDialogManager(
this, platform_delegate_->CreateJavaScriptDialogRunner()));
}
return javascript_dialog_manager_.get();
}
@@ -1260,7 +1255,8 @@ void AlloyBrowserHostImpl::RunFileChooser(
params);
}
bool AlloyBrowserHostImpl::ShowContextMenu(
bool AlloyBrowserHostImpl::HandleContextMenu(
content::WebContents* web_contents,
const content::ContextMenuParams& params) {
CEF_REQUIRE_UIT();
if (!menu_manager_.get() && platform_delegate_) {
@@ -1298,18 +1294,78 @@ void AlloyBrowserHostImpl::RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
content::MediaResponseCallback callback) {
auto returned_callback = media_access_query::RequestMediaAccessPermission(
this, request, std::move(callback), /*default_disallow=*/true);
// Callback should not be returned.
DCHECK(returned_callback.is_null());
CEF_REQUIRE_UIT();
blink::MediaStreamDevices audio_devices;
blink::MediaStreamDevices video_devices;
blink::mojom::StreamDevices stream_devices;
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kEnableMediaStream)) {
// Cancel the request.
std::move(callback).Run(
stream_devices,
blink::mojom::MediaStreamRequestResult::PERMISSION_DENIED,
std::unique_ptr<content::MediaStreamUI>());
return;
}
// Based on chrome/browser/media/media_stream_devices_controller.cc
bool microphone_requested =
(request.audio_type ==
blink::mojom::MediaStreamType::DEVICE_AUDIO_CAPTURE);
bool webcam_requested = (request.video_type ==
blink::mojom::MediaStreamType::DEVICE_VIDEO_CAPTURE);
bool screen_requested =
(request.video_type ==
blink::mojom::MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE);
if (microphone_requested || webcam_requested || screen_requested) {
// Pick the desired device or fall back to the first available of the
// given type.
if (microphone_requested) {
CefMediaCaptureDevicesDispatcher::GetInstance()->GetRequestedDevice(
request.requested_audio_device_id, true, false, &audio_devices);
}
if (webcam_requested) {
CefMediaCaptureDevicesDispatcher::GetInstance()->GetRequestedDevice(
request.requested_video_device_id, false, true, &video_devices);
}
if (screen_requested) {
content::DesktopMediaID media_id;
if (request.requested_video_device_id.empty()) {
media_id =
content::DesktopMediaID(content::DesktopMediaID::TYPE_SCREEN,
-1 /* webrtc::kFullDesktopScreenId */);
} else {
media_id =
content::DesktopMediaID::Parse(request.requested_video_device_id);
}
video_devices.push_back(blink::MediaStreamDevice(
blink::mojom::MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE,
media_id.ToString(), "Screen"));
}
}
// At most one audio device and one video device can be used in a stream.
if (!audio_devices.empty())
stream_devices.audio_device = audio_devices.front();
if (!video_devices.empty())
stream_devices.video_device = video_devices.front();
std::move(callback).Run(stream_devices,
blink::mojom::MediaStreamRequestResult::OK,
std::unique_ptr<content::MediaStreamUI>());
}
bool AlloyBrowserHostImpl::CheckMediaAccessPermission(
content::RenderFrameHost* render_frame_host,
const GURL& security_origin,
blink::mojom::MediaStreamType type) {
return media_access_query::CheckMediaAccessPermission(this, render_frame_host,
security_origin, type);
// Check media access permission without prompting the user.
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
return command_line->HasSwitch(switches::kEnableMediaStream);
}
bool AlloyBrowserHostImpl::IsNeverComposited(

View File

@@ -137,16 +137,12 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
// Returns true if windowless rendering is enabled.
bool IsWindowless() const override;
bool IsVisible() const override;
// Returns true if this browser supports picture-in-picture.
bool IsPictureInPictureSupported() const;
// Called when the OS window hosting the browser is destroyed.
void WindowDestroyed() override;
bool WillBeDestroyed() const override;
// Destroy the browser members. This method should only be called after the
// native browser window is not longer processing messages.
void DestroyBrowser() override;
@@ -176,7 +172,8 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
void OnSetFocus(cef_focus_source_t source) override;
bool ShowContextMenu(const content::ContextMenuParams& params);
bool HandleContextMenu(content::WebContents* web_contents,
const content::ContextMenuParams& params);
enum DestructionState {
DESTRUCTION_STATE_NONE = 0,
@@ -212,6 +209,8 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
bool proceed,
bool* proceed_to_fire_unload) override;
bool TakeFocus(content::WebContents* source, bool reverse) override;
bool HandleContextMenu(content::RenderFrameHost& render_frame_host,
const content::ContextMenuParams& params) override;
void CanDownload(const GURL& url,
const std::string& request_method,
base::OnceCallback<void(bool)> callback) override;

View File

@@ -8,7 +8,6 @@
#include <string>
#include "libcef/browser/alloy/dialogs/alloy_constrained_window_views_client.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/browser_context_keyed_service_factories.h"
#include "libcef/browser/context.h"
@@ -16,22 +15,19 @@
#include "libcef/browser/extensions/extension_system_factory.h"
#include "libcef/browser/file_dialog_runner.h"
#include "libcef/browser/net/chrome_scheme_handler.h"
#include "libcef/browser/permission_prompt.h"
#include "libcef/browser/printing/constrained_window_views_client.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/net/net_resource_provider.h"
#include "base/bind.h"
#include "base/feature_list.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/thread_pool.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/media/router/chrome_media_router_factory.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/plugins/plugin_finder.h"
#include "chrome/browser/ui/javascript_dialogs/chrome_javascript_app_modal_dialog_view_factory.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/common/chrome_switches.h"
#include "components/constrained_window/constrained_window_views.h"
#include "content/public/browser/gpu_data_manager.h"
@@ -52,6 +48,7 @@
#if defined(USE_AURA)
#include "ui/aura/env.h"
#include "ui/display/screen.h"
#include "ui/views/widget/desktop_aura/desktop_screen.h"
#include "ui/wm/core/wm_state.h"
@@ -174,7 +171,7 @@ AlloyBrowserMainParts::~AlloyBrowserMainParts() {
}
void AlloyBrowserMainParts::ToolkitInitialized() {
SetConstrainedWindowViewsClient(CreateAlloyConstrainedWindowViewsClient());
SetConstrainedWindowViewsClient(CreateCefConstrainedWindowViewsClient());
#if defined(USE_AURA)
CHECK(aura::Env::GetInstance());
@@ -191,15 +188,6 @@ void AlloyBrowserMainParts::ToolkitInitialized() {
#if BUILDFLAG(IS_LINUX)
ToolkitInitializedLinux();
#endif
#if BUILDFLAG(IS_MAC)
if (base::FeatureList::IsEnabled(features::kViewsJSAppModalDialog))
InstallChromeJavaScriptAppModalDialogViewFactory();
else
InstallChromeJavaScriptAppModalDialogViewCocoaFactory();
#else
InstallChromeJavaScriptAppModalDialogViewFactory();
#endif
}
void AlloyBrowserMainParts::PreCreateMainMessageLoop() {
@@ -268,9 +256,7 @@ int AlloyBrowserMainParts::PreCreateThreads() {
int AlloyBrowserMainParts::PreMainMessageLoopRun() {
#if defined(USE_AURA)
screen_ = views::CreateDesktopScreen();
#endif
#if BUILDFLAG(IS_MAC)
screen_ = std::make_unique<display::ScopedNativeScreen>();
display::Screen::SetScreenInstance(screen_.get());
#endif
if (extensions::ExtensionsEnabled()) {
@@ -323,7 +309,6 @@ int AlloyBrowserMainParts::PreMainMessageLoopRun() {
scheme::RegisterWebUIControllerFactory();
file_dialog_runner::RegisterFactory();
permission_prompt::RegisterCreateCallback();
#if BUILDFLAG(ENABLE_MEDIA_FOUNDATION_WIDEVINE_CDM) || \
BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)

View File

@@ -13,9 +13,11 @@
#include "build/build_config.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_main_parts.h"
#include "ui/display/screen.h"
#if defined(USE_AURA)
namespace display {
class Screen;
}
namespace wm {
class WMState;
}
@@ -86,7 +88,6 @@ class AlloyBrowserMainParts : public content::BrowserMainParts {
std::unique_ptr<views::ViewsDelegate> views_delegate_;
#if BUILDFLAG(IS_MAC)
std::unique_ptr<display::ScopedNativeScreen> screen_;
std::unique_ptr<views::LayoutProvider> layout_provider_;
#endif
};

View File

@@ -12,7 +12,6 @@
#include "libcef/browser/alloy/alloy_browser_context.h"
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
#include "libcef/browser/alloy/alloy_browser_main.h"
#include "libcef/browser/alloy/alloy_web_contents_view_delegate.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/browser_frame.h"
#include "libcef/browser/browser_info.h"
@@ -1459,12 +1458,6 @@ std::string AlloyContentBrowserClient::GetReducedUserAgent() {
return embedder_support::GetReducedUserAgent();
}
std::unique_ptr<content::WebContentsViewDelegate>
AlloyContentBrowserClient::GetWebContentsViewDelegate(
content::WebContents* web_contents) {
return std::make_unique<AlloyWebContentsViewDelegate>(web_contents);
}
blink::UserAgentMetadata AlloyContentBrowserClient::GetUserAgentMetadata() {
blink::UserAgentMetadata metadata;

View File

@@ -235,8 +235,6 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
std::string GetUserAgent() override;
std::string GetFullUserAgent() override;
std::string GetReducedUserAgent() override;
std::unique_ptr<content::WebContentsViewDelegate> GetWebContentsViewDelegate(
content::WebContents* web_contents) override;
blink::UserAgentMetadata GetUserAgentMetadata() override;
base::flat_set<std::string> GetPluginMimeTypesWithExternalHandlers(
content::BrowserContext* browser_context) override;

View File

@@ -1,22 +0,0 @@
// Copyright 2022 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.
#include "libcef/browser/alloy/alloy_web_contents_view_delegate.h"
#include "content/public/browser/web_contents.h"
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
AlloyWebContentsViewDelegate::AlloyWebContentsViewDelegate(
content::WebContents* web_contents)
: web_contents_(web_contents) {}
void AlloyWebContentsViewDelegate::ShowContextMenu(
content::RenderFrameHost& render_frame_host,
const content::ContextMenuParams& params) {
if (auto browser =
AlloyBrowserHostImpl::GetBrowserForContents(web_contents_)) {
browser->ShowContextMenu(params);
}
}

View File

@@ -1,33 +0,0 @@
// Copyright 2022 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.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_ALLOY_WEB_CONTENTS_VIEW_DELEGATE_H_
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_WEB_CONTENTS_VIEW_DELEGATE_H_
#pragma once
#include "include/internal/cef_ptr.h"
#include "content/public/browser/web_contents_view_delegate.h"
namespace content {
class WebContents;
}
class AlloyWebContentsViewDelegate : public content::WebContentsViewDelegate {
public:
explicit AlloyWebContentsViewDelegate(content::WebContents* web_contents);
AlloyWebContentsViewDelegate(const AlloyWebContentsViewDelegate&) = delete;
AlloyWebContentsViewDelegate& operator=(const AlloyWebContentsViewDelegate&) =
delete;
// WebContentsViewDelegate methods:
void ShowContextMenu(content::RenderFrameHost& render_frame_host,
const content::ContextMenuParams& params) override;
private:
content::WebContents* const web_contents_;
};
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_WEB_CONTENTS_VIEW_DELEGATE_H_

View File

@@ -5,7 +5,6 @@
#include "libcef/browser/alloy/browser_platform_delegate_alloy.h"
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
#include "libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.h"
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/extensions/extension_background_host.h"
#include "libcef/browser/extensions/extension_system.h"
@@ -22,8 +21,6 @@
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
#include "components/find_in_page/find_tab_helper.h"
#include "components/find_in_page/find_types.h"
#include "components/javascript_dialogs/tab_modal_dialog_manager.h"
#include "components/permissions/permission_request_manager.h"
#include "components/zoom/zoom_controller.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
@@ -179,7 +176,6 @@ void CefBrowserPlatformDelegateAlloy::BrowserCreated(
DCHECK(!web_contents_->GetDelegate());
web_contents_->SetDelegate(static_cast<AlloyBrowserHostImpl*>(browser));
permissions::PermissionRequestManager::CreateForWebContents(web_contents_);
PrefsTabHelper::CreateForWebContents(web_contents_);
printing::CefPrintViewManager::CreateForWebContents(web_contents_);
@@ -188,13 +184,10 @@ void CefBrowserPlatformDelegateAlloy::BrowserCreated(
zoom::ZoomController::CreateForWebContents(web_contents_);
}
javascript_dialogs::TabModalDialogManager::CreateForWebContents(
web_contents_,
CreateAlloyJavaScriptTabModalDialogManagerDelegateDesktop(web_contents_));
// Used for print preview and JavaScript dialogs.
web_contents_dialog_helper_.reset(
new AlloyWebContentsDialogHelper(web_contents_, this));
if (IsPrintPreviewSupported()) {
web_contents_dialog_helper_.reset(
new CefWebContentsDialogHelper(web_contents_, this));
}
}
void CefBrowserPlatformDelegateAlloy::CreateExtensionHost(
@@ -249,11 +242,6 @@ void CefBrowserPlatformDelegateAlloy::BrowserDestroyed(
CefBrowserPlatformDelegate::BrowserDestroyed(browser);
}
web_modal::WebContentsModalDialogHost*
CefBrowserPlatformDelegateAlloy::GetWebContentsModalDialogHost() const {
return web_contents_dialog_helper_.get();
}
void CefBrowserPlatformDelegateAlloy::SendCaptureLostEvent() {
if (!web_contents_)
return;

View File

@@ -6,8 +6,8 @@
#ifndef CEF_LIBCEF_BROWSER_ALLOY_BROWSER_PLATFORM_DELEGATE_ALLOY_H_
#define CEF_LIBCEF_BROWSER_ALLOY_BROWSER_PLATFORM_DELEGATE_ALLOY_H_
#include "libcef/browser/alloy/dialogs/alloy_web_contents_dialog_helper.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/web_contents_dialog_helper.h"
#include "base/memory/weak_ptr.h"
#include "components/find_in_page/find_notification_details.h"
@@ -42,8 +42,6 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
extensions::mojom::ViewType host_type) override;
extensions::ExtensionHost* GetExtensionHost() const override;
void BrowserDestroyed(CefBrowserHostBase* browser) override;
web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
const override;
void SendCaptureLostEvent() override;
#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC))
void NotifyMoveOrResizeStarted() override;
@@ -100,7 +98,7 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
std::unique_ptr<content::WebContents> owned_web_contents_;
// Used for the print preview dialog.
std::unique_ptr<AlloyWebContentsDialogHelper> web_contents_dialog_helper_;
std::unique_ptr<CefWebContentsDialogHelper> web_contents_dialog_helper_;
// The last find result. This object contains details about the number of
// matches, the find selection rectangle, etc.

View File

@@ -18,7 +18,6 @@
#include "base/command_line.h"
#include "chrome/browser/component_updater/chrome_component_updater_configurator.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/permissions/chrome_permissions_client.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/browser/printing/background_printing_manager.h"
#include "chrome/browser/printing/print_job_manager.h"
@@ -68,9 +67,6 @@ void ChromeBrowserProcessAlloy::Initialize() {
extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get());
}
// Make sure permissions client has been set.
ChromePermissionsClient::GetInstance();
initialized_ = true;
}

View File

@@ -1,76 +0,0 @@
// Copyright 2022 The Chromium Embedded Framework Authors.
// Portions copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/alloy/dialogs/alloy_constrained_window_views_client.h"
#include "libcef/browser/browser_host_base.h"
#include "base/notreached.h"
#include "components/web_modal/web_contents_modal_dialog_host.h"
namespace {
class AlloyConstrainedWindowViewsClient
: public constrained_window::ConstrainedWindowViewsClient {
public:
AlloyConstrainedWindowViewsClient() = default;
AlloyConstrainedWindowViewsClient(const AlloyConstrainedWindowViewsClient&) =
delete;
AlloyConstrainedWindowViewsClient& operator=(
const AlloyConstrainedWindowViewsClient&) = delete;
private:
// ConstrainedWindowViewsClient methods:
web_modal::ModalDialogHost* GetModalDialogHost(
gfx::NativeWindow parent) override {
if (auto browser = GetPreferredBrowser(parent)) {
return browser->platform_delegate()->GetWebContentsModalDialogHost();
}
NOTREACHED();
return nullptr;
}
gfx::NativeView GetDialogHostView(gfx::NativeWindow parent) override {
if (auto dialog_host = GetModalDialogHost(parent)) {
return dialog_host->GetHostView();
}
return gfx::NativeView();
}
static CefRefPtr<CefBrowserHostBase> GetPreferredBrowser(
gfx::NativeWindow parent) {
CefRefPtr<CefBrowserHostBase> browser;
// 1. Browser associated with the top-level native window (owning_window).
// This should be reliable with windowed browsers. However, |parent| will
// always be nullptr with windowless browsers.
if (parent) {
browser = CefBrowserHostBase::GetBrowserForTopLevelNativeWindow(parent);
if (!browser) {
LOG(WARNING) << "No browser associated with top-level native window";
}
}
// 2. Browser most likely to be focused. This may be somewhat iffy with
// windowless browsers as there is no guarantee that the client has only
// one browser focused at a time.
if (!browser) {
browser = CefBrowserHostBase::GetLikelyFocusedBrowser();
if (!browser) {
LOG(WARNING) << "No likely focused browser";
}
}
return browser;
}
};
} // namespace
std::unique_ptr<constrained_window::ConstrainedWindowViewsClient>
CreateAlloyConstrainedWindowViewsClient() {
return std::make_unique<AlloyConstrainedWindowViewsClient>();
}

View File

@@ -1,17 +0,0 @@
// Copyright 2022 The Chromium Embedded Framework Authors.
// Portions copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_DIALOGS_ALLOY_CONSTRAINED_WINDOW_VIEWS_CLIENT_H_
#define CEF_LIBCEF_BROWSER_ALLOY_DIALOGS_ALLOY_CONSTRAINED_WINDOW_VIEWS_CLIENT_H_
#include <memory>
#include "components/constrained_window/constrained_window_views_client.h"
// Creates a ConstrainedWindowViewsClient for the Chrome environment.
std::unique_ptr<constrained_window::ConstrainedWindowViewsClient>
CreateAlloyConstrainedWindowViewsClient();
#endif // CEF_LIBCEF_BROWSER_ALLOY_DIALOGS_ALLOY_CONSTRAINED_WINDOW_VIEWS_CLIENT_H_

View File

@@ -1,58 +0,0 @@
// Copyright 2022 The Chromium Embedded Framework Authors.
// Portions copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.h"
#include "libcef/browser/browser_host_base.h"
#include "base/logging.h"
namespace {
class AlloyJavaScriptTabModalDialogManagerDelegateDesktop
: public JavaScriptTabModalDialogManagerDelegateDesktop {
public:
explicit AlloyJavaScriptTabModalDialogManagerDelegateDesktop(
content::WebContents* web_contents)
: JavaScriptTabModalDialogManagerDelegateDesktop(web_contents),
web_contents_(web_contents) {}
AlloyJavaScriptTabModalDialogManagerDelegateDesktop(
const AlloyJavaScriptTabModalDialogManagerDelegateDesktop&) = delete;
AlloyJavaScriptTabModalDialogManagerDelegateDesktop& operator=(
const AlloyJavaScriptTabModalDialogManagerDelegateDesktop&) = delete;
// javascript_dialogs::TabModalDialogManagerDelegate methods:
void WillRunDialog() override {}
void DidCloseDialog() override {}
void SetTabNeedsAttention(bool attention) override {}
bool IsWebContentsForemost() override {
if (auto browser =
CefBrowserHostBase::GetBrowserForContents(web_contents_)) {
return browser->IsVisible();
}
return false;
}
bool IsApp() override { return false; }
private:
// The WebContents for the tab over which the dialog will be modal. This may
// be different from the WebContents that requested the dialog, such as with
// Chrome app <webview>s.
raw_ptr<content::WebContents> web_contents_;
};
} // namespace
std::unique_ptr<JavaScriptTabModalDialogManagerDelegateDesktop>
CreateAlloyJavaScriptTabModalDialogManagerDelegateDesktop(
content::WebContents* web_contents) {
return std::make_unique<AlloyJavaScriptTabModalDialogManagerDelegateDesktop>(
web_contents);
}

View File

@@ -1,18 +0,0 @@
// Copyright 2022 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.
#ifndef CEF_LIBCEF_BROWSER_ALLOY_DIALOGS_ALLOY_JAVASCRIPT_DIALOG_MANAGER_DELEGATE_H_
#define CEF_LIBCEF_BROWSER_ALLOY_DIALOGS_ALLOY_JAVASCRIPT_DIALOG_MANAGER_DELEGATE_H_
#include <memory>
#include "chrome/browser/ui/javascript_dialogs/javascript_tab_modal_dialog_manager_delegate_desktop.h"
// Creates a JavaScriptTabModalDialogManagerDelegateDesktop for the Chrome
// environment.
std::unique_ptr<JavaScriptTabModalDialogManagerDelegateDesktop>
CreateAlloyJavaScriptTabModalDialogManagerDelegateDesktop(
content::WebContents* web_contents);
#endif // CEF_LIBCEF_BROWSER_ALLOY_DIALOGS_ALLOY_JAVASCRIPT_DIALOG_MANAGER_DELEGATE_H_

View File

@@ -1,96 +0,0 @@
// Copyright (c) 2019 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.
#include "libcef/browser/alloy/dialogs/alloy_web_contents_dialog_helper.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "base/notreached.h"
#include "chrome/browser/platform_util.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "ui/views/widget/widget.h"
AlloyWebContentsDialogHelper::AlloyWebContentsDialogHelper(
content::WebContents* web_contents,
CefBrowserPlatformDelegate* browser_delegate)
: browser_delegate_(browser_delegate), weak_factory_(this) {
web_modal::WebContentsModalDialogManager::CreateForWebContents(web_contents);
web_modal::WebContentsModalDialogManager::FromWebContents(web_contents)
->SetDelegate(this);
}
base::RepeatingClosure
AlloyWebContentsDialogHelper::GetBoundsChangedCallback() {
return base::BindRepeating(&AlloyWebContentsDialogHelper::OnBoundsChanged,
weak_factory_.GetWeakPtr());
}
bool AlloyWebContentsDialogHelper::IsWebContentsVisible(
content::WebContents* web_contents) {
if (browser_delegate_->IsWindowless()) {
return !browser_delegate_->IsHidden();
} else if (auto native_view = web_contents->GetNativeView()) {
return platform_util::IsVisible(native_view);
}
NOTREACHED();
return false;
}
web_modal::WebContentsModalDialogHost*
AlloyWebContentsDialogHelper::GetWebContentsModalDialogHost() {
return this;
}
gfx::NativeView AlloyWebContentsDialogHelper::GetHostView() const {
// Windowless rendering uses GetHostWidget() instead.
if (browser_delegate_->IsWindowless()) {
return gfx::NativeView();
}
if (auto widget = browser_delegate_->GetWindowWidget()) {
return widget->GetNativeView();
}
NOTREACHED();
return gfx::NativeView();
}
gfx::AcceleratedWidget AlloyWebContentsDialogHelper::GetHostWidget() const {
#if defined(USE_AURA)
// Windowed rendering uses GetHostView() instead.
if (!browser_delegate_->IsWindowless()) {
return gfx::kNullAcceleratedWidget;
}
if (auto parent_widget = browser_delegate_->GetHostWindowHandle()) {
return parent_widget;
}
#endif // defined(USE_AURA)
NOTREACHED();
return gfx::kNullAcceleratedWidget;
}
gfx::Point AlloyWebContentsDialogHelper::GetDialogPosition(
const gfx::Size& size) {
return browser_delegate_->GetDialogPosition(size);
}
gfx::Size AlloyWebContentsDialogHelper::GetMaximumDialogSize() {
return browser_delegate_->GetMaximumDialogSize();
}
void AlloyWebContentsDialogHelper::AddObserver(
web_modal::ModalDialogHostObserver* observer) {
if (observer && !observer_list_.HasObserver(observer))
observer_list_.AddObserver(observer);
}
void AlloyWebContentsDialogHelper::RemoveObserver(
web_modal::ModalDialogHostObserver* observer) {
observer_list_.RemoveObserver(observer);
}
void AlloyWebContentsDialogHelper::OnBoundsChanged() {
for (auto& observer : observer_list_)
observer.OnPositionRequiresUpdate();
}

View File

@@ -42,16 +42,6 @@ void CefBrowserFrame::SendMessage(const std::string& name,
}
}
void CefBrowserFrame::SendSharedMemoryRegion(
const std::string& name,
base::ReadOnlySharedMemoryRegion region) {
// Always send to the newly created RFH, which may be speculative when
// navigating cross-origin.
if (auto host = GetFrameHost(/*prefer_speculative=*/true)) {
host->SendSharedMemoryRegion(name, std::move(region));
}
}
void CefBrowserFrame::FrameAttached(
mojo::PendingRemote<cef::mojom::RenderFrame> render_frame,
bool reattached) {

View File

@@ -36,8 +36,6 @@ class CefBrowserFrame
private:
// cef::mojom::BrowserFrame methods:
void SendMessage(const std::string& name, base::Value arguments) override;
void SendSharedMemoryRegion(const std::string& name,
base::ReadOnlySharedMemoryRegion region) override;
void FrameAttached(mojo::PendingRemote<cef::mojom::RenderFrame> render_frame,
bool reattached) override;
void DidFinishFrameLoad(const GURL& validated_url,

View File

@@ -16,7 +16,6 @@
#include "libcef/common/net/url_util.h"
#include "base/logging.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/spellchecker/spellcheck_factory.h"
#include "chrome/browser/spellchecker/spellcheck_service.h"
#include "components/favicon/core/favicon_url.h"
@@ -139,39 +138,6 @@ CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForGlobalId(
}
}
// static
CefRefPtr<CefBrowserHostBase>
CefBrowserHostBase::GetBrowserForTopLevelNativeWindow(
gfx::NativeWindow owning_window) {
DCHECK(owning_window);
CEF_REQUIRE_UIT();
for (const auto& browser_info :
CefBrowserInfoManager::GetInstance()->GetBrowserInfoList()) {
if (auto browser = browser_info->browser()) {
if (browser->GetTopLevelNativeWindow() == owning_window)
return browser;
}
}
return nullptr;
}
// static
CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetLikelyFocusedBrowser() {
CEF_REQUIRE_UIT();
for (const auto& browser_info :
CefBrowserInfoManager::GetInstance()->GetBrowserInfoList()) {
if (auto browser = browser_info->browser()) {
if (browser->IsFocused())
return browser;
}
}
return nullptr;
}
CefBrowserHostBase::CefBrowserHostBase(
const CefBrowserSettings& settings,
CefRefPtr<CefClient> client,
@@ -204,10 +170,9 @@ void CefBrowserHostBase::InitializeBrowser() {
void CefBrowserHostBase::DestroyBrowser() {
CEF_REQUIRE_UIT();
devtools_manager_.reset();
media_stream_registrar_.reset();
devtools_manager_.reset(nullptr);
platform_delegate_.reset();
platform_delegate_.reset(nullptr);
contents_delegate_->RemoveObserver(this);
contents_delegate_->ObserveWebContents(nullptr);
@@ -233,12 +198,13 @@ bool CefBrowserHostBase::HasView() {
}
void CefBrowserHostBase::SetFocus(bool focus) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT,
base::BindOnce(&CefBrowserHostBase::SetFocus, this, focus));
return;
}
// Always execute asynchronously to work around issue #3040.
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostBase::SetFocusInternal,
this, focus));
}
void CefBrowserHostBase::SetFocusInternal(bool focus) {
CEF_REQUIRE_UIT();
if (focus)
OnSetFocus(FOCUS_SOURCE_SYSTEM);
else if (platform_delegate_)
@@ -972,14 +938,6 @@ content::BrowserContext* CefBrowserHostBase::GetBrowserContext() const {
return nullptr;
}
CefMediaStreamRegistrar* CefBrowserHostBase::GetMediaStreamRegistrar() {
CEF_REQUIRE_UIT();
if (!media_stream_registrar_) {
media_stream_registrar_ = std::make_unique<CefMediaStreamRegistrar>(this);
}
return media_stream_registrar_.get();
}
views::Widget* CefBrowserHostBase::GetWindowWidget() const {
CEF_REQUIRE_UIT();
if (!platform_delegate_)
@@ -1017,18 +975,6 @@ bool CefBrowserHostBase::IsFocused() const {
return false;
}
bool CefBrowserHostBase::IsVisible() const {
CEF_REQUIRE_UIT();
// Windowless browsers always return nullptr from GetNativeView().
if (!IsWindowless()) {
auto web_contents = GetWebContents();
if (web_contents) {
return platform_util::IsVisible(web_contents->GetNativeView());
}
}
return false;
}
bool CefBrowserHostBase::EnsureDevToolsManager() {
CEF_REQUIRE_UIT();
if (!contents_delegate_->web_contents())

View File

@@ -15,7 +15,6 @@
#include "libcef/browser/devtools/devtools_manager.h"
#include "libcef/browser/file_dialog_manager.h"
#include "libcef/browser/frame_host_impl.h"
#include "libcef/browser/media_stream_registrar.h"
#include "libcef/browser/request_context_impl.h"
#include "base/observer_list.h"
@@ -129,14 +128,6 @@ class CefBrowserHostBase : public CefBrowserHost,
// Returns the browser associated with the specified global ID.
static CefRefPtr<CefBrowserHostBase> GetBrowserForGlobalId(
const content::GlobalRenderFrameHostId& global_id);
// Returns the browser associated with the specified top-level window.
static CefRefPtr<CefBrowserHostBase> GetBrowserForTopLevelNativeWindow(
gfx::NativeWindow owning_window);
// Returns the browser most likely to be focused. This may be somewhat iffy
// with windowless browsers as there is no guarantee that the client has only
// one browser focused at a time.
static CefRefPtr<CefBrowserHostBase> GetLikelyFocusedBrowser();
CefBrowserHostBase(
const CefBrowserSettings& settings,
@@ -155,10 +146,6 @@ class CefBrowserHostBase : public CefBrowserHost,
// destroyed.
virtual void WindowDestroyed() = 0;
// Returns true if the browser is in the process of being destroyed. Called on
// the UI thread only.
virtual bool WillBeDestroyed() const = 0;
// Called on the UI thread after the associated WebContents is destroyed.
// Also called from CefBrowserInfoManager::DestroyAllBrowsers if the browser
// was not properly shut down.
@@ -302,7 +289,6 @@ class CefBrowserHostBase : public CefBrowserHost,
CefBrowserContentsDelegate* contents_delegate() const {
return contents_delegate_.get();
}
CefMediaStreamRegistrar* GetMediaStreamRegistrar();
// Returns the Widget owner for the browser window. Only used with windowed
// browsers.
@@ -326,9 +312,6 @@ class CefBrowserHostBase : public CefBrowserHost,
// on the client to properly configure focus state.
bool IsFocused() const;
// Returns true if this browser is currently visible.
virtual bool IsVisible() const;
protected:
bool EnsureDevToolsManager();
void InitializeDevToolsRegistrationOnUIThread(
@@ -337,6 +320,8 @@ class CefBrowserHostBase : public CefBrowserHost,
// Called from LoadMainFrameURL to perform the actual navigation.
virtual bool Navigate(const content::OpenURLParams& params);
void SetFocusInternal(bool focus);
// Create the CefFileDialogManager if it doesn't already exist.
bool EnsureFileDialogManager();
@@ -371,8 +356,6 @@ class CefBrowserHostBase : public CefBrowserHost,
// Used for creating and managing DevTools instances.
std::unique_ptr<CefDevToolsManager> devtools_manager_;
std::unique_ptr<CefMediaStreamRegistrar> media_stream_registrar_;
private:
IMPLEMENT_REFCOUNTING(CefBrowserHostBase);
};

View File

@@ -154,6 +154,7 @@ bool CefBrowserInfoManager::CanCreateWindow(
CefPopupFeatures cef_features;
TranslatePopupFeatures(features, cef_features);
#if (BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC))
// Default to the size from the popup features.
if (cef_features.xSet)
window_info.bounds.x = cef_features.x;
@@ -163,6 +164,7 @@ bool CefBrowserInfoManager::CanCreateWindow(
window_info.bounds.width = cef_features.width;
if (cef_features.heightSet)
window_info.bounds.height = cef_features.height;
#endif
allow = !handler->OnBeforePopup(
browser.get(), opener_frame, pending_popup->target_url.spec(),

View File

@@ -131,12 +131,6 @@ CefRefPtr<CefBrowserView> CefBrowserPlatformDelegate::GetBrowserView() const {
return nullptr;
}
web_modal::WebContentsModalDialogHost*
CefBrowserPlatformDelegate::GetWebContentsModalDialogHost() const {
NOTREACHED();
return nullptr;
}
void CefBrowserPlatformDelegate::PopupWebContentsCreated(
const CefBrowserSettings& settings,
CefRefPtr<CefClient> client,
@@ -232,6 +226,7 @@ CefEventHandle CefBrowserPlatformDelegate::GetEventHandle(
std::unique_ptr<CefJavaScriptDialogRunner>
CefBrowserPlatformDelegate::CreateJavaScriptDialogRunner() {
NOTIMPLEMENTED();
return nullptr;
}
@@ -258,11 +253,6 @@ void CefBrowserPlatformDelegate::WasHidden(bool hidden) {
NOTREACHED();
}
bool CefBrowserPlatformDelegate::IsHidden() const {
NOTREACHED();
return false;
}
void CefBrowserPlatformDelegate::NotifyScreenInfoChanged() {
NOTREACHED();
}
@@ -361,18 +351,13 @@ void CefBrowserPlatformDelegate::AccessibilityLocationChangesReceived(
gfx::Point CefBrowserPlatformDelegate::GetDialogPosition(
const gfx::Size& size) {
const gfx::Size& max_size = GetMaximumDialogSize();
return gfx::Point((max_size.width() - size.width()) / 2,
(max_size.height() - size.height()) / 2);
NOTREACHED();
return gfx::Point();
}
gfx::Size CefBrowserPlatformDelegate::GetMaximumDialogSize() {
if (!web_contents_)
return gfx::Size();
// The dialog should try to fit within the overlay for the web contents.
// Note that, for things like print preview, this is just a suggested maximum.
return web_contents_->GetContainerBounds().size();
NOTREACHED();
return gfx::Size();
}
void CefBrowserPlatformDelegate::SetAutoResizeEnabled(bool enabled,

View File

@@ -61,10 +61,6 @@ namespace views {
class Widget;
}
namespace web_modal {
class WebContentsModalDialogHost;
}
struct CefBrowserCreateParams;
class CefBrowserHostBase;
class CefJavaScriptDialogRunner;
@@ -182,10 +178,6 @@ class CefBrowserPlatformDelegate {
// based browsers.
virtual CefRefPtr<CefBrowserView> GetBrowserView() const;
// Returns the WebContentsModalDialogHost associated with this browser.
virtual web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
const;
// Called after the WebContents have been created for a new popup browser
// parented to this browser but before the AlloyBrowserHostImpl is created for
// the popup. |is_devtools| will be true if the popup will host DevTools. This
@@ -297,10 +289,6 @@ class CefBrowserPlatformDelegate {
// Notify the browser that it was hidden. Only used with windowless rendering.
virtual void WasHidden(bool hidden);
// Returns true if the browser is currently hidden. Only used with windowless
// rendering.
virtual bool IsHidden() const;
// Notify the browser that screen information has changed. Only used with
// windowless rendering.
virtual void NotifyScreenInfoChanged();

View File

@@ -55,15 +55,6 @@ class BrowserDelegate : public content::WebContentsDelegate {
WindowOpenDisposition disposition) {
return false;
}
// Same as RequestMediaAccessPermission but returning |callback| if the
// request is unhandled.
[[nodiscard]] virtual content::MediaResponseCallback
RequestMediaAccessPermissionEx(content::WebContents* web_contents,
const content::MediaStreamRequest& request,
content::MediaResponseCallback callback) {
return callback;
}
};
} // namespace cef

View File

@@ -8,7 +8,6 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/gfx/geometry/point.h"
@@ -48,16 +47,6 @@ CefWindowHandle CefBrowserPlatformDelegateChrome::GetHostWindowHandle() const {
return view_util::GetWindowHandle(GetNativeWindow());
}
web_modal::WebContentsModalDialogHost*
CefBrowserPlatformDelegateChrome::GetWebContentsModalDialogHost() const {
if (chrome_browser_) {
ChromeWebModalDialogManagerDelegate* manager = chrome_browser_;
return manager->GetWebContentsModalDialogHost();
}
NOTREACHED();
return nullptr;
}
SkColor CefBrowserPlatformDelegateChrome::GetBackgroundColor() const {
return native_delegate_->GetBackgroundColor();
}
@@ -135,6 +124,5 @@ void CefBrowserPlatformDelegateChrome::set_chrome_browser(Browser* browser) {
gfx::NativeWindow CefBrowserPlatformDelegateChrome::GetNativeWindow() const {
if (chrome_browser_ && chrome_browser_->window())
return chrome_browser_->window()->GetNativeWindow();
NOTREACHED();
return gfx::NativeWindow();
}

View File

@@ -25,8 +25,6 @@ class CefBrowserPlatformDelegateChrome
void BrowserCreated(CefBrowserHostBase* browser) override;
void BrowserDestroyed(CefBrowserHostBase* browser) override;
CefWindowHandle GetHostWindowHandle() const override;
web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
const override;
SkColor GetBackgroundColor() const override;
void SendKeyEvent(const CefKeyEvent& event) override;
void SendMouseClickEvent(const CefMouseEvent& event,

View File

@@ -11,7 +11,6 @@
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/chrome/chrome_browser_host_impl.h"
#include "libcef/browser/media_access_query.h"
#include "libcef/browser/request_context_impl.h"
#include "libcef/common/app_manager.h"
#include "libcef/common/frame_util.h"
@@ -103,19 +102,6 @@ bool ChromeBrowserDelegate::HandleCommand(int command_id,
return false;
}
content::MediaResponseCallback
ChromeBrowserDelegate::RequestMediaAccessPermissionEx(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
content::MediaResponseCallback callback) {
if (auto browser = ChromeBrowserHostImpl::GetBrowserForBrowser(browser_)) {
return media_access_query::RequestMediaAccessPermission(
browser.get(), request, std::move(callback),
/*default_disallow=*/false);
}
return callback;
}
void ChromeBrowserDelegate::WebContentsCreated(
content::WebContents* source_contents,
int opener_render_process_id,

View File

@@ -54,10 +54,6 @@ class ChromeBrowserDelegate : public cef::BrowserDelegate {
bool ShowStatusBubble(bool show_by_default) override;
bool HandleCommand(int command_id,
WindowOpenDisposition disposition) override;
[[nodiscard]] content::MediaResponseCallback RequestMediaAccessPermissionEx(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
content::MediaResponseCallback callback) override;
// WebContentsDelegate methods:
void WebContentsCreated(content::WebContents* source_contents,

View File

@@ -538,12 +538,6 @@ void ChromeBrowserHostImpl::WindowDestroyed() {
platform_delegate_->CloseHostWindow();
}
bool ChromeBrowserHostImpl::WillBeDestroyed() const {
CEF_REQUIRE_UIT();
// TODO(chrome): Modify this to support DoClose(), see issue #3294.
return !!browser_;
}
void ChromeBrowserHostImpl::DestroyBrowser() {
CEF_REQUIRE_UIT();
browser_ = nullptr;

View File

@@ -150,7 +150,6 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
// CefBrowserHostBase methods:
void WindowDestroyed() override;
bool WillBeDestroyed() const override;
void DestroyBrowser() override;
void DoCloseBrowser(bool force_close);

View File

@@ -8,7 +8,6 @@
#include "libcef/browser/context.h"
#include "libcef/browser/file_dialog_runner.h"
#include "libcef/browser/net/chrome_scheme_handler.h"
#include "libcef/browser/permission_prompt.h"
#include "base/task/thread_pool.h"
@@ -43,5 +42,4 @@ void ChromeBrowserMainExtraPartsCef::PreMainMessageLoopRun() {
scheme::RegisterWebUIControllerFactory();
context_menu::RegisterMenuCreatedCallback();
file_dialog_runner::RegisterFactory();
permission_prompt::RegisterCreateCallback();
}

View File

@@ -103,6 +103,11 @@ CefEventHandle CefBrowserPlatformDelegateBackground::GetEventHandle(
return native_delegate_->GetEventHandle(event);
}
std::unique_ptr<CefJavaScriptDialogRunner>
CefBrowserPlatformDelegateBackground::CreateJavaScriptDialogRunner() {
return native_delegate_->CreateJavaScriptDialogRunner();
}
std::unique_ptr<CefMenuRunner>
CefBrowserPlatformDelegateBackground::CreateMenuRunner() {
// No default menu implementation for background browsers.

View File

@@ -41,6 +41,8 @@ class CefBrowserPlatformDelegateBackground
const content::NativeWebKeyboardEvent& event) override;
CefEventHandle GetEventHandle(
const content::NativeWebKeyboardEvent& event) const override;
std::unique_ptr<CefJavaScriptDialogRunner> CreateJavaScriptDialogRunner()
override;
std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
// CefBrowserPlatformDelegateNative::WindowlessHandler methods:

View File

@@ -69,7 +69,8 @@ bool CefMimeHandlerViewGuestDelegate::HandleContextMenu(
AlloyBrowserHostImpl::GetBrowserForContents(owner_web_contents_);
DCHECK(owner_browser);
return owner_browser->ShowContextMenu(params);
return owner_browser->HandleContextMenu(
content::WebContents::FromRenderFrameHost(&render_frame_host), params);
}
} // namespace extensions

View File

@@ -6,6 +6,7 @@
#include "libcef/browser/file_dialog_runner.h"
#include "libcef/browser/browser_host_base.h"
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "base/memory/singleton.h"
@@ -49,6 +50,32 @@ class CefSelectFileDialogFactory final : public ui::SelectFileDialogFactory {
CefSelectFileDialogFactory() { ui::SelectFileDialog::SetFactory(this); }
};
CefRefPtr<CefBrowserHostBase> GetBrowserForTopLevelNativeWindow(
gfx::NativeWindow owning_window) {
DCHECK(owning_window);
for (const auto& browser_info :
CefBrowserInfoManager::GetInstance()->GetBrowserInfoList()) {
if (auto browser = browser_info->browser()) {
if (browser->GetTopLevelNativeWindow() == owning_window)
return browser;
}
}
return nullptr;
}
CefRefPtr<CefBrowserHostBase> GetLikelyFocusedBrowser() {
for (const auto& browser_info :
CefBrowserInfoManager::GetInstance()->GetBrowserInfoList()) {
if (auto browser = browser_info->browser()) {
if (browser->IsFocused())
return browser;
}
}
return nullptr;
}
// Delegates the running of the dialog to CefFileDialogManager.
class CefSelectFileDialog final : public ui::SelectFileDialog {
public:
@@ -91,8 +118,7 @@ class CefSelectFileDialog final : public ui::SelectFileDialog {
// This should be reliable with windowed browsers. However, |owning_window|
// will always be nullptr with windowless browsers.
if (!browser_ && owning_window) {
browser_ =
CefBrowserHostBase::GetBrowserForTopLevelNativeWindow(owning_window);
browser_ = GetBrowserForTopLevelNativeWindow(owning_window);
if (!browser_) {
LOG(WARNING) << "No browser associated with top-level native window";
}
@@ -102,7 +128,7 @@ class CefSelectFileDialog final : public ui::SelectFileDialog {
// windowless browsers as there is no guarantee that the client has only
// one browser focused at a time.
if (!browser_) {
browser_ = CefBrowserHostBase::GetLikelyFocusedBrowser();
browser_ = GetLikelyFocusedBrowser();
if (!browser_) {
LOG(WARNING) << "No likely focused browser";
}

View File

@@ -13,7 +13,6 @@
#include "libcef/common/frame_util.h"
#include "libcef/common/net/url_util.h"
#include "libcef/common/process_message_impl.h"
#include "libcef/common/process_message_smr_impl.h"
#include "libcef/common/request_impl.h"
#include "libcef/common/string_util.h"
#include "libcef/common/task_runner_impl.h"
@@ -239,31 +238,18 @@ void CefFrameHostImpl::SendProcessMessage(
if (!message || !message->IsValid())
return;
if (message->GetArgumentList() != nullptr) {
// Invalidate the message object immediately by taking the argument list.
auto argument_list =
static_cast<CefProcessMessageImpl*>(message.get())->TakeArgumentList();
// Invalidate the message object immediately by taking the argument list.
auto argument_list =
static_cast<CefProcessMessageImpl*>(message.get())->TakeArgumentList();
SendToRenderFrame(
__FUNCTION__,
base::BindOnce(
[](const CefString& name, base::ListValue argument_list,
const RenderFrameType& render_frame) {
render_frame->SendMessage(name, std::move(argument_list));
},
message->GetName(), std::move(argument_list)));
} else {
auto region =
static_cast<CefProcessMessageSMRImpl*>(message.get())->TakeRegion();
SendToRenderFrame(
__FUNCTION__,
base::BindOnce(
[](const CefString& name, base::ReadOnlySharedMemoryRegion region,
const RenderFrameType& render_frame) {
render_frame->SendSharedMemoryRegion(name, std::move(region));
},
message->GetName(), std::move(region)));
}
SendToRenderFrame(__FUNCTION__,
base::BindOnce(
[](const CefString& name, base::ListValue argument_list,
const RenderFrameType& render_frame) {
render_frame->SendMessage(name,
std::move(argument_list));
},
message->GetName(), std::move(argument_list)));
}
void CefFrameHostImpl::SetFocused(bool focused) {
@@ -578,19 +564,6 @@ void CefFrameHostImpl::SendMessage(const std::string& name,
}
}
void CefFrameHostImpl::SendSharedMemoryRegion(
const std::string& name,
base::ReadOnlySharedMemoryRegion region) {
if (auto browser = GetBrowserHostBase()) {
if (auto client = browser->GetClient()) {
CefRefPtr<CefProcessMessage> message(
new CefProcessMessageSMRImpl(name, std::move(region)));
browser->GetClient()->OnProcessMessageReceived(browser.get(), this,
PID_RENDERER, message);
}
}
}
void CefFrameHostImpl::FrameAttached(
mojo::PendingRemote<cef::mojom::RenderFrame> render_frame_remote,
bool reattached) {

View File

@@ -126,8 +126,6 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
// cef::mojom::BrowserFrame methods forwarded from CefBrowserFrame.
void SendMessage(const std::string& name, base::Value arguments) override;
void SendSharedMemoryRegion(const std::string& name,
base::ReadOnlySharedMemoryRegion region) override;
void FrameAttached(mojo::PendingRemote<cef::mojom::RenderFrame> render_frame,
bool reattached) override;
void DidFinishFrameLoad(const GURL& validated_url,

View File

@@ -7,13 +7,13 @@
#include <utility>
#include "libcef/browser/browser_host_base.h"
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
#include "libcef/browser/thread_util.h"
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/logging.h"
#include "components/javascript_dialogs/tab_modal_dialog_manager.h"
#include "base/strings/utf_string_conversions.h"
#include "components/url_formatter/elide_url.h"
namespace {
@@ -60,26 +60,21 @@ class CefJSDialogCallbackImpl : public CefJSDialogCallback {
IMPLEMENT_REFCOUNTING(CefJSDialogCallbackImpl);
};
javascript_dialogs::TabModalDialogManager* GetTabModalDialogManager(
content::WebContents* web_contents) {
return javascript_dialogs::TabModalDialogManager::FromWebContents(
web_contents);
}
} // namespace
CefJavaScriptDialogManager::CefJavaScriptDialogManager(
CefBrowserHostBase* browser)
: browser_(browser), weak_ptr_factory_(this) {}
AlloyBrowserHostImpl* browser,
std::unique_ptr<CefJavaScriptDialogRunner> runner)
: browser_(browser),
runner_(std::move(runner)),
dialog_running_(false),
weak_ptr_factory_(this) {}
CefJavaScriptDialogManager::~CefJavaScriptDialogManager() {}
void CefJavaScriptDialogManager::Destroy() {
if (handler_) {
CancelDialogs(nullptr, false);
}
if (runner_) {
runner_.reset();
if (runner_.get()) {
runner_.reset(nullptr);
}
}
@@ -91,19 +86,13 @@ void CefJavaScriptDialogManager::RunJavaScriptDialog(
const std::u16string& default_prompt_text,
DialogClosedCallback callback,
bool* did_suppress_message) {
*did_suppress_message = false;
const GURL& origin_url = render_frame_host->GetLastCommittedURL();
// Always call DialogClosed().
callback =
base::BindOnce(&CefJavaScriptDialogManager::DialogClosed,
weak_ptr_factory_.GetWeakPtr(), std::move(callback));
if (auto client = browser_->GetClient()) {
if (auto handler = client->GetJSDialogHandler()) {
// If the dialog is handled this will be cleared in DialogClosed().
handler_ = handler;
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefJSDialogHandler> handler = client->GetJSDialogHandler();
if (handler.get()) {
*did_suppress_message = false;
CefRefPtr<CefJSDialogCallbackImpl> callbackPtr(
new CefJSDialogCallbackImpl(std::move(callback)));
@@ -121,40 +110,32 @@ void CefJavaScriptDialogManager::RunJavaScriptDialog(
// |callback| may be null if the user executed it despite returning false.
callback = callbackPtr->Disconnect();
if (callback.is_null()) {
LOG(WARNING)
<< "OnJSDialog should return true when executing the callback";
if (callback.is_null() || *did_suppress_message)
return;
}
if (*did_suppress_message) {
// Call OnResetDialogState but don't execute |callback|.
CancelDialogs(web_contents, /*reset_state=*/true);
return;
}
handler_ = nullptr;
}
}
DCHECK(!handler_);
*did_suppress_message = false;
if (InitializeRunner()) {
runner_->Run(browser_, message_type, origin_url, message_text,
default_prompt_text, std::move(callback));
if (!runner_.get() || dialog_running_) {
// Suppress the dialog if there is no platform runner or if the dialog is
// currently running.
if (!runner_.get())
LOG(WARNING) << "No javascript dialog runner available for this platform";
*did_suppress_message = true;
return;
}
if (!CanUseChromeDialogs()) {
// Dismiss the dialog.
std::move(callback).Run(false, std::u16string());
return;
}
dialog_running_ = true;
auto manager = GetTabModalDialogManager(web_contents);
manager->RunJavaScriptDialog(web_contents, render_frame_host, message_type,
message_text, default_prompt_text,
std::move(callback), did_suppress_message);
const std::u16string& display_url =
url_formatter::FormatUrlForSecurityDisplay(origin_url);
DCHECK(!callback.is_null());
runner_->Run(
browser_, message_type, display_url, message_text, default_prompt_text,
base::BindOnce(&CefJavaScriptDialogManager::DialogClosed,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
void CefJavaScriptDialogManager::RunBeforeUnloadDialog(
@@ -162,7 +143,8 @@ void CefJavaScriptDialogManager::RunBeforeUnloadDialog(
content::RenderFrameHost* render_frame_host,
bool is_reload,
DialogClosedCallback callback) {
if (browser_->WillBeDestroyed()) {
if (browser_->destruction_state() >=
AlloyBrowserHostImpl::DESTRUCTION_STATE_ACCEPTED) {
// Currently destroying the browser. Accept the unload without showing
// the prompt.
std::move(callback).Run(true, std::u16string());
@@ -171,138 +153,80 @@ void CefJavaScriptDialogManager::RunBeforeUnloadDialog(
const std::u16string& message_text = u"Is it OK to leave/reload this page?";
// Always call DialogClosed().
callback =
base::BindOnce(&CefJavaScriptDialogManager::DialogClosed,
weak_ptr_factory_.GetWeakPtr(), std::move(callback));
if (auto client = browser_->GetClient()) {
if (auto handler = client->GetJSDialogHandler()) {
// If the dialog is handled this will be cleared in DialogClosed().
handler_ = handler;
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefJSDialogHandler> handler = client->GetJSDialogHandler();
if (handler.get()) {
CefRefPtr<CefJSDialogCallbackImpl> callbackPtr(
new CefJSDialogCallbackImpl(std::move(callback)));
// Execute the user callback.
bool handled = handler->OnBeforeUnloadDialog(
browser_, message_text, is_reload, callbackPtr.get());
if (handled) {
if (handled)
return;
}
// |callback| may be null if the user executed it despite returning false.
callback = callbackPtr->Disconnect();
if (callback.is_null()) {
LOG(WARNING) << "OnBeforeUnloadDialog should return true when "
"executing the callback";
if (callback.is_null())
return;
}
handler_ = nullptr;
}
}
DCHECK(!handler_);
if (InitializeRunner()) {
runner_->Run(browser_, content::JAVASCRIPT_DIALOG_TYPE_CONFIRM,
/*origin_url=*/GURL(), message_text,
/*default_prompt_text=*/std::u16string(), std::move(callback));
return;
}
if (!CanUseChromeDialogs()) {
// Accept the unload without showing the prompt.
if (!runner_.get() || dialog_running_) {
if (!runner_.get())
LOG(WARNING) << "No javascript dialog runner available for this platform";
// Suppress the dialog if there is no platform runner or if the dialog is
// currently running.
std::move(callback).Run(true, std::u16string());
return;
}
auto manager = GetTabModalDialogManager(web_contents);
manager->RunBeforeUnloadDialog(web_contents, render_frame_host, is_reload,
std::move(callback));
}
dialog_running_ = true;
bool CefJavaScriptDialogManager::HandleJavaScriptDialog(
content::WebContents* web_contents,
bool accept,
const std::u16string* prompt_override) {
if (handler_) {
DialogClosed(base::NullCallback(), accept,
prompt_override ? *prompt_override : std::u16string());
return true;
}
if (runner_) {
runner_->Handle(accept, prompt_override);
return true;
}
if (!CanUseChromeDialogs())
return true;
auto manager = GetTabModalDialogManager(web_contents);
return manager->HandleJavaScriptDialog(web_contents, accept, prompt_override);
DCHECK(!callback.is_null());
runner_->Run(
browser_, content::JAVASCRIPT_DIALOG_TYPE_CONFIRM,
std::u16string(), // display_url
message_text,
std::u16string(), // default_prompt_text
base::BindOnce(&CefJavaScriptDialogManager::DialogClosed,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
void CefJavaScriptDialogManager::CancelDialogs(
content::WebContents* web_contents,
bool reset_state) {
if (handler_) {
if (reset_state) {
handler_->OnResetDialogState(browser_);
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefJSDialogHandler> handler = client->GetJSDialogHandler();
if (handler.get()) {
// Execute the user callback.
handler->OnResetDialogState(browser_);
}
handler_ = nullptr;
return;
}
if (runner_) {
if (runner_.get() && dialog_running_) {
runner_->Cancel();
return;
dialog_running_ = false;
}
// Null when called from DialogClosed() or Destroy().
if (!web_contents)
return;
if (!CanUseChromeDialogs())
return;
auto manager = GetTabModalDialogManager(web_contents);
manager->CancelDialogs(web_contents, reset_state);
}
void CefJavaScriptDialogManager::DialogClosed(
DialogClosedCallback callback,
bool success,
const std::u16string& user_input) {
if (handler_) {
handler_->OnDialogClosed(browser_);
// Call OnResetDialogState.
CancelDialogs(/*web_contents=*/nullptr, /*reset_state=*/true);
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefJSDialogHandler> handler = client->GetJSDialogHandler();
if (handler.get())
handler->OnDialogClosed(browser_);
}
// Null when called from HandleJavaScriptDialog().
if (!callback.is_null()) {
std::move(callback).Run(success, user_input);
}
DCHECK(runner_.get());
DCHECK(dialog_running_);
dialog_running_ = false;
std::move(callback).Run(success, user_input);
}
bool CefJavaScriptDialogManager::InitializeRunner() {
if (!runner_initialized_) {
runner_ = browser_->platform_delegate()->CreateJavaScriptDialogRunner();
runner_initialized_ = true;
}
return !!runner_.get();
}
bool CefJavaScriptDialogManager::CanUseChromeDialogs() const {
if (browser_->IsWindowless() &&
browser_->GetWindowHandle() == kNullWindowHandle) {
LOG(ERROR) << "Default dialog implementation requires a parent window "
"handle; canceling the JS dialog";
return false;
}
return true;
}

View File

@@ -7,21 +7,20 @@
#define CEF_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_MANAGER_H_
#pragma once
#include <memory>
#include <string>
#include "include/cef_jsdialog_handler.h"
#include "libcef/browser/javascript_dialog_runner.h"
#include "base/memory/weak_ptr.h"
#include "content/public/browser/javascript_dialog_manager.h"
class CefBrowserHostBase;
class AlloyBrowserHostImpl;
class CefJavaScriptDialogManager : public content::JavaScriptDialogManager {
public:
// |runner| may be NULL if the platform doesn't implement dialogs.
explicit CefJavaScriptDialogManager(CefBrowserHostBase* browser);
CefJavaScriptDialogManager(AlloyBrowserHostImpl* browser,
std::unique_ptr<CefJavaScriptDialogRunner> runner);
CefJavaScriptDialogManager(const CefJavaScriptDialogManager&) = delete;
CefJavaScriptDialogManager& operator=(const CefJavaScriptDialogManager&) =
@@ -44,9 +43,6 @@ class CefJavaScriptDialogManager : public content::JavaScriptDialogManager {
content::RenderFrameHost* render_frame_host,
bool is_reload,
DialogClosedCallback callback) override;
bool HandleJavaScriptDialog(content::WebContents* web_contents,
bool accept,
const std::u16string* prompt_override) override;
void CancelDialogs(content::WebContents* web_contents,
bool reset_state) override;
@@ -56,17 +52,13 @@ class CefJavaScriptDialogManager : public content::JavaScriptDialogManager {
bool success,
const std::u16string& user_input);
bool InitializeRunner();
bool CanUseChromeDialogs() const;
// CefBrowserHostBase pointer is guaranteed to outlive this object.
CefBrowserHostBase* const browser_;
CefRefPtr<CefJSDialogHandler> handler_;
// AlloyBrowserHostImpl pointer is guaranteed to outlive this object.
AlloyBrowserHostImpl* browser_;
std::unique_ptr<CefJavaScriptDialogRunner> runner_;
bool runner_initialized_ = false;
// True if a dialog is currently running.
bool dialog_running_;
// Must be the last member.
base::WeakPtrFactory<CefJavaScriptDialogManager> weak_ptr_factory_;

View File

@@ -7,10 +7,10 @@
#define CEF_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_RUNNER_H_
#pragma once
#include "content/public/browser/javascript_dialog_manager.h"
#include "base/callback.h"
#include "content/public/common/javascript_dialog_type.h"
class CefBrowserHostBase;
class AlloyBrowserHostImpl;
class CefJavaScriptDialogRunner {
public:
@@ -19,19 +19,17 @@ class CefJavaScriptDialogRunner {
delete;
using DialogClosedCallback =
content::JavaScriptDialogManager::DialogClosedCallback;
base::OnceCallback<void(bool /* success */,
const std::u16string& /* user_input */)>;
// Run the dialog. Execute |callback| on completion.
virtual void Run(CefBrowserHostBase* browser,
virtual void Run(AlloyBrowserHostImpl* browser,
content::JavaScriptDialogType message_type,
const GURL& origin_url,
const std::u16string& display_url,
const std::u16string& message_text,
const std::u16string& default_prompt_text,
DialogClosedCallback callback) = 0;
// Dismiss the dialog with the specified results.
virtual void Handle(bool accept, const std::u16string* prompt_override) = 0;
// Cancel a dialog mid-flight.
virtual void Cancel() = 0;

View File

@@ -1,356 +0,0 @@
// Copyright 2022 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.
#include "libcef/browser/media_access_query.h"
#include "include/cef_permission_handler.h"
#include "libcef/browser/browser_host_base.h"
#include "libcef/browser/media_capture_devices_dispatcher.h"
#include "libcef/browser/media_stream_registrar.h"
#include "libcef/common/cef_switches.h"
#include "base/callback_helpers.h"
#include "base/command_line.h"
#include "third_party/blink/public/mojom/mediastream/media_stream.mojom.h"
namespace media_access_query {
namespace {
class CefMediaAccessQuery {
public:
using CallbackType = content::MediaResponseCallback;
CefMediaAccessQuery(CefBrowserHostBase* const browser,
const content::MediaStreamRequest& request,
CallbackType&& callback)
: browser_(browser), request_(request), callback_(std::move(callback)) {}
CefMediaAccessQuery(CefMediaAccessQuery&& query)
: browser_(query.browser_),
request_(query.request_),
callback_(std::move(query.callback_)) {}
CefMediaAccessQuery& operator=(CefMediaAccessQuery&& query) {
browser_ = query.browser_;
request_ = query.request_;
callback_ = std::move(query.callback_);
return *this;
}
CefMediaAccessQuery(const CefMediaAccessQuery&) = delete;
CefMediaAccessQuery& operator=(const CefMediaAccessQuery&) = delete;
bool is_null() const { return callback_.is_null(); }
uint32_t requested_permissions() const {
int requested_permissions = CEF_MEDIA_PERMISSION_NONE;
if (device_audio_requested()) {
requested_permissions |= CEF_MEDIA_PERMISSION_DEVICE_AUDIO_CAPTURE;
}
if (device_video_requested()) {
requested_permissions |= CEF_MEDIA_PERMISSION_DEVICE_VIDEO_CAPTURE;
}
if (desktop_audio_requested()) {
requested_permissions |= CEF_MEDIA_PERMISSION_DESKTOP_AUDIO_CAPTURE;
}
if (desktop_video_requested()) {
requested_permissions |= CEF_MEDIA_PERMISSION_DESKTOP_VIDEO_CAPTURE;
}
return requested_permissions;
}
[[nodiscard]] CallbackType DisconnectCallback() {
return std::move(callback_);
}
void ExecuteCallback(uint32_t allowed_permissions) {
CEF_REQUIRE_UIT();
blink::mojom::MediaStreamRequestResult result;
blink::mojom::StreamDevicesSetPtr stream_devices_set;
if (allowed_permissions == CEF_MEDIA_PERMISSION_NONE) {
result = blink::mojom::MediaStreamRequestResult::PERMISSION_DENIED;
stream_devices_set = blink::mojom::StreamDevicesSet::New();
} else {
bool error = false;
if (allowed_permissions == requested_permissions()) {
stream_devices_set = GetRequestedMediaDevices();
} else {
stream_devices_set = GetAllowedMediaDevices(allowed_permissions, error);
}
result = error ? blink::mojom::MediaStreamRequestResult::INVALID_STATE
: blink::mojom::MediaStreamRequestResult::OK;
}
bool has_video = false;
bool has_audio = false;
if (!stream_devices_set->stream_devices.empty()) {
blink::mojom::StreamDevices& devices =
*stream_devices_set->stream_devices[0];
has_video = devices.video_device.has_value();
has_audio = devices.audio_device.has_value();
}
auto media_stream_ui =
browser_->GetMediaStreamRegistrar()->MaybeCreateMediaStreamUI(
has_video, has_audio);
std::move(callback_).Run(*stream_devices_set, result,
std::move(media_stream_ui));
}
private:
bool device_audio_requested() const {
return request_.audio_type ==
blink::mojom::MediaStreamType::DEVICE_AUDIO_CAPTURE;
}
bool device_video_requested() const {
return request_.video_type ==
blink::mojom::MediaStreamType::DEVICE_VIDEO_CAPTURE;
}
bool desktop_audio_requested() const {
return (request_.audio_type ==
blink::mojom::MediaStreamType::GUM_DESKTOP_AUDIO_CAPTURE) ||
(request_.audio_type ==
blink::mojom::MediaStreamType::DISPLAY_AUDIO_CAPTURE);
}
bool desktop_video_requested() const {
return (request_.video_type ==
blink::mojom::MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE) ||
(request_.video_type ==
blink::mojom::MediaStreamType::DISPLAY_VIDEO_CAPTURE);
}
blink::mojom::StreamDevicesSetPtr GetRequestedMediaDevices() const {
CEF_REQUIRE_UIT();
blink::MediaStreamDevices audio_devices;
blink::MediaStreamDevices video_devices;
if (device_audio_requested()) {
// Pick the desired device or fall back to the first available of the
// given type.
CefMediaCaptureDevicesDispatcher::GetInstance()->GetRequestedDevice(
request_.requested_audio_device_id, true, false, &audio_devices);
}
if (device_video_requested()) {
// Pick the desired device or fall back to the first available of the
// given type.
CefMediaCaptureDevicesDispatcher::GetInstance()->GetRequestedDevice(
request_.requested_video_device_id, false, true, &video_devices);
}
if (desktop_audio_requested()) {
audio_devices.push_back(blink::MediaStreamDevice(
request_.audio_type, "loopback", "System Audio"));
}
if (desktop_video_requested()) {
content::DesktopMediaID media_id;
if (request_.requested_video_device_id.empty()) {
media_id =
content::DesktopMediaID(content::DesktopMediaID::TYPE_SCREEN,
-1 /* webrtc::kFullDesktopScreenId */);
} else {
media_id =
content::DesktopMediaID::Parse(request_.requested_video_device_id);
}
video_devices.push_back(blink::MediaStreamDevice(
request_.video_type, media_id.ToString(), "Screen"));
}
blink::mojom::StreamDevicesSetPtr stream_devices_set =
blink::mojom::StreamDevicesSet::New();
stream_devices_set->stream_devices.emplace_back(
blink::mojom::StreamDevices::New());
blink::mojom::StreamDevices& devices =
*stream_devices_set->stream_devices[0];
// At most one audio device and one video device can be used in a stream.
if (!audio_devices.empty())
devices.audio_device = audio_devices.front();
if (!video_devices.empty())
devices.video_device = video_devices.front();
return stream_devices_set;
}
blink::mojom::StreamDevicesSetPtr GetAllowedMediaDevices(
uint32_t allowed_permissions,
bool& error) {
error = false;
const auto req_permissions = requested_permissions();
const bool device_audio_allowed =
allowed_permissions & CEF_MEDIA_PERMISSION_DEVICE_AUDIO_CAPTURE;
const bool device_video_allowed =
allowed_permissions & CEF_MEDIA_PERMISSION_DEVICE_VIDEO_CAPTURE;
const bool desktop_audio_allowed =
allowed_permissions & CEF_MEDIA_PERMISSION_DESKTOP_AUDIO_CAPTURE;
const bool desktop_video_allowed =
allowed_permissions & CEF_MEDIA_PERMISSION_DESKTOP_VIDEO_CAPTURE;
blink::mojom::StreamDevicesSetPtr stream_devices_set;
// getDisplayMedia must always request video
if (desktop_video_requested() &&
(!desktop_video_allowed && desktop_audio_allowed)) {
LOG(WARNING) << "Response to getDisplayMedia is not allowed to only "
"return Audio";
error = true;
} else if (!desktop_video_requested() &&
req_permissions != allowed_permissions) {
LOG(WARNING)
<< "Response to getUserMedia must match requested permissions ("
<< req_permissions << " vs " << allowed_permissions << ")";
error = true;
}
if (error) {
stream_devices_set = blink::mojom::StreamDevicesSet::New();
} else {
if (!device_audio_allowed && !desktop_audio_allowed) {
request_.audio_type = blink::mojom::MediaStreamType::NO_SERVICE;
}
if (!device_video_allowed && !desktop_video_allowed) {
request_.video_type = blink::mojom::MediaStreamType::NO_SERVICE;
}
stream_devices_set = GetRequestedMediaDevices();
}
return stream_devices_set;
}
CefRefPtr<CefBrowserHostBase> browser_;
content::MediaStreamRequest request_;
CallbackType callback_;
};
class CefMediaAccessCallbackImpl : public CefMediaAccessCallback {
public:
using CallbackType = CefMediaAccessQuery;
explicit CefMediaAccessCallbackImpl(CallbackType&& callback)
: callback_(std::move(callback)) {}
CefMediaAccessCallbackImpl(const CefMediaAccessCallbackImpl&) = delete;
CefMediaAccessCallbackImpl& operator=(const CefMediaAccessCallbackImpl&) =
delete;
~CefMediaAccessCallbackImpl() override {
if (!callback_.is_null()) {
// The callback is still pending. Cancel it now.
if (CEF_CURRENTLY_ON_UIT()) {
RunNow(std::move(callback_), CEF_MEDIA_PERMISSION_NONE);
} else {
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(&CefMediaAccessCallbackImpl::RunNow,
std::move(callback_), CEF_MEDIA_PERMISSION_NONE));
}
}
}
void Continue(uint32_t allowed_permissions) override {
if (CEF_CURRENTLY_ON_UIT()) {
if (!callback_.is_null()) {
RunNow(std::move(callback_), allowed_permissions);
}
} else {
CEF_POST_TASK(CEF_UIT,
base::BindOnce(&CefMediaAccessCallbackImpl::Continue, this,
allowed_permissions));
}
}
void Cancel() override { Continue(CEF_MEDIA_PERMISSION_NONE); }
[[nodiscard]] CallbackType Disconnect() { return std::move(callback_); }
bool IsDisconnected() const { return callback_.is_null(); }
private:
static void RunNow(CallbackType callback, uint32_t allowed_permissions) {
callback.ExecuteCallback(allowed_permissions);
}
CallbackType callback_;
IMPLEMENT_REFCOUNTING(CefMediaAccessCallbackImpl);
};
bool CheckCommandLinePermission() {
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
return command_line->HasSwitch(switches::kEnableMediaStream);
}
} // namespace
bool CheckMediaAccessPermission(CefBrowserHostBase* browser,
content::RenderFrameHost* render_frame_host,
const GURL& security_origin,
blink::mojom::MediaStreamType type) {
// Always allowed here. RequestMediaAccessPermission will be called.
return true;
}
content::MediaResponseCallback RequestMediaAccessPermission(
CefBrowserHostBase* browser,
const content::MediaStreamRequest& request,
content::MediaResponseCallback callback,
bool default_disallow) {
CEF_REQUIRE_UIT();
CefMediaAccessQuery query(browser, request, std::move(callback));
if (CheckCommandLinePermission()) {
// Allow all requested permissions.
query.ExecuteCallback(query.requested_permissions());
return base::NullCallback();
}
bool handled = false;
if (auto client = browser->GetClient()) {
if (auto handler = client->GetPermissionHandler()) {
const auto requested_permissions = query.requested_permissions();
CefRefPtr<CefMediaAccessCallbackImpl> callbackImpl(
new CefMediaAccessCallbackImpl(std::move(query)));
auto frame =
browser->GetFrameForGlobalId(content::GlobalRenderFrameHostId(
request.render_process_id, request.render_frame_id));
if (!frame)
frame = browser->GetMainFrame();
handled = handler->OnRequestMediaAccessPermission(
browser, frame, request.security_origin.spec(), requested_permissions,
callbackImpl.get());
if (!handled) {
LOG_IF(ERROR, callbackImpl->IsDisconnected())
<< "Should return true from OnRequestMediaAccessPermission when "
"executing the callback";
query = callbackImpl->Disconnect();
}
}
}
if (!query.is_null()) {
if (default_disallow && !handled) {
// Disallow access by default.
query.ExecuteCallback(CEF_MEDIA_PERMISSION_NONE);
} else {
// Proceed with default handling.
return query.DisconnectCallback();
}
}
return base::NullCallback();
}
} // namespace media_access_query

View File

@@ -1,37 +0,0 @@
// Copyright 2022 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.
#ifndef CEF_LIBCEF_BROWSER_MEDIA_ACCESS_QUERY_H_
#define CEF_LIBCEF_BROWSER_MEDIA_ACCESS_QUERY_H_
#pragma once
#include "content/public/browser/media_stream_request.h"
namespace content {
class RenderFrameHost;
}
class CefBrowserHostBase;
class GURL;
namespace media_access_query {
// Called from WebContentsDelegate::CheckMediaAccessPermission.
bool CheckMediaAccessPermission(CefBrowserHostBase* browser,
content::RenderFrameHost* render_frame_host,
const GURL& security_origin,
blink::mojom::MediaStreamType type);
// Called from WebContentsDelegate::RequestMediaAccessPermission.
// |callback| will be returned if the request is unhandled and
// |default_disallow| is false.
[[nodiscard]] content::MediaResponseCallback RequestMediaAccessPermission(
CefBrowserHostBase* browser,
const content::MediaStreamRequest& request,
content::MediaResponseCallback callback,
bool default_disallow);
} // namespace media_access_query
#endif // CEF_LIBCEF_BROWSER_MEDIA_ACCESS_QUERY_H_

View File

@@ -1,108 +0,0 @@
// Copyright 2022 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.
#include "libcef/browser/media_stream_registrar.h"
#include "libcef/browser/browser_host_base.h"
#include "libcef/browser/thread_util.h"
class CefMediaStreamUI : public content::MediaStreamUI {
public:
CefMediaStreamUI(base::WeakPtr<CefMediaStreamRegistrar> registrar,
bool has_video,
bool has_audio)
: registrar_(registrar), has_video_(has_video), has_audio_(has_audio) {}
~CefMediaStreamUI() override {
if (registrar_) {
registrar_->UnregisterMediaStream(label_);
}
}
CefMediaStreamUI(const CefMediaStreamUI&) = delete;
CefMediaStreamUI& operator=(const CefMediaStreamUI&) = delete;
gfx::NativeViewId OnStarted(
base::RepeatingClosure stop,
SourceCallback source,
const std::string& label,
std::vector<content::DesktopMediaID> screen_capture_ids,
StateChangeCallback state_change) override {
if (registrar_) {
label_ = label;
registrar_->RegisterMediaStream(label, has_video_, has_audio_);
}
return 0;
}
void OnDeviceStoppedForSourceChange(
const std::string& label,
const content::DesktopMediaID& old_media_id,
const content::DesktopMediaID& new_media_id) override {}
void OnDeviceStopped(const std::string& label,
const content::DesktopMediaID& media_id) override {}
private:
base::WeakPtr<CefMediaStreamRegistrar> registrar_;
const bool has_video_;
const bool has_audio_;
std::string label_;
};
CefMediaStreamRegistrar::CefMediaStreamRegistrar(CefBrowserHostBase* browser)
: browser_(browser) {}
std::unique_ptr<content::MediaStreamUI>
CefMediaStreamRegistrar::MaybeCreateMediaStreamUI(bool has_video,
bool has_audio) const {
// Only create the object if the callback will be executed.
if (auto client = browser_->GetClient()) {
if (auto handler = client->GetDisplayHandler()) {
return std::make_unique<CefMediaStreamUI>(weak_ptr_factory_.GetWeakPtr(),
has_video, has_audio);
}
}
return nullptr;
}
void CefMediaStreamRegistrar::RegisterMediaStream(const std::string& label,
bool video,
bool audio) {
CEF_REQUIRE_UIT();
MediaStreamInfo info = {video, audio};
registered_streams_.insert(std::make_pair(label, info));
NotifyMediaStreamChange();
}
void CefMediaStreamRegistrar::UnregisterMediaStream(const std::string& label) {
CEF_REQUIRE_UIT();
registered_streams_.erase(label);
NotifyMediaStreamChange();
}
void CefMediaStreamRegistrar::NotifyMediaStreamChange() {
bool video = false;
bool audio = false;
for (const auto& media_stream : registered_streams_) {
const auto& info = media_stream.second;
if (!video)
video = info.video;
if (!audio)
audio = info.audio;
}
if (audio == last_notified_info_.audio &&
video == last_notified_info_.video) {
return;
}
last_notified_info_ = {video, audio};
if (auto client = browser_->GetClient()) {
if (auto handler = client->GetDisplayHandler()) {
handler->OnMediaAccessChange(browser_, video, audio);
}
}
}

View File

@@ -1,56 +0,0 @@
// Copyright 2022 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.
#ifndef CEF_LIBCEF_BROWSER_MEDIA_STREAM_REGISTRAR_H_
#define CEF_LIBCEF_BROWSER_MEDIA_STREAM_REGISTRAR_H_
#pragma once
#include <map>
#include <memory>
#include <string>
#include "base/memory/weak_ptr.h"
#include "content/public/browser/media_stream_request.h"
class CefBrowserHostBase;
class CefMediaStreamUI;
class CefMediaStreamRegistrar {
public:
explicit CefMediaStreamRegistrar(CefBrowserHostBase* browser);
CefMediaStreamRegistrar(const CefMediaStreamRegistrar&) = delete;
CefMediaStreamRegistrar& operator=(const CefMediaStreamRegistrar&) = delete;
std::unique_ptr<content::MediaStreamUI> MaybeCreateMediaStreamUI(
bool has_video,
bool has_audio) const;
private:
friend class CefMediaStreamUI;
// Called from CefMediaStreamUI.
void RegisterMediaStream(const std::string& label, bool video, bool audio);
void UnregisterMediaStream(const std::string& label);
void NotifyMediaStreamChange();
// Guaranteed to outlive this object.
CefBrowserHostBase* const browser_;
struct MediaStreamInfo {
bool video;
bool audio;
};
// Current in use media streams.
std::map<std::string, MediaStreamInfo> registered_streams_;
// Last notified media stream info.
MediaStreamInfo last_notified_info_{};
base::WeakPtrFactory<CefMediaStreamRegistrar> weak_ptr_factory_{this};
};
#endif // CEF_LIBCEF_BROWSER_MEDIA_STREAM_REGISTRAR_H_

View File

@@ -233,6 +233,17 @@ CefEventHandle CefBrowserPlatformDelegateNativeLinux::GetEventHandle(
return nullptr;
}
gfx::Point CefBrowserPlatformDelegateNativeLinux::GetDialogPosition(
const gfx::Size& size) {
const gfx::Size& max_size = GetMaximumDialogSize();
return gfx::Point((max_size.width() - size.width()) / 2,
(max_size.height() - size.height()) / 2);
}
gfx::Size CefBrowserPlatformDelegateNativeLinux::GetMaximumDialogSize() {
return GetWindowWidget()->GetWindowBoundsInScreen().size();
}
ui::KeyEvent CefBrowserPlatformDelegateNativeLinux::TranslateUiKeyEvent(
const CefKeyEvent& key_event) const {
int flags = TranslateUiEventModifiers(key_event.modifiers);

View File

@@ -34,6 +34,8 @@ class CefBrowserPlatformDelegateNativeLinux
const content::NativeWebKeyboardEvent& event) override;
CefEventHandle GetEventHandle(
const content::NativeWebKeyboardEvent& event) const override;
gfx::Point GetDialogPosition(const gfx::Size& size) override;
gfx::Size GetMaximumDialogSize() override;
// CefBrowserPlatformDelegateNativeAura methods:
ui::KeyEvent TranslateUiKeyEvent(const CefKeyEvent& key_event) const override;

View File

@@ -44,6 +44,8 @@ class CefBrowserPlatformDelegateNativeMac
std::unique_ptr<CefJavaScriptDialogRunner> CreateJavaScriptDialogRunner()
override;
std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
gfx::Point GetDialogPosition(const gfx::Size& size) override;
gfx::Size GetMaximumDialogSize() override;
// CefBrowserPlatformDelegateNative methods:
content::NativeWebKeyboardEvent TranslateWebKeyEvent(

View File

@@ -125,28 +125,21 @@ NSTimeInterval currentEventTimestamp() {
NSUInteger NativeModifiers(int cef_modifiers) {
NSUInteger native_modifiers = 0;
if (cef_modifiers & EVENTFLAG_SHIFT_DOWN)
native_modifiers |= NSEventModifierFlagShift;
native_modifiers |= NSShiftKeyMask;
if (cef_modifiers & EVENTFLAG_CONTROL_DOWN)
native_modifiers |= NSEventModifierFlagControl;
native_modifiers |= NSControlKeyMask;
if (cef_modifiers & EVENTFLAG_ALT_DOWN)
native_modifiers |= NSEventModifierFlagOption;
native_modifiers |= NSAlternateKeyMask;
if (cef_modifiers & EVENTFLAG_COMMAND_DOWN)
native_modifiers |= NSEventModifierFlagCommand;
native_modifiers |= NSCommandKeyMask;
if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON)
native_modifiers |= NSEventModifierFlagCapsLock;
native_modifiers |= NSAlphaShiftKeyMask;
if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON)
native_modifiers |= NSEventModifierFlagNumericPad;
native_modifiers |= NSNumericPadKeyMask;
return native_modifiers;
}
constexpr int kDefaultHeight = 750;
constexpr int kDefaultWidth = 750;
constexpr NSWindowStyleMask kDefaultStyleMask =
NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable |
NSWindowStyleMaskUnifiedTitleAndToolbar;
} // namespace
CefBrowserPlatformDelegateNativeMac::CefBrowserPlatformDelegateNativeMac(
@@ -183,15 +176,18 @@ bool CefBrowserPlatformDelegateNativeMac::CreateHostWindow() {
// Create a new window.
NSRect window_rect = {{x, y}, {width, height}};
if (window_rect.size.width == 0)
window_rect.size.width = kDefaultWidth;
window_rect.size.width = 750;
if (window_rect.size.height == 0)
window_rect.size.height = kDefaultHeight;
window_rect.size.height = 750;
content_rect = {{0, 0}, {window_rect.size.width, window_rect.size.height}};
newWnd = [[UnderlayOpenGLHostingWindow alloc]
initWithContentRect:window_rect
styleMask:kDefaultStyleMask
styleMask:(NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask |
NSResizableWindowMask |
NSUnifiedTitleAndToolbarWindowMask)
backing:NSBackingStoreBuffered
defer:NO];
@@ -355,7 +351,7 @@ void CefBrowserPlatformDelegateNativeMac::ViewText(const std::string& text) {
bool CefBrowserPlatformDelegateNativeMac::HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) {
// Give the top level menu equivalents a chance to handle the event.
if ([event.os_event type] == NSEventTypeKeyDown)
if ([event.os_event type] == NSKeyDown)
return [[NSApp mainMenu] performKeyEquivalent:event.os_event];
return false;
}
@@ -378,6 +374,22 @@ CefBrowserPlatformDelegateNativeMac::CreateMenuRunner() {
return base::WrapUnique(new CefMenuRunnerMac);
}
gfx::Point CefBrowserPlatformDelegateNativeMac::GetDialogPosition(
const gfx::Size& size) {
// Dialogs are always re-positioned by the constrained window sheet controller
// so nothing interesting to return yet.
return gfx::Point();
}
gfx::Size CefBrowserPlatformDelegateNativeMac::GetMaximumDialogSize() {
if (!web_contents_)
return gfx::Size();
// The dialog should try to fit within the overlay for the web contents.
// Note that, for things like print preview, this is just a suggested maximum.
return web_contents_->GetContainerBounds().size();
}
content::NativeWebKeyboardEvent
CefBrowserPlatformDelegateNativeMac::TranslateWebKeyEvent(
const CefKeyEvent& key_event) const {
@@ -393,19 +405,19 @@ CefBrowserPlatformDelegateNativeMac::TranslateWebKeyEvent(
NSEventType event_type;
if (key_event.character == 0 && key_event.unmodified_character == 0) {
// Check if both character and unmodified_characther are empty to determine
// if this was a NSEventTypeFlagsChanged event.
// if this was a NSFlagsChanged event.
// A dead key will have an empty character, but a non-empty unmodified
// character
event_type = NSEventTypeFlagsChanged;
event_type = NSFlagsChanged;
} else {
switch (key_event.type) {
case KEYEVENT_RAWKEYDOWN:
case KEYEVENT_KEYDOWN:
case KEYEVENT_CHAR:
event_type = NSEventTypeKeyDown;
event_type = NSKeyDown;
break;
case KEYEVENT_KEYUP:
event_type = NSEventTypeKeyUp;
event_type = NSKeyUp;
break;
}
}

View File

@@ -10,8 +10,8 @@
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
#include "libcef/browser/context.h"
#include "libcef/browser/native/javascript_dialog_runner_win.h"
#include "libcef/browser/native/window_delegate_view.h"
#include "libcef/browser/screen_util.h"
#include "libcef/browser/thread_util.h"
#include "base/base_paths_win.h"
@@ -147,61 +147,6 @@ float GetWindowScaleFactor(HWND hwnd) {
.device_scale_factor();
}
struct ScreenInfo {
float scale_factor;
CefRect rect;
};
ScreenInfo GetScreenInfo(int x, int y) {
const auto display =
display::Screen::GetScreen()->GetDisplayNearestPoint(gfx::Point(x, y));
const auto rect = display.work_area();
return ScreenInfo{display.device_scale_factor(),
CefRect(rect.x(), rect.y(), rect.width(), rect.height())};
}
CefRect GetFrameRectFromLogicalContentRect(CefRect content,
DWORD style,
DWORD ex_style,
bool has_menu,
float scale) {
const auto scaled_rect = gfx::ScaleToRoundedRect(
gfx::Rect(content.x, content.y, content.width, content.height), scale);
RECT rect = {0, 0, scaled_rect.width(), scaled_rect.height()};
AdjustWindowRectEx(&rect, style, has_menu, ex_style);
return CefRect(scaled_rect.x(), scaled_rect.y(), rect.right - rect.left,
rect.bottom - rect.top);
}
CefRect GetAdjustedWindowRect(CefRect content,
DWORD style,
DWORD ex_style,
bool has_menu) {
// If height or width is not provided, let OS determine position and size,
// similarly to Chromium behavior
if (content.width == CW_USEDEFAULT || content.height == CW_USEDEFAULT) {
return CefRect(CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT);
}
if (content.x == CW_USEDEFAULT) {
content.x = 0;
}
if (content.y == CW_USEDEFAULT) {
content.y = 0;
}
const ScreenInfo screen = GetScreenInfo(content.x, content.y);
const CefRect rect = MakeVisibleOnScreenRect(content, screen.rect);
return GetFrameRectFromLogicalContentRect(rect, style, ex_style, has_menu,
screen.scale_factor);
}
} // namespace
CefBrowserPlatformDelegateNativeWin::CefBrowserPlatformDelegateNativeWin(
@@ -238,23 +183,14 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
has_frame_ = !(window_info_.style & WS_CHILD);
const std::wstring windowName(CefString(&window_info_.window_name));
CefRect window_rect = window_info_.bounds;
if (!window_info_.parent_window) {
const bool has_menu =
!(window_info_.style & WS_CHILD) && (window_info_.menu != NULL);
window_rect = GetAdjustedWindowRect(window_rect, window_info_.style,
window_info_.ex_style, has_menu);
}
std::wstring windowName(CefString(&window_info_.window_name));
// Create the new browser window.
CreateWindowEx(window_info_.ex_style, GetWndClass(), windowName.c_str(),
window_info_.style, window_rect.x, window_rect.y,
window_rect.width, window_rect.height,
window_info_.parent_window, window_info_.menu,
::GetModuleHandle(NULL), this);
window_info_.style, window_info_.bounds.x,
window_info_.bounds.y, window_info_.bounds.width,
window_info_.bounds.height, window_info_.parent_window,
window_info_.menu, ::GetModuleHandle(NULL), this);
// It's possible for CreateWindowEx to fail if the parent window was
// destroyed between the call to CreateBrowser and the above one.
@@ -350,43 +286,28 @@ void CefBrowserPlatformDelegateNativeWin::SetFocus(bool setFocus) {
if (!setFocus)
return;
if (web_contents_) {
// Give logical focus to the RenderWidgetHostViewAura in the views
// hierarchy. This does not change the native keyboard focus.
web_contents_->Focus();
}
if (window_widget_) {
// Give native focus to the DesktopWindowTreeHostWin ("Chrome_WidgetWin_0")
// associated with the root window. The currently focused HWND may be
// "CefBrowserWindow" if we're called in response to our WndProc receiving
// the WM_SETFOCUS event (possibly due to "CefBrowserWindow" recieving the
// top-level WM_ACTIVATE event), or some other HWND if the client calls
// CefBrowserHost::SetFocus(true) directly. DesktopWindowTreeHostWin may
// also receive focus/blur and mouse click events from the OS directly, in
// which case this method will not be called but the below discussion still
// applies.
// Give native focus to the DesktopWindowTreeHostWin associated with the
// root window.
//
// The DesktopWindowTreeHostWin::HandleNativeFocus/HandleNativeBlur methods
// The DesktopWindowTreeHostWin HandleNativeFocus/HandleNativeBlur methods
// are called in response to WM_SETFOCUS/WM_KILLFOCUS respectively. The
// DesktopWindowTreeHostWin::HandleMouseEvent method is called if the user
// clicks on the WebContents. These methods have all been patched to call
// HandleActivationChanged (indirectly via ::SetFocus in the case of mouse
// clicks). HandleActivationChanged will then trigger the following
// behaviors:
// implementation has been patched to call HandleActivationChanged which
// results in the following behaviors:
// 1. Update focus/activation state of the aura::Window indirectly via
// wm::FocusController. This allows focus-related behaviors (e.g. focus
// rings, flashing caret, onFocus/onBlur JS events, etc.) to work as
// expected (see issue #1677) and also triggers an initial call to
// WebContents::Focus which gives logical focus to the
// RenderWidgetHostViewAura in the views hierarchy (see issue #3306).
// expected (see issue #1677).
// 2. Update focus state of the ui::InputMethod. If this does not occur
// then:
// (a) InputMethodBase::GetTextInputClient will return NULL and
// InputMethodWin::OnChar will fail to send character events to the
// renderer (see issue #1700); and
// (b) InputMethodWinBase::IsWindowFocused will return false due to
// ::GetFocus() returning the currently focused HWND (e.g.
// "CefBrowserWindow") instead of the expected "Chrome_WidgetWin_0" HWND,
// causing TSF not to handle IME events (see issue #3306). For this same
// reason, ::SetFocus needs to be called before WebContents::Focus which
// sends the InputMethod OnWillChangeFocusedClient notification that then
// calls IsWindowFocused (e.g. WebContents::Focus is intentionally called
// multiple times).
// then InputMethodBase::GetTextInputClient will return NULL and
// InputMethodWin::OnChar will fail to sent character events to the
// renderer (see issue #1700).
//
// This differs from activation in Chrome which is handled via
// HWNDMessageHandler::PostProcessActivateMessage (Widget::Show indirectly
@@ -402,15 +323,6 @@ void CefBrowserPlatformDelegateNativeWin::SetFocus(bool setFocus) {
// discovered.
::SetFocus(HWNDForWidget(window_widget_));
}
if (web_contents_) {
// Give logical focus to the RenderWidgetHostViewAura in the views
// hierarchy. This does not change the native keyboard focus. When
// |window_widget_| exists this additional Focus() call is necessary to
// correctly assign focus/input state after native focus resulting from
// window activation (see the InputMethod discussion above).
web_contents_->Focus();
}
}
void CefBrowserPlatformDelegateNativeWin::NotifyMoveOrResizeStarted() {
@@ -437,17 +349,18 @@ void CefBrowserPlatformDelegateNativeWin::NotifyMoveOrResizeStarted() {
void CefBrowserPlatformDelegateNativeWin::SizeTo(int width, int height) {
HWND window = window_info_.window;
const DWORD style = GetWindowLong(window, GWL_STYLE);
const DWORD ex_style = GetWindowLong(window, GWL_EXSTYLE);
const bool has_menu = !(style & WS_CHILD) && (GetMenu(window) != NULL);
const float scale = GetWindowScaleFactor(window);
RECT rect = {0, 0, width, height};
DWORD style = GetWindowLong(window, GWL_STYLE);
DWORD ex_style = GetWindowLong(window, GWL_EXSTYLE);
bool has_menu = !(style & WS_CHILD) && (GetMenu(window) != NULL);
const CefRect content_rect(0, 0, width, height);
const CefRect frame_rect = GetFrameRectFromLogicalContentRect(
content_rect, style, ex_style, has_menu, scale);
// The size value is for the client area. Calculate the whole window size
// based on the current style.
AdjustWindowRectEx(&rect, style, has_menu, ex_style);
// Size the window. The left/top values may be negative.
SetWindowPos(window, NULL, 0, 0, frame_rect.width, frame_rect.height,
SetWindowPos(window, NULL, 0, 0, rect.right - rect.left,
rect.bottom - rect.top,
SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
}
@@ -512,6 +425,22 @@ CefEventHandle CefBrowserPlatformDelegateNativeWin::GetEventHandle(
const_cast<CHROME_MSG*>(&event.os_event->native_event()));
}
std::unique_ptr<CefJavaScriptDialogRunner>
CefBrowserPlatformDelegateNativeWin::CreateJavaScriptDialogRunner() {
return base::WrapUnique(new CefJavaScriptDialogRunnerWin);
}
gfx::Point CefBrowserPlatformDelegateNativeWin::GetDialogPosition(
const gfx::Size& size) {
const gfx::Size& max_size = GetMaximumDialogSize();
return gfx::Point((max_size.width() - size.width()) / 2,
(max_size.height() - size.height()) / 2);
}
gfx::Size CefBrowserPlatformDelegateNativeWin::GetMaximumDialogSize() {
return GetWindowWidget()->GetWindowBoundsInScreen().size();
}
ui::KeyEvent CefBrowserPlatformDelegateNativeWin::TranslateUiKeyEvent(
const CefKeyEvent& key_event) const {
int flags = TranslateUiEventModifiers(key_event.modifiers);
@@ -713,4 +642,4 @@ LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(HWND hwnd,
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
}

View File

@@ -33,6 +33,10 @@ class CefBrowserPlatformDelegateNativeWin
const content::NativeWebKeyboardEvent& event) override;
CefEventHandle GetEventHandle(
const content::NativeWebKeyboardEvent& event) const override;
std::unique_ptr<CefJavaScriptDialogRunner> CreateJavaScriptDialogRunner()
override;
gfx::Point GetDialogPosition(const gfx::Size& size) override;
gfx::Size GetMaximumDialogSize() override;
// CefBrowserPlatformDelegateNativeAura methods:
ui::KeyEvent TranslateUiKeyEvent(const CefKeyEvent& key_event) const override;

View File

@@ -9,7 +9,6 @@
#include "libcef/browser/javascript_dialog_runner.h"
#include "base/callback.h"
#include "base/mac/scoped_nsobject.h"
#include "base/memory/weak_ptr.h"
@@ -25,13 +24,12 @@ class CefJavaScriptDialogRunnerMac : public CefJavaScriptDialogRunner {
~CefJavaScriptDialogRunnerMac() override;
// CefJavaScriptDialogRunner methods:
void Run(CefBrowserHostBase* browser,
void Run(AlloyBrowserHostImpl* browser,
content::JavaScriptDialogType message_type,
const GURL& origin_url,
const std::u16string& display_url,
const std::u16string& message_text,
const std::u16string& default_prompt_text,
DialogClosedCallback callback) override;
void Handle(bool accept, const std::u16string* prompt_override) override;
void Cancel() override;
// Callback from CefJavaScriptDialogHelper when the dialog is closed.

View File

@@ -10,7 +10,6 @@
#include "base/bind.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "components/url_formatter/elide_url.h"
// Helper object that receives the notification that the dialog/sheet is
// going away. Is responsible for cleaning itself up.
@@ -88,9 +87,9 @@ CefJavaScriptDialogRunnerMac::~CefJavaScriptDialogRunnerMac() {
}
void CefJavaScriptDialogRunnerMac::Run(
CefBrowserHostBase* browser,
AlloyBrowserHostImpl* browser,
content::JavaScriptDialogType message_type,
const GURL& origin_url,
const std::u16string& display_url,
const std::u16string& message_text,
const std::u16string& default_prompt_text,
DialogClosedCallback callback) {
@@ -127,9 +126,6 @@ void CefJavaScriptDialogRunnerMac::Run(
label = u"JavaScript Confirm";
break;
}
const std::u16string& display_url =
url_formatter::FormatUrlForSecurityDisplay(origin_url);
if (!display_url.empty())
label += u" - " + display_url;
@@ -160,14 +156,6 @@ void CefJavaScriptDialogRunnerMac::Run(
[[alert window] makeFirstResponder:[alert accessoryView]];
}
void CefJavaScriptDialogRunnerMac::Handle(
bool accept,
const std::u16string* prompt_override) {
if (helper_.get()) {
DialogClosed(accept, prompt_override ? *prompt_override : std::u16string());
}
}
void CefJavaScriptDialogRunnerMac::Cancel() {
if (helper_.get()) {
[helper_ cancel];

View File

@@ -0,0 +1,240 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/native/javascript_dialog_runner_win.h"
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
#include "libcef_dll/resource.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
class CefJavaScriptDialogRunnerWin;
HHOOK CefJavaScriptDialogRunnerWin::msg_hook_ = NULL;
int CefJavaScriptDialogRunnerWin::msg_hook_user_count_ = 0;
INT_PTR CALLBACK CefJavaScriptDialogRunnerWin::DialogProc(HWND dialog,
UINT message,
WPARAM wparam,
LPARAM lparam) {
switch (message) {
case WM_INITDIALOG: {
SetWindowLongPtr(dialog, DWLP_USER, static_cast<LONG_PTR>(lparam));
CefJavaScriptDialogRunnerWin* owner =
reinterpret_cast<CefJavaScriptDialogRunnerWin*>(lparam);
owner->dialog_win_ = dialog;
SetDlgItemText(dialog, IDC_DIALOGTEXT, owner->message_text_.c_str());
if (owner->message_type_ == content::JAVASCRIPT_DIALOG_TYPE_PROMPT)
SetDlgItemText(dialog, IDC_PROMPTEDIT,
owner->default_prompt_text_.c_str());
break;
}
case WM_CLOSE: {
CefJavaScriptDialogRunnerWin* owner =
reinterpret_cast<CefJavaScriptDialogRunnerWin*>(
GetWindowLongPtr(dialog, DWLP_USER));
if (owner) {
owner->CloseDialog(false, std::wstring());
// No need for the system to call DestroyWindow() because it will be
// called by the Cancel() method.
return 0;
}
break;
}
case WM_COMMAND: {
CefJavaScriptDialogRunnerWin* owner =
reinterpret_cast<CefJavaScriptDialogRunnerWin*>(
GetWindowLongPtr(dialog, DWLP_USER));
std::wstring user_input;
bool finish = false;
bool result = false;
switch (LOWORD(wparam)) {
case IDOK:
finish = true;
result = true;
if (owner->message_type_ == content::JAVASCRIPT_DIALOG_TYPE_PROMPT) {
size_t length =
GetWindowTextLength(GetDlgItem(dialog, IDC_PROMPTEDIT)) + 1;
if (length > 1) {
user_input.reserve(length);
user_input.resize(length - 1);
GetDlgItemText(dialog, IDC_PROMPTEDIT, &user_input[0], length);
}
}
break;
case IDCANCEL:
finish = true;
result = false;
break;
}
if (finish) {
owner->CloseDialog(result, user_input);
}
break;
}
default:
break;
}
return 0;
}
CefJavaScriptDialogRunnerWin::CefJavaScriptDialogRunnerWin()
: dialog_win_(NULL), parent_win_(NULL), hook_installed_(false) {}
CefJavaScriptDialogRunnerWin::~CefJavaScriptDialogRunnerWin() {
Cancel();
}
void CefJavaScriptDialogRunnerWin::Run(
AlloyBrowserHostImpl* browser,
content::JavaScriptDialogType message_type,
const std::u16string& display_url,
const std::u16string& message_text,
const std::u16string& default_prompt_text,
DialogClosedCallback callback) {
DCHECK(!dialog_win_);
message_type_ = message_type;
message_text_ = base::UTF16ToWide(message_text);
default_prompt_text_ = base::UTF16ToWide(default_prompt_text);
callback_ = std::move(callback);
InstallMessageHook();
hook_installed_ = true;
int dialog_type;
if (message_type == content::JAVASCRIPT_DIALOG_TYPE_ALERT)
dialog_type = IDD_ALERT;
else if (message_type == content::JAVASCRIPT_DIALOG_TYPE_CONFIRM)
dialog_type = IDD_CONFIRM;
else // JAVASCRIPT_DIALOG_TYPE_PROMPT
dialog_type = IDD_PROMPT;
base::FilePath file_path;
HMODULE hModule = NULL;
// Try to load the dialog from the DLL.
if (base::PathService::Get(base::DIR_MODULE, &file_path)) {
file_path = file_path.Append(L"libcef.dll");
hModule = ::GetModuleHandle(file_path.value().c_str());
}
if (!hModule)
hModule = ::GetModuleHandle(NULL);
DCHECK(hModule);
parent_win_ = GetAncestor(browser->GetWindowHandle(), GA_ROOT);
dialog_win_ =
CreateDialogParam(hModule, MAKEINTRESOURCE(dialog_type), parent_win_,
DialogProc, reinterpret_cast<LPARAM>(this));
DCHECK(dialog_win_);
if (!display_url.empty()) {
// Add the display URL to the window title.
wchar_t text[64];
GetWindowText(dialog_win_, text, sizeof(text) / sizeof(wchar_t));
std::wstring new_window_text =
std::wstring(text) + L" - " + base::UTF16ToWide(display_url);
SetWindowText(dialog_win_, new_window_text.c_str());
}
// Disable the parent window so the user can't interact with it.
if (IsWindowEnabled(parent_win_))
EnableWindow(parent_win_, FALSE);
ShowWindow(dialog_win_, SW_SHOWNORMAL);
}
void CefJavaScriptDialogRunnerWin::Cancel() {
// Re-enable the parent before closing the popup to avoid focus/activation/
// z-order issues.
if (parent_win_ && IsWindow(parent_win_) && !IsWindowEnabled(parent_win_)) {
EnableWindow(parent_win_, TRUE);
parent_win_ = NULL;
}
if (dialog_win_ && IsWindow(dialog_win_)) {
SetWindowLongPtr(dialog_win_, DWLP_USER, NULL);
DestroyWindow(dialog_win_);
dialog_win_ = NULL;
}
if (hook_installed_) {
UninstallMessageHook();
hook_installed_ = false;
}
}
void CefJavaScriptDialogRunnerWin::CloseDialog(bool success,
const std::wstring& user_input) {
// Run the callback first so that RenderProcessHostImpl::IsBlocked is
// cleared. Otherwise, RenderWidgetHostImpl::IsIgnoringInputEvents will
// return true and RenderWidgetHostViewAura::OnWindowFocused will fail to
// re-assign browser focus.
std::move(callback_).Run(success, base::WideToUTF16(user_input));
Cancel();
}
// static
LRESULT CALLBACK CefJavaScriptDialogRunnerWin::GetMsgProc(int code,
WPARAM wparam,
LPARAM lparam) {
// Mostly borrowed from http://support.microsoft.com/kb/q187988/
// and http://www.codeproject.com/KB/atl/cdialogmessagehook.aspx.
LPMSG msg = reinterpret_cast<LPMSG>(lparam);
if (code >= 0 && wparam == PM_REMOVE && msg->message >= WM_KEYFIRST &&
msg->message <= WM_KEYLAST) {
HWND hwnd = GetActiveWindow();
if (::IsWindow(hwnd) && ::IsDialogMessage(hwnd, msg)) {
// The value returned from this hookproc is ignored, and it cannot
// be used to tell Windows the message has been handled. To avoid
// further processing, convert the message to WM_NULL before
// returning.
msg->hwnd = NULL;
msg->message = WM_NULL;
msg->lParam = 0L;
msg->wParam = 0;
}
}
// Passes the hook information to the next hook procedure in
// the current hook chain.
return ::CallNextHookEx(msg_hook_, code, wparam, lparam);
}
// static
bool CefJavaScriptDialogRunnerWin::InstallMessageHook() {
msg_hook_user_count_++;
// Make sure we only call this once.
if (msg_hook_ != NULL)
return true;
msg_hook_ = ::SetWindowsHookEx(WH_GETMESSAGE,
&CefJavaScriptDialogRunnerWin::GetMsgProc,
NULL, GetCurrentThreadId());
DCHECK(msg_hook_ != NULL);
return msg_hook_ != NULL;
}
// static
bool CefJavaScriptDialogRunnerWin::UninstallMessageHook() {
msg_hook_user_count_--;
DCHECK_GE(msg_hook_user_count_, 0);
if (msg_hook_user_count_ > 0)
return true;
DCHECK(msg_hook_ != NULL);
BOOL result = ::UnhookWindowsHookEx(msg_hook_);
DCHECK(result);
msg_hook_ = NULL;
return result != FALSE;
}

View File

@@ -0,0 +1,56 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_NATIVE_JAVASCRIPT_DIALOG_RUNNER_WIN_H_
#define CEF_LIBCEF_BROWSER_NATIVE_JAVASCRIPT_DIALOG_RUNNER_WIN_H_
#pragma once
#include <windows.h>
#include "libcef/browser/javascript_dialog_runner.h"
class CefJavaScriptDialogRunnerWin : public CefJavaScriptDialogRunner {
public:
CefJavaScriptDialogRunnerWin();
~CefJavaScriptDialogRunnerWin() override;
// CefJavaScriptDialogRunner methods:
void Run(AlloyBrowserHostImpl* browser,
content::JavaScriptDialogType message_type,
const std::u16string& display_url,
const std::u16string& message_text,
const std::u16string& default_prompt_text,
DialogClosedCallback callback) override;
void Cancel() override;
private:
void CloseDialog(bool success, const std::wstring& user_input);
HWND dialog_win_;
HWND parent_win_;
content::JavaScriptDialogType message_type_;
std::wstring message_text_;
std::wstring default_prompt_text_;
DialogClosedCallback callback_;
bool hook_installed_;
static INT_PTR CALLBACK DialogProc(HWND dialog,
UINT message,
WPARAM wparam,
LPARAM lparam);
// Since the message loop we expect to run in isn't going to be nicely
// calling IsDialogMessage(), we need to hook the wnd proc and call it
// ourselves. See http://support.microsoft.com/kb/q187988/
static bool InstallMessageHook();
static bool UninstallMessageHook();
static LRESULT CALLBACK GetMsgProc(int code, WPARAM wparam, LPARAM lparam);
static HHOOK msg_hook_;
static int msg_hook_user_count_;
};
#endif // CEF_LIBCEF_BROWSER_NATIVE_JAVASCRIPT_DIALOG_RUNNER_WIN_H_

View File

@@ -66,7 +66,7 @@ bool CefMenuRunnerMac::RunContextMenu(
NSPoint position = [window mouseLocationOutsideOfEventStream];
NSTimeInterval eventTime = [currentEvent timestamp];
NSEvent* clickEvent = [NSEvent mouseEventWithType:NSEventTypeRightMouseDown
NSEvent* clickEvent = [NSEvent mouseEventWithType:NSRightMouseDown
location:position
modifierFlags:0
timestamp:eventTime

View File

@@ -39,8 +39,7 @@ network::mojom::CookieManager* GetCookieManager(
->GetCookieManagerForBrowserProcess();
}
net::CookieOptions GetCookieOptions(const network::ResourceRequest& request,
bool for_loading_cookies) {
net::CookieOptions GetCookieOptions(const network::ResourceRequest& request) {
// Match the logic from InterceptionJob::FetchCookies and
// ChromeContentBrowserClient::ShouldIgnoreSameSiteCookieRestrictionsWhenTopLevel.
bool should_treat_as_first_party =
@@ -51,33 +50,14 @@ net::CookieOptions GetCookieOptions(const network::ResourceRequest& request,
request.trusted_params->isolation_info.request_type() ==
net::IsolationInfo::RequestType::kMainFrame;
// Match the logic from URLRequest::SetURLChain.
std::vector<GURL> url_chain{request.url};
if (request.navigation_redirect_chain.size() >= 2) {
// Keep |request.url| as the final entry in the chain.
url_chain.insert(url_chain.begin(),
request.navigation_redirect_chain.begin(),
request.navigation_redirect_chain.begin() +
request.navigation_redirect_chain.size() - 1);
}
// Match the logic from URLRequestHttpJob::AddCookieHeaderAndStart.
net::CookieOptions options;
options.set_include_httponly();
if (for_loading_cookies) {
// Match the logic from URLRequestHttpJob::AddCookieHeaderAndStart.
options.set_same_site_cookie_context(
net::cookie_util::ComputeSameSiteContextForRequest(
request.method, url_chain, request.site_for_cookies,
request.request_initiator, is_main_frame_navigation,
should_treat_as_first_party));
} else {
// Match the logic from
// URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete.
options.set_same_site_cookie_context(
net::cookie_util::ComputeSameSiteContextForResponse(
url_chain, request.site_for_cookies, request.request_initiator,
is_main_frame_navigation, should_treat_as_first_party));
}
options.set_same_site_cookie_context(
net::cookie_util::ComputeSameSiteContextForRequest(
request.method, {request.url}, request.site_for_cookies,
request.request_initiator, is_main_frame_navigation,
should_treat_as_first_party));
return options;
}
@@ -247,11 +227,10 @@ void LoadCookies(const CefBrowserContext::Getter& browser_context_getter,
}
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(LoadCookiesOnUIThread, browser_context_getter, request.url,
GetCookieOptions(request, /*for_loading_cookies=*/true),
net::CookiePartitionKeyCollection(), allow_cookie_callback,
std::move(done_callback)));
CEF_UIT, base::BindOnce(LoadCookiesOnUIThread, browser_context_getter,
request.url, GetCookieOptions(request),
net::CookiePartitionKeyCollection(),
allow_cookie_callback, std::move(done_callback)));
}
void SaveCookies(const CefBrowserContext::Getter& browser_context_getter,
@@ -287,7 +266,7 @@ void SaveCookies(const CefBrowserContext::Getter& browser_context_getter,
net::CookieInclusionStatus returned_status;
std::unique_ptr<net::CanonicalCookie> cookie = net::CanonicalCookie::Create(
request.url, cookie_string, base::Time::Now(),
absl::make_optional(response_date), /*partition_key=*/absl::nullopt,
absl::make_optional(response_date), net::CookiePartitionKey::Todo(),
&returned_status);
if (!returned_status.IsInclude()) {
continue;
@@ -302,10 +281,9 @@ void SaveCookies(const CefBrowserContext::Getter& browser_context_getter,
if (!allowed_cookies.empty()) {
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(
SaveCookiesOnUIThread, browser_context_getter, request.url,
GetCookieOptions(request, /*for_loading_cookies=*/false),
total_count, std::move(allowed_cookies), std::move(done_callback)));
base::BindOnce(SaveCookiesOnUIThread, browser_context_getter,
request.url, GetCookieOptions(request), total_count,
std::move(allowed_cookies), std::move(done_callback)));
} else {
std::move(done_callback).Run(total_count, std::move(allowed_cookies));

View File

@@ -290,7 +290,7 @@ bool CefCookieManagerImpl::SetCookieInternal(
expiration_time,
base::Time(), // Last access time.
cookie.secure ? true : false, cookie.httponly ? true : false, same_site,
priority, /*same_party=*/false, /*partition_key=*/absl::nullopt);
priority, /*same_party=*/false, net::CookiePartitionKey::Todo());
if (!canonical_cookie) {
SetCookieCallbackImpl(

View File

@@ -236,6 +236,8 @@ class InterceptedRequest : public network::mojom::URLLoader,
OnUploadProgressCallback callback) override;
void OnReceiveCachedMetadata(mojo_base::BigBuffer data) override;
void OnTransferSizeUpdated(int32_t transfer_size_diff) override;
void OnStartLoadingResponseBody(
mojo::ScopedDataPipeConsumerHandle body) override;
void OnComplete(const network::URLLoaderCompletionStatus& status) override;
// mojom::URLLoader methods:
@@ -659,6 +661,13 @@ void InterceptedRequest::OnTransferSizeUpdated(int32_t transfer_size_diff) {
target_client_->OnTransferSizeUpdated(transfer_size_diff);
}
void InterceptedRequest::OnStartLoadingResponseBody(
mojo::ScopedDataPipeConsumerHandle body) {
target_client_->OnStartLoadingResponseBody(
factory_->request_handler_->OnFilterResponseBody(id_, request_,
std::move(body)));
}
void InterceptedRequest::OnComplete(
const network::URLLoaderCompletionStatus& status) {
// Only wait for the original loader to possibly have a custom error if the
@@ -1044,11 +1053,12 @@ void InterceptedRequest::ContinueToResponseStarted(int error_code) {
if (proxied_client_receiver_.is_bound())
proxied_client_receiver_.Resume();
target_client_->OnReceiveResponse(
std::move(current_response_),
factory_->request_handler_->OnFilterResponseBody(
id_, request_, std::move(current_body_)));
target_client_->OnReceiveResponse(std::move(current_response_),
std::move(current_body_));
}
if (stream_loader_)
stream_loader_->ContinueResponse(is_redirect);
}
void InterceptedRequest::OnDestroy() {

View File

@@ -696,23 +696,42 @@ void StreamReaderURLLoader::ContinueWithResponseHeaders(
// |this| will be deleted.
CleanUp();
} else {
mojo::ScopedDataPipeConsumerHandle consumer_handle;
if (CreateDataPipe(nullptr /*options*/, producer_handle_,
consumer_handle) != MOJO_RESULT_OK) {
RequestComplete(net::ERR_FAILED);
return;
}
writable_handle_watcher_.Watch(
producer_handle_.get(), MOJO_HANDLE_SIGNAL_WRITABLE,
base::BindRepeating(&StreamReaderURLLoader::OnDataPipeWritable,
base::Unretained(this)));
client_->OnReceiveResponse(std::move(pending_response),
std::move(consumer_handle));
ReadMore();
mojo::ScopedDataPipeConsumerHandle());
}
}
void StreamReaderURLLoader::ContinueResponse(bool was_redirected) {
DCHECK(thread_checker_.CalledOnValidThread());
if (was_redirected) {
// Special case where we allow the client to perform the redirect.
// The client will restart the request with a new loader.
// |this| will be deleted.
CleanUp();
} else {
SendBody();
}
}
void StreamReaderURLLoader::SendBody() {
DCHECK(thread_checker_.CalledOnValidThread());
mojo::ScopedDataPipeConsumerHandle consumer_handle;
if (CreateDataPipe(nullptr /*options*/, producer_handle_, consumer_handle) !=
MOJO_RESULT_OK) {
RequestComplete(net::ERR_FAILED);
return;
}
writable_handle_watcher_.Watch(
producer_handle_.get(), MOJO_HANDLE_SIGNAL_WRITABLE,
base::BindRepeating(&StreamReaderURLLoader::OnDataPipeWritable,
base::Unretained(this)));
client_->OnStartLoadingResponseBody(std::move(consumer_handle));
ReadMore();
}
void StreamReaderURLLoader::ReadMore() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(!pending_buffer_.get());

View File

@@ -126,6 +126,8 @@ class StreamReaderURLLoader : public network::mojom::URLLoader {
void Start();
void ContinueResponse(bool was_redirected);
// network::mojom::URLLoader methods:
void FollowRedirect(
const std::vector<std::string>& removed_headers,
@@ -152,6 +154,7 @@ class StreamReaderURLLoader : public network::mojom::URLLoader {
const absl::optional<std::string>& headers,
const absl::optional<GURL>& redirect_url);
void SendBody();
void ReadMore();
void OnDataPipeWritable(MojoResult result);
void OnReaderReadCompleted(int bytes_read);

View File

@@ -9,7 +9,6 @@
#include "libcef/browser/image_impl.h"
#include "libcef/browser/osr/osr_accessibility_util.h"
#include "libcef/browser/osr/render_widget_host_view_osr.h"
#include "libcef/browser/osr/touch_selection_controller_client_osr.h"
#include "libcef/browser/osr/web_contents_view_osr.h"
#include "libcef/browser/views/view_util.h"
#include "libcef/common/drag_data_impl.h"
@@ -235,13 +234,6 @@ void CefBrowserPlatformDelegateOsr::WasHidden(bool hidden) {
}
}
bool CefBrowserPlatformDelegateOsr::IsHidden() const {
CefRenderWidgetHostViewOSR* view = GetOSRHostView();
if (view)
return view->is_hidden();
return true;
}
void CefBrowserPlatformDelegateOsr::NotifyScreenInfoChanged() {
CefRenderWidgetHostViewOSR* view = GetOSRHostView();
if (view)

View File

@@ -13,7 +13,7 @@ class CefWebContentsViewOSR;
namespace content {
class RenderWidgetHostImpl;
} // namespace content
}
// Base implementation of windowless browser functionality.
class CefBrowserPlatformDelegateOsr
@@ -55,7 +55,6 @@ class CefBrowserPlatformDelegateOsr
std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
bool IsWindowless() const override;
void WasHidden(bool hidden) override;
bool IsHidden() const override;
void NotifyScreenInfoChanged() override;
void Invalidate(cef_paint_element_type_t type) override;
void SendExternalBeginFrame() override;

View File

@@ -6,12 +6,12 @@
#include "libcef/browser/osr/render_widget_host_view_osr.h"
#include <stdint.h>
#include <utility>
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
#include "libcef/browser/osr/osr_util.h"
#include "libcef/browser/osr/synthetic_gesture_target_osr.h"
#include "libcef/browser/osr/touch_selection_controller_client_osr.h"
#include "libcef/browser/osr/video_consumer_osr.h"
#include "libcef/browser/thread_util.h"
@@ -51,7 +51,6 @@
#include "ui/events/gesture_detection/motion_event.h"
#include "ui/gfx/geometry/dip_util.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/touch_selection/touch_selection_controller.h"
namespace {
@@ -180,18 +179,6 @@ ui::ImeTextSpan::UnderlineStyle GetImeUnderlineStyle(
} // namespace
// Logic copied from RenderWidgetHostViewAura::CreateSelectionController.
void CefRenderWidgetHostViewOSR::CreateSelectionController() {
ui::TouchSelectionController::Config tsc_config;
tsc_config.max_tap_duration = base::Milliseconds(
ui::GestureConfiguration::GetInstance()->long_press_time_in_ms());
tsc_config.tap_slop = ui::GestureConfiguration::GetInstance()
->max_touch_move_in_pixels_for_click();
tsc_config.enable_longpress_drag_selection = false;
selection_controller_ = std::make_unique<ui::TouchSelectionController>(
selection_controller_client_.get(), tsc_config);
}
CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
SkColor background_color,
bool use_shared_texture,
@@ -273,10 +260,6 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
if (!render_widget_host_->is_hidden())
Show();
}
selection_controller_client_ =
std::make_unique<CefTouchSelectionControllerClientOSR>(this);
CreateSelectionController();
}
CefRenderWidgetHostViewOSR::~CefRenderWidgetHostViewOSR() {
@@ -409,13 +392,8 @@ void CefRenderWidgetHostViewOSR::Hide() {
is_showing_ = false;
if (browser_impl_) {
if (browser_impl_.get())
browser_impl_->CancelContextMenu();
}
if (selection_controller_client_) {
selection_controller_client_->CloseQuickMenuAndHideHandles();
}
if (video_consumer_) {
video_consumer_->SetActive(false);
@@ -446,11 +424,6 @@ void CefRenderWidgetHostViewOSR::EnsureSurfaceSynchronizedForWebTest() {
absl::nullopt);
}
content::TouchSelectionControllerClientManager*
CefRenderWidgetHostViewOSR::GetTouchSelectionControllerClientManager() {
return selection_controller_client_.get();
}
gfx::Rect CefRenderWidgetHostViewOSR::GetViewBounds() {
if (IsPopupWidget())
return popup_position_;
@@ -975,14 +948,6 @@ void CefRenderWidgetHostViewOSR::OnRenderFrameMetadataChangedAfterActivation(
weak_ptr_factory_.GetWeakPtr()));
}
}
if (metadata.selection.start != selection_start_ ||
metadata.selection.end != selection_end_) {
selection_start_ = metadata.selection.start;
selection_end_ = metadata.selection.end;
selection_controller_client_->UpdateClientSelectionBounds(selection_start_,
selection_end_);
}
}
std::unique_ptr<viz::HostDisplayClient>
@@ -1126,10 +1091,6 @@ void CefRenderWidgetHostViewOSR::SendKeyEvent(
TRACE_EVENT0("cef", "CefRenderWidgetHostViewOSR::SendKeyEvent");
content::RenderWidgetHostImpl* target_host = render_widget_host_;
if (selection_controller_client_) {
selection_controller_client_->CloseQuickMenuAndHideHandles();
}
// If there are multiple widgets on the page (such as when there are
// out-of-process iframes), pick the one that should process this event.
if (render_widget_host_ && render_widget_host_->delegate()) {
@@ -1153,16 +1114,12 @@ void CefRenderWidgetHostViewOSR::SendMouseEvent(
const blink::WebMouseEvent& event) {
TRACE_EVENT0("cef", "CefRenderWidgetHostViewOSR::SendMouseEvent");
if (!IsPopupWidget()) {
if (browser_impl_ &&
if (browser_impl_.get() &&
event.GetType() == blink::WebMouseEvent::Type::kMouseDown &&
event.button != blink::WebPointerProperties::Button::kRight) {
browser_impl_->CancelContextMenu();
}
if (selection_controller_client_) {
selection_controller_client_->CloseQuickMenuAndHideHandles();
}
if (popup_host_view_) {
if (popup_host_view_->popup_position_.Contains(
event.PositionInWidget().x(), event.PositionInWidget().y())) {
@@ -1222,13 +1179,8 @@ void CefRenderWidgetHostViewOSR::SendMouseWheelEvent(
TRACE_EVENT0("cef", "CefRenderWidgetHostViewOSR::SendMouseWheelEvent");
if (!IsPopupWidget()) {
if (browser_impl_) {
if (browser_impl_.get())
browser_impl_->CancelContextMenu();
}
if (selection_controller_client_) {
selection_controller_client_->CloseQuickMenuAndHideHandles();
}
if (popup_host_view_) {
if (popup_host_view_->popup_position_.Contains(
@@ -1322,11 +1274,6 @@ void CefRenderWidgetHostViewOSR::SendTouchEvent(const CefTouchEvent& event) {
if (!pointer_state_.OnTouch(event))
return;
if (selection_controller_->WillHandleTouchEvent(pointer_state_)) {
pointer_state_.CleanupRemovedTouchPoints(event);
return;
}
ui::FilteredGestureProvider::TouchHandlingResult result =
gesture_provider_.OnTouchEvent(pointer_state_);
@@ -1387,13 +1334,8 @@ void CefRenderWidgetHostViewOSR::SetFocus(bool focus) {
widget->GotFocus();
widget->SetActive(true);
} else {
if (browser_impl_) {
if (browser_impl_.get())
browser_impl_->CancelContextMenu();
}
if (selection_controller_client_) {
selection_controller_client_->CloseQuickMenuAndHideHandles();
}
widget->SetActive(false);
widget->LostFocus();
@@ -1538,13 +1480,6 @@ ui::Layer* CefRenderWidgetHostViewOSR::GetRootLayer() const {
return root_layer_.get();
}
ui::TextInputType CefRenderWidgetHostViewOSR::GetTextInputType() {
if (text_input_manager_ && text_input_manager_->GetTextInputState())
return text_input_manager_->GetTextInputState()->type;
return ui::TEXT_INPUT_TYPE_NONE;
}
void CefRenderWidgetHostViewOSR::SetFrameRate() {
CefRefPtr<AlloyBrowserHostImpl> browser;
if (parent_host_view_) {

View File

@@ -32,7 +32,6 @@
#include "third_party/blink/public/mojom/widget/record_content_to_visible_time_request.mojom-forward.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/base/ime/text_input_client.h"
#include "ui/compositor/compositor.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/gesture_detection/filtered_gesture_provider.h"
@@ -48,23 +47,18 @@
#include "ui/gfx/win/window_impl.h"
#endif
namespace ui {
class TouchSelectionController;
} // namespace ui
namespace content {
class BackingStore;
class CursorManager;
class DelegatedFrameHost;
class DelegatedFrameHostClient;
class RenderWidgetHost;
class RenderWidgetHostImpl;
class RenderWidgetHostViewGuest;
class BackingStore;
class CursorManager;
} // namespace content
class CefCopyFrameGenerator;
class CefSoftwareOutputDeviceOSR;
class CefTouchSelectionControllerClientOSR;
class CefVideoConsumerOSR;
class CefWebContentsViewOSR;
@@ -124,8 +118,6 @@ class CefRenderWidgetHostViewOSR
void Hide() override;
bool IsShowing() override;
void EnsureSurfaceSynchronizedForWebTest() override;
content::TouchSelectionControllerClientManager*
GetTouchSelectionControllerClientManager() override;
gfx::Rect GetViewBounds() override;
void SetBackgroundColor(SkColor color) override;
absl::optional<SkColor> GetBackgroundColor() override;
@@ -298,18 +290,6 @@ class CefRenderWidgetHostViewOSR
// content::DelegatedFrameHostClient::InvalidateLocalSurfaceIdOnEviction.
void InvalidateLocalSurfaceId();
ui::TouchSelectionController* selection_controller() const {
return selection_controller_.get();
}
CefTouchSelectionControllerClientOSR* selection_controller_client() const {
return selection_controller_client_.get();
}
ui::TextInputType GetTextInputType();
bool is_hidden() const { return !is_showing_; }
private:
void SetFrameRate();
bool SetScreenInfo();
@@ -322,9 +302,6 @@ class CefRenderWidgetHostViewOSR
void CancelWidget();
// Helper function to create a selection controller.
void CreateSelectionController();
void OnScrollOffsetChanged();
void AddGuestHostView(CefRenderWidgetHostViewOSR* guest_host);
@@ -365,14 +342,6 @@ class CefRenderWidgetHostViewOSR
// opaqueness changes.
void UpdateBackgroundColorFromRenderer(SkColor color);
// The last selection bounds reported to the view.
gfx::SelectionBound selection_start_;
gfx::SelectionBound selection_end_;
std::unique_ptr<CefTouchSelectionControllerClientOSR>
selection_controller_client_;
std::unique_ptr<ui::TouchSelectionController> selection_controller_;
// The background color of the web content.
SkColor background_color_;

View File

@@ -1,128 +0,0 @@
// Copyright 2022 The Chromium Embedded Framework Authors.
// Portions copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/osr/touch_handle_drawable_osr.h"
#include <cmath>
#include "libcef/browser/osr/render_widget_host_view_osr.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/size.h"
namespace {
// Copied from touch_handle_drawable_aura.cc
// The distance by which a handle image is offset from the focal point (i.e.
// text baseline) downwards.
constexpr int kSelectionHandleVerticalVisualOffset = 2;
// The padding around the selection handle image can be used to extend the
// handle so that touch events near the selection handle image are
// targeted to the selection handle.
constexpr int kSelectionHandlePadding = 0;
} // namespace
int CefTouchHandleDrawableOSR::counter_ = 0;
CefTouchHandleDrawableOSR::CefTouchHandleDrawableOSR(
CefRenderWidgetHostViewOSR* rwhv)
: rwhv_(rwhv), id_(counter_++) {}
void CefTouchHandleDrawableOSR::SetEnabled(bool enabled) {
if (enabled == enabled_)
return;
enabled_ = enabled;
CefTouchHandleState touch_handle_state;
touch_handle_state.touch_handle_id = id_;
touch_handle_state.flags = CEF_THS_FLAG_ENABLED;
touch_handle_state.enabled = enabled_;
TouchHandleStateChanged(touch_handle_state);
}
void CefTouchHandleDrawableOSR::SetOrientation(
ui::TouchHandleOrientation orientation,
bool mirror_vertical,
bool mirror_horizontal) {
if (orientation == orientation_)
return;
orientation_ = orientation;
CefSize size;
auto browser = rwhv_->browser_impl();
auto handler = browser->GetClient()->GetRenderHandler();
handler->GetTouchHandleSize(
browser.get(), static_cast<cef_horizontal_alignment_t>(orientation_),
size);
const gfx::Size& image_size = gfx::Size(size.width, size.height);
int handle_width = image_size.width() + 2 * kSelectionHandlePadding;
int handle_height = image_size.height() + 2 * kSelectionHandlePadding;
relative_bounds_ =
gfx::RectF(-kSelectionHandlePadding,
kSelectionHandleVerticalVisualOffset - kSelectionHandlePadding,
handle_width, handle_height);
CefTouchHandleState touch_handle_state;
touch_handle_state.touch_handle_id = id_;
touch_handle_state.flags = CEF_THS_FLAG_ORIENTATION;
touch_handle_state.orientation =
static_cast<cef_horizontal_alignment_t>(orientation_);
touch_handle_state.mirror_vertical = mirror_vertical;
touch_handle_state.mirror_horizontal = mirror_horizontal;
TouchHandleStateChanged(touch_handle_state);
}
void CefTouchHandleDrawableOSR::SetOrigin(const gfx::PointF& position) {
if (position == origin_position_)
return;
origin_position_ = position;
CefTouchHandleState touch_handle_state;
touch_handle_state.touch_handle_id = id_;
touch_handle_state.flags = CEF_THS_FLAG_ORIGIN;
touch_handle_state.origin = {static_cast<int>(std::round(position.x())),
static_cast<int>(std::round(position.y()))};
TouchHandleStateChanged(touch_handle_state);
}
void CefTouchHandleDrawableOSR::SetAlpha(float alpha) {
if (alpha == alpha_)
return;
alpha_ = alpha;
CefTouchHandleState touch_handle_state;
touch_handle_state.touch_handle_id = id_;
touch_handle_state.flags = CEF_THS_FLAG_ALPHA;
touch_handle_state.alpha = alpha_;
TouchHandleStateChanged(touch_handle_state);
}
gfx::RectF CefTouchHandleDrawableOSR::GetVisibleBounds() const {
gfx::RectF bounds = relative_bounds_;
bounds.Offset(origin_position_.x(), origin_position_.y());
bounds.Inset(gfx::InsetsF::TLBR(
kSelectionHandlePadding,
kSelectionHandlePadding + kSelectionHandleVerticalVisualOffset,
kSelectionHandlePadding, kSelectionHandlePadding));
return bounds;
}
float CefTouchHandleDrawableOSR::GetDrawableHorizontalPaddingRatio() const {
return 0.0f;
}
void CefTouchHandleDrawableOSR::TouchHandleStateChanged(
const CefTouchHandleState& state) {
auto browser = rwhv_->browser_impl();
auto handler = browser->GetClient()->GetRenderHandler();
handler->OnTouchHandleStateChanged(browser.get(), state);
}

View File

@@ -1,59 +0,0 @@
// Copyright 2022 The Chromium Embedded Framework Authors.
// Portions copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_OSR_TOUCH_HANDLE_DRAWABLE_OSR_H_
#define CEF_LIBCEF_BROWSER_OSR_TOUCH_HANDLE_DRAWABLE_OSR_H_
#include "include/internal/cef_types_wrappers.h"
#include "base/memory/raw_ptr.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/touch_selection/touch_handle.h"
#include "ui/touch_selection/touch_handle_orientation.h"
#include "ui/touch_selection/ui_touch_selection_export.h"
class CefRenderWidgetHostViewOSR;
// Copied from TouchHandleDrawableAura.
class CefTouchHandleDrawableOSR : public ui::TouchHandleDrawable {
public:
explicit CefTouchHandleDrawableOSR(CefRenderWidgetHostViewOSR* rwhv);
CefTouchHandleDrawableOSR(const CefTouchHandleDrawableOSR&) = delete;
CefTouchHandleDrawableOSR& operator=(const CefTouchHandleDrawableOSR&) =
delete;
private:
// TouchHandleDrawable:
void SetEnabled(bool enabled) override;
void SetOrientation(ui::TouchHandleOrientation orientation,
bool mirror_vertical,
bool mirror_horizontal) override;
void SetOrigin(const gfx::PointF& position) override;
void SetAlpha(float alpha) override;
gfx::RectF GetVisibleBounds() const override;
float GetDrawableHorizontalPaddingRatio() const override;
// Pass the current touch handle state to the CefRenderHandler.
void TouchHandleStateChanged(const CefTouchHandleState& state);
raw_ptr<CefRenderWidgetHostViewOSR> rwhv_;
float alpha_ = 0.f;
static int counter_;
bool enabled_ = false;
int id_;
ui::TouchHandleOrientation orientation_ =
ui::TouchHandleOrientation::UNDEFINED;
// Origin position of the handle set via SetOrigin, in coordinate space of
// selection controller client (i.e. handle's parent).
gfx::PointF origin_position_;
// Handle bounds relative to the focal position.
gfx::RectF relative_bounds_ = gfx::RectF(0.0F, 0.0F, 24.0F, 24.0F);
};
#endif

View File

@@ -1,525 +0,0 @@
// Copyright 2022 The Chromium Embedded Framework Authors.
// Portions copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/browser/osr/touch_selection_controller_client_osr.h"
#include <cmath>
#include <set>
#include "libcef/browser/osr/render_widget_host_view_osr.h"
#include "libcef/browser/osr/touch_handle_drawable_osr.h"
#include "base/bind.h"
#include "content/browser/renderer_host/render_widget_host_delegate.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/public/browser/context_menu_params.h"
#include "content/public/browser/render_view_host.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/data_transfer_policy/data_transfer_endpoint.h"
#include "ui/base/pointer/touch_editing_controller.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/size_conversions.h"
namespace {
// Delay before showing the quick menu, in milliseconds.
constexpr int kQuickMenuDelayInMs = 100;
constexpr cef_quick_menu_edit_state_flags_t kMenuCommands[] = {
QM_EDITFLAG_CAN_ELLIPSIS, QM_EDITFLAG_CAN_CUT, QM_EDITFLAG_CAN_COPY,
QM_EDITFLAG_CAN_PASTE};
constexpr int kInvalidCommandId = -1;
constexpr cef_event_flags_t kEmptyEventFlags =
static_cast<cef_event_flags_t>(0);
class CefRunQuickMenuCallbackImpl : public CefRunQuickMenuCallback {
public:
using Callback = base::OnceCallback<void(int, int)>;
explicit CefRunQuickMenuCallbackImpl(Callback callback)
: callback_(std::move(callback)) {}
CefRunQuickMenuCallbackImpl(const CefRunQuickMenuCallbackImpl&) = delete;
CefRunQuickMenuCallbackImpl& operator=(const CefRunQuickMenuCallbackImpl&) =
delete;
~CefRunQuickMenuCallbackImpl() {
if (!callback_.is_null()) {
// The callback is still pending. Cancel it now.
if (CEF_CURRENTLY_ON_UIT()) {
RunNow(std::move(callback_), kInvalidCommandId, kEmptyEventFlags);
} else {
CEF_POST_TASK(CEF_UIT,
base::BindOnce(&CefRunQuickMenuCallbackImpl::RunNow,
std::move(callback_), kInvalidCommandId,
kEmptyEventFlags));
}
}
}
void Continue(int command_id, cef_event_flags_t event_flags) override {
if (CEF_CURRENTLY_ON_UIT()) {
if (!callback_.is_null()) {
RunNow(std::move(callback_), command_id, event_flags);
}
} else {
CEF_POST_TASK(CEF_UIT,
base::BindOnce(&CefRunQuickMenuCallbackImpl::Continue, this,
command_id, event_flags));
}
}
void Cancel() override { Continue(kInvalidCommandId, kEmptyEventFlags); }
void Disconnect() { callback_.Reset(); }
private:
static void RunNow(Callback callback,
int command_id,
cef_event_flags_t event_flags) {
CEF_REQUIRE_UIT();
std::move(callback).Run(command_id, event_flags);
}
Callback callback_;
IMPLEMENT_REFCOUNTING(CefRunQuickMenuCallbackImpl);
};
} // namespace
CefTouchSelectionControllerClientOSR::CefTouchSelectionControllerClientOSR(
CefRenderWidgetHostViewOSR* rwhv)
: rwhv_(rwhv),
internal_client_(rwhv),
active_client_(&internal_client_),
active_menu_client_(this),
quick_menu_timer_(
FROM_HERE,
base::Milliseconds(kQuickMenuDelayInMs),
base::BindRepeating(
&CefTouchSelectionControllerClientOSR::ShowQuickMenu,
base::Unretained(this))),
weak_ptr_factory_(this) {
DCHECK(rwhv_);
}
CefTouchSelectionControllerClientOSR::~CefTouchSelectionControllerClientOSR() {
for (auto& observer : observers_)
observer.OnManagerWillDestroy(this);
}
void CefTouchSelectionControllerClientOSR::CloseQuickMenuAndHideHandles() {
CloseQuickMenu();
rwhv_->selection_controller()->HideAndDisallowShowingAutomatically();
}
void CefTouchSelectionControllerClientOSR::OnWindowMoved() {
UpdateQuickMenu();
}
void CefTouchSelectionControllerClientOSR::OnTouchDown() {
touch_down_ = true;
UpdateQuickMenu();
}
void CefTouchSelectionControllerClientOSR::OnTouchUp() {
touch_down_ = false;
UpdateQuickMenu();
}
void CefTouchSelectionControllerClientOSR::OnScrollStarted() {
scroll_in_progress_ = true;
rwhv_->selection_controller()->SetTemporarilyHidden(true);
UpdateQuickMenu();
}
void CefTouchSelectionControllerClientOSR::OnScrollCompleted() {
scroll_in_progress_ = false;
active_client_->DidScroll();
rwhv_->selection_controller()->SetTemporarilyHidden(false);
UpdateQuickMenu();
}
bool CefTouchSelectionControllerClientOSR::HandleContextMenu(
const content::ContextMenuParams& params) {
if ((params.source_type == ui::MENU_SOURCE_LONG_PRESS ||
params.source_type == ui::MENU_SOURCE_LONG_TAP) &&
params.is_editable && params.selection_text.empty() &&
IsQuickMenuAvailable()) {
quick_menu_requested_ = true;
UpdateQuickMenu();
return true;
}
const bool from_touch = params.source_type == ui::MENU_SOURCE_LONG_PRESS ||
params.source_type == ui::MENU_SOURCE_LONG_TAP ||
params.source_type == ui::MENU_SOURCE_TOUCH;
if (from_touch && !params.selection_text.empty())
return true;
rwhv_->selection_controller()->HideAndDisallowShowingAutomatically();
return false;
}
void CefTouchSelectionControllerClientOSR::DidStopFlinging() {
OnScrollCompleted();
}
void CefTouchSelectionControllerClientOSR::UpdateClientSelectionBounds(
const gfx::SelectionBound& start,
const gfx::SelectionBound& end) {
UpdateClientSelectionBounds(start, end, &internal_client_, this);
}
void CefTouchSelectionControllerClientOSR::UpdateClientSelectionBounds(
const gfx::SelectionBound& start,
const gfx::SelectionBound& end,
ui::TouchSelectionControllerClient* client,
ui::TouchSelectionMenuClient* menu_client) {
if (client != active_client_ &&
(start.type() == gfx::SelectionBound::EMPTY || !start.visible()) &&
(end.type() == gfx::SelectionBound::EMPTY || !end.visible()) &&
(manager_selection_start_.type() != gfx::SelectionBound::EMPTY ||
manager_selection_end_.type() != gfx::SelectionBound::EMPTY)) {
return;
}
active_client_ = client;
active_menu_client_ = menu_client;
manager_selection_start_ = start;
manager_selection_end_ = end;
// Notify TouchSelectionController if anything should change here. Only
// update if the client is different and not making a change to empty, or
// is the same client.
GetTouchSelectionController()->OnSelectionBoundsChanged(start, end);
}
void CefTouchSelectionControllerClientOSR::InvalidateClient(
ui::TouchSelectionControllerClient* client) {
DCHECK(client != &internal_client_);
if (client == active_client_) {
active_client_ = &internal_client_;
active_menu_client_ = this;
}
}
ui::TouchSelectionController*
CefTouchSelectionControllerClientOSR::GetTouchSelectionController() {
return rwhv_->selection_controller();
}
void CefTouchSelectionControllerClientOSR::AddObserver(
TouchSelectionControllerClientManager::Observer* observer) {
observers_.AddObserver(observer);
}
void CefTouchSelectionControllerClientOSR::RemoveObserver(
TouchSelectionControllerClientManager::Observer* observer) {
observers_.RemoveObserver(observer);
}
bool CefTouchSelectionControllerClientOSR::IsQuickMenuAvailable() const {
DCHECK(active_menu_client_);
const auto is_enabled = [this](cef_quick_menu_edit_state_flags_t command) {
return active_menu_client_->IsCommandIdEnabled(command);
};
return std::any_of(std::cbegin(kMenuCommands), std::cend(kMenuCommands),
is_enabled);
}
void CefTouchSelectionControllerClientOSR::CloseQuickMenu() {
if (!quick_menu_running_)
return;
quick_menu_running_ = false;
auto browser = rwhv_->browser_impl();
if (auto handler = browser->client()->GetContextMenuHandler()) {
handler->OnQuickMenuDismissed(browser.get(), browser->GetFocusedFrame());
}
}
void CefTouchSelectionControllerClientOSR::ShowQuickMenu() {
auto browser = rwhv_->browser_impl();
if (auto handler = browser->client()->GetContextMenuHandler()) {
gfx::RectF rect =
rwhv_->selection_controller()->GetVisibleRectBetweenBounds();
gfx::PointF origin = rect.origin();
gfx::PointF bottom_right = rect.bottom_right();
auto client_bounds = gfx::RectF(rwhv_->GetViewBounds());
origin.SetToMax(client_bounds.origin());
bottom_right.SetToMin(client_bounds.bottom_right());
if (origin.x() > bottom_right.x() || origin.y() > bottom_right.y())
return;
gfx::Vector2dF diagonal = bottom_right - origin;
gfx::SizeF size(diagonal.x(), diagonal.y());
int quickmenuflags = 0;
for (const auto& command : kMenuCommands) {
if (active_menu_client_->IsCommandIdEnabled(command)) {
quickmenuflags |= command;
}
}
CefRefPtr<CefRunQuickMenuCallbackImpl> callbackImpl(
new CefRunQuickMenuCallbackImpl(base::BindOnce(
&CefTouchSelectionControllerClientOSR::ExecuteCommand,
weak_ptr_factory_.GetWeakPtr())));
quick_menu_running_ = true;
if (!handler->RunQuickMenu(
browser, browser->GetFocusedFrame(),
{static_cast<int>(std::round(origin.x())),
static_cast<int>(std::round(origin.y()))},
{static_cast<int>(std::round(size.width())),
static_cast<int>(std::round(size.height()))},
static_cast<CefContextMenuHandler::QuickMenuEditStateFlags>(
quickmenuflags),
callbackImpl)) {
callbackImpl->Disconnect();
CloseQuickMenu();
}
}
}
void CefTouchSelectionControllerClientOSR::UpdateQuickMenu() {
// Hide the quick menu if there is any. This should happen even if the menu
// should be shown again, in order to update its location or content.
if (quick_menu_running_) {
CloseQuickMenu();
} else {
quick_menu_timer_.Stop();
}
// Start timer to show quick menu if necessary.
if (ShouldShowQuickMenu()) {
quick_menu_timer_.Reset();
}
}
bool CefTouchSelectionControllerClientOSR::SupportsAnimation() const {
return false;
}
bool CefTouchSelectionControllerClientOSR::InternalClient::SupportsAnimation()
const {
NOTREACHED();
return false;
}
void CefTouchSelectionControllerClientOSR::SetNeedsAnimate() {
NOTREACHED();
}
void CefTouchSelectionControllerClientOSR::InternalClient::SetNeedsAnimate() {
NOTREACHED();
}
void CefTouchSelectionControllerClientOSR::MoveCaret(
const gfx::PointF& position) {
active_client_->MoveCaret(position);
}
void CefTouchSelectionControllerClientOSR::InternalClient::MoveCaret(
const gfx::PointF& position) {
if (auto host_delegate = rwhv_->host()->delegate()) {
host_delegate->MoveCaret(gfx::ToRoundedPoint(position));
}
}
void CefTouchSelectionControllerClientOSR::MoveRangeSelectionExtent(
const gfx::PointF& extent) {
active_client_->MoveRangeSelectionExtent(extent);
}
void CefTouchSelectionControllerClientOSR::InternalClient::
MoveRangeSelectionExtent(const gfx::PointF& extent) {
if (auto host_delegate = rwhv_->host()->delegate()) {
host_delegate->MoveRangeSelectionExtent(gfx::ToRoundedPoint(extent));
}
}
void CefTouchSelectionControllerClientOSR::SelectBetweenCoordinates(
const gfx::PointF& base,
const gfx::PointF& extent) {
active_client_->SelectBetweenCoordinates(base, extent);
}
void CefTouchSelectionControllerClientOSR::InternalClient::
SelectBetweenCoordinates(const gfx::PointF& base,
const gfx::PointF& extent) {
if (auto host_delegate = rwhv_->host()->delegate()) {
host_delegate->SelectRange(gfx::ToRoundedPoint(base),
gfx::ToRoundedPoint(extent));
}
}
void CefTouchSelectionControllerClientOSR::OnSelectionEvent(
ui::SelectionEventType event) {
// This function (implicitly) uses active_menu_client_, so we don't go to the
// active view for this.
switch (event) {
case ui::SELECTION_HANDLES_SHOWN:
quick_menu_requested_ = true;
[[fallthrough]];
case ui::INSERTION_HANDLE_SHOWN:
UpdateQuickMenu();
break;
case ui::SELECTION_HANDLES_CLEARED:
case ui::INSERTION_HANDLE_CLEARED:
quick_menu_requested_ = false;
UpdateQuickMenu();
break;
case ui::SELECTION_HANDLE_DRAG_STARTED:
case ui::INSERTION_HANDLE_DRAG_STARTED:
handle_drag_in_progress_ = true;
UpdateQuickMenu();
break;
case ui::SELECTION_HANDLE_DRAG_STOPPED:
case ui::INSERTION_HANDLE_DRAG_STOPPED:
handle_drag_in_progress_ = false;
UpdateQuickMenu();
break;
case ui::SELECTION_HANDLES_MOVED:
case ui::INSERTION_HANDLE_MOVED:
UpdateQuickMenu();
break;
case ui::INSERTION_HANDLE_TAPPED:
quick_menu_requested_ = !quick_menu_requested_;
UpdateQuickMenu();
break;
}
}
void CefTouchSelectionControllerClientOSR::InternalClient::OnSelectionEvent(
ui::SelectionEventType event) {
NOTREACHED();
}
void CefTouchSelectionControllerClientOSR::OnDragUpdate(
const ui::TouchSelectionDraggable::Type type,
const gfx::PointF& position) {}
void CefTouchSelectionControllerClientOSR::InternalClient::OnDragUpdate(
const ui::TouchSelectionDraggable::Type type,
const gfx::PointF& position) {
NOTREACHED();
}
std::unique_ptr<ui::TouchHandleDrawable>
CefTouchSelectionControllerClientOSR::CreateDrawable() {
return std::make_unique<CefTouchHandleDrawableOSR>(rwhv_);
}
void CefTouchSelectionControllerClientOSR::DidScroll() {}
std::unique_ptr<ui::TouchHandleDrawable>
CefTouchSelectionControllerClientOSR::InternalClient::CreateDrawable() {
NOTREACHED();
return nullptr;
}
void CefTouchSelectionControllerClientOSR::InternalClient::DidScroll() {
NOTREACHED();
}
bool CefTouchSelectionControllerClientOSR::IsCommandIdEnabled(
int command_id) const {
bool editable = rwhv_->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE;
bool readable = rwhv_->GetTextInputType() != ui::TEXT_INPUT_TYPE_PASSWORD;
bool has_selection = !rwhv_->GetSelectedText().empty();
switch (command_id) {
case QM_EDITFLAG_CAN_ELLIPSIS:
return true; // Always allowed to show the ellipsis button.
case QM_EDITFLAG_CAN_CUT:
return editable && readable && has_selection;
case QM_EDITFLAG_CAN_COPY:
return readable && has_selection;
case QM_EDITFLAG_CAN_PASTE: {
std::u16string result;
ui::DataTransferEndpoint data_dst = ui::DataTransferEndpoint(
ui::EndpointType::kDefault, /*notify_if_restricted=*/false);
ui::Clipboard::GetForCurrentThread()->ReadText(
ui::ClipboardBuffer::kCopyPaste, &data_dst, &result);
return editable && !result.empty();
}
default:
return false;
}
}
void CefTouchSelectionControllerClientOSR::ExecuteCommand(int command_id,
int event_flags) {
if (command_id == kInvalidCommandId) {
return;
}
if (command_id != QM_EDITFLAG_CAN_ELLIPSIS) {
rwhv_->selection_controller()->HideAndDisallowShowingAutomatically();
}
content::RenderWidgetHostDelegate* host_delegate = rwhv_->host()->delegate();
if (!host_delegate) {
return;
}
auto browser = rwhv_->browser_impl();
if (auto handler = browser->client()->GetContextMenuHandler()) {
if (handler->OnQuickMenuCommand(
browser.get(), browser->GetFocusedFrame(), command_id,
static_cast<cef_event_flags_t>(event_flags))) {
return;
}
}
switch (command_id) {
case QM_EDITFLAG_CAN_CUT:
host_delegate->Cut();
break;
case QM_EDITFLAG_CAN_COPY:
host_delegate->Copy();
break;
case QM_EDITFLAG_CAN_PASTE:
host_delegate->Paste();
break;
case QM_EDITFLAG_CAN_ELLIPSIS:
CloseQuickMenu();
RunContextMenu();
break;
default:
// Invalid command, do nothing.
// Also reached when callback is destroyed/cancelled.
break;
}
}
void CefTouchSelectionControllerClientOSR::RunContextMenu() {
const gfx::RectF anchor_rect =
rwhv_->selection_controller()->GetVisibleRectBetweenBounds();
const gfx::PointF anchor_point =
gfx::PointF(anchor_rect.CenterPoint().x(), anchor_rect.y());
rwhv_->host()->ShowContextMenuAtPoint(gfx::ToRoundedPoint(anchor_point),
ui::MENU_SOURCE_TOUCH_EDIT_MENU);
// Hide selection handles after getting rect-between-bounds from touch
// selection controller; otherwise, rect would be empty and the above
// calculations would be invalid.
rwhv_->selection_controller()->HideAndDisallowShowingAutomatically();
}
bool CefTouchSelectionControllerClientOSR::ShouldShowQuickMenu() {
return quick_menu_requested_ && !touch_down_ && !scroll_in_progress_ &&
!handle_drag_in_progress_ && IsQuickMenuAvailable();
}
std::u16string CefTouchSelectionControllerClientOSR::GetSelectedText() {
return rwhv_->GetSelectedText();
}

Some files were not shown because too many files have changed in this diff Show More