Compare commits

..

48 Commits
5060 ... 5112

Author SHA1 Message Date
Marshall Greenblatt
4180781f54 alloy: Fix crashes related to permissions checks (fixes issue #3379, fixes issue #3381) 2022-08-26 16:04:32 -04:00
Marshall Greenblatt
d80d4671c3 Fix same-site calculation for saving cookies from intercepted responses
This fixes an issue where authentication cookies from SAML responses were not
being saved.
2022-08-19 12:40:15 -04:00
Marshall Greenblatt
df482f6b12 Fix crashes with PrintToPDF (fixes issue #3373)
- Configure the DPI setting (see https://crrev.com/40e28bcba3)
- Call StopWorker on the UI thread (see https://crrev.com/564fa1d8a4)
2022-08-18 12:34:05 -04:00
Marshall Greenblatt
46ae630452 Update to Chromium version 104.0.5112.102 2022-08-17 15:37:25 +00:00
Marshall Greenblatt
181df42df2 alloy: Fix flaky OnDraggableRegionsChanged behavior (fixes issue #3374)
Disable BackForwardCache globally for the Alloy runtime so that
blink::RuntimeEnabledFeatures::BackForwardCacheEnabled reports the
correct value in the renderer process.
2022-08-11 17:39:13 -04:00
Marshall Greenblatt
69bf4a73da Fix DisplayTest.AutoResize failure 2022-08-11 17:39:07 -04:00
Marshall Greenblatt
bdfed81c70 Fix DOMTest failure related to device scaling 2022-08-11 17:39:01 -04:00
Marshall Greenblatt
47dab09c5e Fix browser focus assignment on mouse click (fixes issue #3306)
DesktopWindowTreeHostWin ("Chrome_WidgetWin_0") focus needs to be set before
the associated call to WebContents::Focus. In the case of mouse click events,
this means ::SetFocus needs to be called explicitly. See updated comments in
CefBrowserPlatformDelegateNativeWin::SetFocus.
2022-08-10 14:39:20 -04:00
Marshall Greenblatt
2587cf23c5 Fix issues with browser focus assignment (fixes issue #3306, fixes issue #3166, see issue #3040)
DesktopWindowTreeHostWin ("Chrome_WidgetWin_0") focus needs to be set
synchronously in response to the parent window WM_SETFOCUS message and
before the associated call to WebContents::Focus. See updated comments in
CefBrowserPlatformDelegateNativeWin::SetFocus.
2022-08-05 15:25:10 -04:00
Marshall Greenblatt
75c6895fb5 windows: cefclient: Fix crash when triggering IME popup (see issue #3313) 2022-08-05 15:25:04 -04:00
Marshall Greenblatt
e4239b9373 Update to Chromium version 104.0.5112.81 2022-08-02 13:39:39 +00:00
Marshall Greenblatt
12fbff866e Update to Chromium version 104.0.5112.65 2022-07-28 14:00:24 +00:00
Marshall Greenblatt
8c9bbb1a73 windows: Fix Views test failures (fixes issue #3365) 2022-07-27 14:24:53 -04:00
Marshall Greenblatt
44748db484 windows: Fix ARM64 v8:run_mksnapshot_default build failure (see https://crbug.com/1344759) 2022-07-21 10:56:24 -04:00
Marshall Greenblatt
269879747d Update to Chromium version 104.0.5112.57 2022-07-21 13:33:42 +00:00
Marshall Greenblatt
43181176cf windows: Fix warning C4267 conversion from 'size_t' to 'int' (see issue #3126) 2022-07-19 10:11:10 -04:00
Marshall Greenblatt
5d82749377 Add missing newline at end of file (see issue #3126) 2022-07-19 10:11:02 -04:00
Nik Pavlov
8c5d64ce83 Fix compilation errors from shared message unit tests (see issue #3126) 2022-07-19 10:10:56 -04:00
Marshall Greenblatt
418ae98476 alloy: win: Focus the browser after dismissal of a modal dialog (fixes issue #3361) 2022-07-15 14:08:12 +03:00
Marshall Greenblatt
dac76df7e3 Update to Chromium version 104.0.5112.48 2022-07-14 07:58:07 +00:00
Marshall Greenblatt
ca90a945cc Don't copy dbghelp.dll/dbgcore.dll from the Windows SDK (fixes issue #3356) 2022-07-13 13:47:48 +03:00
Marshall Greenblatt
3f98be4c95 Increase frame reconnect timeout to 10 seconds (see issue #3260) 2022-07-13 12:18:16 +03:00
Marshall Greenblatt
b195ddd4a8 alloy: Mac: Fix crash related to geolocation permissions (see issue #3352) 2022-07-08 14:45:01 +03:00
Marshall Greenblatt
1724b57845 Update libcef_dll_dylib.cc for compiler deduce types 2022-07-08 14:44:52 +03:00
Sergey Markelov
f8ce93ba3c libcef_dll/wrapper: Let the compiler deduce types of func ptr 2022-07-08 14:44:46 +03:00
Marshall Greenblatt
64a5754959 chrome: Add support for OnRequestMediaAccessPermission callback (see issue #2582) 2022-07-08 10:42:36 +03:00
Marshall Greenblatt
d9a7422346 Add CefPermissionHandler callbacks for permission prompts (see issue #3352) 2022-07-08 10:42:35 +03:00
Marshall Greenblatt
4a7583d5d3 Update to Chromium version 104.0.5112.39 2022-07-08 07:32:27 +00:00
Nik Pavlov
3dc9464583 Add a shared memory variant of CefProcessMessage (fixes issue #3126)
CefSharedProcessMessageBuilder supports creation of a CefProcessMessage
backed by a CefSharedMemoryRegion.

Performance tests comparing the existing ArgumentList approach and the new
SharedMemoryRegion approach have been added to cefclient at
http://tests/ipc_performance.

CefMessageRouter has been updated to use SharedMemoryRegion as transport
for larger message payloads. The threshold is configurable via
|CefMessageRouterConfig.message_size_threshold|.

To test:
run `ceftests --gtest_filter=SendSharedProcessMessageTest.*:SharedProcessMessageTest.*:MessageRouterTest.Threshold*`
2022-07-04 12:55:03 +03:00
Jelle Bleyaert
608df0a86d Fix duplicate symbol error on MakeVisibleOnScreenRect (fixes issue #3353) 2022-07-01 17:16:27 +03:00
Marshall Greenblatt
521546d6b7 Add OnMediaAccessChange notification (fixes issue #3310) 2022-06-30 16:02:18 +03:00
Nik Pavlov
e34e9142ee Use nothrow new when allocating memory for zip file data 2022-06-30 16:02:18 +03:00
Marshall Greenblatt
85bda40d95 Add CefPermissionHandler callback for media access (fixes issue #2582) 2022-06-30 16:02:18 +03:00
Nik Pavlov
c05cb73de1 alloy: mac: Fix default popup window positioning (see issue #3244)
Popup windows will be created on the display that best matches the requested
coordinates. The requested size will apply to the content area (as required by
JS documentation) and window size will be reduced if necessary to fit within the
target display. The requested origin will apply to the window (including frame)
and will be modified if necessary so that the window is fully visible on the
target display.

This change does not implement popup positioning for cefclient which uses an
application-created parent window.

This change grants access to the getScreenDetails JS API without user prompt.
2022-06-30 16:02:18 +03:00
Marshall Greenblatt
fb71a32356 Update to Chromium version 104.0.5112.29 2022-06-30 07:30:08 +00:00
Marshall Greenblatt
6250f07099 Update to Chromium version 104.0.5112.20 2022-06-29 10:39:50 +00:00
Marshall Greenblatt
1eff0baf94 Windows: Fix AssertBlockingAllowed failure in GetAzureADJoinStateStorage (fixes issue #3342) 2022-06-23 14:00:21 +03:00
Marshall Greenblatt
335922b64d Update to Chromium version 104.0.5112.12 2022-06-23 11:22:04 +03:00
Marshall Greenblatt
95373bb042 Windows: Fix unresolved symbol for cef_sandbox build 2022-06-23 11:20:39 +03:00
Marshall Greenblatt
ec8076536e Fix timing issue with OnDraggableRegionsChanged
When bfcache is disabled use the RenderFrameObserver::DidFinishLoad notification
instead of the DidStopLoading notification that originates from the browser
process. During fast navigation the DidStopLoading notification may arrive in
the renderer after a new navigation has commenced and cause the wrong regions to
be reported.
2022-06-22 18:57:52 +03:00
Marshall Greenblatt
100b457743 Windows: Fix time_win.cc compile error with cef_sandbox 2022-06-22 11:17:06 +03:00
Marshall Greenblatt
c7ea0c5958 Update to Chromium version 104.0.5112.0 (#1012729)
- Mac: 10.13 is now the minimum required macOS version
2022-06-22 10:56:35 +03:00
Marshall Greenblatt
35654cd709 alloy: Use Chrome JS dialogs on Windows/Linux (fixes issue #3316) 2022-06-03 22:45:23 +03:00
Marshall Greenblatt
b5eba89598 cefclient: Linux: Fix OSR context menu placement (see issue #2640)
This only fixes the top-level menu placement. Sub-menus are still
placed incorrectly.
2022-06-03 22:45:10 +03:00
JohnKarel
d9b764860a alloy: Add touch handle and quick menu support for OSR (fixes issue #3268)
The client is responsible for rendering both as no default implementation
is currently available for OSR.
2022-05-30 10:51:39 +03:00
Marshall Greenblatt
771e5c7c0c ceftests: Replace unicode characters with encoded equivalent 2022-05-30 10:26:12 +03:00
Marshall Greenblatt
464efb1162 Call OnResourceRedirect for internal network service redirects (fixes issue #3336) 2022-05-25 16:43:30 +03:00
Marshall Greenblatt
ee15eca351 ceftests: Minor code cleanup 2022-05-25 16:42:41 +03:00
286 changed files with 12438 additions and 3300 deletions

View File

@@ -373,6 +373,8 @@ 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 = [
@@ -389,6 +391,7 @@ source_set("libcef_static_unittested") {
test("libcef_static_unittests") {
sources = [
"libcef/browser/devtools/devtools_util_unittest.cc",
"libcef/browser/screen_util_unittest.cc",
]
deps = [
@@ -416,8 +419,16 @@ 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",
@@ -564,6 +575,8 @@ 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",
@@ -576,6 +589,8 @@ 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",
@@ -636,11 +651,17 @@ 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",
@@ -649,8 +670,6 @@ 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",
@@ -734,8 +753,6 @@ 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",
@@ -797,6 +814,8 @@ 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",
@@ -1020,8 +1039,6 @@ 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",
]
@@ -1639,7 +1656,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.
@@ -2243,7 +2260,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/103.0.5060.134',
'depot_tools_checkout': '964f8124b6'
'chromium_checkout': 'refs/tags/104.0.5112.102',
'depot_tools_checkout': '350d210871'
}

View File

@@ -8,7 +8,7 @@
# by hand. See the translator.README.txt file in the tools directory for
# more information.
#
# $hash=5f2e9bf79ec768c0eb978ff5e1dd0178701dcc21$
# $hash=3ed1afd1b5f881884e6cfd0186fe41bb7b19fd38$
#
{
@@ -55,6 +55,7 @@
'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',
@@ -74,6 +75,8 @@
'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',
@@ -154,6 +157,7 @@
'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',
@@ -173,6 +177,8 @@
'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',
@@ -328,6 +334,8 @@
'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',
@@ -364,6 +372,10 @@
'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',
@@ -416,6 +428,8 @@
'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',
@@ -434,6 +448,10 @@
'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',
@@ -634,6 +652,8 @@
'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',
@@ -670,6 +690,10 @@
'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',
@@ -722,6 +746,8 @@
'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',
@@ -740,6 +766,10 @@
'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,6 +177,8 @@
'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',
@@ -289,6 +291,8 @@
'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',
@@ -298,6 +302,7 @@
'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',
@@ -475,13 +480,20 @@
'tests/ceftests/image_util.h',
'tests/ceftests/jsdialog_unittest.cc',
'tests/ceftests/life_span_unittest.cc',
'tests/ceftests/message_router_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/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',
@@ -498,6 +510,8 @@
'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',
@@ -562,9 +576,16 @@
'tests/ceftests/cors_unittest.cc',
'tests/ceftests/dom_unittest.cc',
'tests/ceftests/frame_unittest.cc',
'tests/ceftests/message_router_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/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',
@@ -574,6 +595,8 @@
'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 10.12 10.11)
foreach(OS_VERSION 10.15 10.14 10.13)
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.11")
set(CEF_TARGET_SDK "10.13")
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=7df3c13b75072c2ad5061cd3a344811222798903$
// $hash=03ae4ba9762510e2b0c19ea29322c20ebaf2e683$
//
#ifndef CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
@@ -55,6 +55,7 @@
#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"
@@ -139,6 +140,12 @@ 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=d007b3dc26f3f049bf67623da8fae59dc75a193b$
// $hash=d9498ae2e32ec124df3dd2c3017bcf415d4205f8$
//
#ifndef CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_
@@ -74,6 +74,29 @@ 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.
@@ -133,16 +156,56 @@ typedef struct _cef_context_menu_handler_t {
///
// Called when the context menu is dismissed irregardless of whether the menu
// was NULL or a command was selected.
// was canceled 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 ethods of this
// Provides information about the context menu state. The functions 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=142637539a094a03adc71d2f3f5b711ba64918b1$
// $hash=5e52ae520b7eda3595683d428aa578bbc776956b$
//
#ifndef CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_
@@ -154,6 +154,16 @@ 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=c6de3fb4d64a2b2ad06a4b9c5e9d7625d40b5bb6$
// $hash=ddff4ad975fc26d0abfe05799aedb597b8274ffd$
//
#ifndef CEF_INCLUDE_CAPI_CEF_DOM_CAPI_H_
@@ -335,7 +335,8 @@ typedef struct _cef_domnode_t {
struct _cef_domnode_t* self);
///
// Returns the bounds of the element.
// Returns the bounds of the element in device pixels. Use
// "window.devicePixelRatio" to convert to/from CSS pixels.
///
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=c68332a779bab425aa2e6a858d20a43448631890$
// $hash=942579315e4b8c0819cd2b06becb93670310cd09$
//
#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 default implementation dialog is closed.
// Called when the dialog is closed.
///
void(CEF_CALLBACK* on_dialog_closed)(struct _cef_jsdialog_handler_t* self,
struct _cef_browser_t* browser);

View File

@@ -0,0 +1,108 @@
// 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

@@ -0,0 +1,162 @@
// 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=2549ea10cd3a41bc04ab81bad24eb12787de68b9$
// $hash=026a7f827962222a1df8b62a8e7bdfbf4dce27e0$
//
#ifndef CEF_INCLUDE_CAPI_CEF_PROCESS_MESSAGE_CAPI_H_
@@ -41,6 +41,7 @@
#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
@@ -69,7 +70,8 @@ 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 a writable copy of this object. Returns nullptr when message
// contains a shared memory region.
///
struct _cef_process_message_t*(CEF_CALLBACK* copy)(
struct _cef_process_message_t* self);
@@ -82,10 +84,18 @@ typedef struct _cef_process_message_t {
struct _cef_process_message_t* self);
///
// Returns the list of arguments.
// Returns the list of arguments. Returns nullptr when message contains a
// shared memory region.
///
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=7fc75c41ce47a5e715471b9bb82c848d6cf25472$
// $hash=b0688a7d24b67b74a62841be60217a8e48c7228e$
//
#ifndef CEF_INCLUDE_CAPI_CEF_RENDER_HANDLER_CAPI_H_
@@ -161,6 +161,25 @@ 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

@@ -0,0 +1,79 @@
// 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

@@ -0,0 +1,101 @@
// 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=6a8166eca76513b59a4f6355f4f765dc1d77e4ee$
// $hash=a75487288913e4646f67ee8aded4bc9ef328bb79$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_DELEGATE_CAPI_H_
@@ -49,9 +49,10 @@ extern "C" {
struct _cef_view_t;
///
// Implement this structure to handle view events. The functions of this
// structure will be called on the browser process UI thread unless otherwise
// indicated.
// 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.
///
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 "b6255e15aa977a7214cf28e4e1a2372b454838d4"
#define CEF_API_HASH_UNIVERSAL "1f35577ebd00c5e6cc03a172bb41e3c0d820f3d1"
#if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "b262c3a2cbd2632de1bfed887da8b8114c9ecbf5"
#define CEF_API_HASH_PLATFORM "99f91193dce6b93011526269c4dc5d0c32569b70"
#elif defined(OS_MAC)
#define CEF_API_HASH_PLATFORM "fd6d3d83442fe31ad26d5648755e0cf2e14a7fc7"
#define CEF_API_HASH_PLATFORM "316e120c0bf151de8145ee3b45ef3451e1ff60dc"
#elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "d686964de5e01eed900d78d5f8a7da9f8fc3a777"
#define CEF_API_HASH_PLATFORM "e061aecbfbf09b9068391bdfcd80c9d5ed1faece"
#endif
#ifdef __cplusplus

View File

@@ -53,6 +53,7 @@
#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"
@@ -132,6 +133,14 @@ 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,14 +51,12 @@ 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, EventFlags event_flags) = 0;
virtual void Continue(int command_id, cef_event_flags_t event_flags) = 0;
///
// Cancel context menu display.
@@ -67,6 +65,26 @@ 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.
@@ -75,6 +93,7 @@ class CefRunContextMenuCallback : 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
@@ -126,15 +145,55 @@ class CefContextMenuHandler : public virtual CefBaseRefCounted {
///
// Called when the context menu is dismissed irregardless of whether the menu
// was empty or a command was selected.
// was canceled 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 ethods of this class
// Provides information about the context menu state. The methods of this class
// can only be accessed on browser process the UI thread.
///
/*--cef(source=library)--*/

View File

@@ -148,6 +148,15 @@ 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,7 +323,8 @@ class CefDOMNode : public virtual CefBaseRefCounted {
virtual CefString GetElementInnerText() = 0;
///
// Returns the bounds of the element.
// Returns the bounds of the element in device pixels. Use
// "window.devicePixelRatio" to convert to/from CSS pixels.
///
/*--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 default implementation dialog is closed.
// Called when the dialog is closed.
///
/*--cef()--*/
virtual void OnDialogClosed(CefRefPtr<CefBrowser> browser) {}

View File

@@ -0,0 +1,148 @@
// 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,6 +39,7 @@
#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;
@@ -71,6 +72,7 @@ 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;
@@ -83,9 +85,17 @@ 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,6 +163,23 @@ 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

@@ -0,0 +1,69 @@
// 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

@@ -0,0 +1,87 @@
// 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,6 +1996,17 @@ 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.
///
@@ -3230,6 +3241,138 @@ 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,6 +820,25 @@ 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,8 +43,10 @@
class CefView;
///
// Implement this interface to handle view events. The methods of this class
// will be called on the browser process UI thread unless otherwise indicated.
// 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.
///
/*--cef(source=client)--*/
class CefViewDelegate : public virtual CefBaseRefCounted {

View File

@@ -207,6 +207,10 @@ 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,6 +22,7 @@
#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"
@@ -30,6 +31,7 @@
#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"
@@ -380,7 +382,7 @@ content::SSLHostStateDelegate* AlloyBrowserContext::GetSSLHostStateDelegate() {
content::PermissionControllerDelegate*
AlloyBrowserContext::GetPermissionControllerDelegate() {
return nullptr;
return PermissionManagerFactory::GetForProfile(this);
}
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_capture_devices_dispatcher.h"
#include "libcef/browser/media_access_query.h"
#include "libcef/browser/osr/osr_util.h"
#include "libcef/browser/request_context_impl.h"
#include "libcef/browser/thread_util.h"
@@ -51,7 +51,6 @@
#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;
@@ -618,6 +617,14 @@ 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();
@@ -630,6 +637,11 @@ void AlloyBrowserHostImpl::WindowDestroyed() {
CloseBrowser(true);
}
bool AlloyBrowserHostImpl::WillBeDestroyed() const {
CEF_REQUIRE_UIT();
return destruction_state_ >= DESTRUCTION_STATE_ACCEPTED;
}
void AlloyBrowserHostImpl::DestroyBrowser() {
CEF_REQUIRE_UIT();
@@ -1119,12 +1131,6 @@ 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,
@@ -1239,9 +1245,8 @@ void AlloyBrowserHostImpl::DidNavigatePrimaryMainFramePostCommit(
content::JavaScriptDialogManager*
AlloyBrowserHostImpl::GetJavaScriptDialogManager(content::WebContents* source) {
if (!javascript_dialog_manager_.get() && platform_delegate_) {
javascript_dialog_manager_.reset(new CefJavaScriptDialogManager(
this, platform_delegate_->CreateJavaScriptDialogRunner()));
if (!javascript_dialog_manager_) {
javascript_dialog_manager_.reset(new CefJavaScriptDialogManager(this));
}
return javascript_dialog_manager_.get();
}
@@ -1255,8 +1260,7 @@ void AlloyBrowserHostImpl::RunFileChooser(
params);
}
bool AlloyBrowserHostImpl::HandleContextMenu(
content::WebContents* web_contents,
bool AlloyBrowserHostImpl::ShowContextMenu(
const content::ContextMenuParams& params) {
CEF_REQUIRE_UIT();
if (!menu_manager_.get() && platform_delegate_) {
@@ -1294,78 +1298,18 @@ void AlloyBrowserHostImpl::RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
content::MediaResponseCallback callback) {
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>());
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());
}
bool AlloyBrowserHostImpl::CheckMediaAccessPermission(
content::RenderFrameHost* render_frame_host,
const GURL& security_origin,
blink::mojom::MediaStreamType type) {
// Check media access permission without prompting the user.
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
return command_line->HasSwitch(switches::kEnableMediaStream);
return media_access_query::CheckMediaAccessPermission(this, render_frame_host,
security_origin, type);
}
bool AlloyBrowserHostImpl::IsNeverComposited(

View File

@@ -137,12 +137,16 @@ 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;
@@ -172,8 +176,7 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
void OnSetFocus(cef_focus_source_t source) override;
bool HandleContextMenu(content::WebContents* web_contents,
const content::ContextMenuParams& params);
bool ShowContextMenu(const content::ContextMenuParams& params);
enum DestructionState {
DESTRUCTION_STATE_NONE = 0,
@@ -209,8 +212,6 @@ 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,6 +8,7 @@
#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"
@@ -15,19 +16,22 @@
#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/printing/constrained_window_views_client.h"
#include "libcef/browser/permission_prompt.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"
@@ -48,7 +52,6 @@
#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"
@@ -171,7 +174,7 @@ AlloyBrowserMainParts::~AlloyBrowserMainParts() {
}
void AlloyBrowserMainParts::ToolkitInitialized() {
SetConstrainedWindowViewsClient(CreateCefConstrainedWindowViewsClient());
SetConstrainedWindowViewsClient(CreateAlloyConstrainedWindowViewsClient());
#if defined(USE_AURA)
CHECK(aura::Env::GetInstance());
@@ -188,6 +191,15 @@ 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() {
@@ -256,7 +268,9 @@ int AlloyBrowserMainParts::PreCreateThreads() {
int AlloyBrowserMainParts::PreMainMessageLoopRun() {
#if defined(USE_AURA)
screen_ = views::CreateDesktopScreen();
display::Screen::SetScreenInstance(screen_.get());
#endif
#if BUILDFLAG(IS_MAC)
screen_ = std::make_unique<display::ScopedNativeScreen>();
#endif
if (extensions::ExtensionsEnabled()) {
@@ -309,6 +323,7 @@ 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,11 +13,9 @@
#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;
}
@@ -88,6 +86,7 @@ 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,6 +12,7 @@
#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"
@@ -1458,6 +1459,12 @@ 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,6 +235,8 @@ 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

@@ -0,0 +1,22 @@
// 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

@@ -0,0 +1,33 @@
// 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,6 +5,7 @@
#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"
@@ -21,6 +22,8 @@
#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"
@@ -176,6 +179,7 @@ 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_);
@@ -184,10 +188,13 @@ void CefBrowserPlatformDelegateAlloy::BrowserCreated(
zoom::ZoomController::CreateForWebContents(web_contents_);
}
if (IsPrintPreviewSupported()) {
web_contents_dialog_helper_.reset(
new CefWebContentsDialogHelper(web_contents_, this));
}
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));
}
void CefBrowserPlatformDelegateAlloy::CreateExtensionHost(
@@ -242,6 +249,11 @@ 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,6 +42,8 @@ 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;
@@ -98,7 +100,7 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
std::unique_ptr<content::WebContents> owned_web_contents_;
// Used for the print preview dialog.
std::unique_ptr<CefWebContentsDialogHelper> web_contents_dialog_helper_;
std::unique_ptr<AlloyWebContentsDialogHelper> 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,6 +18,7 @@
#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"
@@ -67,6 +68,9 @@ void ChromeBrowserProcessAlloy::Initialize() {
extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get());
}
// Make sure permissions client has been set.
ChromePermissionsClient::GetInstance();
initialized_ = true;
}

View File

@@ -0,0 +1,76 @@
// 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

@@ -0,0 +1,17 @@
// 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

@@ -0,0 +1,58 @@
// 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

@@ -0,0 +1,18 @@
// 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

@@ -0,0 +1,96 @@
// 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

@@ -2,8 +2,8 @@
// 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_WEB_CONTENTS_DIALOG_HELPER_H_
#define CEF_LIBCEF_BROWSER_WEB_CONTENTS_DIALOG_HELPER_H_
#ifndef CEF_LIBCEF_BROWSER_ALLOY_DIALOGS_ALLOY_WEB_CONTENTS_DIALOG_HELPER_H_
#define CEF_LIBCEF_BROWSER_ALLOY_DIALOGS_ALLOY_WEB_CONTENTS_DIALOG_HELPER_H_
#pragma once
#include "base/callback_forward.h"
@@ -15,12 +15,12 @@
class CefBrowserPlatformDelegate;
class CefWebContentsDialogHelper
class AlloyWebContentsDialogHelper
: public web_modal::WebContentsModalDialogManagerDelegate,
public web_modal::WebContentsModalDialogHost {
public:
CefWebContentsDialogHelper(content::WebContents* web_contents,
CefBrowserPlatformDelegate* browser_delegate);
AlloyWebContentsDialogHelper(content::WebContents* web_contents,
CefBrowserPlatformDelegate* browser_delegate);
base::RepeatingClosure GetBoundsChangedCallback();
@@ -31,6 +31,7 @@ class CefWebContentsDialogHelper
// web_modal::WebContentsModalDialogHost methods:
gfx::NativeView GetHostView() const override;
gfx::AcceleratedWidget GetHostWidget() const override;
gfx::Point GetDialogPosition(const gfx::Size& size) override;
gfx::Size GetMaximumDialogSize() override;
void AddObserver(web_modal::ModalDialogHostObserver* observer) override;
@@ -45,7 +46,7 @@ class CefWebContentsDialogHelper
base::ObserverList<web_modal::ModalDialogHostObserver>::Unchecked
observer_list_;
base::WeakPtrFactory<CefWebContentsDialogHelper> weak_factory_;
base::WeakPtrFactory<AlloyWebContentsDialogHelper> weak_factory_;
};
#endif // CEF_LIBCEF_BROWSER_WEB_CONTENTS_DIALOG_HELPER_H_
#endif // CEF_LIBCEF_BROWSER_ALLOY_DIALOGS_ALLOY_WEB_CONTENTS_DIALOG_HELPER_H_

View File

@@ -42,6 +42,16 @@ 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,6 +36,8 @@ 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,6 +16,7 @@
#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"
@@ -138,6 +139,39 @@ 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,
@@ -170,9 +204,10 @@ void CefBrowserHostBase::InitializeBrowser() {
void CefBrowserHostBase::DestroyBrowser() {
CEF_REQUIRE_UIT();
devtools_manager_.reset(nullptr);
devtools_manager_.reset();
media_stream_registrar_.reset();
platform_delegate_.reset(nullptr);
platform_delegate_.reset();
contents_delegate_->RemoveObserver(this);
contents_delegate_->ObserveWebContents(nullptr);
@@ -198,13 +233,12 @@ bool CefBrowserHostBase::HasView() {
}
void CefBrowserHostBase::SetFocus(bool focus) {
// Always execute asynchronously to work around issue #3040.
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostBase::SetFocusInternal,
this, focus));
}
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT,
base::BindOnce(&CefBrowserHostBase::SetFocus, this, focus));
return;
}
void CefBrowserHostBase::SetFocusInternal(bool focus) {
CEF_REQUIRE_UIT();
if (focus)
OnSetFocus(FOCUS_SOURCE_SYSTEM);
else if (platform_delegate_)
@@ -938,6 +972,14 @@ 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_)
@@ -975,6 +1017,18 @@ 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,6 +15,7 @@
#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"
@@ -128,6 +129,14 @@ 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,
@@ -146,6 +155,10 @@ 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.
@@ -289,6 +302,7 @@ 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.
@@ -312,6 +326,9 @@ 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(
@@ -320,8 +337,6 @@ 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();
@@ -356,6 +371,8 @@ 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,7 +154,6 @@ 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;
@@ -164,7 +163,6 @@ 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,6 +131,12 @@ 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,
@@ -226,7 +232,6 @@ CefEventHandle CefBrowserPlatformDelegate::GetEventHandle(
std::unique_ptr<CefJavaScriptDialogRunner>
CefBrowserPlatformDelegate::CreateJavaScriptDialogRunner() {
NOTIMPLEMENTED();
return nullptr;
}
@@ -253,6 +258,11 @@ void CefBrowserPlatformDelegate::WasHidden(bool hidden) {
NOTREACHED();
}
bool CefBrowserPlatformDelegate::IsHidden() const {
NOTREACHED();
return false;
}
void CefBrowserPlatformDelegate::NotifyScreenInfoChanged() {
NOTREACHED();
}
@@ -351,13 +361,18 @@ void CefBrowserPlatformDelegate::AccessibilityLocationChangesReceived(
gfx::Point CefBrowserPlatformDelegate::GetDialogPosition(
const gfx::Size& size) {
NOTREACHED();
return gfx::Point();
const gfx::Size& max_size = GetMaximumDialogSize();
return gfx::Point((max_size.width() - size.width()) / 2,
(max_size.height() - size.height()) / 2);
}
gfx::Size CefBrowserPlatformDelegate::GetMaximumDialogSize() {
NOTREACHED();
return gfx::Size();
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();
}
void CefBrowserPlatformDelegate::SetAutoResizeEnabled(bool enabled,

View File

@@ -61,6 +61,10 @@ namespace views {
class Widget;
}
namespace web_modal {
class WebContentsModalDialogHost;
}
struct CefBrowserCreateParams;
class CefBrowserHostBase;
class CefJavaScriptDialogRunner;
@@ -178,6 +182,10 @@ 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
@@ -289,6 +297,10 @@ 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,6 +55,15 @@ 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,6 +8,7 @@
#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"
@@ -47,6 +48,16 @@ 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();
}
@@ -124,5 +135,6 @@ 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,6 +25,8 @@ 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,6 +11,7 @@
#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"
@@ -102,6 +103,19 @@ 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,6 +54,10 @@ 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,6 +538,12 @@ 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,6 +150,7 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
// CefBrowserHostBase methods:
void WindowDestroyed() override;
bool WillBeDestroyed() const override;
void DestroyBrowser() override;
void DoCloseBrowser(bool force_close);

View File

@@ -8,6 +8,7 @@
#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"
@@ -42,4 +43,5 @@ void ChromeBrowserMainExtraPartsCef::PreMainMessageLoopRun() {
scheme::RegisterWebUIControllerFactory();
context_menu::RegisterMenuCreatedCallback();
file_dialog_runner::RegisterFactory();
permission_prompt::RegisterCreateCallback();
}

View File

@@ -103,11 +103,6 @@ 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,8 +41,6 @@ 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,8 +69,7 @@ bool CefMimeHandlerViewGuestDelegate::HandleContextMenu(
AlloyBrowserHostImpl::GetBrowserForContents(owner_web_contents_);
DCHECK(owner_browser);
return owner_browser->HandleContextMenu(
content::WebContents::FromRenderFrameHost(&render_frame_host), params);
return owner_browser->ShowContextMenu(params);
}
} // namespace extensions

View File

@@ -6,7 +6,6 @@
#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"
@@ -50,32 +49,6 @@ 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:
@@ -118,7 +91,8 @@ 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_ = GetBrowserForTopLevelNativeWindow(owning_window);
browser_ =
CefBrowserHostBase::GetBrowserForTopLevelNativeWindow(owning_window);
if (!browser_) {
LOG(WARNING) << "No browser associated with top-level native window";
}
@@ -128,7 +102,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_ = GetLikelyFocusedBrowser();
browser_ = CefBrowserHostBase::GetLikelyFocusedBrowser();
if (!browser_) {
LOG(WARNING) << "No likely focused browser";
}

View File

@@ -13,6 +13,7 @@
#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"
@@ -238,18 +239,31 @@ void CefFrameHostImpl::SendProcessMessage(
if (!message || !message->IsValid())
return;
// Invalidate the message object immediately by taking the argument list.
auto argument_list =
static_cast<CefProcessMessageImpl*>(message.get())->TakeArgumentList();
if (message->GetArgumentList() != nullptr) {
// 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)));
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)));
}
}
void CefFrameHostImpl::SetFocused(bool focused) {
@@ -564,6 +578,19 @@ 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,6 +126,8 @@ 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/alloy/alloy_browser_host_impl.h"
#include "libcef/browser/browser_host_base.h"
#include "libcef/browser/thread_util.h"
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/logging.h"
#include "base/strings/utf_string_conversions.h"
#include "components/url_formatter/elide_url.h"
#include "components/javascript_dialogs/tab_modal_dialog_manager.h"
namespace {
@@ -60,21 +60,26 @@ 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(
AlloyBrowserHostImpl* browser,
std::unique_ptr<CefJavaScriptDialogRunner> runner)
: browser_(browser),
runner_(std::move(runner)),
dialog_running_(false),
weak_ptr_factory_(this) {}
CefBrowserHostBase* browser)
: browser_(browser), weak_ptr_factory_(this) {}
CefJavaScriptDialogManager::~CefJavaScriptDialogManager() {}
void CefJavaScriptDialogManager::Destroy() {
if (runner_.get()) {
runner_.reset(nullptr);
if (handler_) {
CancelDialogs(nullptr, false);
}
if (runner_) {
runner_.reset();
}
}
@@ -86,13 +91,19 @@ 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();
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefJSDialogHandler> handler = client->GetJSDialogHandler();
if (handler.get()) {
*did_suppress_message = false;
// 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<CefJSDialogCallbackImpl> callbackPtr(
new CefJSDialogCallbackImpl(std::move(callback)));
@@ -110,32 +121,40 @@ void CefJavaScriptDialogManager::RunJavaScriptDialog(
// |callback| may be null if the user executed it despite returning false.
callback = callbackPtr->Disconnect();
if (callback.is_null() || *did_suppress_message)
if (callback.is_null()) {
LOG(WARNING)
<< "OnJSDialog should return true when executing the callback";
return;
}
if (*did_suppress_message) {
// Call OnResetDialogState but don't execute |callback|.
CancelDialogs(web_contents, /*reset_state=*/true);
return;
}
handler_ = nullptr;
}
}
*did_suppress_message = false;
DCHECK(!handler_);
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;
if (InitializeRunner()) {
runner_->Run(browser_, message_type, origin_url, message_text,
default_prompt_text, std::move(callback));
return;
}
dialog_running_ = true;
if (!CanUseChromeDialogs()) {
// Dismiss the dialog.
std::move(callback).Run(false, std::u16string());
return;
}
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)));
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);
}
void CefJavaScriptDialogManager::RunBeforeUnloadDialog(
@@ -143,8 +162,7 @@ void CefJavaScriptDialogManager::RunBeforeUnloadDialog(
content::RenderFrameHost* render_frame_host,
bool is_reload,
DialogClosedCallback callback) {
if (browser_->destruction_state() >=
AlloyBrowserHostImpl::DESTRUCTION_STATE_ACCEPTED) {
if (browser_->WillBeDestroyed()) {
// Currently destroying the browser. Accept the unload without showing
// the prompt.
std::move(callback).Run(true, std::u16string());
@@ -153,80 +171,138 @@ void CefJavaScriptDialogManager::RunBeforeUnloadDialog(
const std::u16string& message_text = u"Is it OK to leave/reload this page?";
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefJSDialogHandler> handler = client->GetJSDialogHandler();
if (handler.get()) {
// 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<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())
if (callback.is_null()) {
LOG(WARNING) << "OnBeforeUnloadDialog should return true when "
"executing the callback";
return;
}
handler_ = nullptr;
}
}
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.
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.
std::move(callback).Run(true, std::u16string());
return;
}
dialog_running_ = true;
auto manager = GetTabModalDialogManager(web_contents);
manager->RunBeforeUnloadDialog(web_contents, render_frame_host, is_reload,
std::move(callback));
}
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)));
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);
}
void CefJavaScriptDialogManager::CancelDialogs(
content::WebContents* web_contents,
bool reset_state) {
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefJSDialogHandler> handler = client->GetJSDialogHandler();
if (handler.get()) {
// Execute the user callback.
handler->OnResetDialogState(browser_);
if (handler_) {
if (reset_state) {
handler_->OnResetDialogState(browser_);
}
handler_ = nullptr;
return;
}
if (runner_.get() && dialog_running_) {
if (runner_) {
runner_->Cancel();
dialog_running_ = false;
return;
}
// 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) {
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefJSDialogHandler> handler = client->GetJSDialogHandler();
if (handler.get())
handler->OnDialogClosed(browser_);
if (handler_) {
handler_->OnDialogClosed(browser_);
// Call OnResetDialogState.
CancelDialogs(/*web_contents=*/nullptr, /*reset_state=*/true);
}
DCHECK(runner_.get());
DCHECK(dialog_running_);
dialog_running_ = false;
std::move(callback).Run(success, user_input);
// Null when called from HandleJavaScriptDialog().
if (!callback.is_null()) {
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,20 +7,21 @@
#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 AlloyBrowserHostImpl;
class CefBrowserHostBase;
class CefJavaScriptDialogManager : public content::JavaScriptDialogManager {
public:
// |runner| may be NULL if the platform doesn't implement dialogs.
CefJavaScriptDialogManager(AlloyBrowserHostImpl* browser,
std::unique_ptr<CefJavaScriptDialogRunner> runner);
explicit CefJavaScriptDialogManager(CefBrowserHostBase* browser);
CefJavaScriptDialogManager(const CefJavaScriptDialogManager&) = delete;
CefJavaScriptDialogManager& operator=(const CefJavaScriptDialogManager&) =
@@ -43,6 +44,9 @@ 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;
@@ -52,13 +56,17 @@ class CefJavaScriptDialogManager : public content::JavaScriptDialogManager {
bool success,
const std::u16string& user_input);
// AlloyBrowserHostImpl pointer is guaranteed to outlive this object.
AlloyBrowserHostImpl* browser_;
bool InitializeRunner();
bool CanUseChromeDialogs() const;
// CefBrowserHostBase pointer is guaranteed to outlive this object.
CefBrowserHostBase* const browser_;
CefRefPtr<CefJSDialogHandler> handler_;
std::unique_ptr<CefJavaScriptDialogRunner> runner_;
// True if a dialog is currently running.
bool dialog_running_;
bool runner_initialized_ = false;
// 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 "base/callback.h"
#include "content/public/browser/javascript_dialog_manager.h"
#include "content/public/common/javascript_dialog_type.h"
class AlloyBrowserHostImpl;
class CefBrowserHostBase;
class CefJavaScriptDialogRunner {
public:
@@ -19,17 +19,19 @@ class CefJavaScriptDialogRunner {
delete;
using DialogClosedCallback =
base::OnceCallback<void(bool /* success */,
const std::u16string& /* user_input */)>;
content::JavaScriptDialogManager::DialogClosedCallback;
// Run the dialog. Execute |callback| on completion.
virtual void Run(AlloyBrowserHostImpl* browser,
virtual void Run(CefBrowserHostBase* browser,
content::JavaScriptDialogType message_type,
const std::u16string& display_url,
const GURL& origin_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

@@ -0,0 +1,356 @@
// 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

@@ -0,0 +1,37 @@
// 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

@@ -0,0 +1,108 @@
// 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

@@ -0,0 +1,56 @@
// 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,17 +233,6 @@ 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,8 +34,6 @@ 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,8 +44,6 @@ 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,21 +125,28 @@ NSTimeInterval currentEventTimestamp() {
NSUInteger NativeModifiers(int cef_modifiers) {
NSUInteger native_modifiers = 0;
if (cef_modifiers & EVENTFLAG_SHIFT_DOWN)
native_modifiers |= NSShiftKeyMask;
native_modifiers |= NSEventModifierFlagShift;
if (cef_modifiers & EVENTFLAG_CONTROL_DOWN)
native_modifiers |= NSControlKeyMask;
native_modifiers |= NSEventModifierFlagControl;
if (cef_modifiers & EVENTFLAG_ALT_DOWN)
native_modifiers |= NSAlternateKeyMask;
native_modifiers |= NSEventModifierFlagOption;
if (cef_modifiers & EVENTFLAG_COMMAND_DOWN)
native_modifiers |= NSCommandKeyMask;
native_modifiers |= NSEventModifierFlagCommand;
if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON)
native_modifiers |= NSAlphaShiftKeyMask;
native_modifiers |= NSEventModifierFlagCapsLock;
if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON)
native_modifiers |= NSNumericPadKeyMask;
native_modifiers |= NSEventModifierFlagNumericPad;
return native_modifiers;
}
constexpr int kDefaultHeight = 750;
constexpr int kDefaultWidth = 750;
constexpr NSWindowStyleMask kDefaultStyleMask =
NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable |
NSWindowStyleMaskUnifiedTitleAndToolbar;
} // namespace
CefBrowserPlatformDelegateNativeMac::CefBrowserPlatformDelegateNativeMac(
@@ -176,18 +183,15 @@ bool CefBrowserPlatformDelegateNativeMac::CreateHostWindow() {
// Create a new window.
NSRect window_rect = {{x, y}, {width, height}};
if (window_rect.size.width == 0)
window_rect.size.width = 750;
window_rect.size.width = kDefaultWidth;
if (window_rect.size.height == 0)
window_rect.size.height = 750;
window_rect.size.height = kDefaultHeight;
content_rect = {{0, 0}, {window_rect.size.width, window_rect.size.height}};
newWnd = [[UnderlayOpenGLHostingWindow alloc]
initWithContentRect:window_rect
styleMask:(NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask |
NSResizableWindowMask |
NSUnifiedTitleAndToolbarWindowMask)
styleMask:kDefaultStyleMask
backing:NSBackingStoreBuffered
defer:NO];
@@ -351,7 +355,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] == NSKeyDown)
if ([event.os_event type] == NSEventTypeKeyDown)
return [[NSApp mainMenu] performKeyEquivalent:event.os_event];
return false;
}
@@ -374,22 +378,6 @@ 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 {
@@ -405,19 +393,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 NSFlagsChanged event.
// if this was a NSEventTypeFlagsChanged event.
// A dead key will have an empty character, but a non-empty unmodified
// character
event_type = NSFlagsChanged;
event_type = NSEventTypeFlagsChanged;
} else {
switch (key_event.type) {
case KEYEVENT_RAWKEYDOWN:
case KEYEVENT_KEYDOWN:
case KEYEVENT_CHAR:
event_type = NSKeyDown;
event_type = NSEventTypeKeyDown;
break;
case KEYEVENT_KEYUP:
event_type = NSKeyUp;
event_type = NSEventTypeKeyUp;
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,6 +147,61 @@ 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(
@@ -183,14 +238,23 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
has_frame_ = !(window_info_.style & WS_CHILD);
std::wstring windowName(CefString(&window_info_.window_name));
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);
}
// Create the new browser window.
CreateWindowEx(window_info_.ex_style, GetWndClass(), windowName.c_str(),
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);
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);
// It's possible for CreateWindowEx to fail if the parent window was
// destroyed between the call to CreateBrowser and the above one.
@@ -286,28 +350,43 @@ 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 associated with the
// root window.
// 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.
//
// The DesktopWindowTreeHostWin HandleNativeFocus/HandleNativeBlur methods
// The DesktopWindowTreeHostWin::HandleNativeFocus/HandleNativeBlur methods
// are called in response to WM_SETFOCUS/WM_KILLFOCUS respectively. The
// implementation has been patched to call HandleActivationChanged which
// results in the following behaviors:
// 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:
// 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).
// 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).
// 2. Update focus state of the ui::InputMethod. If this does not occur
// then InputMethodBase::GetTextInputClient will return NULL and
// InputMethodWin::OnChar will fail to sent character events to the
// renderer (see issue #1700).
// 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).
//
// This differs from activation in Chrome which is handled via
// HWNDMessageHandler::PostProcessActivateMessage (Widget::Show indirectly
@@ -323,6 +402,15 @@ 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() {
@@ -349,18 +437,17 @@ void CefBrowserPlatformDelegateNativeWin::NotifyMoveOrResizeStarted() {
void CefBrowserPlatformDelegateNativeWin::SizeTo(int width, int height) {
HWND window = window_info_.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 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);
// 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);
const CefRect content_rect(0, 0, width, height);
const CefRect frame_rect = GetFrameRectFromLogicalContentRect(
content_rect, style, ex_style, has_menu, scale);
// Size the window. The left/top values may be negative.
SetWindowPos(window, NULL, 0, 0, rect.right - rect.left,
rect.bottom - rect.top,
SetWindowPos(window, NULL, 0, 0, frame_rect.width, frame_rect.height,
SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
}
@@ -425,22 +512,6 @@ 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);
@@ -642,4 +713,4 @@ LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(HWND hwnd,
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
}

View File

@@ -33,10 +33,6 @@ 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,6 +9,7 @@
#include "libcef/browser/javascript_dialog_runner.h"
#include "base/callback.h"
#include "base/mac/scoped_nsobject.h"
#include "base/memory/weak_ptr.h"
@@ -24,12 +25,13 @@ class CefJavaScriptDialogRunnerMac : public CefJavaScriptDialogRunner {
~CefJavaScriptDialogRunnerMac() override;
// CefJavaScriptDialogRunner methods:
void Run(AlloyBrowserHostImpl* browser,
void Run(CefBrowserHostBase* browser,
content::JavaScriptDialogType message_type,
const std::u16string& display_url,
const GURL& origin_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,6 +10,7 @@
#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.
@@ -87,9 +88,9 @@ CefJavaScriptDialogRunnerMac::~CefJavaScriptDialogRunnerMac() {
}
void CefJavaScriptDialogRunnerMac::Run(
AlloyBrowserHostImpl* browser,
CefBrowserHostBase* browser,
content::JavaScriptDialogType message_type,
const std::u16string& display_url,
const GURL& origin_url,
const std::u16string& message_text,
const std::u16string& default_prompt_text,
DialogClosedCallback callback) {
@@ -126,6 +127,9 @@ 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;
@@ -156,6 +160,14 @@ 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

@@ -1,240 +0,0 @@
// 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

@@ -1,56 +0,0 @@
// 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:NSRightMouseDown
NSEvent* clickEvent = [NSEvent mouseEventWithType:NSEventTypeRightMouseDown
location:position
modifierFlags:0
timestamp:eventTime

View File

@@ -39,7 +39,8 @@ network::mojom::CookieManager* GetCookieManager(
->GetCookieManagerForBrowserProcess();
}
net::CookieOptions GetCookieOptions(const network::ResourceRequest& request) {
net::CookieOptions GetCookieOptions(const network::ResourceRequest& request,
bool for_loading_cookies) {
// Match the logic from InterceptionJob::FetchCookies and
// ChromeContentBrowserClient::ShouldIgnoreSameSiteCookieRestrictionsWhenTopLevel.
bool should_treat_as_first_party =
@@ -50,14 +51,33 @@ net::CookieOptions GetCookieOptions(const network::ResourceRequest& request) {
request.trusted_params->isolation_info.request_type() ==
net::IsolationInfo::RequestType::kMainFrame;
// Match the logic from URLRequestHttpJob::AddCookieHeaderAndStart.
// 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);
}
net::CookieOptions options;
options.set_include_httponly();
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));
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));
}
return options;
}
@@ -227,10 +247,11 @@ void LoadCookies(const CefBrowserContext::Getter& browser_context_getter,
}
CEF_POST_TASK(
CEF_UIT, base::BindOnce(LoadCookiesOnUIThread, browser_context_getter,
request.url, GetCookieOptions(request),
net::CookiePartitionKeyCollection(),
allow_cookie_callback, std::move(done_callback)));
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)));
}
void SaveCookies(const CefBrowserContext::Getter& browser_context_getter,
@@ -266,7 +287,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), net::CookiePartitionKey::Todo(),
absl::make_optional(response_date), /*partition_key=*/absl::nullopt,
&returned_status);
if (!returned_status.IsInclude()) {
continue;
@@ -281,9 +302,10 @@ 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), total_count,
std::move(allowed_cookies), std::move(done_callback)));
base::BindOnce(
SaveCookiesOnUIThread, browser_context_getter, request.url,
GetCookieOptions(request, /*for_loading_cookies=*/false),
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, net::CookiePartitionKey::Todo());
priority, /*same_party=*/false, /*partition_key=*/absl::nullopt);
if (!canonical_cookie) {
SetCookieCallbackImpl(

View File

@@ -236,8 +236,6 @@ 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:
@@ -661,13 +659,6 @@ 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
@@ -1053,12 +1044,11 @@ void InterceptedRequest::ContinueToResponseStarted(int error_code) {
if (proxied_client_receiver_.is_bound())
proxied_client_receiver_.Resume();
target_client_->OnReceiveResponse(std::move(current_response_),
std::move(current_body_));
target_client_->OnReceiveResponse(
std::move(current_response_),
factory_->request_handler_->OnFilterResponseBody(
id_, request_, std::move(current_body_)));
}
if (stream_loader_)
stream_loader_->ContinueResponse(is_redirect);
}
void InterceptedRequest::OnDestroy() {

View File

@@ -696,42 +696,23 @@ 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),
mojo::ScopedDataPipeConsumerHandle());
std::move(consumer_handle));
ReadMore();
}
}
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,8 +126,6 @@ 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,
@@ -154,7 +152,6 @@ 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,6 +9,7 @@
#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"
@@ -234,6 +235,13 @@ 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,6 +55,7 @@ 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,6 +51,7 @@
#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 {
@@ -179,6 +180,18 @@ 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,
@@ -260,6 +273,10 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
if (!render_widget_host_->is_hidden())
Show();
}
selection_controller_client_ =
std::make_unique<CefTouchSelectionControllerClientOSR>(this);
CreateSelectionController();
}
CefRenderWidgetHostViewOSR::~CefRenderWidgetHostViewOSR() {
@@ -392,8 +409,13 @@ void CefRenderWidgetHostViewOSR::Hide() {
is_showing_ = false;
if (browser_impl_.get())
if (browser_impl_) {
browser_impl_->CancelContextMenu();
}
if (selection_controller_client_) {
selection_controller_client_->CloseQuickMenuAndHideHandles();
}
if (video_consumer_) {
video_consumer_->SetActive(false);
@@ -424,6 +446,11 @@ void CefRenderWidgetHostViewOSR::EnsureSurfaceSynchronizedForWebTest() {
absl::nullopt);
}
content::TouchSelectionControllerClientManager*
CefRenderWidgetHostViewOSR::GetTouchSelectionControllerClientManager() {
return selection_controller_client_.get();
}
gfx::Rect CefRenderWidgetHostViewOSR::GetViewBounds() {
if (IsPopupWidget())
return popup_position_;
@@ -948,6 +975,14 @@ 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>
@@ -1091,6 +1126,10 @@ 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()) {
@@ -1114,12 +1153,16 @@ void CefRenderWidgetHostViewOSR::SendMouseEvent(
const blink::WebMouseEvent& event) {
TRACE_EVENT0("cef", "CefRenderWidgetHostViewOSR::SendMouseEvent");
if (!IsPopupWidget()) {
if (browser_impl_.get() &&
if (browser_impl_ &&
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())) {
@@ -1179,8 +1222,13 @@ void CefRenderWidgetHostViewOSR::SendMouseWheelEvent(
TRACE_EVENT0("cef", "CefRenderWidgetHostViewOSR::SendMouseWheelEvent");
if (!IsPopupWidget()) {
if (browser_impl_.get())
if (browser_impl_) {
browser_impl_->CancelContextMenu();
}
if (selection_controller_client_) {
selection_controller_client_->CloseQuickMenuAndHideHandles();
}
if (popup_host_view_) {
if (popup_host_view_->popup_position_.Contains(
@@ -1274,6 +1322,11 @@ 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_);
@@ -1334,8 +1387,13 @@ void CefRenderWidgetHostViewOSR::SetFocus(bool focus) {
widget->GotFocus();
widget->SetActive(true);
} else {
if (browser_impl_.get())
if (browser_impl_) {
browser_impl_->CancelContextMenu();
}
if (selection_controller_client_) {
selection_controller_client_->CloseQuickMenuAndHideHandles();
}
widget->SetActive(false);
widget->LostFocus();
@@ -1480,6 +1538,13 @@ 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,6 +32,7 @@
#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"
@@ -47,18 +48,23 @@
#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;
@@ -118,6 +124,8 @@ 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;
@@ -290,6 +298,18 @@ 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();
@@ -302,6 +322,9 @@ class CefRenderWidgetHostViewOSR
void CancelWidget();
// Helper function to create a selection controller.
void CreateSelectionController();
void OnScrollOffsetChanged();
void AddGuestHostView(CefRenderWidgetHostViewOSR* guest_host);
@@ -342,6 +365,14 @@ 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

@@ -0,0 +1,128 @@
// 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

@@ -0,0 +1,59 @@
// 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

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