diff --git a/BUILD.gn b/BUILD.gn index 9862d72303bce542bb4a353e69f996f9c000f396..a45ab7a3183980f252105fe5605ccb85f0c9440c 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -408,20 +408,31 @@ test("libcef_static_unittests") { testonly = true sources = [ + "libcef/browser/browser_platform_delegate_unittest.cc", "libcef/browser/devtools/devtools_util_unittest.cc", "libcef/browser/geometry_util_unittest.cc", + "libcef/browser/osr/browser_platform_delegate_osr_unittest.cc", ] deps = [ + ":libcef_static", ":libcef_static_unittested", + "libcef/common/mojom", "//base/test:run_all_unittests", + "//testing/gmock", "//testing/gtest", + "libcef/common/mojom", ] configs += [ "libcef/features:config", "//build/config:precompiled_headers", ] + + include_dirs = [ + "//third_party/skia", + "//third_party/boringssl/src/include" + ] } # Source files that are linked into libcef and cef_framework and implement @@ -485,6 +496,8 @@ source_set("libcef_static") { "libcef/browser/alloy/chrome_profile_alloy.h", "libcef/browser/alloy/chrome_profile_manager_alloy.cc", "libcef/browser/alloy/chrome_profile_manager_alloy.h", + "libcef/browser/alloy/render_process_state_handler.cc", + "libcef/browser/alloy/render_process_state_handler.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", @@ -521,8 +534,6 @@ source_set("libcef_static") { "libcef/browser/browser_util.h", "libcef/browser/certificate_query.cc", "libcef/browser/certificate_query.h", - "libcef/browser/received_slice_helper.h", - "libcef/browser/received_slice_helper.cc", "libcef/browser/chrome/browser_delegate.h", "libcef/browser/chrome/browser_platform_delegate_chrome.cc", "libcef/browser/chrome/browser_platform_delegate_chrome.h", @@ -679,12 +690,12 @@ source_set("libcef_static") { "libcef/browser/net/devtools_scheme_handler.h", "libcef/browser/net/internal_scheme_handler.cc", "libcef/browser/net/internal_scheme_handler.h", + "libcef/browser/net/ohos_applink_throttle.cc", + "libcef/browser/net/ohos_applink_throttle.h", "libcef/browser/net/scheme_handler.cc", "libcef/browser/net/scheme_handler.h", "libcef/browser/net/throttle_handler.cc", "libcef/browser/net/throttle_handler.h", - "libcef/browser/net/ohos_applink_throttle.cc", - "libcef/browser/net/ohos_applink_throttle.h", "libcef/browser/net_database/cef_data_base_impl.cc", "libcef/browser/net_database/cef_data_base_impl.h", "libcef/browser/net_service/browser_urlrequest_impl.cc", @@ -767,6 +778,8 @@ source_set("libcef_static") { "libcef/browser/printing/print_util.cc", "libcef/browser/printing/print_util.h", "libcef/browser/process_util_impl.cc", + "libcef/browser/received_slice_helper.cc", + "libcef/browser/received_slice_helper.h", "libcef/browser/request_context_handler_map.cc", "libcef/browser/request_context_handler_map.h", "libcef/browser/request_context_impl.cc", @@ -989,6 +1002,8 @@ source_set("libcef_static") { "//chrome/app/chrome_main_delegate.h", # For Javascript + "libcef/browser/first_meaningful_paint_details_impl.cc", + "libcef/browser/first_meaningful_paint_details_impl.h", "libcef/browser/javascript/oh_gin_javascript_bridge_dispatcher_host.cc", "libcef/browser/javascript/oh_gin_javascript_bridge_dispatcher_host.h", "libcef/browser/javascript/oh_gin_javascript_bridge_message_filter.cc", @@ -997,10 +1012,8 @@ source_set("libcef_static") { "libcef/browser/javascript/oh_gin_javascript_bridge_object_deletion_message_filter.h", "libcef/browser/javascript/oh_javascript_injector.cc", "libcef/browser/javascript/oh_javascript_injector.h", - "libcef/browser/first_meaningful_paint_details_impl.h", - "libcef/browser/first_meaningful_paint_details_impl.cc", - "libcef/browser/largest_contentful_paint_details_impl.h", "libcef/browser/largest_contentful_paint_details_impl.cc", + "libcef/browser/largest_contentful_paint_details_impl.h", "libcef/common/javascript/oh_gin_javascript_bridge_errors.cc", "libcef/common/javascript/oh_gin_javascript_bridge_errors.h", "libcef/common/javascript/oh_gin_javascript_bridge_message_generator.cc", @@ -1169,7 +1182,11 @@ source_set("libcef_static") { "//cef/libcef/features", # Support relative include paths. + "//ohos_nweb:nweb_sources", "//third_party/abseil-cpp:absl", + + # Support ohos_nweb include paths. + "//ohos_nweb:nweb_sources", ] deps = [ @@ -1264,6 +1281,7 @@ source_set("libcef_static") { "//third_party/widevine/cdm", "//third_party/widevine/cdm:headers", "//third_party/zlib:minizip", + "//third_party:huawei_securec", "//ui/base", "//ui/base/ime", "//ui/events", @@ -1324,6 +1342,13 @@ source_set("libcef_static") { #endif // defined(OHOS_PRINT) + #if defined(OHOS_CA) + if (defined(ohos_ca) && ohos_ca) { + deps += [ "//third_party:huawei_securec" ] + } + + #endif // defined(OHOS_CA) + #if defined(OHOS_NO_STATE_PREFETCH) if (defined(ohos_no_state_prefetch) && ohos_no_state_prefetch) { sources += [ @@ -1348,7 +1373,10 @@ source_set("libcef_static") { "libcef/browser/predictors/resource_prefetch_predictor.cc", "libcef/browser/predictors/resource_prefetch_predictor.h", ] - deps += [ "//components/no_state_prefetch/renderer" ] + deps += [ + "//components/no_state_prefetch/renderer", + "//third_party:huawei_securec", + ] } #endif // defined(OHOS_NO_STATE_PREFETCH) if (safe_browsing_mode != 0) { @@ -1620,6 +1648,13 @@ grit("cef_strings") { source = "libcef/resources/cef_strings.grd" outputs = [ "grit/cef_strings.h" ] all_locales = platform_pak_locales + [ "fake-bidi" ] + + #ifdef ohos_i18n + if (is_ohos && ohos_i18n) { + all_locales += extra_locales + } + + #endif foreach(locale, all_locales) { outputs += [ "cef_strings_${locale}.pak" ] } @@ -1737,6 +1772,7 @@ make_pack_header("strings") { "$root_gen_dir/third_party/blink/public/strings/grit/blink_accessibility_strings.h", "$root_gen_dir/third_party/blink/public/strings/grit/blink_strings.h", "$root_gen_dir/ui/strings/grit/ui_strings.h", + "$root_gen_dir/ohos_resources/components/string/grit/ohos_components_strings.h", ] deps = [ @@ -1750,6 +1786,7 @@ make_pack_header("strings") { "//components/strings:components_locale_settings", "//components/strings:components_strings", "//extensions/strings", + "//ohos_resources/components/string:ohos_components_strings", "//services/strings", "//third_party/blink/public/strings", "//third_party/blink/public/strings:accessibility_strings", @@ -1934,7 +1971,7 @@ if (is_mac) { } } - shared_library("libweb_engine") { + shared_library("libarkweb_engine") { configs += [ "//build/config/sanitizers:cfi_config" ] defines = [ "LOGGING_TAG=\"cef#\"" ] sources = @@ -2387,8 +2424,8 @@ if (is_mac) { gypi_paths2.cefclient_sources_renderer deps = [ + ":libarkweb_engine", ":libcef_dll_wrapper", - ":libweb_engine", ] defines = [ "CEF_USE_SANDBOX" ] @@ -2466,8 +2503,8 @@ if (is_mac) { gypi_paths2.cefsimple_sources_common deps = [ + ":libarkweb_engine", ":libcef_dll_wrapper", - ":libweb_engine", ] defines = [ "CEF_USE_SANDBOX" ] @@ -2527,8 +2564,8 @@ if (is_mac) { deps = [ ":gtest_teamcity", + ":libarkweb_engine", ":libcef_dll_wrapper", - ":libweb_engine", "//testing/gtest", ] diff --git a/cef_paths.gypi b/cef_paths.gypi index 97e1f9903a70497bfcd9b4bde7e6889fef773761..23ce0702dc2ccd3bc96c2de721a9d66aee8fafee 100644 --- a/cef_paths.gypi +++ b/cef_paths.gypi @@ -435,6 +435,8 @@ '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/pdf_value_callback_ctocpp.cc', + 'libcef_dll/ctocpp/pdf_value_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', @@ -823,6 +825,8 @@ '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/pdf_value_callback_cpptoc.cc', + 'libcef_dll/cpptoc/pdf_value_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', diff --git a/include/capi/cef_app_capi.h b/include/capi/cef_app_capi.h index f108c63b70c67bc249a7fb1f81965cb565f79e23..c4aa9b511b3f1a925e54e1f652f1f392eb1d8a09 100644 --- a/include/capi/cef_app_capi.h +++ b/include/capi/cef_app_capi.h @@ -33,7 +33,7 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // -// $hash=f70d48ba4a8bd1fc8bcc7b3d6fb92d811e929498$ +// $hash=eadf7b3b90074e9b8a67aea85be1c85321fb5430$ // #ifndef CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_ @@ -207,6 +207,11 @@ CEF_EXPORT void cef_resume_download(const cef_string_t* guid, const cef_string_t* last_modified, const cef_string_t* received_slices_string); +/// +/// This function should be called on the main application thread. +/// +CEF_EXPORT struct _cef_download_item_t* cef_get_download_item(const char* guid); + #ifdef __cplusplus } #endif diff --git a/include/capi/cef_browser_capi.h b/include/capi/cef_browser_capi.h index 2b17257ad8b6448ddfafcb2e70aa96b491fd4680..fe1c6112d1a4456c47376962d3d7fa730b585b7c 100644 --- a/include/capi/cef_browser_capi.h +++ b/include/capi/cef_browser_capi.h @@ -33,7 +33,7 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // -// $hash=8d712ec9183206266dbdf83e324ef4332889bae7$ +// $hash=517a730fa2379060935e9921061a0c8b6149cfab$ // #ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_ @@ -74,9 +74,9 @@ typedef struct _cef_java_script_result_callback_t { /// Method that will be called upon completion. |num_deleted| will be the /// number of cookies that were deleted. /// - void(CEF_CALLBACK *on_java_script_exe_result)( - struct _cef_java_script_result_callback_t *self, - struct _cef_value_t *result); + void(CEF_CALLBACK* on_java_script_exe_result)( + struct _cef_java_script_result_callback_t* self, + struct _cef_value_t* result); } cef_java_script_result_callback_t; /// @@ -94,14 +94,14 @@ typedef struct _cef_store_web_archive_result_callback_t { /// filename under which the file was saved, or NULL if saving the file /// failed. /// - void(CEF_CALLBACK *on_store_web_archive_done)( - struct _cef_store_web_archive_result_callback_t *self, - const cef_string_t *result); + void(CEF_CALLBACK* on_store_web_archive_done)( + struct _cef_store_web_archive_result_callback_t* self, + const cef_string_t* result); } cef_store_web_archive_result_callback_t; /// /// Structure to implement to be notified of asynchronous completion via -/// cef_browser_host_tBase::SetGestureEventResult(). +/// cef_browser_host_tBase::set_gesture_event_result(). /// typedef struct _cef_gesture_event_callback_t { /// @@ -112,7 +112,7 @@ typedef struct _cef_gesture_event_callback_t { /// /// Method that will be called upon completion. /// - void(CEF_CALLBACK *continue_task)(struct _cef_gesture_event_callback_t *self, + void(CEF_CALLBACK* continue_task)(struct _cef_gesture_event_callback_t* self, int result); } cef_gesture_event_callback_t; @@ -129,8 +129,15 @@ typedef struct _cef_web_message_receiver_t { /// Method that will be called upon |PostPortMessage|. |message| will be sent /// to another end of web message channel. /// - void(CEF_CALLBACK *on_message)(struct _cef_web_message_receiver_t *self, - struct _cef_value_t *message); + void(CEF_CALLBACK* on_message)(struct _cef_web_message_receiver_t* self, + struct _cef_value_t* message); + + /// + /// The same as OnMessage, the result of the execution will be returned. + /// + int(CEF_CALLBACK* on_message_with_bool_result)( + struct _cef_web_message_receiver_t* self, + struct _cef_value_t* message); } cef_web_message_receiver_t; /// @@ -146,8 +153,9 @@ typedef struct _cef_precompile_callback_t { /// /// Method that will be called upon completion. /// - void(CEF_CALLBACK *on_precompile_finished)( - struct _cef_precompile_callback_t *self, int32_t result); + void(CEF_CALLBACK* on_precompile_finished)( + struct _cef_precompile_callback_t* self, + int32_t result); } cef_precompile_callback_t; /// @@ -162,8 +170,8 @@ typedef struct _cef_cache_options_t { /// /// Return the response headers of javascript request. /// - cef_string_map_t(CEF_CALLBACK *get_response_headers)( - struct _cef_cache_options_t *self); + cef_string_map_t(CEF_CALLBACK* get_response_headers)( + struct _cef_cache_options_t* self); } cef_cache_options_t; /// @@ -178,7 +186,7 @@ typedef struct _cef_set_lock_callback_t { /// /// Handle. /// - void(CEF_CALLBACK *handle)(struct _cef_set_lock_callback_t *self, int key); + void(CEF_CALLBACK* handle)(struct _cef_set_lock_callback_t* self, int key); } cef_set_lock_callback_t; /// @@ -197,77 +205,77 @@ typedef struct _cef_browser_t { /// True if this object is currently valid. This will return false (0) after /// cef_life_span_handler_t::OnBeforeClose is called. /// - int(CEF_CALLBACK *is_valid)(struct _cef_browser_t *self); + int(CEF_CALLBACK* is_valid)(struct _cef_browser_t* self); /// /// Returns the browser host object. This function can only be called in the /// browser process. /// - struct _cef_browser_host_t *(CEF_CALLBACK *get_host)( - struct _cef_browser_t *self); + struct _cef_browser_host_t*(CEF_CALLBACK* get_host)( + struct _cef_browser_t* self); /// /// Returns true (1) if the browser can navigate backwards. /// - int(CEF_CALLBACK *can_go_back)(struct _cef_browser_t *self); + int(CEF_CALLBACK* can_go_back)(struct _cef_browser_t* self); /// /// Navigate backwards. /// - void(CEF_CALLBACK *go_back)(struct _cef_browser_t *self); + void(CEF_CALLBACK* go_back)(struct _cef_browser_t* self); /// /// Returns true (1) if the browser can navigate forwards. /// - int(CEF_CALLBACK *can_go_forward)(struct _cef_browser_t *self); + int(CEF_CALLBACK* can_go_forward)(struct _cef_browser_t* self); /// /// Navigate forwards. /// - void(CEF_CALLBACK *go_forward)(struct _cef_browser_t *self); + void(CEF_CALLBACK* go_forward)(struct _cef_browser_t* self); /// /// Returns true (1) if the browser is currently loading. /// - int(CEF_CALLBACK *is_loading)(struct _cef_browser_t *self); + int(CEF_CALLBACK* is_loading)(struct _cef_browser_t* self); /// /// Reload the current page. /// - void(CEF_CALLBACK *reload)(struct _cef_browser_t *self); + void(CEF_CALLBACK* reload)(struct _cef_browser_t* self); /// /// Reload the current page ignoring any cached data. /// - void(CEF_CALLBACK *reload_ignore_cache)(struct _cef_browser_t *self); + void(CEF_CALLBACK* reload_ignore_cache)(struct _cef_browser_t* self); /// /// Stop loading the page. /// - void(CEF_CALLBACK *stop_load)(struct _cef_browser_t *self); + void(CEF_CALLBACK* stop_load)(struct _cef_browser_t* self); /// /// Returns the globally unique identifier for this browser. This value is /// also used as the tabId for extension APIs. /// - int(CEF_CALLBACK *get_identifier)(struct _cef_browser_t *self); + int(CEF_CALLBACK* get_identifier)(struct _cef_browser_t* self); /// /// Returns true (1) if this object is pointing to the same handle as |that| /// object. /// - int(CEF_CALLBACK *is_same)(struct _cef_browser_t *self, - struct _cef_browser_t *that); + int(CEF_CALLBACK* is_same)(struct _cef_browser_t* self, + struct _cef_browser_t* that); /// /// Returns true (1) if the browser is a popup. /// - int(CEF_CALLBACK *is_popup)(struct _cef_browser_t *self); + int(CEF_CALLBACK* is_popup)(struct _cef_browser_t* self); /// /// Returns true (1) if a document has been loaded in the browser. /// - int(CEF_CALLBACK *has_document)(struct _cef_browser_t *self); + int(CEF_CALLBACK* has_document)(struct _cef_browser_t* self); /// /// Returns the main (top-level) frame for the browser. In the browser process @@ -278,240 +286,251 @@ typedef struct _cef_browser_t { /// change during cross-origin navigation or re-navigation after renderer /// process termination (due to crashes, etc). /// - struct _cef_frame_t *(CEF_CALLBACK *get_main_frame)( - struct _cef_browser_t *self); + struct _cef_frame_t*(CEF_CALLBACK* get_main_frame)( + struct _cef_browser_t* self); /// /// Returns the focused frame for the browser. /// - struct _cef_frame_t *(CEF_CALLBACK *get_focused_frame)( - struct _cef_browser_t *self); + struct _cef_frame_t*(CEF_CALLBACK* get_focused_frame)( + struct _cef_browser_t* self); /// /// Returns the frame with the specified identifier, or NULL if not found. /// - struct _cef_frame_t *(CEF_CALLBACK *get_frame_byident)( - struct _cef_browser_t *self, int64 identifier); + struct _cef_frame_t*(CEF_CALLBACK* get_frame_byident)( + struct _cef_browser_t* self, + int64 identifier); /// /// Returns the frame with the specified name, or NULL if not found. /// - struct _cef_frame_t *(CEF_CALLBACK *get_frame)(struct _cef_browser_t *self, - const cef_string_t *name); + struct _cef_frame_t*(CEF_CALLBACK* get_frame)(struct _cef_browser_t* self, + const cef_string_t* name); /// /// Returns the number of frames that currently exist. /// - size_t(CEF_CALLBACK *get_frame_count)(struct _cef_browser_t *self); + size_t(CEF_CALLBACK* get_frame_count)(struct _cef_browser_t* self); /// /// Returns the identifiers of all existing frames. /// - void(CEF_CALLBACK *get_frame_identifiers)(struct _cef_browser_t *self, - size_t *identifiersCount, - int64 *identifiers); + void(CEF_CALLBACK* get_frame_identifiers)(struct _cef_browser_t* self, + size_t* identifiersCount, + int64* identifiers); /// /// Returns the names of all existing frames. /// - void(CEF_CALLBACK *get_frame_names)(struct _cef_browser_t *self, + void(CEF_CALLBACK* get_frame_names)(struct _cef_browser_t* self, cef_string_list_t names); /// /// Returns the Permission Request Delegate object. /// - struct _cef_browser_permission_request_delegate_t *( - CEF_CALLBACK *get_permission_request_delegate)( - struct _cef_browser_t *self); + struct _cef_browser_permission_request_delegate_t*( + CEF_CALLBACK* get_permission_request_delegate)( + struct _cef_browser_t* self); /// /// Returns the Geolocation Permission handler object. /// - struct _cef_geolocation_acess_t *(CEF_CALLBACK *get_geolocation_permissions)( - struct _cef_browser_t *self); + struct _cef_geolocation_acess_t*(CEF_CALLBACK* get_geolocation_permissions)( + struct _cef_browser_t* self); /// /// Returns true (1) if the browser can navigate forwards. /// - int(CEF_CALLBACK *can_go_back_or_forward)(struct _cef_browser_t *self, + int(CEF_CALLBACK* can_go_back_or_forward)(struct _cef_browser_t* self, int num_steps); /// /// Navigate backwards or forwards. /// - void(CEF_CALLBACK *go_back_or_forward)(struct _cef_browser_t *self, + void(CEF_CALLBACK* go_back_or_forward)(struct _cef_browser_t* self, int num_steps); /// /// DeleteHistory /// - void(CEF_CALLBACK *delete_history)(struct _cef_browser_t *self); + void(CEF_CALLBACK* delete_history)(struct _cef_browser_t* self); /// /// display the selection control when click Free copy structure /// - void(CEF_CALLBACK *select_and_copy)(struct _cef_browser_t *self); + void(CEF_CALLBACK* select_and_copy)(struct _cef_browser_t* self); /// /// should show free copy menu /// - int(CEF_CALLBACK *should_show_free_copy)(struct _cef_browser_t *self); + int(CEF_CALLBACK* should_show_free_copy)(struct _cef_browser_t* self); /// /// select password dialog to fill /// - void(CEF_CALLBACK *password_suggestion_selected)(struct _cef_browser_t *self, + void(CEF_CALLBACK* password_suggestion_selected)(struct _cef_browser_t* self, int list_index); /// /// Update browser controls state. /// - void(CEF_CALLBACK *update_browser_controls_state)(struct _cef_browser_t *self, + void(CEF_CALLBACK* update_browser_controls_state)(struct _cef_browser_t* self, int constraints, - int current, int animate); + int current, + int animate); /// /// Update browser controls height. /// - void(CEF_CALLBACK *update_browser_controls_height)( - struct _cef_browser_t *self, int height, int animate); + void(CEF_CALLBACK* update_browser_controls_height)( + struct _cef_browser_t* self, + int height, + int animate); /// /// Prefetch the resources required by the page, but will not execute js or /// render the page. /// - void(CEF_CALLBACK *prefetch_page)(struct _cef_browser_t *self, - cef_string_t *url, - cef_string_t *additionalHttpHeaders); + void(CEF_CALLBACK* prefetch_page)(struct _cef_browser_t* self, + cef_string_t* url, + cef_string_t* additionalHttpHeaders); /// /// Reload the current page with original url. /// - void(CEF_CALLBACK *reload_original_url)(struct _cef_browser_t *self); + void(CEF_CALLBACK* reload_original_url)(struct _cef_browser_t* self); /// /// Can save current page as a archive. /// - int(CEF_CALLBACK *can_store_web_archive)(struct _cef_browser_t *self); + int(CEF_CALLBACK* can_store_web_archive)(struct _cef_browser_t* self); /// /// Set user agent for current page. /// - void(CEF_CALLBACK *set_browser_user_agent_string)( - struct _cef_browser_t *self, const cef_string_t *user_agent); + void(CEF_CALLBACK* set_browser_user_agent_string)( + struct _cef_browser_t* self, + const cef_string_t* user_agent); /// /// Is loading to different document. /// - int(CEF_CALLBACK *should_show_loading_ui)(struct _cef_browser_t *self); + int(CEF_CALLBACK* should_show_loading_ui)(struct _cef_browser_t* self); /// /// Set force enable zoom. /// - void(CEF_CALLBACK *set_force_enable_zoom)(struct _cef_browser_t *self, + void(CEF_CALLBACK* set_force_enable_zoom)(struct _cef_browser_t* self, int forceEnableZoom); /// /// Whether force enable zoom had been enabled. /// - int(CEF_CALLBACK *get_force_enable_zoom)(struct _cef_browser_t *self); + int(CEF_CALLBACK* get_force_enable_zoom)(struct _cef_browser_t* self); /// /// Returns the NWeb Id. /// - int(CEF_CALLBACK *get_nweb_id)(struct _cef_browser_t *self); + int(CEF_CALLBACK* get_nweb_id)(struct _cef_browser_t* self); /// /// Set whether the target_blank pop-up window is opened in the current tab. /// - void(CEF_CALLBACK *set_enable_blank_target_popup_intercept)( - struct _cef_browser_t *self, int enableBlankTargetPopup); + void(CEF_CALLBACK* set_enable_blank_target_popup_intercept)( + struct _cef_browser_t* self, + int enableBlankTargetPopup); /// /// Whether automatically saving password had been enabled. /// - int(CEF_CALLBACK *get_save_password_automatically)( - struct _cef_browser_t *self); + int(CEF_CALLBACK* get_save_password_automatically)( + struct _cef_browser_t* self); /// /// Set enable to allow automatically save password /// - void(CEF_CALLBACK *set_save_password_automatically)( - struct _cef_browser_t *self, int enable); + void(CEF_CALLBACK* set_save_password_automatically)( + struct _cef_browser_t* self, + int enable); /// /// save or upddate current page password /// - void(CEF_CALLBACK *save_or_update_password)(struct _cef_browser_t *self, + void(CEF_CALLBACK* save_or_update_password)(struct _cef_browser_t* self, int is_update); /// /// Whether saving password had been enabled. /// - int(CEF_CALLBACK *get_save_password)(struct _cef_browser_t *self); + int(CEF_CALLBACK* get_save_password)(struct _cef_browser_t* self); /// /// Set enable to save password /// - void(CEF_CALLBACK *set_save_password)(struct _cef_browser_t *self, + void(CEF_CALLBACK* set_save_password)(struct _cef_browser_t* self, int enable); /// /// Get security level for current page. /// - int(CEF_CALLBACK *get_security_level)(struct _cef_browser_t *self); + int(CEF_CALLBACK* get_security_level)(struct _cef_browser_t* self); /// /// Enable the ability to check website security risks. /// - void(CEF_CALLBACK *enable_safe_browsing)(struct _cef_browser_t *self, + void(CEF_CALLBACK* enable_safe_browsing)(struct _cef_browser_t* self, int enable); /// /// Get whether checking website security risks is enabled. /// - int(CEF_CALLBACK *is_safe_browsing_enabled)(struct _cef_browser_t *self); + int(CEF_CALLBACK* is_safe_browsing_enabled)(struct _cef_browser_t* self); /// /// Enable the ability to intelligent tracking prevention, default disabled. /// - void(CEF_CALLBACK *enable_intelligent_tracking_prevention)( - struct _cef_browser_t *self, int enable); + void(CEF_CALLBACK* enable_intelligent_tracking_prevention)( + struct _cef_browser_t* self, + int enable); /// /// Get whether intelligent tracking prevention is enabled. /// - int(CEF_CALLBACK *is_intelligent_tracking_prevention_enabled)( - struct _cef_browser_t *self); + int(CEF_CALLBACK* is_intelligent_tracking_prevention_enabled)( + struct _cef_browser_t* self); /// /// Get whether Ads block is enabled. /// - int(CEF_CALLBACK *is_ads_block_enabled)(struct _cef_browser_t *self); + int(CEF_CALLBACK* is_ads_block_enabled)(struct _cef_browser_t* self); /// /// Get whether Ads block is enabled for current page. /// - int(CEF_CALLBACK *is_ads_block_enabled_for_cur_page)( - struct _cef_browser_t *self); + int(CEF_CALLBACK* is_ads_block_enabled_for_cur_page)( + struct _cef_browser_t* self); /// /// Set enable to allow automatically save password /// - void(CEF_CALLBACK *enable_ads_block)(struct _cef_browser_t *self, int enable); + void(CEF_CALLBACK* enable_ads_block)(struct _cef_browser_t* self, int enable); /// /// Set url trust list. /// - int(CEF_CALLBACK *set_url_trust_list_with_err_msg)( - struct _cef_browser_t *self, const cef_string_t *urlTrustList, - cef_string_t *detailErrMsg); + int(CEF_CALLBACK* set_url_trust_list_with_err_msg)( + struct _cef_browser_t* self, + const cef_string_t* urlTrustList, + cef_string_t* detailErrMsg); /// /// Set url trust list. /// - void(CEF_CALLBACK *set_back_forward_cache_options)( - struct _cef_browser_t *self, int32_t size, int32_t timeToLive); + void(CEF_CALLBACK* set_back_forward_cache_options)( + struct _cef_browser_t* self, + int32_t size, + int32_t timeToLive); } cef_browser_t; /// @@ -529,8 +548,8 @@ typedef struct _cef_run_file_dialog_callback_t { /// will be a single value or a list of values depending on the dialog mode. /// If the selection was cancelled |file_paths| will be NULL. /// - void(CEF_CALLBACK *on_file_dialog_dismissed)( - struct _cef_run_file_dialog_callback_t *self, + void(CEF_CALLBACK* on_file_dialog_dismissed)( + struct _cef_run_file_dialog_callback_t* self, cef_string_list_t file_paths); } cef_run_file_dialog_callback_t; @@ -551,9 +570,11 @@ typedef struct _cef_navigation_entry_visitor_t { /// navigation entry. |index| is the 0-based index of this entry and |total| /// is the total number of entries. /// - int(CEF_CALLBACK *visit)(struct _cef_navigation_entry_visitor_t *self, - struct _cef_navigation_entry_t *entry, int current, - int index, int total); + int(CEF_CALLBACK* visit)(struct _cef_navigation_entry_visitor_t* self, + struct _cef_navigation_entry_t* entry, + int current, + int index, + int total); } cef_navigation_entry_visitor_t; /// @@ -571,8 +592,10 @@ typedef struct _cef_pdf_print_callback_t { /// is the output path. |ok| will be true (1) if the printing completed /// successfully or false (0) otherwise. /// - void(CEF_CALLBACK *on_pdf_print_finished)( - struct _cef_pdf_print_callback_t *self, const cef_string_t *path, int ok); + void(CEF_CALLBACK* on_pdf_print_finished)( + struct _cef_pdf_print_callback_t* self, + const cef_string_t* path, + int ok); } cef_pdf_print_callback_t; /// @@ -591,12 +614,32 @@ typedef struct _cef_download_image_callback_t { /// resulting HTTP status code. |image| is the resulting image, possibly at /// multiple scale factors, or NULL if the download failed. /// - void(CEF_CALLBACK *on_download_image_finished)( - struct _cef_download_image_callback_t *self, - const cef_string_t *image_url, int http_status_code, - struct _cef_image_t *image); + void(CEF_CALLBACK* on_download_image_finished)( + struct _cef_download_image_callback_t* self, + const cef_string_t* image_url, + int http_status_code, + struct _cef_image_t* image); } cef_download_image_callback_t; +/// +/// Callback structure for cef_browser_host_t::CreateToPDF. The functions of +/// this structure will be called on the browser process UI thread. +/// +typedef struct _cef_pdf_value_callback_t { + /// + /// Base structure. + /// + cef_base_ref_counted_t base; + + /// + /// Method that will be executed when the PDF create has completed. |value| is + /// the output pdf data stream. successfully or false (0) otherwise. + /// + void(CEF_CALLBACK* on_receive_value)(struct _cef_pdf_value_callback_t* self, + const char* value, + const long size); +} cef_pdf_value_callback_t; + /// /// Structure used to represent the browser process aspects of a browser. The /// functions of this structure can only be called in the browser process. They @@ -612,8 +655,8 @@ typedef struct _cef_browser_host_t { /// /// Returns the hosted browser object. /// - struct _cef_browser_t *(CEF_CALLBACK *get_browser)( - struct _cef_browser_host_t *self); + struct _cef_browser_t*(CEF_CALLBACK* get_browser)( + struct _cef_browser_host_t* self); /// /// Request that the browser close. The JavaScript 'onbeforeunload' event will @@ -625,7 +668,7 @@ typedef struct _cef_browser_host_t { /// or if |force_close| is true (1). See cef_life_span_handler_t::do_close() /// documentation for additional usage information. /// - void(CEF_CALLBACK *close_browser)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* close_browser)(struct _cef_browser_host_t* self, int force_close); /// @@ -637,12 +680,12 @@ typedef struct _cef_browser_host_t { /// additional usage information. This function must be called on the browser /// process UI thread. /// - int(CEF_CALLBACK *try_close_browser)(struct _cef_browser_host_t *self); + int(CEF_CALLBACK* try_close_browser)(struct _cef_browser_host_t* self); /// /// Set whether the browser is focused. /// - void(CEF_CALLBACK *set_focus)(struct _cef_browser_host_t *self, int focus); + void(CEF_CALLBACK* set_focus)(struct _cef_browser_host_t* self, int focus); /// /// Retrieve the window handle (if any) for this browser. If this browser is @@ -650,8 +693,8 @@ typedef struct _cef_browser_host_t { /// browser process UI thread and it will return the handle for the top-level /// native window. /// - cef_window_handle_t(CEF_CALLBACK *get_window_handle)( - struct _cef_browser_host_t *self); + cef_window_handle_t(CEF_CALLBACK* get_window_handle)( + struct _cef_browser_host_t* self); /// /// Retrieve the window handle (if any) of the browser that opened this @@ -659,31 +702,31 @@ typedef struct _cef_browser_host_t { /// wrapped in a cef_browser_view_t. This function can be used in combination /// with custom handling of modal windows. /// - cef_window_handle_t(CEF_CALLBACK *get_opener_window_handle)( - struct _cef_browser_host_t *self); + cef_window_handle_t(CEF_CALLBACK* get_opener_window_handle)( + struct _cef_browser_host_t* self); /// /// Returns true (1) if this browser is wrapped in a cef_browser_view_t. /// - int(CEF_CALLBACK *has_view)(struct _cef_browser_host_t *self); + int(CEF_CALLBACK* has_view)(struct _cef_browser_host_t* self); /// /// Returns the client for this browser. /// - struct _cef_client_t *(CEF_CALLBACK *get_client)( - struct _cef_browser_host_t *self); + struct _cef_client_t*(CEF_CALLBACK* get_client)( + struct _cef_browser_host_t* self); /// /// Returns the request context for this browser. /// - struct _cef_request_context_t *(CEF_CALLBACK *get_request_context)( - struct _cef_browser_host_t *self); + struct _cef_request_context_t*(CEF_CALLBACK* get_request_context)( + struct _cef_browser_host_t* self); /// /// Get the current zoom level. The default zoom level is 0.0. This function /// can only be called on the UI thread. /// - double(CEF_CALLBACK *get_zoom_level)(struct _cef_browser_host_t *self); + double(CEF_CALLBACK* get_zoom_level)(struct _cef_browser_host_t* self); /// /// Change the zoom level to the specified value. Specify 0.0 to reset the @@ -691,7 +734,7 @@ typedef struct _cef_browser_host_t { /// immediately. Otherwise, the change will be applied asynchronously on the /// UI thread. /// - void(CEF_CALLBACK *set_zoom_level)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* set_zoom_level)(struct _cef_browser_host_t* self, double zoomLevel); /// @@ -709,17 +752,19 @@ typedef struct _cef_browser_host_t { /// dismissed or immediately if another dialog is already pending. The dialog /// will be initiated asynchronously on the UI thread. /// - void(CEF_CALLBACK *run_file_dialog)( - struct _cef_browser_host_t *self, cef_file_dialog_mode_t mode, - const cef_string_t *title, const cef_string_t *default_file_path, + void(CEF_CALLBACK* run_file_dialog)( + struct _cef_browser_host_t* self, + cef_file_dialog_mode_t mode, + const cef_string_t* title, + const cef_string_t* default_file_path, cef_string_list_t accept_filters, - struct _cef_run_file_dialog_callback_t *callback); + struct _cef_run_file_dialog_callback_t* callback); /// /// Download the file at |url| using cef_download_handler_t. /// - void(CEF_CALLBACK *start_download)(struct _cef_browser_host_t *self, - const cef_string_t *url); + void(CEF_CALLBACK* start_download)(struct _cef_browser_host_t* self, + const cef_string_t* url); /// /// Download |image_url| and execute |callback| on completion with the images @@ -733,15 +778,18 @@ typedef struct _cef_browser_host_t { /// 0 means unlimited. If |bypass_cache| is true (1) then |image_url| is /// requested from the server even if it is present in the browser cache. /// - void(CEF_CALLBACK *download_image)( - struct _cef_browser_host_t *self, const cef_string_t *image_url, - int is_favicon, uint32 max_image_size, int bypass_cache, - struct _cef_download_image_callback_t *callback); + void(CEF_CALLBACK* download_image)( + struct _cef_browser_host_t* self, + const cef_string_t* image_url, + int is_favicon, + uint32 max_image_size, + int bypass_cache, + struct _cef_download_image_callback_t* callback); /// /// Print the current browser contents. /// - void(CEF_CALLBACK *print)(struct _cef_browser_host_t *self); + void(CEF_CALLBACK* print)(struct _cef_browser_host_t* self); /// /// Print the current browser contents to the PDF file specified by |path| and @@ -749,10 +797,11 @@ typedef struct _cef_browser_host_t { /// |path| when done. For PDF printing to work on Linux you must implement the /// cef_print_handler_t::GetPdfPaperSize function. /// - void(CEF_CALLBACK *print_to_pdf)( - struct _cef_browser_host_t *self, const cef_string_t *path, - const struct _cef_pdf_print_settings_t *settings, - struct _cef_pdf_print_callback_t *callback); + void(CEF_CALLBACK* print_to_pdf)( + struct _cef_browser_host_t* self, + const cef_string_t* path, + const struct _cef_pdf_print_settings_t* settings, + struct _cef_pdf_print_callback_t* callback); /// /// Search for |searchText|. |forward| indicates whether to search forward or @@ -763,14 +812,17 @@ typedef struct _cef_browser_host_t { /// The cef_find_handler_t instance, if any, returned via /// cef_client_t::GetFindHandler will be called to report find results. /// - void(CEF_CALLBACK *find)(struct _cef_browser_host_t *self, - const cef_string_t *searchText, int forward, - int matchCase, int findNext, int newSession); + void(CEF_CALLBACK* find)(struct _cef_browser_host_t* self, + const cef_string_t* searchText, + int forward, + int matchCase, + int findNext, + int newSession); /// /// Cancel all searches that are currently going on. /// - void(CEF_CALLBACK *stop_finding)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* stop_finding)(struct _cef_browser_host_t* self, int clearSelection); /// @@ -782,22 +834,23 @@ typedef struct _cef_browser_host_t { /// location will be inspected. The |windowInfo| parameter will be ignored if /// this browser is wrapped in a cef_browser_view_t. /// - void(CEF_CALLBACK *show_dev_tools)( - struct _cef_browser_host_t *self, - const struct _cef_window_info_t *windowInfo, struct _cef_client_t *client, - const struct _cef_browser_settings_t *settings, - const cef_point_t *inspect_element_at); + void(CEF_CALLBACK* show_dev_tools)( + struct _cef_browser_host_t* self, + const struct _cef_window_info_t* windowInfo, + struct _cef_client_t* client, + const struct _cef_browser_settings_t* settings, + const cef_point_t* inspect_element_at); /// /// Explicitly close the associated DevTools browser, if any. /// - void(CEF_CALLBACK *close_dev_tools)(struct _cef_browser_host_t *self); + void(CEF_CALLBACK* close_dev_tools)(struct _cef_browser_host_t* self); /// /// Returns true (1) if this browser currently has an associated DevTools /// browser. Must be called on the browser process UI thread. /// - int(CEF_CALLBACK *has_dev_tools)(struct _cef_browser_host_t *self); + int(CEF_CALLBACK* has_dev_tools)(struct _cef_browser_host_t* self); /// /// Send a function call message over the DevTools protocol. |message| must be @@ -832,8 +885,8 @@ typedef struct _cef_browser_host_t { /// for development purposes by passing the `--devtools-protocol-log- /// file=` command-line flag. /// - int(CEF_CALLBACK *send_dev_tools_message)(struct _cef_browser_host_t *self, - const void *message, + int(CEF_CALLBACK* send_dev_tools_message)(struct _cef_browser_host_t* self, + const void* message, size_t message_size); /// @@ -849,9 +902,11 @@ typedef struct _cef_browser_host_t { /// See the SendDevToolsMessage documentation for additional usage /// information. /// - int(CEF_CALLBACK *execute_dev_tools_method)( - struct _cef_browser_host_t *self, int message_id, - const cef_string_t *method, struct _cef_dictionary_value_t *params); + int(CEF_CALLBACK* execute_dev_tools_method)( + struct _cef_browser_host_t* self, + int message_id, + const cef_string_t* method, + struct _cef_dictionary_value_t* params); /// /// Add an observer for DevTools protocol messages (function results and @@ -859,9 +914,9 @@ typedef struct _cef_browser_host_t { /// Registration object is destroyed. See the SendDevToolsMessage /// documentation for additional usage information. /// - struct _cef_registration_t *(CEF_CALLBACK *add_dev_tools_message_observer)( - struct _cef_browser_host_t *self, - struct _cef_dev_tools_message_observer_t *observer); + struct _cef_registration_t*(CEF_CALLBACK* add_dev_tools_message_observer)( + struct _cef_browser_host_t* self, + struct _cef_dev_tools_message_observer_t* observer); /// /// Retrieve a snapshot of current navigation entries as values sent to the @@ -869,28 +924,29 @@ typedef struct _cef_browser_host_t { /// navigation entry will be sent, otherwise all navigation entries will be /// sent. /// - void(CEF_CALLBACK *get_navigation_entries)( - struct _cef_browser_host_t *self, - struct _cef_navigation_entry_visitor_t *visitor, int current_only); + void(CEF_CALLBACK* get_navigation_entries)( + struct _cef_browser_host_t* self, + struct _cef_navigation_entry_visitor_t* visitor, + int current_only); /// /// If a misspelled word is currently selected in an editable node calling /// this function will replace it with the specified |word|. /// - void(CEF_CALLBACK *replace_misspelling)(struct _cef_browser_host_t *self, - const cef_string_t *word); + void(CEF_CALLBACK* replace_misspelling)(struct _cef_browser_host_t* self, + const cef_string_t* word); /// /// Add the specified |word| to the spelling dictionary. /// - void(CEF_CALLBACK *add_word_to_dictionary)(struct _cef_browser_host_t *self, - const cef_string_t *word); + void(CEF_CALLBACK* add_word_to_dictionary)(struct _cef_browser_host_t* self, + const cef_string_t* word); /// /// Returns true (1) if window rendering is disabled. /// - int(CEF_CALLBACK *is_window_rendering_disabled)( - struct _cef_browser_host_t *self); + int(CEF_CALLBACK* is_window_rendering_disabled)( + struct _cef_browser_host_t* self); /// /// Notify the browser that the widget has been resized. The browser will @@ -898,45 +954,46 @@ typedef struct _cef_browser_host_t { /// call cef_render_handler_t::OnPaint asynchronously with the updated /// regions. This function is only used when window rendering is disabled. /// - void(CEF_CALLBACK *was_resized)(struct _cef_browser_host_t *self); + void(CEF_CALLBACK* was_resized)(struct _cef_browser_host_t* self); /// /// Notify the browser that it has been hidden or shown. Layouting and /// cef_render_handler_t::OnPaint notification will stop when the browser is /// hidden. This function is only used when window rendering is disabled. /// - void(CEF_CALLBACK *was_hidden)(struct _cef_browser_host_t *self, int hidden); + void(CEF_CALLBACK* was_hidden)(struct _cef_browser_host_t* self, int hidden); /// /// Notify the browser that it has been occluded or unoccluded. Layouting and /// cef_render_handler_t::OnPaint notification will stop when the browser is /// occluded. This function is only used when window rendering is disabled. /// - void(CEF_CALLBACK *was_occluded)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* was_occluded)(struct _cef_browser_host_t* self, int occluded); /// /// Running and do something when the window show /// - void(CEF_CALLBACK *on_window_show)(struct _cef_browser_host_t *self); + void(CEF_CALLBACK* on_window_show)(struct _cef_browser_host_t* self); /// /// Running and do something when the window hide /// - void(CEF_CALLBACK *on_window_hide)(struct _cef_browser_host_t *self); + void(CEF_CALLBACK* on_window_hide)(struct _cef_browser_host_t* self); /// /// Running and do something when the render visible /// - void(CEF_CALLBACK *on_online_render_to_foreground)( - struct _cef_browser_host_t *self); + void(CEF_CALLBACK* on_online_render_to_foreground)( + struct _cef_browser_host_t* self); /// /// Send touch event list to the browser for a windowless browser. /// - void(CEF_CALLBACK *send_touch_event_list)( - struct _cef_browser_host_t *self, size_t event_listCount, - cef_touch_event_t const *event_list); + void(CEF_CALLBACK* send_touch_event_list)( + struct _cef_browser_host_t* self, + size_t event_listCount, + cef_touch_event_t const* event_list); /// /// Send a notification to the browser that the screen info has changed. The @@ -946,45 +1003,46 @@ typedef struct _cef_browser_host_t { /// current display. This function is only used when window rendering is /// disabled. /// - void(CEF_CALLBACK *notify_screen_info_changed)( - struct _cef_browser_host_t *self); + void(CEF_CALLBACK* notify_screen_info_changed)( + struct _cef_browser_host_t* self); /// /// Invalidate the view. The browser will call cef_render_handler_t::OnPaint /// asynchronously. This function is only used when window rendering is /// disabled. /// - void(CEF_CALLBACK *invalidate)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* invalidate)(struct _cef_browser_host_t* self, cef_paint_element_type_t type); /// /// Issue a BeginFrame request to Chromium. Only valid when /// cef_window_tInfo::external_begin_frame_enabled is set to true (1). /// - void(CEF_CALLBACK *send_external_begin_frame)( - struct _cef_browser_host_t *self); + void(CEF_CALLBACK* send_external_begin_frame)( + struct _cef_browser_host_t* self); /// /// Send a key event to the browser. /// - void(CEF_CALLBACK *send_key_event)(struct _cef_browser_host_t *self, - const cef_key_event_t *event); + void(CEF_CALLBACK* send_key_event)(struct _cef_browser_host_t* self, + const cef_key_event_t* event); /// /// Send a mouse click event to the browser. The |x| and |y| coordinates are /// relative to the upper-left corner of the view. /// - void(CEF_CALLBACK *send_mouse_click_event)(struct _cef_browser_host_t *self, - const cef_mouse_event_t *event, + void(CEF_CALLBACK* send_mouse_click_event)(struct _cef_browser_host_t* self, + const cef_mouse_event_t* event, cef_mouse_button_type_t type, - int mouseUp, int clickCount); + int mouseUp, + int clickCount); /// /// Send a mouse move event to the browser. The |x| and |y| coordinates are /// relative to the upper-left corner of the view. /// - void(CEF_CALLBACK *send_mouse_move_event)(struct _cef_browser_host_t *self, - const cef_mouse_event_t *event, + void(CEF_CALLBACK* send_mouse_move_event)(struct _cef_browser_host_t* self, + const cef_mouse_event_t* event, int mouseLeave); /// @@ -995,27 +1053,28 @@ typedef struct _cef_browser_host_t { /// rendering disabled cef_render_handler_t::GetScreenPoint should be /// implemented properly. /// - void(CEF_CALLBACK *send_mouse_wheel_event)(struct _cef_browser_host_t *self, - const cef_mouse_event_t *event, - int deltaX, int deltaY); + void(CEF_CALLBACK* send_mouse_wheel_event)(struct _cef_browser_host_t* self, + const cef_mouse_event_t* event, + int deltaX, + int deltaY); /// /// Send a touch event to the browser for a windowless browser. /// - void(CEF_CALLBACK *send_touch_event)(struct _cef_browser_host_t *self, - const cef_touch_event_t *event); + void(CEF_CALLBACK* send_touch_event)(struct _cef_browser_host_t* self, + const cef_touch_event_t* event); /// /// Send a capture lost event to the browser. /// - void(CEF_CALLBACK *send_capture_lost_event)(struct _cef_browser_host_t *self); + void(CEF_CALLBACK* send_capture_lost_event)(struct _cef_browser_host_t* self); /// /// Notify the browser that the window hosting it is about to be moved or /// resized. This function is only used on Windows and Linux. /// - void(CEF_CALLBACK *notify_move_or_resize_started)( - struct _cef_browser_host_t *self); + void(CEF_CALLBACK* notify_move_or_resize_started)( + struct _cef_browser_host_t* self); /// /// Returns the maximum rate in frames per second (fps) that @@ -1024,8 +1083,8 @@ typedef struct _cef_browser_host_t { /// requested rate. The minimum value is 1 and the maximum value is 60 /// (default 30). This function can only be called on the UI thread. /// - int(CEF_CALLBACK *get_windowless_frame_rate)( - struct _cef_browser_host_t *self); + int(CEF_CALLBACK* get_windowless_frame_rate)( + struct _cef_browser_host_t* self); /// /// Set the maximum rate in frames per second (fps) that @@ -1035,8 +1094,9 @@ typedef struct _cef_browser_host_t { /// (default 30). Can also be set at browser creation via /// cef_browser_tSettings.windowless_frame_rate. /// - void(CEF_CALLBACK *set_windowless_frame_rate)( - struct _cef_browser_host_t *self, int frame_rate); + void(CEF_CALLBACK* set_windowless_frame_rate)( + struct _cef_browser_host_t* self, + int frame_rate); /// /// Begins a new composition or updates the existing composition. Blink has a @@ -1063,10 +1123,13 @@ typedef struct _cef_browser_host_t { /// /// This function is only used when window rendering is disabled. /// - void(CEF_CALLBACK *ime_set_composition)( - struct _cef_browser_host_t *self, const cef_string_t *text, - size_t underlinesCount, cef_composition_underline_t const *underlines, - const cef_range_t *replacement_range, const cef_range_t *selection_range); + void(CEF_CALLBACK* ime_set_composition)( + struct _cef_browser_host_t* self, + const cef_string_t* text, + size_t underlinesCount, + cef_composition_underline_t const* underlines, + const cef_range_t* replacement_range, + const cef_range_t* selection_range); /// /// Completes the existing composition by optionally inserting the specified @@ -1077,9 +1140,9 @@ typedef struct _cef_browser_host_t { /// |relative_cursor_pos| values are only used on OS X. This function is only /// used when window rendering is disabled. /// - void(CEF_CALLBACK *ime_commit_text)(struct _cef_browser_host_t *self, - const cef_string_t *text, - const cef_range_t *replacement_range, + void(CEF_CALLBACK* ime_commit_text)(struct _cef_browser_host_t* self, + const cef_string_t* text, + const cef_range_t* replacement_range, int relative_cursor_pos); /// @@ -1088,15 +1151,16 @@ typedef struct _cef_browser_host_t { /// any, will be discarded. See comments on ImeSetComposition for usage. This /// function is only used when window rendering is disabled. /// - void(CEF_CALLBACK *ime_finish_composing_text)( - struct _cef_browser_host_t *self, int keep_selection); + void(CEF_CALLBACK* ime_finish_composing_text)( + struct _cef_browser_host_t* self, + int keep_selection); /// /// Cancels the existing composition and discards the composition node /// contents without applying them. See comments on ImeSetComposition for /// usage. This function is only used when window rendering is disabled. /// - void(CEF_CALLBACK *ime_cancel_composition)(struct _cef_browser_host_t *self); + void(CEF_CALLBACK* ime_cancel_composition)(struct _cef_browser_host_t* self); /// /// Call this function when the user drags the mouse into the web view (before @@ -1107,9 +1171,11 @@ typedef struct _cef_browser_host_t { /// cef_render_handler_t::StartDragging). This function is only used when /// window rendering is disabled. /// - void(CEF_CALLBACK *drag_target_drag_enter)( - struct _cef_browser_host_t *self, struct _cef_drag_data_t *drag_data, - const cef_mouse_event_t *event, cef_drag_operations_mask_t allowed_ops); + void(CEF_CALLBACK* drag_target_drag_enter)( + struct _cef_browser_host_t* self, + struct _cef_drag_data_t* drag_data, + const cef_mouse_event_t* event, + cef_drag_operations_mask_t allowed_ops); /// /// Call this function each time the mouse is moved across the web view during @@ -1117,8 +1183,9 @@ typedef struct _cef_browser_host_t { /// DragTargetDragLeave/DragTargetDrop). This function is only used when /// window rendering is disabled. /// - void(CEF_CALLBACK *drag_target_drag_over)( - struct _cef_browser_host_t *self, const cef_mouse_event_t *event, + void(CEF_CALLBACK* drag_target_drag_over)( + struct _cef_browser_host_t* self, + const cef_mouse_event_t* event, cef_drag_operations_mask_t allowed_ops); /// @@ -1126,7 +1193,7 @@ typedef struct _cef_browser_host_t { /// (after calling DragTargetDragEnter). This function is only used when /// window rendering is disabled. /// - void(CEF_CALLBACK *drag_target_drag_leave)(struct _cef_browser_host_t *self); + void(CEF_CALLBACK* drag_target_drag_leave)(struct _cef_browser_host_t* self); /// /// Call this function when the user completes the drag operation by dropping @@ -1135,8 +1202,8 @@ typedef struct _cef_browser_host_t { /// DragTargetDragEnter call. This function is only used when window rendering /// is disabled. /// - void(CEF_CALLBACK *drag_target_drop)(struct _cef_browser_host_t *self, - const cef_mouse_event_t *event); + void(CEF_CALLBACK* drag_target_drop)(struct _cef_browser_host_t* self, + const cef_mouse_event_t* event); /// /// Call this function when the drag operation started by a @@ -1147,8 +1214,9 @@ typedef struct _cef_browser_host_t { /// DragSource* mthods. This function is only used when window rendering is /// disabled. /// - void(CEF_CALLBACK *drag_source_ended_at)(struct _cef_browser_host_t *self, - int x, int y, + void(CEF_CALLBACK* drag_source_ended_at)(struct _cef_browser_host_t* self, + int x, + int y, cef_drag_operations_mask_t op); /// @@ -1159,15 +1227,15 @@ typedef struct _cef_browser_host_t { /// target then all DragTarget* functions should be called before DragSource* /// mthods. This function is only used when window rendering is disabled. /// - void(CEF_CALLBACK *drag_source_system_drag_ended)( - struct _cef_browser_host_t *self); + void(CEF_CALLBACK* drag_source_system_drag_ended)( + struct _cef_browser_host_t* self); /// /// Returns the current visible navigation entry for this browser. This /// function can only be called on the UI thread. /// - struct _cef_navigation_entry_t *(CEF_CALLBACK *get_visible_navigation_entry)( - struct _cef_browser_host_t *self); + struct _cef_navigation_entry_t*(CEF_CALLBACK* get_visible_navigation_entry)( + struct _cef_browser_host_t* self); /// /// Set accessibility state for all frames. |accessibility_state| may be @@ -1194,7 +1262,7 @@ typedef struct _cef_browser_host_t { /// accessibility objects are not created. The client may implement platform /// accessibility objects using CefAccessibiltyHandler callbacks if desired. /// - void(CEF_CALLBACK *set_accessibility_state)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* set_accessibility_state)(struct _cef_browser_host_t* self, cef_state_t accessibility_state); /// @@ -1202,278 +1270,295 @@ typedef struct _cef_browser_host_t { /// cef_display_handler_t::OnAutoResize. Notifications are disabled by /// default. |min_size| and |max_size| define the range of allowed sizes. /// - void(CEF_CALLBACK *set_auto_resize_enabled)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* set_auto_resize_enabled)(struct _cef_browser_host_t* self, int enabled, - const cef_size_t *min_size, - const cef_size_t *max_size); + const cef_size_t* min_size, + const cef_size_t* max_size); /// /// Returns the extension hosted in this browser or NULL if no extension is /// hosted. See cef_request_context_t::LoadExtension for details. /// - struct _cef_extension_t *(CEF_CALLBACK *get_extension)( - struct _cef_browser_host_t *self); + struct _cef_extension_t*(CEF_CALLBACK* get_extension)( + struct _cef_browser_host_t* self); /// /// Returns true (1) if this browser is hosting an extension background /// script. Background hosts do not have a window and are not displayable. See /// cef_request_context_t::LoadExtension for details. /// - int(CEF_CALLBACK *is_background_host)(struct _cef_browser_host_t *self); + int(CEF_CALLBACK* is_background_host)(struct _cef_browser_host_t* self); /// /// Set whether the browser's audio is muted. /// - void(CEF_CALLBACK *set_audio_muted)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* set_audio_muted)(struct _cef_browser_host_t* self, int mute); /// /// Returns true (1) if the browser's audio is muted. This function can only /// be called on the UI thread. /// - int(CEF_CALLBACK *is_audio_muted)(struct _cef_browser_host_t *self); + int(CEF_CALLBACK* is_audio_muted)(struct _cef_browser_host_t* self); /// /// GetRootBrowserAccessibilityManager /// - void(CEF_CALLBACK *get_root_browser_accessibility_manager)( - struct _cef_browser_host_t *self, void **manager); + void(CEF_CALLBACK* get_root_browser_accessibility_manager)( + struct _cef_browser_host_t* self, + void** manager); /// /// Execute a string of JavaScript code, return result by callback /// - void(CEF_CALLBACK *execute_java_script)( - struct _cef_browser_host_t *self, const char *code, - struct _cef_java_script_result_callback_t *callback, int extention); + void(CEF_CALLBACK* execute_java_script)( + struct _cef_browser_host_t* self, + const char* code, + struct _cef_java_script_result_callback_t* callback, + int extention); /// /// Execute a string of JavaScript code, return result by callback /// - void(CEF_CALLBACK *execute_java_script_ext)( - struct _cef_browser_host_t *self, const int fd, const uint64 scriptLength, - struct _cef_java_script_result_callback_t *callback, int extention); + void(CEF_CALLBACK* execute_java_script_ext)( + struct _cef_browser_host_t* self, + const int fd, + const uint64 scriptLength, + struct _cef_java_script_result_callback_t* callback, + int extention); /// /// Set native window from ohos rs /// - void(CEF_CALLBACK *set_native_window)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* set_native_window)(struct _cef_browser_host_t* self, cef_native_window_t window); /// /// Set web debugging access /// - void(CEF_CALLBACK *set_web_debugging_access)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* set_web_debugging_access)(struct _cef_browser_host_t* self, int isEnableDebug); /// /// Get web debugging access /// - int(CEF_CALLBACK *get_web_debugging_access)(struct _cef_browser_host_t *self); + int(CEF_CALLBACK* get_web_debugging_access)(struct _cef_browser_host_t* self); /// /// GetImageForContextNode /// - void(CEF_CALLBACK *get_image_for_context_node)( - struct _cef_browser_host_t *self); + void(CEF_CALLBACK* get_image_for_context_node)( + struct _cef_browser_host_t* self); /// /// GetImageFromCache /// - void(CEF_CALLBACK *get_image_from_cache)(struct _cef_browser_host_t *self, - const cef_string_t *url); + void(CEF_CALLBACK* get_image_from_cache)(struct _cef_browser_host_t* self, + const cef_string_t* url); /// /// ExitFullScreen /// - void(CEF_CALLBACK *exit_full_screen)(struct _cef_browser_host_t *self); + void(CEF_CALLBACK* exit_full_screen)(struct _cef_browser_host_t* self); /// /// UpdateLocale /// - void(CEF_CALLBACK *update_locale)(struct _cef_browser_host_t *self, - const cef_string_t *locale); + void(CEF_CALLBACK* update_locale)(struct _cef_browser_host_t* self, + const cef_string_t* locale); /// /// Returns the original url of the request. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t(CEF_CALLBACK *get_original_url)( - struct _cef_browser_host_t *self); + cef_string_userfree_t(CEF_CALLBACK* get_original_url)( + struct _cef_browser_host_t* self); /// /// Set network status /// - void(CEF_CALLBACK *put_network_available)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* put_network_available)(struct _cef_browser_host_t* self, int available); /// /// Remove web cache /// - void(CEF_CALLBACK *remove_cache)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* remove_cache)(struct _cef_browser_host_t* self, int include_disk_files); /// /// Post task to ui thread. /// - void(CEF_CALLBACK *post_task_to_uithread)(struct _cef_browser_host_t *self, - struct _cef_task_t *task); + void(CEF_CALLBACK* post_task_to_uithread)(struct _cef_browser_host_t* self, + struct _cef_task_t* task); /// /// Set the virtual pixel ratio /// - void(CEF_CALLBACK *set_virtual_pixel_ratio)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* set_virtual_pixel_ratio)(struct _cef_browser_host_t* self, float ratio); /// /// Get the virtual pixel ratio /// - float(CEF_CALLBACK *get_virtual_pixel_ratio)( - struct _cef_browser_host_t *self); + float(CEF_CALLBACK* get_virtual_pixel_ratio)( + struct _cef_browser_host_t* self); /// /// Recompute the WebPreferences based on the current state of the /// CefSettings, we will also call SetWebPreferences and send the updated /// WebPreferences to all RenderViews by WebContents. /// - void(CEF_CALLBACK *set_web_preferences)( - struct _cef_browser_host_t *self, - const struct _cef_browser_settings_t *browser_settings); + void(CEF_CALLBACK* set_web_preferences)( + struct _cef_browser_host_t* self, + const struct _cef_browser_settings_t* browser_settings); /// /// PutUserAgent /// - void(CEF_CALLBACK *put_user_agent)(struct _cef_browser_host_t *self, - const cef_string_t *ua); + void(CEF_CALLBACK* put_user_agent)(struct _cef_browser_host_t* self, + const cef_string_t* ua); /// /// DefaultUserAgent /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t(CEF_CALLBACK *default_user_agent)( - struct _cef_browser_host_t *self); + cef_string_userfree_t(CEF_CALLBACK* default_user_agent)( + struct _cef_browser_host_t* self); /// /// SetBackgroundColor /// - void(CEF_CALLBACK *set_background_color)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* set_background_color)(struct _cef_browser_host_t* self, int color); /// /// UpdateEasyListRules /// - void(CEF_CALLBACK *update_adblock_easy_list_rules)( - struct _cef_browser_host_t *self, long adBlockEasyListVersion); + void(CEF_CALLBACK* update_adblock_easy_list_rules)( + struct _cef_browser_host_t* self, + long adBlockEasyListVersion); /// /// RegisterArkJSfunction /// - void(CEF_CALLBACK *register_ark_jsfunction)( - struct _cef_browser_host_t *self, const cef_string_t *object_name, - cef_string_list_t method_list, cef_string_list_t async_method_list, - int32_t object_id, const cef_string_t *permission); + void(CEF_CALLBACK* register_ark_jsfunction)( + struct _cef_browser_host_t* self, + const cef_string_t* object_name, + cef_string_list_t method_list, + cef_string_list_t async_method_list, + int32_t object_id, + const cef_string_t* permission); /// /// UnregisterArkJSfunction /// - void(CEF_CALLBACK *unregister_ark_jsfunction)( - struct _cef_browser_host_t *self, const cef_string_t *object_name, + void(CEF_CALLBACK* unregister_ark_jsfunction)( + struct _cef_browser_host_t* self, + const cef_string_t* object_name, cef_string_list_t method_list); /// /// CallH5Function /// - void(CEF_CALLBACK *call_h5function)(struct _cef_browser_host_t *self, - int32_t routing_id, int32_t h5_object_id, - const cef_string_t *h5_method_name, + void(CEF_CALLBACK* call_h5function)(struct _cef_browser_host_t* self, + int32_t routing_id, + int32_t h5_object_id, + const cef_string_t* h5_method_name, size_t argsCount, - struct _cef_value_t *const *args); + struct _cef_value_t* const* args); /// /// Saves the current view as a web archive. /// - void(CEF_CALLBACK *store_web_archive)( - struct _cef_browser_host_t *self, const cef_string_t *base_name, - int auto_name, struct _cef_store_web_archive_result_callback_t *callback); + void(CEF_CALLBACK* store_web_archive)( + struct _cef_browser_host_t* self, + const cef_string_t* base_name, + int auto_name, + struct _cef_store_web_archive_result_callback_t* callback); /// /// Notify the browser that the widget has been resized because of virtual /// keyboard. /// - void(CEF_CALLBACK *was_keyboard_resized)(struct _cef_browser_host_t *self); + void(CEF_CALLBACK* was_keyboard_resized)(struct _cef_browser_host_t* self); /// /// Set if lower the frame rate. /// - void(CEF_CALLBACK *set_enable_lower_frame_rate)( - struct _cef_browser_host_t *self, int enabled); + void(CEF_CALLBACK* set_enable_lower_frame_rate)( + struct _cef_browser_host_t* self, + int enabled); /// /// Gets the title for the current page. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t(CEF_CALLBACK *title)(struct _cef_browser_host_t *self); + cef_string_userfree_t(CEF_CALLBACK* title)(struct _cef_browser_host_t* self); /// /// Create a message channel, which include two message ports. /// - void(CEF_CALLBACK *create_web_message_ports)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* create_web_message_ports)(struct _cef_browser_host_t* self, cef_string_list_t ports); /// /// Posts a MessageEvent to the main frame. /// - void(CEF_CALLBACK *post_web_message)(struct _cef_browser_host_t *self, - cef_string_t *message, + void(CEF_CALLBACK* post_web_message)(struct _cef_browser_host_t* self, + cef_string_t* message, cef_string_list_t ports, - cef_string_t *targetUri); + cef_string_t* targetUri); /// /// Close the web message port. /// - void(CEF_CALLBACK *close_port)(struct _cef_browser_host_t *self, - cef_string_t *port_handle); + void(CEF_CALLBACK* close_port)(struct _cef_browser_host_t* self, + cef_string_t* port_handle); /// /// Destroy all web message ports. /// - void(CEF_CALLBACK *destroy_all_web_message_ports)( - struct _cef_browser_host_t *self); + void(CEF_CALLBACK* destroy_all_web_message_ports)( + struct _cef_browser_host_t* self); /// /// Post a message to the port. /// - void(CEF_CALLBACK *post_port_message)(struct _cef_browser_host_t *self, - cef_string_t *port_handle, - struct _cef_value_t *message); + void(CEF_CALLBACK* post_port_message)(struct _cef_browser_host_t* self, + const cef_string_t* port_handle, + struct _cef_value_t* message); /// /// Set the callback of the port. /// - void(CEF_CALLBACK *set_port_message_callback)( - struct _cef_browser_host_t *self, cef_string_t *port_handle, - struct _cef_web_message_receiver_t *callback); + void(CEF_CALLBACK* set_port_message_callback)( + struct _cef_browser_host_t* self, + const cef_string_t* port_handle, + struct _cef_web_message_receiver_t* callback); /// /// Gets the latest hitdata /// - void(CEF_CALLBACK *get_hit_data)(struct _cef_browser_host_t *self, int *type, - cef_string_t *extra_data); + void(CEF_CALLBACK* get_hit_data)(struct _cef_browser_host_t* self, + int* type, + cef_string_t* extra_data); /// /// Set the inital page scale /// - void(CEF_CALLBACK *set_initial_scale)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* set_initial_scale)(struct _cef_browser_host_t* self, float scale); /// /// Gets the progress for the current page. /// - int(CEF_CALLBACK *page_load_progress)(struct _cef_browser_host_t *self); + int(CEF_CALLBACK* page_load_progress)(struct _cef_browser_host_t* self); /// /// Gets the progress for the current page. /// - float(CEF_CALLBACK *scale)(struct _cef_browser_host_t *self); + float(CEF_CALLBACK* scale)(struct _cef_browser_host_t* self); /// /// Loads the given data into this WebView, using baseUrl as the base URL for @@ -1483,411 +1568,472 @@ typedef struct _cef_browser_host_t { /// optional_param=mimeType, optional_param=encoding, /// optional_param=historyUrl /// - void(CEF_CALLBACK *load_with_data_and_base_url)( - struct _cef_browser_host_t *self, const cef_string_t *baseUrl, - const cef_string_t *data, const cef_string_t *mimeType, - const cef_string_t *encoding, const cef_string_t *historyUrl); + void(CEF_CALLBACK* load_with_data_and_base_url)( + struct _cef_browser_host_t* self, + const cef_string_t* baseUrl, + const cef_string_t* data, + const cef_string_t* mimeType, + const cef_string_t* encoding, + const cef_string_t* historyUrl); /// /// Loads the given data into this WebView optional_param=data, /// optional_param=mimeType, optional_param=encoding, /// - void(CEF_CALLBACK *load_with_data)(struct _cef_browser_host_t *self, - const cef_string_t *data, - const cef_string_t *mimeType, - const cef_string_t *encoding); + void(CEF_CALLBACK* load_with_data)(struct _cef_browser_host_t* self, + const cef_string_t* data, + const cef_string_t* mimeType, + const cef_string_t* encoding); /// /// add visited url. /// - void(CEF_CALLBACK *add_visited_links)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* add_visited_links)(struct _cef_browser_host_t* self, cef_string_list_t urls); /// /// Resume download after interrupted. /// - void(CEF_CALLBACK *resume_download)( - struct _cef_browser_host_t *self, const cef_string_t *url, - const cef_string_t *full_path, int64 received_bytes, int64 total_bytes, - const cef_string_t *etag, const cef_string_t *mime_type, - const cef_string_t *last_modified, - const cef_string_t *received_slices_string); + void(CEF_CALLBACK* resume_download)( + struct _cef_browser_host_t* self, + const cef_string_t* url, + const cef_string_t* full_path, + int64 received_bytes, + int64 total_bytes, + const cef_string_t* etag, + const cef_string_t* mime_type, + const cef_string_t* last_modified, + const cef_string_t* received_slices_string); /// /// Set the audio resume interval of the broswer. /// - void(CEF_CALLBACK *set_audio_resume_interval)( - struct _cef_browser_host_t *self, int resumeInterval); + void(CEF_CALLBACK* set_audio_resume_interval)( + struct _cef_browser_host_t* self, + int resumeInterval); /// /// Set whether the browser's audio is exclusive. /// - void(CEF_CALLBACK *set_audio_exclusive)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* set_audio_exclusive)(struct _cef_browser_host_t* self, int audioExclusive); /// /// Close fullScreen video. /// - void(CEF_CALLBACK *close_media)(struct _cef_browser_host_t *self); + void(CEF_CALLBACK* close_media)(struct _cef_browser_host_t* self); /// /// Stop all audio and video playback on the web page. /// - void(CEF_CALLBACK *stop_media)(struct _cef_browser_host_t *self); + void(CEF_CALLBACK* stop_media)(struct _cef_browser_host_t* self); /// /// Restart playback of all audio and video on the web page. /// - void(CEF_CALLBACK *resume_media)(struct _cef_browser_host_t *self); + void(CEF_CALLBACK* resume_media)(struct _cef_browser_host_t* self); /// /// Pause all audio and video playback on the web page. /// - void(CEF_CALLBACK *pause_media)(struct _cef_browser_host_t *self); + void(CEF_CALLBACK* pause_media)(struct _cef_browser_host_t* self); /// /// View the playback status of all audio and video on the web page. /// - int(CEF_CALLBACK *get_media_playback_state)(struct _cef_browser_host_t *self); + int(CEF_CALLBACK* get_media_playback_state)(struct _cef_browser_host_t* self); /// /// Scroll page up or down /// - void(CEF_CALLBACK *scroll_page_up_down)(struct _cef_browser_host_t *self, - int is_up, int is_half, + void(CEF_CALLBACK* scroll_page_up_down)(struct _cef_browser_host_t* self, + int is_up, + int is_half, float view_height); /// /// Get web history state /// - struct _cef_binary_value_t *(CEF_CALLBACK *get_web_state)( - struct _cef_browser_host_t *self); + struct _cef_binary_value_t*(CEF_CALLBACK* get_web_state)( + struct _cef_browser_host_t* self); /// /// Restore web history state /// - int(CEF_CALLBACK *restore_web_state)(struct _cef_browser_host_t *self, - struct _cef_binary_value_t *state); + int(CEF_CALLBACK* restore_web_state)(struct _cef_browser_host_t* self, + struct _cef_binary_value_t* state); /// /// Scroll to the position. /// - void(CEF_CALLBACK *scroll_to)(struct _cef_browser_host_t *self, float x, + void(CEF_CALLBACK* scroll_to)(struct _cef_browser_host_t* self, + float x, float y); /// /// Scroll by the delta distance. /// - void(CEF_CALLBACK *scroll_by)(struct _cef_browser_host_t *self, float delta_x, + void(CEF_CALLBACK* scroll_by)(struct _cef_browser_host_t* self, + float delta_x, float delta_y); /// /// Slide Scroll by the speed. /// - void(CEF_CALLBACK *slide_scroll)(struct _cef_browser_host_t *self, float vx, + void(CEF_CALLBACK* slide_scroll)(struct _cef_browser_host_t* self, + float vx, float vy); /// /// Set whether webview can access files /// - void(CEF_CALLBACK *set_file_access)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* set_file_access)(struct _cef_browser_host_t* self, int falg); /// /// Set whether webview can access network /// - void(CEF_CALLBACK *set_block_network)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* set_block_network)(struct _cef_browser_host_t* self, int falg); /// /// Set the cache mode of webview /// - void(CEF_CALLBACK *set_cache_mode)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* set_cache_mode)(struct _cef_browser_host_t* self, int falg); /// /// Set should frame submission before draw /// - void(CEF_CALLBACK *set_should_frame_submission_before_draw)( - struct _cef_browser_host_t *self, int should); + void(CEF_CALLBACK* set_should_frame_submission_before_draw)( + struct _cef_browser_host_t* self, + int should); /// /// Set zoom with the dela facetor /// - void(CEF_CALLBACK *zoom_by)(struct _cef_browser_host_t *self, float delta, - float width, float height); + void(CEF_CALLBACK* zoom_by)(struct _cef_browser_host_t* self, + float delta, + float width, + float height); /// /// Set the window id of the UI framework /// - void(CEF_CALLBACK *set_window_id)(struct _cef_browser_host_t *self, - int window_id, int nweb_id); + void(CEF_CALLBACK* set_window_id)(struct _cef_browser_host_t* self, + int window_id, + int nweb_id); /// /// Set the token of the UI framework /// - void(CEF_CALLBACK *set_token)(struct _cef_browser_host_t *self, void *token); + void(CEF_CALLBACK* set_token)(struct _cef_browser_host_t* self, void* token); /// /// Set the property values for width, height, and keyboard height /// - void(CEF_CALLBACK *set_virtual_key_board_arg)( - struct _cef_browser_host_t *self, int32_t width, int32_t height, + void(CEF_CALLBACK* set_virtual_key_board_arg)( + struct _cef_browser_host_t* self, + int32_t width, + int32_t height, double keyboard); /// /// Set the virtual keyboard to override the web status /// - int(CEF_CALLBACK *should_virtual_keyboard_overlay)( - struct _cef_browser_host_t *self); + int(CEF_CALLBACK* should_virtual_keyboard_overlay)( + struct _cef_browser_host_t* self); /// /// JavaScriptOnDocumentStart /// - void(CEF_CALLBACK *java_script_on_document_start)( - struct _cef_browser_host_t *self, const cef_string_t *script, + void(CEF_CALLBACK* java_script_on_document_start)( + struct _cef_browser_host_t* self, + const cef_string_t* script, cef_string_list_t script_rules); /// /// RemoveJavaScriptOnDocumentStart /// - void(CEF_CALLBACK *remove_java_script_on_document_start)( - struct _cef_browser_host_t *self); + void(CEF_CALLBACK* remove_java_script_on_document_start)( + struct _cef_browser_host_t* self); /// /// JavaScriptOnDocumentEnd /// - void(CEF_CALLBACK *java_script_on_document_end)( - struct _cef_browser_host_t *self, const cef_string_t *script, + void(CEF_CALLBACK* java_script_on_document_end)( + struct _cef_browser_host_t* self, + const cef_string_t* script, cef_string_list_t script_rules); /// /// RemoveJavaScriptOnDocumentEnd /// - void(CEF_CALLBACK *remove_java_script_on_document_end)( - struct _cef_browser_host_t *self); + void(CEF_CALLBACK* remove_java_script_on_document_end)( + struct _cef_browser_host_t* self); /// /// Set the draw rect /// - void(CEF_CALLBACK *set_draw_rect)(struct _cef_browser_host_t *self, int x, - int y, int width, int height); + void(CEF_CALLBACK* set_draw_rect)(struct _cef_browser_host_t* self, + int x, + int y, + int width, + int height); /// /// Set the draw mode /// - void(CEF_CALLBACK *set_draw_mode)(struct _cef_browser_host_t *self, int mode); + void(CEF_CALLBACK* set_draw_mode)(struct _cef_browser_host_t* self, int mode); /// /// Create the Web print document adapter of the UI framework /// - void(CEF_CALLBACK *create_web_print_document_adapter)( - struct _cef_browser_host_t *self, const cef_string_t *jobName, - void **webPrintDocumentAdapter); + void(CEF_CALLBACK* create_web_print_document_adapter)( + struct _cef_browser_host_t* self, + const cef_string_t* jobName, + void** webPrintDocumentAdapter); /// /// Set the over-scroll mode of web /// - void(CEF_CALLBACK *set_overscroll_mode)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* set_overscroll_mode)(struct _cef_browser_host_t* self, int mode); /// /// Discard a webview window /// - int(CEF_CALLBACK *discard)(struct _cef_browser_host_t *self); + int(CEF_CALLBACK* discard)(struct _cef_browser_host_t* self); /// /// Restore the discarded webview window /// - int(CEF_CALLBACK *restore)(struct _cef_browser_host_t *self); + int(CEF_CALLBACK* restore)(struct _cef_browser_host_t* self); /// /// Change the zoom factor for browser zoom. If called on the UI thread the /// change will be applied immediately. Otherwise, the change will be applied /// asynchronously on the UI thread. /// - void(CEF_CALLBACK *set_browser_zoom_level)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* set_browser_zoom_level)(struct _cef_browser_host_t* self, double zoomFactor); /// /// Get the top controls offset. /// - int(CEF_CALLBACK *get_top_controls_offset)(struct _cef_browser_host_t *self); + int(CEF_CALLBACK* get_top_controls_offset)(struct _cef_browser_host_t* self); /// /// Get the shrink viewport height. /// - int(CEF_CALLBACK *get_shrink_viewport_height)( - struct _cef_browser_host_t *self); + int(CEF_CALLBACK* get_shrink_viewport_height)( + struct _cef_browser_host_t* self); /// /// Set background print enable. /// - void(CEF_CALLBACK *set_print_background)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* set_print_background)(struct _cef_browser_host_t* self, int enable); /// /// Get whether print background. /// - int(CEF_CALLBACK *get_print_background)(struct _cef_browser_host_t *self); + int(CEF_CALLBACK* get_print_background)(struct _cef_browser_host_t* self); /// /// set Scrollable /// - void(CEF_CALLBACK *set_scrollable)(struct _cef_browser_host_t *self, - int enable); + void(CEF_CALLBACK* set_scrollable)(struct _cef_browser_host_t* self, + int enable, + int scrollType); /// /// Start current camera. /// - void(CEF_CALLBACK *start_camera)(struct _cef_browser_host_t *self); + void(CEF_CALLBACK* start_camera)(struct _cef_browser_host_t* self); /// /// Stop current camera. /// - void(CEF_CALLBACK *stop_camera)(struct _cef_browser_host_t *self); + void(CEF_CALLBACK* stop_camera)(struct _cef_browser_host_t* self); /// /// Close current camera. /// - void(CEF_CALLBACK *close_camera)(struct _cef_browser_host_t *self); + void(CEF_CALLBACK* close_camera)(struct _cef_browser_host_t* self); /// /// Get the last javascript proxy calling frame url. /// // The resulting string must be freed by calling cef_string_userfree_free(). cef_string_userfree_t( - CEF_CALLBACK *get_last_javascript_proxy_calling_frame_url)( - struct _cef_browser_host_t *self); + CEF_CALLBACK* get_last_javascript_proxy_calling_frame_url)( + struct _cef_browser_host_t* self); /// /// Set NWebID. /// - void(CEF_CALLBACK *set_nweb_id)(struct _cef_browser_host_t *self, int nWebId); + void(CEF_CALLBACK* set_nweb_id)(struct _cef_browser_host_t* self, int nWebId); /// /// get pendingSizeStatus. /// - int(CEF_CALLBACK *get_pending_size_status)(struct _cef_browser_host_t *self); + int(CEF_CALLBACK* get_pending_size_status)(struct _cef_browser_host_t* self); /// /// precompile javascript and generate code cache. /// - void(CEF_CALLBACK *precompile_java_script)( - struct _cef_browser_host_t *self, const char *url, const char *script, - struct _cef_cache_options_t *cacheOptions, - struct _cef_precompile_callback_t *callback); + void(CEF_CALLBACK* precompile_java_script)( + struct _cef_browser_host_t* self, + const char* url, + const char* script, + struct _cef_cache_options_t* cacheOptions, + struct _cef_precompile_callback_t* callback); /// /// SetWakeLockHandler. /// - void(CEF_CALLBACK *set_wake_lock_handler)( - struct _cef_browser_host_t *self, int32_t windowId, - struct _cef_set_lock_callback_t *callback); + void(CEF_CALLBACK* set_wake_lock_handler)( + struct _cef_browser_host_t* self, + int32_t windowId, + struct _cef_set_lock_callback_t* callback); /// /// Get cef_download_item_t by download_item_id. /// - struct _cef_download_item_t *(CEF_CALLBACK *get_download_item)( - struct _cef_browser_host_t *self, uint32 item_id); + struct _cef_download_item_t*(CEF_CALLBACK* get_download_item)( + struct _cef_browser_host_t* self, + uint32 item_id); /// /// Notify browser host needs reload when the render process terminated. /// - void(CEF_CALLBACK *notify_needs_reload)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* notify_needs_reload)(struct _cef_browser_host_t* self, int needs_reload); /// /// Return true if needs reload page, or false if nees not reload. /// - int(CEF_CALLBACK *needs_reload)(struct _cef_browser_host_t *self); + int(CEF_CALLBACK* needs_reload)(struct _cef_browser_host_t* self); /// /// Terminate render process /// - int(CEF_CALLBACK *terminate_render_process)(struct _cef_browser_host_t *self); + int(CEF_CALLBACK* terminate_render_process)(struct _cef_browser_host_t* self); /// /// RegisterNativeJSProxy /// - void(CEF_CALLBACK *register_native_jsproxy)(struct _cef_browser_host_t *self, - const cef_string_t *object_name, + void(CEF_CALLBACK* register_native_jsproxy)(struct _cef_browser_host_t* self, + const cef_string_t* object_name, cef_string_list_t method_list, - int32_t object_id, int is_async, - const cef_string_t *permission); + int32_t object_id, + int is_async, + const cef_string_t* permission); /// /// SendTouchpadFlingEvent /// - void(CEF_CALLBACK *send_touchpad_fling_event)( - struct _cef_browser_host_t *self, const cef_mouse_event_t *event, - double vx, double vy); + void(CEF_CALLBACK* send_touchpad_fling_event)( + struct _cef_browser_host_t* self, + const cef_mouse_event_t* event, + double vx, + double vy); /// /// Set the fit content mode /// - void(CEF_CALLBACK *set_fit_content_mode)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* set_fit_content_mode)(struct _cef_browser_host_t* self, int mode); /// /// update draw_rect state. /// - void(CEF_CALLBACK *update_draw_rect)(struct _cef_browser_host_t *self); + void(CEF_CALLBACK* update_draw_rect)(struct _cef_browser_host_t* self); /// /// Called when text is selected. /// - void(CEF_CALLBACK *on_text_selected)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* on_text_selected)(struct _cef_browser_host_t* self, int flag); /// /// Get page scale factor. /// - float(CEF_CALLBACK *get_page_scale_factor)(struct _cef_browser_host_t *self); + float(CEF_CALLBACK* get_page_scale_factor)(struct _cef_browser_host_t* self); /// /// WebPageSnapshot, return result by callback /// - int(CEF_CALLBACK *web_page_snapshot)(struct _cef_browser_host_t *self, - const char *id, int width, int height, + int(CEF_CALLBACK* web_page_snapshot)(struct _cef_browser_host_t* self, + const char* id, + int width, + int height, cef_web_snapshot_callback_t callback); /// /// Advance focus for IME to the browser. /// - void(CEF_CALLBACK *advance_focus_for_ime)(struct _cef_browser_host_t *self, + void(CEF_CALLBACK* advance_focus_for_ime)(struct _cef_browser_host_t* self, int focusType); /// - /// OnSafeInsetsChange + /// Scroll to the position with anime. /// - void(CEF_CALLBACK *on_safe_insets_change)(struct _cef_browser_host_t *self, - int left, int top, int right, - int bottom); + void(CEF_CALLBACK* scroll_to_with_anime)(struct _cef_browser_host_t* self, + float x, + float y, + int32_t duration); /// - /// Notify for next touch move event. + /// Scroll by the delta with anime. /// - void(CEF_CALLBACK *notify_for_next_touch_event)( - struct _cef_browser_host_t *self); + void(CEF_CALLBACK* scroll_by_with_anime)(struct _cef_browser_host_t* self, + float delta_x, + float delta_y, + int32_t duration); /// - /// Set grant file access dirs. + /// Get the current scroll offset of the webpage. /// - void(CEF_CALLBACK *set_grant_file_access_dirs)( - struct _cef_browser_host_t *self, cef_string_list_t dir_list); + void(CEF_CALLBACK* get_scroll_offset)(struct _cef_browser_host_t* self, + float* offset_x, + float* offset_y); /// - /// Scroll to the position with anime. + /// Get the current overscroll offset of the webpage. /// - void(CEF_CALLBACK *scroll_to_with_anime)(struct _cef_browser_host_t *self, - float x, float y, int32_t duration); + void(CEF_CALLBACK* get_over_scroll_offset)(struct _cef_browser_host_t* self, + float* offset_x, + float* offset_y); /// - /// Scroll by the delta with anime. + /// OnSafeInsetsChange + /// + void(CEF_CALLBACK* on_safe_insets_change)(struct _cef_browser_host_t* self, + int left, + int top, + int right, + int bottom); + + /// + /// SetNativeEmbedMode. + /// + void(CEF_CALLBACK* set_native_embed_mode)(struct _cef_browser_host_t* self, + int flag); + + /// + /// Notify for next touch move event. /// - void(CEF_CALLBACK *scroll_by_with_anime)(struct _cef_browser_host_t *self, - float delta_x, float delta_y, int32_t duration); + void(CEF_CALLBACK* notify_for_next_touch_event)( + struct _cef_browser_host_t* self); + + /// + /// Set grant file access dirs. + /// + void(CEF_CALLBACK* set_grant_file_access_dirs)( + struct _cef_browser_host_t* self, + cef_string_list_t dir_list); /// /// Set the callback of the autofill event. @@ -1922,6 +2068,20 @@ typedef struct _cef_browser_host_t { int is_other_account, int is_new_password, const char* content); + + /// + /// Create pdf data stream. + /// + void(CEF_CALLBACK* create_to_pdf)( + struct _cef_browser_host_t* self, + const struct _cef_pdf_print_settings_t* settings, + struct _cef_pdf_value_callback_t* callback); + + /// + /// SetPopupWindow. + /// + void(CEF_CALLBACK* set_popup_window)(struct _cef_browser_host_t* self, + cef_native_window_t window); } cef_browser_host_t; /// @@ -1935,10 +2095,12 @@ typedef struct _cef_browser_host_t { /// the render process. /// CEF_EXPORT int cef_browser_host_create_browser( - const cef_window_info_t *windowInfo, struct _cef_client_t *client, - const cef_string_t *url, const struct _cef_browser_settings_t *settings, - struct _cef_dictionary_value_t *extra_info, - struct _cef_request_context_t *request_context); + const cef_window_info_t* windowInfo, + struct _cef_client_t* client, + const cef_string_t* url, + const struct _cef_browser_settings_t* settings, + struct _cef_dictionary_value_t* extra_info, + struct _cef_request_context_t* request_context); /// /// Create a new browser using the window parameters specified by |windowInfo|. @@ -1948,14 +2110,16 @@ CEF_EXPORT int cef_browser_host_create_browser( /// specific to the created browser that will be passed to /// cef_render_process_handler_t::on_browser_created() in the render process. /// -CEF_EXPORT cef_browser_t *cef_browser_host_create_browser_sync( - const cef_window_info_t *windowInfo, struct _cef_client_t *client, - const cef_string_t *url, const struct _cef_browser_settings_t *settings, - struct _cef_dictionary_value_t *extra_info, - struct _cef_request_context_t *request_context); +CEF_EXPORT cef_browser_t* cef_browser_host_create_browser_sync( + const cef_window_info_t* windowInfo, + struct _cef_client_t* client, + const cef_string_t* url, + const struct _cef_browser_settings_t* settings, + struct _cef_dictionary_value_t* extra_info, + struct _cef_request_context_t* request_context); #ifdef __cplusplus } #endif -#endif // CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_ \ No newline at end of file +#endif // CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_ diff --git a/include/capi/cef_context_menu_handler_capi.h b/include/capi/cef_context_menu_handler_capi.h index b8c0ad08c79063f90083dbeef4304a49fc346866..78235b690fc7f969fd3f71a22e4479f2963ebecf 100644 --- a/include/capi/cef_context_menu_handler_capi.h +++ b/include/capi/cef_context_menu_handler_capi.h @@ -33,7 +33,7 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // -// $hash=b4593fab0fae90e9b9ff4658ab94055a465f2b3d$ +// $hash=ee64b4aa6e77fb09f64e448d335424a6877fc2d7$ // #ifndef CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_ @@ -182,7 +182,8 @@ typedef struct _cef_context_menu_handler_t { const cef_rect_t* select_bounds, cef_quick_menu_edit_state_flags_t edit_state_flags, struct _cef_run_quick_menu_callback_t* callback, - int is_mouse_trigger); + int is_mouse_trigger, + int is_long_press_actived); /// /// UpdateClippedSelectionBounds. @@ -237,6 +238,12 @@ typedef struct _cef_context_menu_handler_t { void(CEF_CALLBACK* hide_handle_and_quick_menu_if_necessary)( struct _cef_context_menu_handler_t* self, int hide); + + /// + /// Called when you click on the selected area. + /// + void(CEF_CALLBACK* change_visibility_of_quick_menu)( + struct _cef_context_menu_handler_t* self); } cef_context_menu_handler_t; /// diff --git a/include/capi/cef_cookie_capi.h b/include/capi/cef_cookie_capi.h index 20adae8accd70dcf6cc5ce7b89e0b325e05eabf7..c570f850d638872346c52a98be02c3c1d467b611 100644 --- a/include/capi/cef_cookie_capi.h +++ b/include/capi/cef_cookie_capi.h @@ -33,7 +33,7 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // -// $hash=cb6483fc6c0cda8419cd2be92b97f98392a417b9$ +// $hash=5945af881beaaf6a79dd46fa0aa7ee8b31a4deef$ // #ifndef CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_ @@ -66,8 +66,8 @@ typedef struct _cef_cookie_manager_t { /// longest path, then by earliest creation date. Returns false (0) if cookies /// cannot be accessed. /// - int(CEF_CALLBACK* visit_all_cookies)(struct _cef_cookie_manager_t* self, - struct _cef_cookie_visitor_t* visitor, + int(CEF_CALLBACK *visit_all_cookies)(struct _cef_cookie_manager_t *self, + struct _cef_cookie_visitor_t *visitor, int is_sync); /// @@ -77,11 +77,12 @@ typedef struct _cef_cookie_manager_t { /// cookies are ordered by longest path, then by earliest creation date. /// Returns false (0) if cookies cannot be accessed. /// - int(CEF_CALLBACK* visit_url_cookies)(struct _cef_cookie_manager_t* self, - const cef_string_t* url, + int(CEF_CALLBACK *visit_url_cookies)(struct _cef_cookie_manager_t *self, + const cef_string_t *url, int includeHttpOnly, - struct _cef_cookie_visitor_t* visitor, - int is_sync); + struct _cef_cookie_visitor_t *visitor, + int is_sync, + int is_from_ndk); /// /// Sets a cookie given a valid URL and explicit user-provided cookie @@ -92,12 +93,12 @@ typedef struct _cef_cookie_manager_t { /// asnychronously on the UI thread after the cookie has been set. Returns /// false (0) if an invalid URL is specified or if cookies cannot be accessed. /// - int(CEF_CALLBACK* set_cookie)(struct _cef_cookie_manager_t* self, - const cef_string_t* url, - const struct _cef_cookie_t* cookie, - struct _cef_set_cookie_callback_t* callback, - int is_sync, - const cef_string_t* str_cookie); + int(CEF_CALLBACK *set_cookie)(struct _cef_cookie_manager_t *self, + const cef_string_t *url, + const struct _cef_cookie_t *cookie, + struct _cef_set_cookie_callback_t *callback, + int is_sync, const cef_string_t *str_cookie, + int includeHttpOnly); /// /// Delete all cookies that match the specified parameters. If both |url| and @@ -110,64 +111,58 @@ typedef struct _cef_cookie_manager_t { /// specified or if cookies cannot be accessed. Cookies can alternately be /// deleted using the Visit*Cookies() functions. /// - int(CEF_CALLBACK* delete_cookies)( - struct _cef_cookie_manager_t* self, - const cef_string_t* url, - const cef_string_t* cookie_name, - int is_session, - struct _cef_delete_cookies_callback_t* callback, - int is_sync); + int(CEF_CALLBACK *delete_cookies)( + struct _cef_cookie_manager_t *self, const cef_string_t *url, + const cef_string_t *cookie_name, int is_session, + struct _cef_delete_cookies_callback_t *callback, int is_sync); /// /// Flush the backing store (if any) to disk. If |callback| is non-NULL it /// will be executed asnychronously on the UI thread after the flush is /// complete. Returns false (0) if cookies cannot be accessed. /// - int(CEF_CALLBACK* flush_store)(struct _cef_cookie_manager_t* self, - struct _cef_completion_callback_t* callback); + int(CEF_CALLBACK *flush_store)(struct _cef_cookie_manager_t *self, + struct _cef_completion_callback_t *callback); /// /// Get whether this cookie manager can accpet and send cookies. Returns false /// (0) if can't. /// - int(CEF_CALLBACK* is_accept_cookie_allowed)( - struct _cef_cookie_manager_t* self); + int(CEF_CALLBACK *is_accept_cookie_allowed)( + struct _cef_cookie_manager_t *self); /// /// Set whether this cookie manager can accpet and send cookies. /// - void(CEF_CALLBACK* put_accept_cookie_enabled)( - struct _cef_cookie_manager_t* self, - int accept); + void(CEF_CALLBACK *put_accept_cookie_enabled)( + struct _cef_cookie_manager_t *self, int accept); /// /// Gets whether cookies of third parties are allowed to be set. Returns false /// (0) if can't. /// - int(CEF_CALLBACK* is_third_party_cookie_allowed)( - struct _cef_cookie_manager_t* self); + int(CEF_CALLBACK *is_third_party_cookie_allowed)( + struct _cef_cookie_manager_t *self); /// /// Set whether cookies of third parties are allowed to be set. /// - void(CEF_CALLBACK* put_accept_third_party_cookie_enabled)( - struct _cef_cookie_manager_t* self, - int accept); + void(CEF_CALLBACK *put_accept_third_party_cookie_enabled)( + struct _cef_cookie_manager_t *self, int accept); /// /// Get whether this cookie manager can accpet and send cookies for file /// scheme URL. Returns false (0) if can't. /// - int(CEF_CALLBACK* is_file_urlscheme_cookies_allowed)( - struct _cef_cookie_manager_t* self); + int(CEF_CALLBACK *is_file_urlscheme_cookies_allowed)( + struct _cef_cookie_manager_t *self); /// /// Set whether this cookie manager can accpet and send cookies for file /// scheme URL. /// - void(CEF_CALLBACK* put_accept_file_urlscheme_cookies_enabled)( - struct _cef_cookie_manager_t* self, - int allow); + void(CEF_CALLBACK *put_accept_file_urlscheme_cookies_enabled)( + struct _cef_cookie_manager_t *self, int allow); } cef_cookie_manager_t; /// @@ -178,8 +173,8 @@ typedef struct _cef_cookie_manager_t { /// calling cef_request_context_t::cef_request_context_get_global_context()->Get /// DefaultCookieManager(). /// -CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager( - struct _cef_completion_callback_t* callback); +CEF_EXPORT cef_cookie_manager_t *cef_cookie_manager_get_global_manager( + struct _cef_completion_callback_t *callback); /// /// Returns the global cookie manager in incognito mode. By default data will be @@ -188,18 +183,18 @@ CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager( /// initialized. Using this function is equivalent to calling cef_request_contex /// t_t::cef_request_context_get_global_otrcontext()->GetDefaultCookieManager(). /// -CEF_EXPORT cef_cookie_manager_t* +CEF_EXPORT cef_cookie_manager_t * cef_cookie_manager_get_global_incognito_manager( - struct _cef_completion_callback_t* callback); + struct _cef_completion_callback_t *callback); /// /// Convert string cookie to CefCookie. The function will return true (1) when /// excuted success, otherwise return false (0). /// -CEF_EXPORT int cef_cookie_manager_create_cef_cookie( - const cef_string_t* url, - const cef_string_t* value, - struct _cef_cookie_t* cef_cookie); +CEF_EXPORT int +cef_cookie_manager_create_cef_cookie(const cef_string_t *url, + const cef_string_t *value, + struct _cef_cookie_t *cef_cookie); /// /// Structure to implement for visiting cookie values. The functions of this @@ -218,19 +213,17 @@ typedef struct _cef_cookie_visitor_t { /// Return false (0) to stop visiting cookies. This function may never be /// called if no cookies are found. /// - int(CEF_CALLBACK* visit)(struct _cef_cookie_visitor_t* self, - const struct _cef_cookie_t* cookie, - int count, - int total, - int* deleteCookie); + int(CEF_CALLBACK *visit)(struct _cef_cookie_visitor_t *self, + const struct _cef_cookie_t *cookie, int count, + int total, int *deleteCookie); /// /// Method that will be called when all cookies have been visited, contenate /// them into one string line. The string cookie line will be passed into this /// function. /// - void(CEF_CALLBACK* set_cookie_line)(struct _cef_cookie_visitor_t* self, - const cef_string_t* cookieLine); + void(CEF_CALLBACK *set_cookie_line)(struct _cef_cookie_visitor_t *self, + const cef_string_t *cookieLine); } cef_cookie_visitor_t; /// @@ -247,7 +240,7 @@ typedef struct _cef_set_cookie_callback_t { /// Method that will be called upon completion. |success| will be true (1) if /// the cookie was set successfully. /// - void(CEF_CALLBACK* on_complete)(struct _cef_set_cookie_callback_t* self, + void(CEF_CALLBACK *on_complete)(struct _cef_set_cookie_callback_t *self, int success); } cef_set_cookie_callback_t; @@ -265,7 +258,7 @@ typedef struct _cef_delete_cookies_callback_t { /// Method that will be called upon completion. |num_deleted| will be the /// number of cookies that were deleted. /// - void(CEF_CALLBACK* on_complete)(struct _cef_delete_cookies_callback_t* self, + void(CEF_CALLBACK *on_complete)(struct _cef_delete_cookies_callback_t *self, int num_deleted); } cef_delete_cookies_callback_t; @@ -273,4 +266,4 @@ typedef struct _cef_delete_cookies_callback_t { } #endif -#endif // CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_ +#endif // CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_ diff --git a/include/capi/cef_render_handler_capi.h b/include/capi/cef_render_handler_capi.h index 6826ca9c031fb72984011747ea01cacf3e6a3201..ccbb92d6235606f55ad8ea18c90424b24cf5217e 100644 --- a/include/capi/cef_render_handler_capi.h +++ b/include/capi/cef_render_handler_capi.h @@ -33,7 +33,7 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // -// $hash=898a08a55883581483a35459d60c09c1553fc3ec$ +// $hash=93eb46d8f54c452312b03c0b1c291a27ec5714fb$ // #ifndef CEF_INCLUDE_CAPI_CEF_RENDER_HANDLER_CAPI_H_ @@ -422,18 +422,19 @@ typedef struct _cef_render_handler_t { /// Called to retrieve the visible view rectangle in screen DIP coordinates. /// This function must always provide a non-NULL rectangle. /// - void(CEF_CALLBACK *get_visible_viewport_rect)( - struct _cef_render_handler_t *self, - struct _cef_browser_t *browser, - cef_rect_t *rect); + void(CEF_CALLBACK* get_visible_viewport_rect)( + struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, + cef_rect_t* rect); /// - /// Called when loss frame. + /// SendDynamicFrameLossEvent /// - void(CEF_CALLBACK* send_dynamic_frame_loss_event)(struct _cef_render_handler_t* self, - struct _cef_browser_t* browser, - const cef_string_t* sceneId, - bool isStart); + void(CEF_CALLBACK* send_dynamic_frame_loss_event)( + struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, + const cef_string_t* sceneId, + int isStart); /// /// OnResizeScrollableViewport. @@ -447,6 +448,26 @@ typedef struct _cef_render_handler_t { /// void(CEF_CALLBACK* set_fill_content)(struct _cef_render_handler_t* self, const char* content); + + /// + /// SetGestureEventResult + /// + void(CEF_CALLBACK* set_gesture_event_result)( + struct _cef_render_handler_t* self, + const int result); + + /// + /// Called when you need to start vibrator. + /// + void(CEF_CALLBACK* start_vibra_feedback)(struct _cef_render_handler_t* self, + const char* vibratorType); + + /// + /// Get Device pixel size. + /// + void(CEF_CALLBACK* get_device_pixel_size)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, + cef_size_t* size); } cef_render_handler_t; #ifdef __cplusplus diff --git a/include/cef_api_hash.h b/include/cef_api_hash.h index 964c3b1ac31c4b3b8ce6ff8f78909055ab891901..f8c804e1cdf7291b9c8ec24751bdb0989b096307 100644 --- a/include/cef_api_hash.h +++ b/include/cef_api_hash.h @@ -42,15 +42,15 @@ // 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 "0f3e9ee7da33d3b884f322dcace4ed57ba36b900" +#define CEF_API_HASH_UNIVERSAL "11519792ccaa661800c47d8f8367dd1024ff78f7" #if defined(OS_WIN) -#define CEF_API_HASH_PLATFORM "f97f5a3f9653b2eb8209e723130ecdb7616fafb5" +#define CEF_API_HASH_PLATFORM "1ef52c383cd0ece8f2d568a6fcf3a0f9ac33ba77" #elif defined(OS_MAC) -#define CEF_API_HASH_PLATFORM "40551c88b9d5b451148996049897e4b6462d8197" +#define CEF_API_HASH_PLATFORM "03e8cf4e47fd30ef68b16e56f30710df19fbf008" #elif defined(OS_LINUX) -#define CEF_API_HASH_PLATFORM "b3bd6943a0fe8325a39de461d4373b6433f8f5c6" +#define CEF_API_HASH_PLATFORM "7281878a0dfcc9bd4f87244611538939912aa17b" #elif defined(OS_OHOS) -#define CEF_API_HASH_PLATFORM "b3bd6943a0fe8325a39de461d4373b6433f8f5c6" +#define CEF_API_HASH_PLATFORM "7281878a0dfcc9bd4f87244611538939912aa17b" #endif #ifdef __cplusplus diff --git a/include/cef_browser.h b/include/cef_browser.h index ec59787b5cac79edc71ca907acdbf1f340ee4f8f..770a1366aa69e62d2743326c1965edecafcf4e20 100644 --- a/include/cef_browser.h +++ b/include/cef_browser.h @@ -117,6 +117,12 @@ class CefWebMessageReceiver : public virtual CefBaseRefCounted { /// /*--cef()--*/ virtual void OnMessage(CefRefPtr message) = 0; + + /// + /// The same as OnMessage, the result of the execution will be returned. + /// + /*--cef()--*/ + virtual bool OnMessageWithBoolResult(CefRefPtr message) = 0; }; /// @@ -596,6 +602,22 @@ class CefDownloadImageCallback : public virtual CefBaseRefCounted { CefRefPtr image) = 0; }; +/// +/// Callback interface for CefBrowserHost::CreateToPDF. The methods of this +/// class will be called on the browser process UI thread. +/// +/*--cef(source=client)--*/ +class CefPdfValueCallback : public virtual CefBaseRefCounted { + public: + /// + /// Method that will be executed when the PDF create has completed. |value| + /// is the output pdf data stream. + /// successfully or false otherwise. + /// + /*--cef()--*/ + virtual void OnReceiveValue(const char* value, const long size) = 0; +}; + /// /// Class used to represent the browser process aspects of a browser. The /// methods of this class can only be called in the browser process. They may be @@ -1524,7 +1546,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { /// Post a message to the port. /// /*--cef()--*/ - virtual void PostPortMessage(CefString& port_handle, + virtual void PostPortMessage(const CefString& port_handle, CefRefPtr message) = 0; /// @@ -1532,7 +1554,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { /// /*--cef()--*/ virtual void SetPortMessageCallback( - CefString& port_handle, + const CefString& port_handle, CefRefPtr callback) = 0; /// @@ -1842,7 +1864,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { /// set Scrollable /// /*--cef()--*/ - virtual void SetScrollable(bool enable) = 0; + virtual void SetScrollable(bool enable, int scrollType) = 0; /// /// Start current camera. @@ -1986,6 +2008,26 @@ class CefBrowserHost : public virtual CefBaseRefCounted { /// /*--cef()--*/ virtual void ScrollByWithAnime(float delta_x, float delta_y, int32_t duration) = 0; + + /// + /// SetNativeEmbedMode. + /// + /*--cef()--*/ + virtual void SetNativeEmbedMode(bool flag) = 0; + +#if defined(OHOS_GET_SCROLL_OFFSET) + /// + /// Get the current scroll offset of the webpage. + /// + /*--cef()--*/ + virtual void GetScrollOffset(float* offset_x, float* offset_y) = 0; + + /// + /// Get the current overscroll offset of the webpage. + /// + /*--cef()--*/ + virtual void GetOverScrollOffset(float* offset_x, float* offset_y) = 0; +#endif #endif // BUILDFLAG(IS_OHOS) /// @@ -2038,5 +2080,17 @@ class CefBrowserHost : public virtual CefBaseRefCounted { bool is_other_account, bool is_new_password, const std::string& content) = 0; + + /// + /// Create pdf data stream. + /// + /*--cef()--*/ + virtual void CreateToPDF(const CefPdfPrintSettings& settings, + CefRefPtr callback) = 0; + /// + /// SetPopupWindow. + /// + /*--cef()--*/ + virtual void SetPopupWindow(cef_native_window_t window) = 0; }; #endif // CEF_INCLUDE_CEF_BROWSER_H_ diff --git a/include/cef_context_menu_handler.h b/include/cef_context_menu_handler.h index 257a0293c59f8768d80e8ff5bc813456a5b4b551..60f89482cb3c2b5704d0450f5b4588ca03ebd611 100644 --- a/include/cef_context_menu_handler.h +++ b/include/cef_context_menu_handler.h @@ -171,7 +171,8 @@ class CefContextMenuHandler : public virtual CefBaseRefCounted { const CefRect& select_bounds, QuickMenuEditStateFlags edit_state_flags, CefRefPtr callback, - bool is_mouse_trigger) { + bool is_mouse_trigger, + bool is_long_press_actived) { return false; } @@ -230,6 +231,14 @@ class CefContextMenuHandler : public virtual CefBaseRefCounted { /*--cef()--*/ virtual void HideHandleAndQuickMenuIfNecessary(bool hide) {} #endif + +#if defined(OHOS_CLIPBOARD) + /// + /// Called when you click on the selected area. + /// + /*--cef()--*/ + virtual void ChangeVisibilityOfQuickMenu() {} +#endif }; /// diff --git a/include/cef_cookie.h b/include/cef_cookie.h index ee6b4d85e10a666a4850b4dd8e9b487d702539d1..5b13e3615e1fc031991779951515f56701fc7467 100644 --- a/include/cef_cookie.h +++ b/include/cef_cookie.h @@ -97,7 +97,8 @@ class CefCookieManager : public virtual CefBaseRefCounted { virtual bool VisitUrlCookies(const CefString& url, bool includeHttpOnly, CefRefPtr visitor, - bool is_sync) = 0; + bool is_sync, + bool is_from_ndk) = 0; /// /// Sets a cookie given a valid URL and explicit user-provided cookie @@ -113,7 +114,8 @@ class CefCookieManager : public virtual CefBaseRefCounted { const CefCookie& cookie, CefRefPtr callback, bool is_sync, - const CefString& str_cookie) = 0; + const CefString& str_cookie, + bool includeHttpOnly) = 0; /// /// Delete all cookies that match the specified parameters. If both |url| and diff --git a/include/cef_load_handler.h b/include/cef_load_handler.h index 04c55cd7a997912670b62c613d6b497aae62e89d..26d237c1e5dab777ec127d01cfab8afed9460508 100644 --- a/include/cef_load_handler.h +++ b/include/cef_load_handler.h @@ -210,6 +210,14 @@ class CefLoadHandler : public virtual CefBaseRefCounted { const CefString& website_host, const CefString& tracker_host) {} +#ifdef OHOS_BFCACHE + /// + /// Called when page load from bfcache. + /// + /*--cef()--*/ + virtual void UpdateFavicon(CefRefPtr browser) {} +#endif + #endif // BUILDFLAG(IS_OHOS) }; diff --git a/include/cef_render_handler.h b/include/cef_render_handler.h index 1517ddbf70133522e9c1d4df3c88a171f3303c6b..0aa4c6dea275eb6847da5f0f46147ce44801c93f 100644 --- a/include/cef_render_handler.h +++ b/include/cef_render_handler.h @@ -374,6 +374,13 @@ class CefRenderHandler : public virtual CefBaseRefCounted { /*--cef()--*/ virtual void OnNativeEmbedLifecycleChange(CefRefPtr browser, const CefNativeEmbedData& info) {} + + /// + /// Called when embed visibility. + /// + /*--cef()--*/ + virtual void OnNativeEmbedVisibilityChange(const std::string& embed_id, + bool visibility) {} /// /// Called when select all is clicked. @@ -449,6 +456,24 @@ class CefRenderHandler : public virtual CefBaseRefCounted { /// /*--cef()--*/ virtual void SetFillContent(const std::string& content) {} + + /// + /// SetGestureEventResult + /// + /*--cef()--*/ + virtual void SetGestureEventResult(const bool result) {} + + /// + /// Called when you need to start vibrator. + /// + /*--cef()--*/ + virtual void StartVibraFeedback(const std::string& vibratorType) {} + + /// + /// Get Device pixel size. + /// + /*--cef()--*/ + virtual void GetDevicePixelSize(CefRefPtr browser, CefSize& size) {} #endif // BUILDFLAG(IS_OHOS) }; diff --git a/include/cef_resource_handler.h b/include/cef_resource_handler.h index a13b34d8c34b746df4f6395f273ae81918eceb0e..7a93c29a9c690b8840301d9a01e0228b3fd47102 100644 --- a/include/cef_resource_handler.h +++ b/include/cef_resource_handler.h @@ -141,7 +141,7 @@ class CefResourceHandler : public virtual CefBaseRefCounted { #if BUILDFLAG(IS_OHOS) virtual const std::string& GetResponseData() {static const std::string data; return data;} - virtual size_t GetResponseDataBuffer(char* data) {return 0;} + virtual size_t GetResponseDataBuffer(char* data, size_t dest_size) {return 0;} virtual size_t GetResponseDataBufferSize() {return 0;} #endif diff --git a/include/cef_resource_request_handler.h b/include/cef_resource_request_handler.h index 01d667815571ae1645a54d727ce3e0b0ef08dfa2..25edb15d2e5af14d8c94da3f2280f30bb7cd952d 100644 --- a/include/cef_resource_request_handler.h +++ b/include/cef_resource_request_handler.h @@ -47,8 +47,23 @@ #include "include/cef_response.h" #include "include/cef_response_filter.h" +#include "include/cef_scheme.h" + class CefCookieAccessFilter; +/// +/// CefInterceptCallback +/// +/*--cef(source=library)--*/ +class CefInterceptCallback : public virtual CefBaseRefCounted { + public: + /// + /// Continue. + /// + /*--cef(capi_name=cont)--*/ + virtual void ContinueLoad(CefRefPtr resource_handler) {} +}; + /// /// Implement this interface to handle events related to browser requests. The /// methods of this class will be called on the IO thread unless otherwise @@ -204,6 +219,18 @@ class CefResourceRequestHandler : public virtual CefBaseRefCounted { CefRefPtr frame, CefRefPtr request, bool& allow_os_execution) {} + + /// + /// GetResourceHandlerByIO. + /// + /*--cef(optional_param=browser,optional_param=frame)--*/ + virtual void GetResourceHandlerByIO( + CefRefPtr browser, + CefRefPtr frame, + CefRefPtr request, + CefRefPtr callback, + CefRefPtr scheme_factory, + const CefString& scheme) {} }; /// diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h index b6ef91895e4dfb40c070387e3cc3a9866dea8c46..15b97b7bab9f48c53bf8c0da1d891ef8a7e539e8 100644 --- a/include/internal/cef_types.h +++ b/include/internal/cef_types.h @@ -706,6 +706,7 @@ typedef struct _cef_browser_settings_t { int draw_mode; cef_state_t text_autosizing_enabled; cef_state_t universal_access_from_file_urls; + bool force_zero_layout_height; /* ohos webview end */ #endif // BUILDFLAG(IS_OHOS) diff --git a/include/internal/cef_types_wrappers.h b/include/internal/cef_types_wrappers.h index 6c990e3875ff8f62be6d0a51d53939e567ccdc79..5f4a0711dbfc0374aef53f79e9d788903bf9829d 100644 --- a/include/internal/cef_types_wrappers.h +++ b/include/internal/cef_types_wrappers.h @@ -616,6 +616,7 @@ struct CefBrowserSettingsTraits { target->scroll_enabled = src->scroll_enabled; target->is_safe_browsing_enable = src->is_safe_browsing_enable; target->draw_mode = src->draw_mode; + target->force_zero_layout_height = src->force_zero_layout_height; /* ohos webview end */ #endif // BUILDFLAG(IS_OHOS) diff --git a/libcef/browser/alloy/alloy_browser_host_impl.cc b/libcef/browser/alloy/alloy_browser_host_impl.cc index 42d9a41065df0abb54fdda144debba6bec4792a2..b861de904b43646dae3f12ce964d66eac7393295 100644 --- a/libcef/browser/alloy/alloy_browser_host_impl.cc +++ b/libcef/browser/alloy/alloy_browser_host_impl.cc @@ -59,6 +59,7 @@ #include "base/ohos/ltpo/include/dynamic_frame_rate_decision.h" #include "base/ohos/sys_info_utils.h" #include "content/browser/gpu/gpu_process_host.h" +#include "libcef/browser/alloy/render_process_state_handler.h" #include "libcef/browser/osr/render_widget_host_view_osr.h" #include "libcef/browser/osr/touch_selection_controller_client_osr.h" #include "libcef/browser/prefs/renderer_prefs.h" @@ -777,13 +778,13 @@ void AlloyBrowserHostImpl::WasOccluded(bool occluded) { void AlloyBrowserHostImpl::OnWindowShow() { TRACE_EVENT0("base", "AlloyBrowserHostImpl::OnWindowShow"); LOG(DEBUG) << "AlloyBrowserHostImpl::OnWindowShow"; - ReportRenderProcessStatus(false); + RenderProcessStateHandler::GetInstance()->UpdateRenderProcessState(GetRenderProcessId(), nweb_id_, false); } void AlloyBrowserHostImpl::OnWindowHide() { TRACE_EVENT0("base", "AlloyBrowserHostImpl::OnWindowHide"); LOG(DEBUG) << "AlloyBrowserHostImpl::OnWindowHide"; - ReportRenderProcessStatus(true); + RenderProcessStateHandler::GetInstance()->UpdateRenderProcessState(GetRenderProcessId(), nweb_id_, true); SetVisible(false); } @@ -833,35 +834,26 @@ void AlloyBrowserHostImpl::SetVisible(bool visible) } } -void AlloyBrowserHostImpl::ReportRenderProcessStatus(bool is_web_hidden) { - using namespace OHOS::NWeb; - +base::ProcessId AlloyBrowserHostImpl::GetRenderProcessId() { content::WebContents* contents = web_contents(); if (!contents) { - LOG(ERROR) << "AlloyBrowserHostImpl::ReportRenderProcessStatus web_contents is null"; - return; + LOG(ERROR) << "AlloyBrowserHostImpl::GetRenderProcessId web_contents is null"; + return 0; } if (auto render_view_host = contents->GetRenderViewHost()) { auto render_process_host = render_view_host->GetProcess(); if (!render_process_host) { - LOG(ERROR) << "AlloyBrowserHostImpl::ReportRenderProcessStatus render_process_host is null"; - return; + LOG(ERROR) << "AlloyBrowserHostImpl::GetRenderProcessId render_process_host is null"; + return 0; } - - ResSchedStatusAdapter status = is_web_hidden - ? ResSchedStatusAdapter::WEB_INACTIVE - : ResSchedStatusAdapter::WEB_ACTIVE; - base::ProcessId process_id = render_process_host->GetProcess().Pid(); - ResSchedClientAdapter::ReportRenderProcessStatus(status, process_id); - TRACE_EVENT2("base", "ResSchedClientAdapter::ReportRenderProcessStatus", "status", static_cast(status), - "process_id", process_id); - LOG(DEBUG) << "AlloyBrowserHostImpl::ReportRenderProcessStatus is_web_hidden: " << is_web_hidden << " process_id: " << process_id; + return render_process_host->GetProcess().Pid(); } else { - LOG(ERROR) << "AlloyBrowserHostImpl::ReportRenderProcessStatus render_view_host is null"; - return; + LOG(ERROR) << "AlloyBrowserHostImpl::GetRenderProcessId render_view_host is null"; + return 0; } } + void AlloyBrowserHostImpl::SetEnableLowerFrameRate(bool enabled) { LOG(DEBUG) << "SetEnableLowerFrameRate:" << enabled; if (!CEF_CURRENTLY_ON_UIT()) { @@ -1916,7 +1908,11 @@ bool AlloyBrowserHostImpl::IsBackForwardCacheSupported() { content::PreloadingEligibility AlloyBrowserHostImpl::IsPrerender2Supported( content::WebContents& web_contents) { +#if BUILDFLAG(IS_OHOS) + return content::PreloadingEligibility::kPreloadingUnsupportedByWebContents; +#else return content::PreloadingEligibility::kEligible; +#endif } #ifdef OHOS_FOCUS @@ -1975,6 +1971,14 @@ void AlloyBrowserHostImpl::OnNativeEmbedStatusUpdate( platform_delegate_->OnNativeEmbedLifecycleChange(data_info); } + +void AlloyBrowserHostImpl::OnLayerRectVisibilityChange(const std::string& embed_id, bool visibility) { + if (!platform_delegate_) { + return; + } + + platform_delegate_->OnNativeEmbedVisibilityChange(embed_id, visibility); +} #endif // content::WebContentsObserver methods. // ----------------------------------------------------------------------------- @@ -2413,6 +2417,7 @@ void AlloyBrowserHostImpl::UpdateBackgroundColor(int color) { } void AlloyBrowserHostImpl::RenderViewReady() { + RenderProcessStateHandler::GetInstance()->InitRenderProcessState(GetRenderProcessId(), nweb_id_); if (!CEF_CURRENTLY_ON_UIT()) { CEF_POST_TASK( CEF_UIT, @@ -2420,7 +2425,6 @@ void AlloyBrowserHostImpl::RenderViewReady() { return; } ReportWindowStatus(true); - ReportRenderProcessStatus(is_hidden_); LOG(DEBUG) << "AlloyBrowserHostImpl::RenderViewReady"; SetVisible(true); #if BUILDFLAG(IS_OHOS) @@ -2486,6 +2490,12 @@ void AlloyBrowserHostImpl::UpdateZoomSupportEnabled() { } } +void AlloyBrowserHostImpl::SetNativeEmbedMode(bool flag) { + if (platform_delegate_) { + platform_delegate_->SetNativeEmbedMode(flag); + } +} + #ifdef OHOS_HTML_SELECT void AlloyBrowserHostImpl::ShowPopupMenu( mojo::PendingRemote popup_client, diff --git a/libcef/browser/alloy/alloy_browser_host_impl.h b/libcef/browser/alloy/alloy_browser_host_impl.h index cc8c335bba6628cadd44c358c14557a51e95f63f..74e2fcb33d5491a9140ecd88b514c968e11e8262 100644 --- a/libcef/browser/alloy/alloy_browser_host_impl.h +++ b/libcef/browser/alloy/alloy_browser_host_impl.h @@ -374,6 +374,8 @@ bool NeedsReload() override; void OnNativeEmbedStatusUpdate( const content::NativeEmbedInfo& native_embed_info, content::NativeEmbedInfo::TagState state) override; + + void OnLayerRectVisibilityChange(const std::string& embed_id, bool visibility) override; #endif // content::WebContentsObserver methods. @@ -511,10 +513,11 @@ bool NeedsReload() override; void UpdateZoomSupportEnabled(); void ReportWindowStatus(bool first_view_ready); void InactiveUnloadOldProcess(base::ProcessId pid); - void ReportRenderProcessStatus(bool is_web_hidden); + base::ProcessId GetRenderProcessId(); void UpdateVSyncFrequency(); void ResetVSyncFrequency(); void SetVisible(bool visible); + void SetNativeEmbedMode(bool flag) override; #endif #if defined(OHOS_INPUT_EVENTS) diff --git a/libcef/browser/alloy/alloy_browser_main.cc b/libcef/browser/alloy/alloy_browser_main.cc index 7a454913c5f1ba931647f7ef7894e19b984f8623..37e2630a704f8bc0c7f94331125f289c2dbd45a6 100644 --- a/libcef/browser/alloy/alloy_browser_main.cc +++ b/libcef/browser/alloy/alloy_browser_main.cc @@ -251,8 +251,10 @@ void AlloyBrowserMainParts::PostCreateMainMessageLoop() { // OSCrypt can be disabled in a special settings file. config->should_use_preference = command_line->HasSwitch(switches::kEnableEncryptionSelection); +#if !BUILDFLAG(IS_OHOS) base::PathService::Get(chrome::DIR_USER_DATA, &config->user_data_path); DCHECK(!config->user_data_path.empty()); +#endif //!BUILDFLAG(IS_OHOS) OSCrypt::SetConfig(std::move(config)); #endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_OHOS) } diff --git a/libcef/browser/alloy/alloy_content_browser_client.cc b/libcef/browser/alloy/alloy_content_browser_client.cc index 2cb276c44b0b4f9aaf7a5920ea14d38852210edd..7ff0edc2acf72bde5c579d66c44fff7ff30d8c4b 100644 --- a/libcef/browser/alloy/alloy_content_browser_client.cc +++ b/libcef/browser/alloy/alloy_content_browser_client.cc @@ -286,6 +286,10 @@ using extensions::mojom::APIPermissionID; #include "libcef/browser/subresource_filter/adblock_content_subresource_filter_web_contents_helper_factory.h" #endif // OHOS_ARKWEB_ADBLOCK +#ifdef OHOS_CA +#include "third_party/bounds_checking_function/include/securec.h" +#endif // OHOS_CA + #if defined(OHOS_SITE_ISOLATION) bool g_siteIsolationMode = false; #endif @@ -306,6 +310,13 @@ void TransferVector(const std::vector& source, } #endif +#if defined(OHOS_CACHE) +constexpr int64_t LARGE_CAPACITY_DEVICE_THRESHOLD = static_cast(100) * 1024 * 1024 * 1024; +constexpr int64_t LARGE_CAPACITY_DEVICE_CACHE_SIZE = 100 * 1024 * 1024; +constexpr int64_t SMALL_CAPACITY_DEVICE_CACHE_SIZE = 20 * 1024 * 1024; +constexpr char WEB_CACHE_PATH[] = "/data/storage/e12/base/cache/web"; +#endif // defined(OHOS_CACHE) + #if defined(OHOS_ARKWEB_EXTENSIONS) // The SpecialAccessFileURLLoaderFactory provided to the extension background // pages. Checks with the ChildProcessSecurityPolicy to validate the file @@ -672,7 +683,9 @@ class CefSelectClientCertificateCallbackImpl return; } - memset(certData, 0, certMaxSize); + if (memset_s(certData, certMaxSize, 0, certMaxSize) != EOK) { + return; + } uint32_t len = 0; RootCertDataAdapter->GetAppCert((uint8_t*)uri, certData, &len); if (len == 0) { @@ -2758,7 +2771,15 @@ bool AlloyContentBrowserClient::ConfigureNetworkContextParams( // Determined by DiskCache itself. network_context_params->http_cache_max_size = 0; } else { - network_context_params->http_cache_max_size = 20 * 1024 * 1024; + int64_t tatalDiskSpace = + base::SysInfo::AmountOfTotalDiskSpace(base::FilePath(WEB_CACHE_PATH)); + if (tatalDiskSpace >= LARGE_CAPACITY_DEVICE_THRESHOLD) { + LOG(DEBUG) << "Set http cache max size to 100MB for large capacity device"; + network_context_params->http_cache_max_size = LARGE_CAPACITY_DEVICE_CACHE_SIZE; + } else { + LOG(DEBUG) << "Set http cache max size to 20MB for small capacity device"; + network_context_params->http_cache_max_size = SMALL_CAPACITY_DEVICE_CACHE_SIZE; + } } } #endif // defined(OHOS_CACHE) diff --git a/libcef/browser/alloy/browser_platform_delegate_alloy.cc b/libcef/browser/alloy/browser_platform_delegate_alloy.cc index ede6319b7dbcbdfa8a3e7209dda10a6820e87e0f..ab0de2a228d78eb9a2130efb5ba6bdb07b8ad677 100644 --- a/libcef/browser/alloy/browser_platform_delegate_alloy.cc +++ b/libcef/browser/alloy/browser_platform_delegate_alloy.cc @@ -245,12 +245,12 @@ void CefBrowserPlatformDelegateAlloy::BrowserCreated( } #if defined(OHOS_DATALIST) - autofill::OhAutofillClient::CreateForWebContents(web_contents_, true); + autofill::OhAutofillClient::CreateForWebContents(web_contents_, false); #endif #if defined(OHOS_EX_PASSWORD) || defined(OHOS_DATALIST) || defined(OHOS_PASSWORD_AUTOFILL) // need use components/autofill/core/browser/ module impl save password - autofill::OhAutofillClient::CreateForWebContents(web_contents_, true); + autofill::OhAutofillClient::CreateForWebContents(web_contents_, false); OhPasswordManagerClient::CreateForWebContentsWithAutofillClient( web_contents_, autofill::OhAutofillClient::FromWebContents(web_contents_)); diff --git a/libcef/browser/alloy/render_process_state_handler.cc b/libcef/browser/alloy/render_process_state_handler.cc new file mode 100644 index 0000000000000000000000000000000000000000..32708197b28bb759d01e9f37bc227d3d7c3084d0 --- /dev/null +++ b/libcef/browser/alloy/render_process_state_handler.cc @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "cef/libcef/browser/alloy/render_process_state_handler.h" +#include "base/logging.h" +#include "base/trace_event/trace_event.h" +#include "res_sched_client_adapter.h" + +RenderProcessStateHandler* RenderProcessStateHandler::instance = nullptr; + +RenderProcessStateHandler::RenderProcessStateHandler() {} + +RenderProcessStateHandler* RenderProcessStateHandler::GetInstance() { + if (instance == nullptr) { + instance = new RenderProcessStateHandler(); + } + return instance; +} + +RenderProcessStateHandler::~RenderProcessStateHandler() { + instance = nullptr; +} + +void RenderProcessStateHandler::UpdateRenderProcessState( + uint32_t render_process_id, + int nweb_id, + bool is_to_background) { + using namespace OHOS::NWeb; + if (render_process_id == 0) { + LOG(DEBUG) << "RenderProcessStateHandler::UpdateRenderProcessState: render " + "process has not init, nweb_id: " + << nweb_id << " is_to_background: " << is_to_background; + for (WebComponentState& web_item : initial_web_component_list_) { + if (web_item.nweb_id == nweb_id) { + web_item.state = is_to_background; + return; + } + } + + WebComponentState initial_web_component = {nweb_id, is_to_background}; + initial_web_component_list_.push_back(initial_web_component); + return; + } + + LOG(DEBUG) + << "RenderProcessStateHandler::UpdateRenderProcessState: render_id:" + << render_process_id << " nweb_id: " << nweb_id + << " is_to_background: " << is_to_background; + bool report_background_state = is_to_background; + bool is_render_init = true; + for (RenderProcessStateMap& item : render_process_map_list_) { + LOG(DEBUG) + << "RenderProcessStateHandler::UpdateRenderProcessState: for_render_id:" + << item.render_process_id; + if (item.render_process_id != render_process_id) { + continue; + } + is_render_init = false; + + bool is_web_init = true; + for (WebComponentState& web_component_state : item.web_component_list) { + LOG(DEBUG) << "RenderProcessStateHandler::UpdateRenderProcessState: " + "item.nweb_id: " + << web_component_state.nweb_id + << " state: " << web_component_state.state; + if (web_component_state.nweb_id != nweb_id) { + if (report_background_state && !web_component_state.state) { + report_background_state = false; + } + continue; + } + is_web_init = false; + web_component_state.state = is_to_background; + } + + if (is_web_init) { + LOG(DEBUG) << "RenderProcessStateHandler::UpdateRenderProcessState: add " + "new web: " + << nweb_id << " state: " << is_to_background; + + WebComponentState new_web_component = {nweb_id, is_to_background}; + item.web_component_list.push_back(new_web_component); + } + } + + if (is_render_init) { + LOG(DEBUG) << "RenderProcessStateHandler::UpdateRenderProcessState: add " + "new render: " + << render_process_id << " nweb_id: " << nweb_id + << " state: " << is_to_background; + WebComponentState new_web_component = {nweb_id, is_to_background}; + std::vector web_component_list; + web_component_list.push_back(new_web_component); + RenderProcessStateMap new_render_process_state_map = {render_process_id, web_component_list}; + render_process_map_list_.push_back(new_render_process_state_map); + } + + LOG(INFO) << "RenderProcessStateHandler::UpdateRenderProcessState: " + "ReportRenderProcessStatus render_id: " + << render_process_id + << " report_background_state: " << report_background_state; + ResSchedStatusAdapter status = report_background_state + ? ResSchedStatusAdapter::WEB_INACTIVE + : ResSchedStatusAdapter::WEB_ACTIVE; + ResSchedClientAdapter::ReportRenderProcessStatus(status, render_process_id); + TRACE_EVENT2("base", "ResSchedClientAdapter::ReportRenderProcessStatus", + "render_process_id", render_process_id, "status", + static_cast(status)); + + for (auto item = initial_web_component_list_.begin(); item != initial_web_component_list_.end();) { + if (item->nweb_id == nweb_id) { + LOG(DEBUG) << "UpdateRenderProcessState: delete from init list: " + << " nweb_id: " << nweb_id + << " state: " << item->state; + item = initial_web_component_list_.erase(item); + } else { + ++item; + } + } +} + +void RenderProcessStateHandler::InitRenderProcessState( + uint32_t render_process_id, + int nweb_id) { + LOG(DEBUG) << "RenderProcessStateHandler::InitRenderProcessState: render_id: " + << render_process_id << " nweb_id: " << nweb_id; + if (initial_web_component_list_.size() == 0) { + LOG(DEBUG) << "RenderProcessStateHandler::InitRenderProcessState: No task"; + return; + } + + for (auto item = initial_web_component_list_.begin(); + item != initial_web_component_list_.end(); ++item) { + if (item->nweb_id == nweb_id) { + UpdateRenderProcessState(render_process_id, nweb_id, item->state); + LOG(DEBUG) << "RenderProcessStateHandler::InitRenderProcessState: size: " + << initial_web_component_list_.size(); + return; + } + } +} \ No newline at end of file diff --git a/libcef/browser/alloy/render_process_state_handler.h b/libcef/browser/alloy/render_process_state_handler.h new file mode 100644 index 0000000000000000000000000000000000000000..239986a5a484c90f91d907a5a0dc1845b2afb583 --- /dev/null +++ b/libcef/browser/alloy/render_process_state_handler.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef CEF_LIBCEF_BROWSER_ALLOY_RENDER_PROCESS_STATE_HANDLER_H_ +#define CEF_LIBCEF_BROWSER_ALLOY_RENDER_PROCESS_STATE_HANDLER_H_ + +#include + +struct WebComponentState +{ + int nweb_id; + bool state; +}; + +struct RenderProcessStateMap +{ + uint32_t render_process_id; + std::vector web_component_list; +}; + +class RenderProcessStateHandler +{ +private: + RenderProcessStateHandler(); + ~RenderProcessStateHandler(); + + RenderProcessStateHandler(const RenderProcessStateHandler &) = delete; + RenderProcessStateHandler &operator=(const RenderProcessStateHandler &) = delete; + + std::vector render_process_map_list_; + + std::vector initial_web_component_list_; + + static RenderProcessStateHandler *instance; + +public: + static RenderProcessStateHandler *GetInstance(); + + void UpdateRenderProcessState( + uint32_t render_process_id, + int nweb_id, + bool is_to_background); + + void InitRenderProcessState( + uint32_t render_process_id, + int nweb_id); +}; + +#endif // CEF_LIBCEF_BROWSER_ALLOY_RENDER_PROCESS_STATE_HANDLER_H_ \ No newline at end of file diff --git a/libcef/browser/autofill/oh_autofill_client.cc b/libcef/browser/autofill/oh_autofill_client.cc index a1a848761423afc743c5fe29e4400237264b934c..2d808f1d68bb807fc88a36320be8af1419a2ef3b 100644 --- a/libcef/browser/autofill/oh_autofill_client.cc +++ b/libcef/browser/autofill/oh_autofill_client.cc @@ -55,22 +55,25 @@ OhAutofillClient::~OhAutofillClient() { } void OhAutofillClient::FillData(CefRefPtr data) { +#if defined(OHOS_AUTOFILL) std::string json_str = data->GetStdString(); content::RenderFrameHost* rfh = GetWebContents().GetFocusedFrame(); autofill::ContentAutofillDriver* driver = autofill::ContentAutofillDriver::GetForRenderFrameHost(rfh); - auto mgr = static_cast(driver->autofill_manager()); + auto mgr = static_cast(driver->oh_autofill_manager()); if (mgr) { mgr->FillData(json_str); } +#endif } -void OhAutofillClient::OnAutofillEvent(const std::string& json_str) { +bool OhAutofillClient::OnAutofillEvent(const std::string& json_str) { if (callback_) { CefRefPtr data = CefValue::Create(); data->SetStdString(json_str); - callback_->OnMessage(data); + return callback_->OnMessageWithBoolResult(data); } + return false; } void OhAutofillClient::SetSaveFormData(bool enabled) { @@ -440,6 +443,14 @@ void OhAutofillClient::SuggestionSelected(int position) { } } +void DriverInit(AutofillClient* client, const std::string& app_locale, + ContentAutofillDriver* driver) { + autofill::BrowserDriverInitHook(client, app_locale, driver); +#if defined(OHOS_AUTOFILL) + autofill::OhDriverInitHook(client, driver); +#endif +} + // Ownership: The native object is created (if autofill enabled) and owned by // AwContents. The native object creates the java peer which handles most // autofill functionality at the java side. The java peer is owned by Java @@ -450,7 +461,7 @@ OhAutofillClient::OhAutofillClient(WebContents* contents, contents, use_autofill_manager ? base::BindRepeating(&autofill::OhDriverInitHook, this) - : base::BindRepeating(&autofill::BrowserDriverInitHook, + : base::BindRepeating(&autofill::DriverInit, this, g_browser_process->GetApplicationLocale())) #if DCHECK_IS_ON() diff --git a/libcef/browser/autofill/oh_autofill_client.h b/libcef/browser/autofill/oh_autofill_client.h index 1e7304f2c583bf884f8607a75cfd473cf54aa54d..f80b0d7bcc8bd1921db4ff11d05793a5b98be172 100644 --- a/libcef/browser/autofill/oh_autofill_client.h +++ b/libcef/browser/autofill/oh_autofill_client.h @@ -82,7 +82,7 @@ class OhAutofillClient : public autofill::ContentAutofillClient, callback_ = callback; } void FillData(CefRefPtr data); - void OnAutofillEvent(const std::string& json_str); + bool OnAutofillEvent(const std::string& json_str); bool IsOffTheRecord() override; scoped_refptr GetURLLoaderFactory() override; autofill::AutofillDownloadManager* GetDownloadManager() override; diff --git a/libcef/browser/autofill/oh_autofill_manager.cc b/libcef/browser/autofill/oh_autofill_manager.cc index bf09605925bc2e585bcb07aa4cd45d89bc8b5f09..a819a4f6c9d972717157de71059bc39aaa74fe8c 100644 --- a/libcef/browser/autofill/oh_autofill_manager.cc +++ b/libcef/browser/autofill/oh_autofill_manager.cc @@ -14,13 +14,13 @@ */ #include "libcef/browser/autofill/oh_autofill_manager.h" -#include #include #include "base/containers/contains.h" #include "base/json/json_reader.h" #include "base/json/json_writer.h" #include "base/memory/ptr_util.h" +#include "base/strings/utf_string_conversions.h" #include "components/android_autofill/browser/autofill_provider.h" #include "components/autofill/content/browser/content_autofill_driver.h" #include "components/autofill/content/renderer/autofill_agent.h" @@ -48,9 +48,10 @@ const std::string KEY_PLACEHOLDER = "placeholder"; const std::string KEY_VALUE = "value"; #if defined(OHOS_PASSWORD_AUTOFILL) -const std::string KEY_PAGE_URL = "pageUrl"; const std::string KEY_USERNAME = "username"; const std::string KEY_PASSWORD = "password"; +const std::string KEY_RETURN_PAGE_URL = "autofill_viewdata_origin_pageurl"; +const std::string KEY_RETURN_OTHER_ACCOUNT = "autofill_viewdata_other_account"; #endif } // namespace @@ -59,12 +60,15 @@ namespace autofill { using base::TimeTicks; void OhDriverInitHook(AutofillClient* client, ContentAutofillDriver* driver) { +#if defined(OHOS_AUTOFILL) + driver->set_oh_autofill_manager( + base::WrapUnique(new OhAutofillManager(driver, client))); +#else driver->set_autofill_manager( base::WrapUnique(new OhAutofillManager(driver, client))); +#endif driver->GetAutofillAgent()->SetUserGestureRequired(false); - driver->GetAutofillAgent()->SetSecureContextRequired(true); driver->GetAutofillAgent()->SetFocusRequiresScroll(false); - driver->GetAutofillAgent()->SetQueryPasswordSuggestion(true); } OhAutofillManager::OhAutofillManager(AutofillDriver* driver, @@ -83,6 +87,15 @@ CreditCardAccessManager* OhAutofillManager::GetCreditCardAccessManager() { return nullptr; } +std::string OhAutofillManager::GetAttributeOrUniqueId(const FormFieldData& field) { + auto attribute = field.autocomplete_attribute; + if (!attribute.empty()) { + return attribute; + } + auto unique_renderer_id = base::NumberToString(field.unique_renderer_id.value()); + return unique_renderer_id; +} + absl::optional OhAutofillManager::FormDataToJson( const FormData& form, const FormFieldData& field, @@ -106,12 +119,12 @@ absl::optional OhAutofillManager::FormDataToJson( base::Value::List view_data_list; view_data_list.Append(base::Value::Dict().Set(EVENT, event)); - std::wstring_convert, char16_t> convert; for (const FormFieldData& field_data : form.fields) { base::Value::List list; + auto key = GetAttributeOrUniqueId(field_data); list.Append(base::Value::Dict().Set( KEY_FOUCS, - field_data.autocomplete_attribute == field.autocomplete_attribute ? 1 : 0)); + key == GetAttributeOrUniqueId(field) ? 1 : 0)); list.Append(base::Value::Dict().Set( KEY_RECT_X, static_cast((field_data.bounds.x() + offset.x()) * ratio))); @@ -122,12 +135,12 @@ absl::optional OhAutofillManager::FormDataToJson( KEY_RECT_W, static_cast(field_data.bounds.width() * ratio))); list.Append(base::Value::Dict().Set( KEY_RECT_H, static_cast(field_data.bounds.height() * ratio))); - list.Append( - base::Value::Dict().Set(KEY_PLACEHOLDER, convert.to_bytes(field_data.placeholder))); - list.Append( - base::Value::Dict().Set(KEY_VALUE, convert.to_bytes(field_data.value))); + list.Append(base::Value::Dict().Set( + KEY_PLACEHOLDER, base::UTF16ToUTF8(base::StringPiece16(field_data.placeholder)))); + list.Append(base::Value::Dict().Set( + KEY_VALUE, base::UTF16ToUTF8(base::StringPiece16(field_data.value)))); - auto dict = base::Value::Dict().Set(field_data.autocomplete_attribute, std::move(list)); + auto dict = base::Value::Dict().Set(key, std::move(list)); view_data_list.Append(std::move(dict)); } @@ -158,10 +171,10 @@ absl::optional OhAutofillManager::FormDataToJsonForSave(const FormD base::Value::List view_data_list; view_data_list.Append(base::Value::Dict().Set(EVENT, EVENT_SAVE)); - std::wstring_convert, char16_t> convert; int32_t index = 0; for (const FormFieldData& field_data : form.fields) { base::Value::List list; + auto key = GetAttributeOrUniqueId(field_data); list.Append(base::Value::Dict().Set(KEY_FOUCS, 0)); list.Append(base::Value::Dict().Set( KEY_RECT_X, @@ -173,12 +186,12 @@ absl::optional OhAutofillManager::FormDataToJsonForSave(const FormD KEY_RECT_W, static_cast(form_->fields[index].bounds.width() * ratio))); list.Append(base::Value::Dict().Set( KEY_RECT_H, static_cast(form_->fields[index].bounds.height() * ratio))); - list.Append( - base::Value::Dict().Set(KEY_PLACEHOLDER, convert.to_bytes(field_data.placeholder))); - list.Append( - base::Value::Dict().Set(KEY_VALUE, convert.to_bytes(field_data.value))); + list.Append(base::Value::Dict().Set( + KEY_PLACEHOLDER, base::UTF16ToUTF8(base::StringPiece16(field_data.placeholder)))); + list.Append(base::Value::Dict().Set( + KEY_VALUE, base::UTF16ToUTF8(base::StringPiece16(field_data.value)))); - auto dict = base::Value::Dict().Set(field_data.autocomplete_attribute, std::move(list)); + auto dict = base::Value::Dict().Set(key, std::move(list)); view_data_list.Append(std::move(dict)); index++; } @@ -187,10 +200,6 @@ absl::optional OhAutofillManager::FormDataToJsonForSave(const FormD } void OhAutofillManager::FillData(const std::string& json_str) { - if (form_ == nullptr) { - return; - } - absl::optional root = base::JSONReader::Read(json_str); if (!root.has_value()) { return; @@ -202,25 +211,46 @@ void OhAutofillManager::FillData(const std::string& json_str) { } #if defined(OHOS_PASSWORD_AUTOFILL) - const std::string* page_url = root_dict->FindString(KEY_PAGE_URL); const std::string* username = root_dict->FindString(KEY_USERNAME); const std::string* password = root_dict->FindString(KEY_PASSWORD); + const std::string* page_url = root_dict->FindString(KEY_RETURN_PAGE_URL); + bool is_other_account = root_dict->FindBool(KEY_RETURN_OTHER_ACCOUNT).value_or(false); if (username || password) { ForwardDataToPasswordManager(page_url ? *page_url : std::string(), username ? *username : std::string(), - password ? *password : std::string()); + password ? *password : std::string(), + is_other_account); return; } #endif - std::wstring_convert, char16_t> convert; + if (form_ == nullptr) { + return; + } + for (const FormFieldData& field_data : form_->fields) { const std::string* value = root_dict->FindString(field_data.autocomplete_attribute); - if (!value) { + if (!value || value->empty()) { continue; } driver()->RendererShouldFillFieldWithValue(field_data.global_id(), - convert.from_bytes(*value)); + base::UTF8ToUTF16(*value)); + } + for (auto it = root_dict->begin(); it != root_dict->end(); it++) { + const base::Value::Dict* sub_dict = root_dict->FindDict(it->first); + if (sub_dict) { + const std::string* str = sub_dict->FindString(KEY_VALUE); + if (!str) { + continue; + } + absl::optional index = sub_dict->FindInt(KEY_PLACEHOLDER); + if (!index.has_value() || index.value() <= 0 || index.value() > form_->fields.size()) { + continue; + } + uint32_t i = static_cast(index.value()) - 1; + driver()->RendererShouldFillFieldWithValue(form_->fields[i].global_id(), + base::UTF8ToUTF16(*str)); + } } is_show_ = false; } @@ -229,8 +259,9 @@ void OhAutofillManager::FillData(const std::string& json_str) { void OhAutofillManager::ForwardDataToPasswordManager( const std::string& page_url, const std::string& username, - const std::string& password) { - LOG(INFO) << "autofill save, forward to password_manager"; + const std::string& password, + bool is_other_account) { + LOG(INFO) << "autofill fill data, forward to password_manager"; auto* rfh = static_cast(driver())->render_frame_host(); if (!rfh || !rfh->IsActive()) { @@ -248,10 +279,8 @@ void OhAutofillManager::ForwardDataToPasswordManager( return; } - std::wstring_convert, char16_t> convert; - password_manager->FillAccountSuggestion(GURL(page_url), - convert.from_bytes(username), - convert.from_bytes(password)); + password_manager->FillData(page_url, username, password, is_other_account); + is_password_popup_show_ = false; } bool OhAutofillManager::IsUsernamePasswordFormField(FormRendererId form_id, @@ -426,14 +455,21 @@ void OhAutofillManager::OnDidFillAutofillFormDataImpl( } void OhAutofillManager::OnHidePopupImpl() { - LOG(INFO) << "OnHidePopupImpl"; - - if (!is_show_) { + auto* rfh = static_cast(driver())->render_frame_host(); + if (!rfh || !rfh->IsActive()) { + LOG(ERROR) << "rfh is nullptr or not active"; return; } - auto* rfh = static_cast(driver())->render_frame_host(); - if (!rfh || !rfh->IsActive()) { + bool is_focused = false; + auto browser = CefBrowserHostBase::GetBrowserForHost(rfh); + if (browser) { + is_focused = browser->IsFocused(); + } + LOG(INFO) << "OnHidePopupImpl, is_show=" << is_show_ + << ", is_password_popup_show=" << is_password_popup_show_ + << ", is_focused=" << is_focused; + if (!is_show_ && !(is_password_popup_show_ && is_focused)) { return; } @@ -451,9 +487,11 @@ void OhAutofillManager::OnHidePopupImpl() { view_data_list.Append(base::Value::Dict().Set(EVENT, EVENT_CLOSE)); absl::optional json_str = base::WriteJson(view_data_list); if (json_str.has_value()) { + LOG(INFO) << "send event to hide autofill popup"; autofill_client->OnAutofillEvent(json_str.value()); } is_show_ = false; + is_password_popup_show_ = false; } void OhAutofillManager::PropagateAutofillPredictions( @@ -477,6 +515,7 @@ void OhAutofillManager::Reset() { LOG(INFO) << "Reset"; AutofillManager::Reset(); is_show_ = false; + is_password_popup_show_ = false; if (form_) { form_.reset(nullptr); } diff --git a/libcef/browser/autofill/oh_autofill_manager.h b/libcef/browser/autofill/oh_autofill_manager.h index af53aa40817ceb1ecd79cad4e938e920f0d8e7bf..bc46e2e798577b52c57f174464b478052c84d08b 100644 --- a/libcef/browser/autofill/oh_autofill_manager.h +++ b/libcef/browser/autofill/oh_autofill_manager.h @@ -94,14 +94,17 @@ class OhAutofillManager : public AutofillManager { const std::string& event); absl::optional FormDataToJsonForSave(const FormData& form); void FillData(const std::string& json_str); + std::string GetAttributeOrUniqueId(const FormFieldData& field); #if defined(OHOS_PASSWORD_AUTOFILL) void ForwardDataToPasswordManager(const std::string& page_url, const std::string& username, - const std::string& password); + const std::string& password, + bool is_other_account); bool IsUsernamePasswordFormField(FormRendererId form_id, FieldRendererId field_id); + void SetPasswordPopupShow(bool is_show) { is_password_popup_show_ = is_show; } #endif protected: @@ -174,6 +177,7 @@ class OhAutofillManager : public AutofillManager { bool has_server_prediction_ = false; base::WeakPtrFactory weak_ptr_factory_{this}; bool is_show_ = false; + bool is_password_popup_show_ = false; std::unique_ptr form_; }; diff --git a/libcef/browser/browser_contents_delegate.cc b/libcef/browser/browser_contents_delegate.cc index 3f58f54839cd6a4711943660c547c233fdadeaf9..15b6a2929672e99b0ecdc28e28d0b6967a48d987 100644 --- a/libcef/browser/browser_contents_delegate.cc +++ b/libcef/browser/browser_contents_delegate.cc @@ -96,8 +96,9 @@ void MaybeSetUserAgentOverrideForMainFrame( std::string final_ua = nweb_ex::AlloyBrowserUAConfig::GetInstance()->GetUserAgentForHost(host); LOG(DEBUG) << "DidStartNavigation, host " << host << ", final_ua " << final_ua - << ", user_gesture " << navigation->HasUserGesture() << ", url " - << url.spec(); + << ", user_gesture " << navigation->HasUserGesture() + << ", is_main_frame " << navigation->IsInMainFrame() + << ", is_reload " << is_reload; navigation->SetRequestHeader(net::HttpRequestHeaders::kUserAgent, final_ua); if (!navigation->IsInMainFrame()) { @@ -858,6 +859,15 @@ void CefBrowserContentsDelegate::DidFinishNavigation( OnLoadStart(frame.get(), navigation_handle->GetPageTransition()); if (navigation_handle->IsServedFromBackForwardCache()) { // We won't get an OnLoadEnd notification from anywhere else. +#ifdef OHOS_BFCACHE + LOG(INFO) << "[Favicon] page load form bfcache."; + if (auto c = client()) { + if (auto handler = c->GetLoadHandler()) { + auto navigation_lock = browser_info_->CreateNavigationLock(); + handler->UpdateFavicon(browser()); + } + } +#endif // OHOS_BFCACHE OnLoadEnd(frame.get(), navigation_handle->GetURL(), 0); } } diff --git a/libcef/browser/browser_host_base.cc b/libcef/browser/browser_host_base.cc index 46af438918944900b3ffa6702387d7de1ae04836..d5193739a9098f8adade5da675211f653105e3ff 100644 --- a/libcef/browser/browser_host_base.cc +++ b/libcef/browser/browser_host_base.cc @@ -119,6 +119,12 @@ namespace { #if defined(OHOS_INPUT_EVENTS) static float DEFAULT_MIN_ZOOM_FACTOR = 0.01f; static float DEFAULT_MAX_ZOOM_FACTOR = 100.0f; + +enum class WebScrollType : int { + UNKNOWN = -1, + EVENT = 0, + POSITION +}; #endif // defined(OHOS_INPUT_EVENTS) #if defined(OHOS_EX_DOWNLOAD) @@ -680,6 +686,18 @@ void CefBrowserHostBase::PrintToPDF(const CefString& path, print_util::PrintToPDF(web_contents, path, settings, callback); } +void CefBrowserHostBase::CreateToPDF(const CefPdfPrintSettings& settings, + CefRefPtr callback) { + auto web_contents = GetWebContents(); + if (!web_contents || !callback) { + LOG(ERROR) << "CefBrowserHostBase::CreateToPDF " + "callback is nullptr or web_contents is null"; + return; + } + + print_util::CreateToPDF(web_contents, settings, callback); +} + bool CefBrowserHostBase::SendDevToolsMessage(const void* message, size_t message_size) { if (!message || message_size == 0) { @@ -888,6 +906,7 @@ void CefBrowserHostBase::UpdateBrowserSettings( settings_.embed_tag_type); settings_.draw_mode = browser_settings.draw_mode; settings_.text_autosizing_enabled = browser_settings.text_autosizing_enabled; + settings_.force_zero_layout_height = browser_settings.force_zero_layout_height; #endif // BUILDFLAG(IS_OHOS) #ifdef OHOS_SCROLLBAR settings_.scrollbar_color = browser_settings.scrollbar_color; @@ -1043,8 +1062,7 @@ void CefBrowserHostBase::JavaScriptOnDocumentStart( js_injection::JsCommunicationHost::AddScriptResult result = host->AddDocumentStartJavaScript(script, scriptRules); if (result.script_id.has_value()) { - document_start_script_result_map_.emplace( - std::make_pair(stdScript, result.script_id.value())); + document_start_script_result_map_[stdScript] = result.script_id.value(); } } } @@ -1073,8 +1091,7 @@ void CefBrowserHostBase::JavaScriptOnDocumentEnd( js_injection::JsCommunicationHost::AddScriptResult result = host->AddDocumentEndJavaScript(script, scriptRules); if (result.script_id.has_value()) { - document_end_script_result_map_.emplace( - std::make_pair(stdScript, result.script_id.value())); + document_end_script_result_map_[stdScript] = result.script_id.value(); } } } @@ -1570,7 +1587,7 @@ void CefBrowserHostBase::UpdateLocale(const CefString& locale) { std::string origin_locale = ui::ResourceBundle::GetSharedInstance().GetLoadedLocaleForTesting(); if (origin_locale == update_locale) { - LOG(ERROR) << "CefBrowserHostBase::UpdateLocale no need to update locale"; + LOG(WARNING) << "CefBrowserHostBase::UpdateLocale no need to update locale"; return; } @@ -1680,6 +1697,10 @@ void CefBrowserHostBase::SetBrowserZoomLevel(double zoom_factor) { void CefBrowserHostBase::AdvanceFocusForIME(int focusType) { // todo(ohos):impl this function then remove todo } + +void CefBrowserHostBase::SetNativeEmbedMode(bool flag) { + // todo(ohos):impl this function then remove todo +} #endif // IS_OHOS void CefBrowserHostBase::StopLoad() { @@ -2299,6 +2320,11 @@ CefString CefBrowserHostBase::Title() { // WebMessagePort>> portMap_; first is the paif of port_handles. second is the // WebMessagePort of the pipe. void CefBrowserHostBase::CreateWebMessagePorts(std::vector& ports) { + if (!CEF_CURRENTLY_ON_UIT()) { + DCHECK(false) << "called on invalid thread"; + return; + } + base::AutoLock msg_lock(web_message_lock_); auto web_contents = GetWebContents(); if (web_contents) { int retry_times = 0; @@ -2311,16 +2337,13 @@ void CefBrowserHostBase::CreateWebMessagePorts(std::vector& ports) { return; } uint64_t pointer0 = base::RandUint64(); - if (pointer0 == ULLONG_MAX) { + if (pointer0 == ULLONG_MAX || ((pointer0 + 1) == ULLONG_MAX)) { retry_times++; continue; } + pointer0 = ((pointer0 % 2) == 0) ? (pointer0 + 1) : pointer0; uint64_t pointer1 = pointer0 + 1; - auto iter = std::find_if(portMap_.begin(), portMap_.end(), [&pointer0, &pointer1](auto& cc){ - std::pair rnd = cc.first; - return (rnd.first == pointer0 || rnd.second == pointer0 || rnd.first == pointer1); - }); - + auto iter = portMap_.find(std::make_pair(pointer0, pointer1)); if (iter == portMap_.end()) { portMap_[std::make_pair(pointer0, pointer1)] = std::make_pair(std::move(portArr[0]), std::move(portArr[1])); @@ -2341,6 +2364,11 @@ void CefBrowserHostBase::CreateWebMessagePorts(std::vector& ports) { void CefBrowserHostBase::PostWebMessage(CefString& message, std::vector& port_handles, CefString& targetUri) { + if (!CEF_CURRENTLY_ON_UIT()) { + DCHECK(false) << "called on invalid thread"; + return; + } + base::AutoLock msg_lock(web_message_lock_); auto web_contents = GetWebContents(); if (!web_contents) { LOG(ERROR) << "PostWebMessage web_contents its null"; @@ -2384,6 +2412,11 @@ void CefBrowserHostBase::PostWebMessage(CefString& message, // WebMessagePort>> portMap_; first is the paif of port_handles. second is the // WebMessagePort of the pipe. void CefBrowserHostBase::ClosePort(CefString& portHandle) { + if (!CEF_CURRENTLY_ON_UIT()) { + DCHECK(false) << "called on invalid thread"; + return; + } + base::AutoLock msg_lock(web_message_lock_); LOG(DEBUG) << "ClosePort ClosePort"; auto web_contents = GetWebContents(); if (!web_contents) { @@ -2529,14 +2562,10 @@ bool CefBrowserHostBase::ConvertCefValueToBlinkMsg( return true; } -void CefBrowserHostBase::PostPortMessage(CefString& portHandle, +void CefBrowserHostBase::PostPortMessageInternal(const CefString& portHandle, CefRefPtr data) { - auto web_contents = GetWebContents(); - if (!web_contents) { - LOG(ERROR) << "GetWebContents null"; - return; - } - + base::ScopedAllowBlocking scoped_allow_blocking; + base::AutoLock msg_lock(web_message_lock_); // construct blink message blink::WebMessagePort::Message message; if (!ConvertCefValueToBlinkMsg(data, message)) { @@ -2565,27 +2594,19 @@ void CefBrowserHostBase::PostPortMessage(CefString& portHandle, } } -// in the std::map, std::pair> portMap_; first is the paif of port_handles. second is the -// WebMessagePort of the pipe. -void CefBrowserHostBase::SetPortMessageCallback( - CefString& portHandle, - CefRefPtr callback) { - auto web_contents = GetWebContents(); - if (!web_contents) { - LOG(ERROR) << "GetWebContents null"; - return; - } +void CefBrowserHostBase::PostPortMessage(const CefString& portHandle, + CefRefPtr data) { + sequenced_task_runner_->PostTask( + FROM_HERE, base::BindOnce(&CefBrowserHostBase::PostPortMessageInternal, + this, portHandle, data)); +} - // get sequenced task runner +void CefBrowserHostBase::SetPortMessageCallbackInternal( + const CefString& portHandle, + CefRefPtr callback) { + base::ScopedAllowBlocking scoped_allow_blocking; + base::AutoLock msg_lock(web_message_lock_); std::string pointer0 = portHandle.ToString(); - if (!base::SequencedTaskRunner::HasCurrentDefault()) - { - LOG(ERROR) << "not in SequencedTaskRunner"; - return; - } - - auto sequenced_task_runner_ = base::SequencedTaskRunner::GetCurrentDefault(); // get web message receiver instance std::shared_ptr webMsgReceiver; @@ -2622,7 +2643,19 @@ void CefBrowserHostBase::SetPortMessageCallback( receiverMap_[pointer0] = webMsgReceiver; } +// in the std::map, std::pair> portMap_; first is the paif of port_handles. second is the +// WebMessagePort of the pipe. +void CefBrowserHostBase::SetPortMessageCallback( + const CefString& portHandle, + CefRefPtr callback) { + sequenced_task_runner_->PostTask( + FROM_HERE, base::BindOnce(&CefBrowserHostBase::SetPortMessageCallbackInternal, + this, portHandle, callback)); +} + void CefBrowserHostBase::DestroyAllWebMessagePorts() { + base::AutoLock msg_lock(web_message_lock_); LOG(DEBUG) << "clear all message ports"; portMap_.clear(); receiverMap_.clear(); @@ -3028,8 +3061,11 @@ void CefBrowserHostBase::SetNativeWindow(cef_native_window_t window) { widget_ = NWebNativeWindowTracker::GetInstance()->AddNativeWindow(window); } -cef_accelerated_widget_t CefBrowserHostBase::GetAcceleratedWidget() { - return widget_; +cef_accelerated_widget_t CefBrowserHostBase::GetAcceleratedWidget(bool isPopup) { + if (!isPopup) { + return widget_; + } + return popup_widget_; } void CefBrowserHostBase::SetWebDebuggingAccess(bool isEnableDebug) { @@ -3153,6 +3189,17 @@ void CefBrowserHostBase::ScrollPageUpDown(bool is_up, ->ScrollPageUpDown(is_up, is_half, view_height); } } + +#ifdef OHOS_GET_SCROLL_OFFSET +void CefBrowserHostBase::GetScrollOffset(float* offset_x, + float* offset_y) { + auto frame = GetMainFrame(); + if (frame && frame->IsValid()) { + static_cast(frame.get()) + ->GetScrollOffset(offset_x, offset_y); + } +} +#endif #endif // #ifdef OHOS_PAGE_UP_DOWN CefRefPtr CefBrowserHostBase::GetWebState() { @@ -3215,14 +3262,20 @@ void CefBrowserHostBase::SetOverscrollMode(int overscrollMode) { } } -void CefBrowserHostBase::SetScrollable(bool enable) { +void CefBrowserHostBase::SetScrollable(bool enable, int scrollType) { LOG(DEBUG) << "set scrollable: " << enable; + if (platform_delegate_) { platform_delegate_->SetScrollable(enable); } - auto frame = GetMainFrame(); - if (frame && frame->IsValid()) { - static_cast(frame.get())->SetScrollable(enable); + + if (scrollType == static_cast(WebScrollType::UNKNOWN) || + scrollType == static_cast(WebScrollType::POSITION) || + enable) { + auto frame = GetMainFrame(); + if (frame && frame->IsValid()) { + static_cast(frame.get())->SetScrollable(enable); + } } } @@ -3260,6 +3313,17 @@ void CefBrowserHostBase::ScrollByWithAnime(float delta_x, float delta_y, int32_t static_cast(frame.get())->ScrollByWithAnime(delta_x, delta_y, duration); } } + +#if defined(OHOS_GET_SCROLL_OFFSET) +void CefBrowserHostBase::GetOverScrollOffset(float* offset_x, + float* offset_y) { + auto frame = GetMainFrame(); + if (frame && frame->IsValid()) { + static_cast(frame.get()) + ->GetOverScrollOffset(offset_x, offset_y); + } +} +#endif #endif // defined(OHOS_INPUT_EVENTS) #ifdef OHOS_NETWORK_CONNINFO @@ -3604,8 +3668,8 @@ void CefBrowserHostBase::PasswordSuggestionSelected(int list_index) { } void CefBrowserHostBase::EnableSafeBrowsing(bool enable) { - LOG(INFO) << "enable safe browsing" << enable; if (settings_.is_safe_browsing_enable != enable) { + LOG(INFO) << "enable safe browsing" << enable; settings_.is_safe_browsing_enable = enable; } } @@ -3944,6 +4008,8 @@ void CefBrowserHostBase::SetBackForwardCacheOptions(int32_t size, int32_t timeTo return; } + LOG(INFO) << "SetBackForwardCacheOptions param size: " << size + << " timeToLive: " << timeToLive; content::NavigationController& controller = web_contents->GetController(); controller.GetBackForwardCache().SetCacheSize(size); controller.GetBackForwardCache().SetTimeToLive(timeToLive); @@ -3955,3 +4021,8 @@ void CefBrowserHostBase::ScrollFocusedEditableNodeIntoView() { // TODO(ohos): please impl the function and remove this comment. } #endif + +void CefBrowserHostBase::SetPopupWindow(cef_native_window_t window) +{ + popup_widget_ = NWebNativeWindowTracker::GetInstance()->AddNativeWindow(window); +} diff --git a/libcef/browser/browser_host_base.h b/libcef/browser/browser_host_base.h index 0bbd64dabd93306645a0bcd191e11db2032857ab..1078b419e6a2bc802cc48f6144002f9943810b66 100644 --- a/libcef/browser/browser_host_base.h +++ b/libcef/browser/browser_host_base.h @@ -230,6 +230,8 @@ class CefBrowserHostBase : public CefBrowserHost, void PrintToPDF(const CefString& path, const CefPdfPrintSettings& settings, CefRefPtr callback) override; + void CreateToPDF(const CefPdfPrintSettings& settings, + CefRefPtr callback) override; void ReplaceMisspelling(const CefString& word) override; void AddWordToDictionary(const CefString& word) override; void SendKeyEvent(const CefKeyEvent& event) override; @@ -343,6 +345,7 @@ class CefBrowserHostBase : public CefBrowserHost, CefRefPtr cacheOptions, CefRefPtr callback) override; void AdvanceFocusForIME(int focusType) override; + void SetNativeEmbedMode(bool flag) override; /* ohos webview end */ #endif #ifdef OHOS_NAVIGATION @@ -453,6 +456,9 @@ bool NeedsReload() override; #endif #ifdef OHOS_PAGE_UP_DOWN void ScrollPageUpDown(bool is_up, bool is_half, float view_height) override; +#ifdef OHOS_GET_SCROLL_OFFSET + void GetScrollOffset(float* offset_x, float* offset_y) override; +#endif #endif // OHOS_PAGE_UP_DOWN #if defined(OHOS_INPUT_EVENTS) void ScrollTo(float x, float y) override; @@ -462,10 +468,13 @@ bool NeedsReload() override; void GetHitData(int& type, CefString& extra_data) override; uint64_t GetCurrentTimestamp(); void SetOverscrollMode(int overScrollMode) override; - void SetScrollable(bool enable) override; + void SetScrollable(bool enable, int scrollType) override; void UpdateDrawRect() override; void ScrollToWithAnime(float x, float y, int32_t duration) override; void ScrollByWithAnime(float delta_x, float delta_y, int32_t duration) override; +#if defined(OHOS_GET_SCROLL_OFFSET) + void GetOverScrollOffset(float* offset_x, float* offset_y) override; +#endif #endif // defined(OHOS_INPUT_EVENTS) #ifdef OHOS_NETWORK_CONNINFO void SetFileAccess(bool falg) override; @@ -507,10 +516,10 @@ bool NeedsReload() override; void ClosePort(CefString& port_handle) override; bool ConvertCefValueToBlinkMsg(CefRefPtr& original, blink::WebMessagePort::Message& message); - void PostPortMessage(CefString& port_handle, + void PostPortMessage(const CefString& port_handle, CefRefPtr message) override; void SetPortMessageCallback( - CefString& port_handle, + const CefString& port_handle, CefRefPtr callback) override; void DestroyAllWebMessagePorts() override; #endif // defined(OHOS_MSGPORT) @@ -696,7 +705,7 @@ bool TerminateRenderProcess() override; std::string GetDataURI(const std::string& data); void SetNativeWindow(cef_native_window_t window) override; - cef_accelerated_widget_t GetAcceleratedWidget(); + cef_accelerated_widget_t GetAcceleratedWidget(bool isPopup); void SetWebDebuggingAccess(bool isEnableDebug) override; bool GetWebDebuggingAccess() override; @@ -742,6 +751,7 @@ bool TerminateRenderProcess() override; void SetBackForwardCacheOptions(int32_t size, int32_t timeToLive) override; #endif + void SetPopupWindow(cef_native_window_t popupWindow) override; protected: bool EnsureDevToolsManager(); void InitializeDevToolsRegistrationOnUIThread( @@ -825,6 +835,13 @@ bool TerminateRenderProcess() override; CefRefPtr callback); void OnDidGenerateCodeCache(CefRefPtr callback, int32_t result); + + void SetPortMessageCallbackInternal( + const CefString& portHandle, + CefRefPtr callback); + void PostPortMessageInternal(const CefString& portHandle, + CefRefPtr data); + // GURL is supplied by the content layer as requesting frame. // Callback is supplied by the content layer, and is invoked with the result // from the permission prompt. @@ -834,10 +851,13 @@ bool TerminateRenderProcess() override; using MessagePipe = std::pair; using PortHandle = std::pair; - std::map portMap_; - std::set postedPorts_; + base::Lock web_message_lock_; + std::map portMap_ GUARDED_BY(web_message_lock_); + std::set postedPorts_ GUARDED_BY(web_message_lock_); std::unordered_map> - receiverMap_; + receiverMap_ GUARDED_BY(web_message_lock_); + scoped_refptr sequenced_task_runner_ = + base::ThreadPool::CreateSequencedTaskRunner({}); #if defined(OHOS_INPUT_EVENTS) uint64_t last_zoom_time_ = 0; @@ -847,6 +867,7 @@ bool TerminateRenderProcess() override; std::unique_ptr permission_request_handler_; cef_accelerated_widget_t widget_; + cef_accelerated_widget_t popup_widget_; bool is_web_debugging_access_ = false; float virtual_pixel_ratio_ = 2.0; base::WeakPtrFactory weak_ptr_factory_; diff --git a/libcef/browser/browser_info_manager.cc b/libcef/browser/browser_info_manager.cc index 48e680b9811ce2fd9e3ccd9b25c7d990fbc25ebb..802cc2d248df36aee8c3834b485a20b2429b67ea 100644 --- a/libcef/browser/browser_info_manager.cc +++ b/libcef/browser/browser_info_manager.cc @@ -25,6 +25,12 @@ #include "content/public/browser/web_contents.h" #include "content/public/common/url_constants.h" +#if defined(OHOS_NO_STATE_PREFETCH) +#include "chrome/browser/preloading/prefetch/no_state_prefetch/no_state_prefetch_manager_factory.h" +#include "components/no_state_prefetch/browser/no_state_prefetch_contents.h" +#include "components/no_state_prefetch/browser/no_state_prefetch_manager.h" +#endif // defined(OHOS_NO_STATE_PREFETCH) + namespace { // Timeout delay for new browser info responses. @@ -338,11 +344,61 @@ bool CefBrowserInfoManager::AddWebContents(content::WebContents* new_contents) { return false; } +#if defined(OHOS_NO_STATE_PREFETCH) +bool CefBrowserInfoManager::IsPrerendering( + const content::GlobalRenderFrameHostId& global_id) { + std::vector browser_context_all = + CefBrowserContext::GetAll(); + if (browser_context_all.size() == 0) { + return false; + } + + auto* rfh = content::RenderFrameHost::FromID(global_id); + content::WebContents* web_contents = + content::WebContents::FromRenderFrameHost(rfh); + if (!web_contents) { + return false; + } + + for (auto& context: CefBrowserContext::GetAll()) { + prerender::NoStatePrefetchManager* no_state_prefetch_manager = + prerender::NoStatePrefetchManagerFactory::GetForBrowserContext( + context->AsBrowserContext()); + if (no_state_prefetch_manager) { + auto* no_state_prefetch_content = + no_state_prefetch_manager->GetNoStatePrefetchContents(web_contents); + if (no_state_prefetch_content) { + return true; + } + } + } + + return false; +} + +void CefBrowserInfoManager::CancelForPrerendering( + const content::GlobalRenderFrameHostId& global_id, + int timeout_id) { + CEF_REQUIRE_UIT(); + LOG(INFO) << "cancel for prerendering"; + if (!g_info_manager) { + return; + } + + if (!IsPrerendering(global_id)) { + return; + } + + TimeoutNewBrowserInfoResponse(global_id, timeout_id); +} +#endif + void CefBrowserInfoManager::OnGetNewBrowserInfo( const content::GlobalRenderFrameHostId& global_id, cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback) { DCHECK(frame_util::IsValidGlobalId(global_id)); DCHECK(callback); + LOG(INFO) << "on get new browser info"; auto callback_runner = base::SequencedTaskRunner::GetCurrentDefault(); @@ -375,6 +431,14 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo( pending_new_browser_info_map_.insert( std::make_pair(global_id, std::move(pending))); + LOG(INFO) << "on get new browser info wait timeout"; +#if defined(OHOS_NO_STATE_PREFETCH) + CEF_POST_TASK( + CEF_UIT, + base::BindOnce(&CefBrowserInfoManager::CancelForPrerendering, + global_id, timeout_id)); +#endif + // Register a timeout for the pending response so that the renderer process // doesn't hang forever. With the Chrome runtime, timeouts may occur in cases // where chrome::AddWebContents or WebContents::Create are called directly @@ -641,6 +705,7 @@ void CefBrowserInfoManager::TimeoutNewBrowserInfoResponse( const content::GlobalRenderFrameHostId& global_id, int timeout_id) { CEF_REQUIRE_UIT(); + LOG(INFO) << "on get new browser info timeout"; if (!g_info_manager) { return; } diff --git a/libcef/browser/browser_info_manager.h b/libcef/browser/browser_info_manager.h index e53d5ead1647ad1327b83a1c11772a43d36897a8..847cb0e94f1e7dbecaa9e10458eda9a30da39325 100644 --- a/libcef/browser/browser_info_manager.h +++ b/libcef/browser/browser_info_manager.h @@ -245,6 +245,12 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver { const content::GlobalRenderFrameHostId& global_id, int timeout_id); +#if defined(OHOS_NO_STATE_PREFETCH) + static bool IsPrerendering(const content::GlobalRenderFrameHostId& global_id); + static void CancelForPrerendering( + const content::GlobalRenderFrameHostId& global_id, int timeout_id); +#endif + mutable base::Lock browser_info_lock_; // Access to the below members must be protected by |browser_info_lock_|. diff --git a/libcef/browser/browser_platform_delegate.h b/libcef/browser/browser_platform_delegate.h index f97e4c715299873d51c3385d45884fdb6a9f5821..ba16d5e87a824aba0541e3fd8669737314a1a0fc 100644 --- a/libcef/browser/browser_platform_delegate.h +++ b/libcef/browser/browser_platform_delegate.h @@ -337,6 +337,8 @@ class CefBrowserPlatformDelegate { virtual void SendTouchEventList(const std::vector& event_list); virtual void NotifyForNextTouchEvent(); + + virtual void SetNativeEmbedMode(bool flag) {}; #endif // Notify the browser that screen information has changed. Only used with @@ -469,6 +471,8 @@ class CefBrowserPlatformDelegate { virtual bool ShouldVirtualKeyboardOverlay() { return false; } virtual void OnNativeEmbedLifecycleChange( const CefRenderHandler::CefNativeEmbedData& info) {} + virtual void OnNativeEmbedVisibilityChange( + const std::string& embed_id, bool visibility) {} virtual void SetScrollable(bool enable) {} virtual void AdvanceFocusForIME(int focusType) {} #endif diff --git a/libcef/browser/browser_platform_delegate_unittest.cc b/libcef/browser/browser_platform_delegate_unittest.cc new file mode 100644 index 0000000000000000000000000000000000000000..9c3febf13f672be47468f2215a5190621d317900 --- /dev/null +++ b/libcef/browser/browser_platform_delegate_unittest.cc @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define protected public +#include "libcef/browser/browser_platform_delegate.h" +#undef protected + +#include "libcef/browser/alloy/alloy_browser_host_impl.h" + +#include "base/logging.h" +#include "content/public/browser/render_view_host.h" +#include "content/public/browser/render_widget_host.h" +#include "content/public/browser/render_widget_host_view.h" + +#include +#include + +std::shared_ptr g_browser_platform_delegate; + +class CefBrowserPlatformDelegateTest : public testing::Test { + public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void CefBrowserPlatformDelegateTest::SetUpTestCase(void) {} + +void CefBrowserPlatformDelegateTest::TearDownTestCase(void) {} + +void CefBrowserPlatformDelegateTest::SetUp(void) { + g_browser_platform_delegate = std::make_shared(); + ASSERT_NE(g_browser_platform_delegate, nullptr); +} + +void CefBrowserPlatformDelegateTest::TearDown(void) { + g_browser_platform_delegate = nullptr; +} + +TEST_F(CefBrowserPlatformDelegateTest, WebPageSnapshot) { + const char* id = "test_id"; + int width = 1024; + int height = 768; + bool result = false; + + result = g_browser_platform_delegate->WebPageSnapshot( + id, width, height, + base::BindOnce([](const char* str, bool is, void* ptr, int a, int b) {})); + EXPECT_FALSE(result); +} \ No newline at end of file diff --git a/libcef/browser/certificate_query.cc b/libcef/browser/certificate_query.cc index 220bdc481f26047ea49ba5d7a096e190af19c046..cfbafcde065dc0629a6b87591962e242fbaf9d02 100644 --- a/libcef/browser/certificate_query.cc +++ b/libcef/browser/certificate_query.cc @@ -209,7 +209,6 @@ CertificateErrorCallback AllowAllCertificateError( new CefAllowCertificateErrorCallbackImpl(std::move(callback))); result = OnCertificateError(web_contents, cert_error, sslInfo, request_url, is_main_frame_request, strict_enforcement, origin_url, referrer, mainCallbackImpl, true); - if (!result) { callback = mainCallbackImpl->Disconnect(); LOG_IF(ERROR, callback.is_null()) << "Should return true from OnCertificateError when executing the callback"; diff --git a/libcef/browser/devtools/devtools_manager_delegate.cc b/libcef/browser/devtools/devtools_manager_delegate.cc index 98e2c05c758df01a814bf3d722ddc660c0c4b45d..6d1abf808fa239fae9c690cec7e1c7a261d9cdbe 100644 --- a/libcef/browser/devtools/devtools_manager_delegate.cc +++ b/libcef/browser/devtools/devtools_manager_delegate.cc @@ -44,18 +44,25 @@ namespace content { bool CanUserConnectToDevTools( const net::UnixDomainServerSocket::Credentials& credentials) { + if (credentials.group_id != credentials.user_id) { + LOG(WARNING) << "DevTools: credentials.group_id = " + << credentials.group_id + << " is not equal to credentials.user_id = " + << credentials.user_id; + return false; + } + // From processes signed with the same key + if (credentials.user_id == getuid()) { + return true; + } struct passwd* creds = getpwuid(credentials.user_id); if (!creds || !creds->pw_name) { LOG(WARNING) << "DevTools: can't obtain creds for uid " << credentials.user_id; return false; } - if (credentials.group_id == credentials.user_id && - (strcmp("root", creds->pw_name) == 0 || // For rooted devices - strcmp("shell", creds->pw_name) == 0 || // For non-rooted devices - - // From processes signed with the same key - credentials.user_id == getuid())) { + if (strcmp("root", creds->pw_name) == 0 || // For rooted devices + strcmp("shell", creds->pw_name) == 0) { // For non-rooted devices return true; } LOG(WARNING) << "DevTools: connection attempt from " << creds->pw_name; diff --git a/libcef/browser/download_manager_delegate.cc b/libcef/browser/download_manager_delegate.cc index 29255524a5dd95fdaab7b7bc4a6e46573da295e6..85e7e514703c4d134fbb7efae75c074f2bb56b92 100644 --- a/libcef/browser/download_manager_delegate.cc +++ b/libcef/browser/download_manager_delegate.cc @@ -462,10 +462,12 @@ void CefDownloadManagerDelegate::OnDownloadCreated(DownloadManager* manager, // associated WebContents and consequently no associated CEF browser. In // that case DetermineDownloadTarget will be called before this method. // TODO(cef): Figure out how to expose this via a client callback. +#if !defined(OHOS_EX_DOWNLOAD) const std::vector& url_chain = item->GetUrlChain(); if (!url_chain.empty()) { LOG(INFO) << "Rejected download of " << url_chain.back().spec(); } +#endif #if defined(OHOS_EX_DOWNLOAD) // When download item not has associated browser, do not cancel the download item. #else diff --git a/libcef/browser/frame_host_impl.cc b/libcef/browser/frame_host_impl.cc index 1603a2847bd640c293c888086cda9e161334661c..849fbef481b3d3079edaa6b51b59206cde60b68e 100644 --- a/libcef/browser/frame_host_impl.cc +++ b/libcef/browser/frame_host_impl.cc @@ -32,6 +32,14 @@ #include "third_party/skia/include/core/SkImage.h" #endif // BUILDFLAG(IS_OHOS) +#ifdef OHOS_CLIPBOARD +#include "skia/ext/image_operations.h" +#endif + +#ifdef OHOS_NETWORK_LOAD +#include "base/strings/escape.h" +#endif + namespace { void StringVisitCallback(CefRefPtr visitor, @@ -78,6 +86,48 @@ void ExecWebContentsCommand(CefFrameHostImpl* fh, fh->SendCommand(command); } +#ifdef OHOS_CLIPBOARD +const int kMaxContextImageNodeSizeIfDownScale = 1024; + +bool NeedsDownScale(const gfx::Size& original_image_size) { + if (original_image_size.width() <= kMaxContextImageNodeSizeIfDownScale && + original_image_size.height() <= kMaxContextImageNodeSizeIfDownScale) { + return false; + } + LOG(DEBUG) << "The origin image size width: " << original_image_size.width() + << ", height: " << original_image_size.height(); + return true; +} + +SkBitmap DownScale(const SkBitmap& image) { + if (image.isNull()) { + return SkBitmap(); + } + + gfx::Size image_size(image.width(), image.height()); + if (!NeedsDownScale(image_size)) { + return image; + } + + gfx::SizeF scaled_size = gfx::SizeF(image_size); + + if (scaled_size.width() > kMaxContextImageNodeSizeIfDownScale) { + scaled_size.Scale(kMaxContextImageNodeSizeIfDownScale / + scaled_size.width()); + } + + if (scaled_size.height() > kMaxContextImageNodeSizeIfDownScale) { + scaled_size.Scale(kMaxContextImageNodeSizeIfDownScale / + scaled_size.height()); + } + + return skia::ImageOperations::Resize(image, + skia::ImageOperations::RESIZE_GOOD, + static_cast(scaled_size.width()), + static_cast(scaled_size.height())); +} +#endif + #define EXEC_WEBCONTENTS_COMMAND(name) \ ExecWebContentsCommand(this, &CefFrameHostImpl::name, \ &content::WebContents::name, #name); @@ -376,11 +426,11 @@ void CefFrameHostImpl::LoadRequest(cef::mojom::RequestParamsPtr params) { void CefFrameHostImpl::LoadURLWithUserGesture(const CefString& url, bool user_gesture) { LoadURLWithExtras(url, content::Referrer(), kPageTransitionExplicit, std::string() #ifdef OHOS_POST_URL - , +, std::string(), std::vector() #endif - , +, user_gesture); } #endif @@ -390,12 +440,12 @@ void CefFrameHostImpl::LoadURLWithExtras(const std::string& url, ui::PageTransition transition, const std::string& extra_headers #ifdef OHOS_POST_URL - , +, const std::string& method, const std::vector& post_data #endif #ifdef OHOS_NETWORK_LOAD - , +, bool user_gesture #endif ) { @@ -408,6 +458,11 @@ void CefFrameHostImpl::LoadURLWithExtras(const std::string& url, // Any necessary fixup will occur in LoadRequest. #ifdef OHOS_NETWORK_LOAD GURL gurl = url_util::FixupGURL(url); + if (!base::StartsWith(url, "file:/") && gurl.SchemeIsFile()) { + std::string unscaped_url_str = base::UnescapeURLComponent(gurl.spec(), + base::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS); + gurl = GURL(unscaped_url_str); + } #else GURL gurl = url_util::MakeGURL(url, /*fixup=*/false); #endif @@ -886,8 +941,14 @@ void CefFrameHostImpl::OnGetImageFromCache( sk_sp sk_image = SkImages::DeferredFromEncodedData(sk_data); if (sk_image) { SkBitmap bitmap; - sk_image->asLegacyBitmap(&bitmap); - image_impl->AddBitmap(1.0, bitmap); + if (sk_image->asLegacyBitmap(&bitmap)) { +#ifdef OHOS_CLIPBOARD + SkBitmap resize_image = DownScale(bitmap); + image_impl->AddBitmap(1.0, resize_image); +#else + image_impl->AddBitmap(1.0, bitmap); +#endif + } } } handler->OnGetImageFromCache(image_impl); @@ -1053,6 +1114,20 @@ void CefFrameHostImpl::ScrollPageUpDown(bool is_up, }, is_up, is_half, view_height)); } + +#ifdef OHOS_GET_SCROLL_OFFSET +void CefFrameHostImpl::GetScrollOffset(float* offset_x, + float* offset_y) { + SendToRenderFrame(__FUNCTION__, + base::BindOnce( + [](float* offset_x, float* offset_y, + const RenderFrameType& render_frame) { + render_frame->GetScrollOffset(offset_x, + offset_y); + }, + offset_x, offset_y)); +} +#endif #endif // #ifdef OHOS_PAGE_UP_DOWN #if defined(OHOS_INPUT_EVENTS) @@ -1152,6 +1227,20 @@ void CefFrameHostImpl::ScrollByWithAnime(float delta_x, float delta_y, int32_t d }, delta_x, delta_y, duration)); } + +#if defined(OHOS_GET_SCROLL_OFFSET) +void CefFrameHostImpl::GetOverScrollOffset(float* offset_x, + float* offset_y) { + SendToRenderFrame(__FUNCTION__, + base::BindOnce( + [](float* offset_x, float* offset_y, + const RenderFrameType& render_frame) { + render_frame->GetOverScrollOffset(offset_x, + offset_y); + }, + offset_x, offset_y)); +} +#endif #endif // defined(OHOS_INPUT_EVENTS) #endif // BUILDFLAG(IS_OHOS) diff --git a/libcef/browser/frame_host_impl.h b/libcef/browser/frame_host_impl.h index c3ed281924cee95d60943764f0fc2a77cddfd325..c9176bc8cfd444c88c8b472101d12092a6c7e361 100644 --- a/libcef/browser/frame_host_impl.h +++ b/libcef/browser/frame_host_impl.h @@ -213,6 +213,9 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame { void RemoveCache(bool include_disk_files); #ifdef OHOS_PAGE_UP_DOWN void ScrollPageUpDown(bool is_up, bool is_half, float view_height); +#ifdef OHOS_GET_SCROLL_OFFSET + void GetScrollOffset(float* offset_x, float* offset_y); +#endif #endif // #ifdef OHOS_PAGE_UP_DOWN #if defined(OHOS_INPUT_EVENTS) void ScrollTo(float x, float y); @@ -225,6 +228,9 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame { void UpdateDrawRect(); void ScrollToWithAnime(float x, float y, int32_t duration); void ScrollByWithAnime(float delta_x, float delta_y, int32_t duration); +#if defined(OHOS_GET_SCROLL_OFFSET) + void GetOverScrollOffset(float* offset_x, float* offset_y); +#endif #endif // defined(OHOS_INPUT_EVENTS) #endif // BUILDFLAG(IS_OHOS) diff --git a/libcef/browser/javascript/oh_gin_javascript_bridge_dispatcher_host.cc b/libcef/browser/javascript/oh_gin_javascript_bridge_dispatcher_host.cc index e70811b9c79fb8560e5ff6cbe9d230ddb4bb9ccc..3c8c6541587d3175e60b499be661375acb31973f 100644 --- a/libcef/browser/javascript/oh_gin_javascript_bridge_dispatcher_host.cc +++ b/libcef/browser/javascript/oh_gin_javascript_bridge_dispatcher_host.cc @@ -80,6 +80,7 @@ OhGinJavascriptBridgeDispatcherHost::~OhGinJavascriptBridgeDispatcherHost() { javascript_sync_permission_map_.clear(); javascript_async_permission_map_.clear(); object_id_map_.clear(); + async_object_id_map_.clear(); } // Run on the UI thread. @@ -134,6 +135,14 @@ void OhGinJavascriptBridgeDispatcherHost::RenderFrameCreated( filter->AddRoutingIdForHost(this, render_frame_host); } else { InstallFilterAndRegisterAllRoutingIds(); + // if filter not created, it will be re-created. + // During application startup and loading, JS pre-registers ifream-related hosts. + if (!OhGinJavascriptBridgeMessageFilter::FromHost(agent_scheduling_group, false)) { + scoped_refptr filter_new = + OhGinJavascriptBridgeMessageFilter::FromHost( + agent_scheduling_group, /*create_if_not_exists=*/true); + filter_new->AddRoutingIdForHost(this, render_frame_host); + } } std::shared_lock lock(share_mutex_); @@ -151,8 +160,7 @@ void OhGinJavascriptBridgeDispatcherHost::RenderFrameCreated( // sync_method_map_ has no async method infomation, so send an empty list. base::Value::List empty_list; render_frame_host->Send(new OhGinJavascriptBridgeMsg_AddNamedObject( - render_frame_host->GetRoutingID(), object_name, object_id, empty_list, - false)); + render_frame_host->GetRoutingID(), object_name, object_id, empty_list, false)); } } } @@ -377,6 +385,7 @@ void OhGinJavascriptBridgeDispatcherHost::AddNamedObjectForWebController( async_object_pair.first = object_name; async_object_pair.second = async_method_set; async_method_map_[object_id_] = async_object_pair; + async_object_id_map_[object_id_].insert(object_name); ParseJson(permission, object_id_, true); } @@ -430,6 +439,7 @@ void OhGinJavascriptBridgeDispatcherHost::AddNamedObjectForWebViewController( async_object_pair.first = object_name; async_object_pair.second = async_method_set; async_method_map_[object_id] = async_object_pair; + async_object_id_map_[object_id].insert(object_name); ParseJson(permission, object_id, true); } @@ -545,7 +555,7 @@ void OhGinJavascriptBridgeDispatcherHost::RemoveNamedObject( const std::vector& method_list) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); if (sync_method_map_.empty() && async_method_map_.empty()) { - LOG(ERROR) << "OhGinJavascriptBridgeDispatcherHost::RemoveNamedObject:Map " + LOG(DEBUG) << "OhGinJavascriptBridgeDispatcherHost::RemoveNamedObject:Map " "is empty!"; return; } @@ -554,21 +564,23 @@ void OhGinJavascriptBridgeDispatcherHost::RemoveNamedObject( } bool OhGinJavascriptBridgeDispatcherHost::RemoveNamedObjectInternal( - const std::string& object_name, - bool is_async) { + const std::string& object_name, bool is_async) { + LOG(DEBUG) << "OhGinJavascriptBridgeDispatcherHost::RemoveNamedObjectInternal " + << "target object name: " << object_name; + auto& method_map = is_async ? async_method_map_ : sync_method_map_; bool ret = false; - auto& map = is_async ? async_method_map_ : sync_method_map_; - if (map.empty()) { - return ret = false; + if (method_map.empty()) { + return ret; } + auto& id_map = is_async ? async_object_id_map_ : object_id_map_; std::unique_lock lock(share_mutex_); - for (auto& [object_id, object_name_set] : object_id_map_) { + for (auto& [object_id, object_name_set] : id_map) { for (const std::string& now_object_name : object_name_set) { if (now_object_name == object_name) { object_name_set.erase(object_name); if (object_name_set.size() == 0) { - object_id_map_.erase(object_id); - map.erase(object_id); + id_map.erase(object_id); + method_map.erase(object_id); } ret = true; @@ -586,6 +598,7 @@ bool OhGinJavascriptBridgeDispatcherHost::RemoveNamedObjectInternal( new OhGinJavascriptBridgeMsg_RemoveNamedObject( render_frame_host->GetRoutingID(), copied_name)); }); + return ret; } } } @@ -960,7 +973,6 @@ CefRefPtr ParseBaseValueTOCefValue(base::Value::List* value) { bool OhGinJavascriptBridgeDispatcherHost::CheckIsInJsPermission(const std::string& document_url, const std::string& method_name, int32_t object_id, bool is_async) { LOG(DEBUG) << "OhGinJavascriptBridgeDispatcherHost::CheckIsInJsPermission: " - << "document_url: " << document_url << ", method_name: " << method_name << ", object_id: " << object_id << ", is_async: " << is_async; diff --git a/libcef/browser/javascript/oh_gin_javascript_bridge_dispatcher_host.h b/libcef/browser/javascript/oh_gin_javascript_bridge_dispatcher_host.h index 181e0a263017b1121ae6cdb18921c50139f4caf0..e82b73de0aa3ff21d7055aeebbb31a7c8f6ffee5 100644 --- a/libcef/browser/javascript/oh_gin_javascript_bridge_dispatcher_host.h +++ b/libcef/browser/javascript/oh_gin_javascript_bridge_dispatcher_host.h @@ -196,8 +196,9 @@ class OhGinJavascriptBridgeDispatcherHost PermissionMap javascript_async_permission_map_; std::shared_mutex share_mutex_; int32_t object_id_ = MIN_NATIVE_OBJ_ID; - std::unordered_map> object_id_map_; + std::unordered_map> object_id_map_; + std::unordered_map> async_object_id_map_; CefRefPtr client_; bool install_filter_when_render_process_gone_ = false; }; diff --git a/libcef/browser/menu_manager.cc b/libcef/browser/menu_manager.cc index d897d7871734259b4a19db3f40471cde04b4f0b4..636c790a49e51c88f08b60764fe457c22b1f0ebe 100644 --- a/libcef/browser/menu_manager.cc +++ b/libcef/browser/menu_manager.cc @@ -145,20 +145,13 @@ bool CefMenuManager::IsCommandIdEnabled( case CM_EDITFLAG_CAN_COPY: return !!(params.edit_flags & CM_EDITFLAG_CAN_COPY); case CM_EDITFLAG_CAN_PASTE: { - std::u16string result; bool can_paste = false; - ui::DataTransferEndpoint data_dst = - ui::DataTransferEndpoint(ui::EndpointType::kDefault, false); - ui::Clipboard::GetForCurrentThread()->ReadText( - ui::ClipboardBuffer::kCopyPaste, &data_dst, &result); - - if (result.empty()) { - can_paste = ui::Clipboard::GetForCurrentThread()->IsFormatAvailable( - ui::ClipboardFormatType::BitmapType(), - ui::ClipboardBuffer::kCopyPaste, &data_dst); + if (!editable) { + LOG(INFO) << "This area is not editable."; + return can_paste; } - can_paste = can_paste ? can_paste : !result.empty(); - return editable && can_paste; + can_paste = ui::Clipboard::GetForCurrentThread()->HasPasteData(); + return can_paste; } case CM_EDITFLAG_CAN_SELECT_ALL: return !!(params.edit_flags & CM_EDITFLAG_CAN_SELECT_ALL); diff --git a/libcef/browser/net_service/cookie_helper.cc b/libcef/browser/net_service/cookie_helper.cc index b0f75365359520f3d9c1bae2b5821234e8a21013..732804d401f7024b08d27babd4edf94be8798065 100644 --- a/libcef/browser/net_service/cookie_helper.cc +++ b/libcef/browser/net_service/cookie_helper.cc @@ -178,7 +178,14 @@ void SaveCookiesOnUIThread( auto browser_context = cef_browser_context ? cef_browser_context->AsBrowserContext() : nullptr; if (!browser_context) { +#if BUILDFLAG(IS_OHOS) + CEF_POST_TASK(CEF_IOT, + base::BindOnce(std::move(done_callback), + 0, + net::CookieList())); +#else std::move(done_callback).Run(0, net::CookieList()); +#endif return; } diff --git a/libcef/browser/net_service/cookie_manager_impl.cc b/libcef/browser/net_service/cookie_manager_impl.cc index e8d4332a82dfb2d08076b97222d3a5366cdf1443..c80e87433fdf8019e6e11b666ac0d3f426efe0c7 100644 --- a/libcef/browser/net_service/cookie_manager_impl.cc +++ b/libcef/browser/net_service/cookie_manager_impl.cc @@ -207,7 +207,8 @@ bool CefCookieManagerImpl::VisitUrlCookies( const CefString& url, bool includeHttpOnly, CefRefPtr visitor, - bool is_sync) { + bool is_sync, + bool is_from_ndk) { if (!visitor.get()) { return false; } @@ -226,28 +227,29 @@ bool CefCookieManagerImpl::VisitUrlCookies( if (!ValidContext()) { StoreOrTriggerInitCallback(base::BindOnce( base::IgnoreResult(&CefCookieManagerImpl::VisitUrlCookiesInternal), - this, gurl, includeHttpOnly, visitor, is_sync)); + this, gurl, includeHttpOnly, visitor, is_sync, is_from_ndk)); return true; } - return VisitUrlCookiesInternal(gurl, includeHttpOnly, visitor, is_sync); + return VisitUrlCookiesInternal(gurl, includeHttpOnly, visitor, is_sync, is_from_ndk); } bool CefCookieManagerImpl::SetCookie(const CefString& url, const CefCookie& cookie, CefRefPtr callback, bool is_sync, - const CefString& str_cookie) { + const CefString& str_cookie, + bool includeHttpOnly) { GURL gurl = GURL(url.ToString()); if (!ValidContext()) { StoreOrTriggerInitCallback(base::BindOnce( base::IgnoreResult(&CefCookieManagerImpl::SetCookieInternal), this, - gurl, cookie, callback, is_sync, str_cookie)); + gurl, cookie, callback, is_sync, str_cookie, includeHttpOnly)); return true; } - return SetCookieInternal(gurl, cookie, callback, is_sync, str_cookie); + return SetCookieInternal(gurl, cookie, callback, is_sync, str_cookie, includeHttpOnly); } bool CefCookieManagerImpl::DeleteCookies( @@ -329,13 +331,17 @@ bool CefCookieManagerImpl::VisitUrlCookiesInternal( const GURL& url, bool includeHttpOnly, CefRefPtr visitor, - bool is_sync) { + bool is_sync, + bool is_from_ndk) { DCHECK(ValidContext()); DCHECK(visitor); DCHECK(url.is_valid()); #ifdef OHOS_COOKIE net::CookieOptions options = net::CookieOptions::MakeAllInclusive(); + if (is_from_ndk && !includeHttpOnly) { + options.set_exclude_httponly(); + } #else net::CookieOptions options; if (includeHttpOnly) { @@ -383,7 +389,7 @@ bool CefCookieManagerImpl::SetCookieInternal( const GURL& url, const CefCookie& cookie, CefRefPtr callback, - bool is_sync, const CefString& str_cookie) { + bool is_sync, const CefString& str_cookie, bool includeHttpOnly) { DCHECK(ValidContext()); DCHECK(url.is_valid()); @@ -426,7 +432,7 @@ bool CefCookieManagerImpl::SetCookieInternal( } net::CookieOptions options; - if (cookie.httponly) { + if (includeHttpOnly || cookie.httponly) { options.set_include_httponly(); } options.set_same_site_cookie_context( diff --git a/libcef/browser/net_service/cookie_manager_impl.h b/libcef/browser/net_service/cookie_manager_impl.h index 86b0dc8cbab6aafc095f77d21e58e85a556dc0b6..23194a954f2d7be656008e0542c0d63769363c5b 100644 --- a/libcef/browser/net_service/cookie_manager_impl.h +++ b/libcef/browser/net_service/cookie_manager_impl.h @@ -38,12 +38,14 @@ class CefCookieManagerImpl : public CefCookieManager { bool VisitUrlCookies(const CefString& url, bool includeHttpOnly, CefRefPtr visitor, - bool is_sync) override; + bool is_sync, + bool is_from_ndk) override; bool SetCookie(const CefString& url, const CefCookie& cookie, CefRefPtr callback, bool is_sync, - const CefString& str_cookie) override; + const CefString& str_cookie, + bool includeHttpOnly) override; bool DeleteCookies(const CefString& url, const CefString& cookie_name, #if BUILDFLAG(IS_OHOS) @@ -67,12 +69,13 @@ class CefCookieManagerImpl : public CefCookieManager { bool VisitAllCookiesInternal(CefRefPtr visitor, bool sync); bool VisitUrlCookiesInternal(const GURL& url, bool includeHttpOnly, - CefRefPtr visitor, bool sync); + CefRefPtr visitor, bool sync, bool is_from_ndk); bool SetCookieInternal(const GURL& url, const CefCookie& cookie, CefRefPtr callback, bool sync, - const CefString& str_cookie); + const CefString& str_cookie + bool includeHttpOnly); bool DeleteCookiesInternal(const GURL& url, const CefString& cookie_name, bool is_session, diff --git a/libcef/browser/net_service/cookie_manager_ohos_impl.cc b/libcef/browser/net_service/cookie_manager_ohos_impl.cc index 717b3c9f20ab806f2d1f8013d076a9be4aa60063..683f9a0067d26e04dd50b77480bd83c4e4b2a78d 100644 --- a/libcef/browser/net_service/cookie_manager_ohos_impl.cc +++ b/libcef/browser/net_service/cookie_manager_ohos_impl.cc @@ -331,7 +331,8 @@ bool CefCookieManagerImpl::VisitUrlCookies( const CefString& url, bool includeHttpOnly, CefRefPtr visitor, - bool is_sync) { + bool is_sync, + bool is_from_ndk) { if (!visitor.get()) { return false; } @@ -341,16 +342,17 @@ bool CefCookieManagerImpl::VisitUrlCookies( return false; } LOG(DEBUG) << "CefCookieManagerImpl::VisitUrlCookies is_sync: " << is_sync; - return VisitUrlCookiesInternal(gurl, includeHttpOnly, visitor, is_sync); + return VisitUrlCookiesInternal(gurl, includeHttpOnly, visitor, is_sync, is_from_ndk); } bool CefCookieManagerImpl::SetCookie(const CefString& url, const CefCookie& cookie, CefRefPtr callback, - bool is_sync, const CefString& str_cookie) { + bool is_sync, const CefString& str_cookie, + bool includeHttpOnly) { GURL gurl = GURL(url.ToString()); LOG(DEBUG) << "CefCookieManagerImpl::SetCookie is_sync: " << is_sync; - return SetCookieInternal(gurl, cookie, callback, is_sync, str_cookie); + return SetCookieInternal(gurl, cookie, callback, is_sync, str_cookie, includeHttpOnly); } bool CefCookieManagerImpl::DeleteCookies( @@ -491,11 +493,16 @@ bool CefCookieManagerImpl::VisitUrlCookiesInternal( const GURL& url, bool includeHttpOnly, CefRefPtr visitor, - bool is_sync) { + bool is_sync, + bool is_from_ndk) { DCHECK(visitor); DCHECK(url.is_valid()); net::CookieOptions options = net::CookieOptions::MakeAllInclusive(); + if (is_from_ndk && !includeHttpOnly) { + options.set_exclude_httponly(); + } + LOG(DEBUG) << "CefCookieManagerImpl::VisitUrlCookiesInternal is_sync : " << is_sync; if (is_sync) { RunCookieTaskSync(base::BindOnce(&CefCookieManagerImpl::GetCookieListCookieTask, @@ -538,7 +545,8 @@ bool CefCookieManagerImpl::SetCookieInternal( const CefCookie& cookie, CefRefPtr callback, bool is_sync, - const CefString& str_cookie) { + const CefString& str_cookie, + bool includeHttpOnly) { DCHECK(url.is_valid()); std::unique_ptr canonical_cookie(net::CanonicalCookie::Create( @@ -551,7 +559,7 @@ bool CefCookieManagerImpl::SetCookieInternal( } net::CookieOptions options; - if (cookie.httponly) { + if (includeHttpOnly || cookie.httponly) { options.set_include_httponly(); } options.set_same_site_cookie_context( diff --git a/libcef/browser/net_service/cookie_manager_ohos_impl.h b/libcef/browser/net_service/cookie_manager_ohos_impl.h index 00f66ccbae7f99b0137a64914fa120ed7bc4987c..ac589530f75892c3fbd91657f6cf4dbc6426fbc7 100644 --- a/libcef/browser/net_service/cookie_manager_ohos_impl.h +++ b/libcef/browser/net_service/cookie_manager_ohos_impl.h @@ -55,12 +55,14 @@ class CefCookieManagerImpl : public CefCookieManager { bool VisitUrlCookies(const CefString& url, bool includeHttpOnly, CefRefPtr visitor, - bool is_sync) override; + bool is_sync, + bool is_from_ndk) override; bool SetCookie(const CefString& url, const CefCookie& cookie, CefRefPtr callback, bool is_sync, - const CefString& str_cookie) override; + const CefString& str_cookie, + bool includeHttpOnly) override; bool DeleteCookies(const CefString& url, const CefString& cookie_name, bool is_session, @@ -121,12 +123,14 @@ class CefCookieManagerImpl : public CefCookieManager { bool VisitUrlCookiesInternal(const GURL& url, bool includeHttpOnly, CefRefPtr visitor, - bool is_sync); + bool is_sync, + bool is_from_ndk); bool SetCookieInternal(const GURL& url, const CefCookie& cookie, CefRefPtr callback, bool is_sync, - const CefString& str_cookie); + const CefString& str_cookie, + bool includeHttpOnly); bool DeleteCookiesInternal(const GURL& url, const CefString& cookie_name, bool is_session, diff --git a/libcef/browser/net_service/incognito_cookie_manager_ohos_impl.cc b/libcef/browser/net_service/incognito_cookie_manager_ohos_impl.cc index e3020530930ae21b8ffa4d6abe4437c6b1b448b6..bba2fe47444dc79ea24daace812f33b0ffcbc7fd 100644 --- a/libcef/browser/net_service/incognito_cookie_manager_ohos_impl.cc +++ b/libcef/browser/net_service/incognito_cookie_manager_ohos_impl.cc @@ -354,7 +354,8 @@ bool CefIncognitoCookieManagerImpl::VisitUrlCookies( const CefString& url, bool includeHttpOnly, CefRefPtr visitor, - bool is_sync) { + bool is_sync, + bool is_from_ndk) { if (!visitor.get()) { return false; } @@ -364,15 +365,15 @@ bool CefIncognitoCookieManagerImpl::VisitUrlCookies( return false; } LOG(DEBUG) << "VisitUrlCookies is_sync: " << is_sync; - return VisitUrlCookiesInternal(gurl, includeHttpOnly, visitor, is_sync); + return VisitUrlCookiesInternal(gurl, includeHttpOnly, visitor, is_sync, is_from_ndk); } bool CefIncognitoCookieManagerImpl::SetCookie(const CefString& url, const CefCookie& cookie, CefRefPtr callback, - bool is_sync, const CefString& str_cookie) { + bool is_sync, const CefString& str_cookie, bool includeHttpOnly) { GURL gurl = GURL(url.ToString()); LOG(DEBUG) << "SetCookie is_sync: " << is_sync; - return SetCookieInternal(gurl, cookie, callback, is_sync, str_cookie); + return SetCookieInternal(gurl, cookie, callback, is_sync, str_cookie, includeHttpOnly); } bool CefIncognitoCookieManagerImpl::DeleteCookies( @@ -523,11 +524,16 @@ bool CefIncognitoCookieManagerImpl::VisitUrlCookiesInternal( const GURL& url, bool includeHttpOnly, CefRefPtr visitor, - bool is_sync) { + bool is_sync, + bool is_from_ndk) { DCHECK(visitor); DCHECK(url.is_valid()); net::CookieOptions options = net::CookieOptions::MakeAllInclusive(); + if (is_from_ndk && !includeHttpOnly) { + options.set_exclude_httponly(); + } + LOG(DEBUG) << "VisitUrlCookiesInternal is_sync : " << is_sync; if (is_sync) { RunCookieTaskSync(base::BindOnce( @@ -573,7 +579,8 @@ bool CefIncognitoCookieManagerImpl::SetCookieInternal( const CefCookie& cookie, CefRefPtr callback, bool is_sync, - const CefString& str_cookie) { + const CefString& str_cookie, + bool includeHttpOnly) { DCHECK(url.is_valid()); std::unique_ptr canonical_cookie( @@ -589,9 +596,10 @@ bool CefIncognitoCookieManagerImpl::SetCookieInternal( } net::CookieOptions options; - if (cookie.httponly) { + if (includeHttpOnly || cookie.httponly) { options.set_include_httponly(); } + options.set_same_site_cookie_context( net::CookieOptions::SameSiteCookieContext::MakeInclusive()); diff --git a/libcef/browser/net_service/incognito_cookie_manager_ohos_impl.h b/libcef/browser/net_service/incognito_cookie_manager_ohos_impl.h index e2e457afb51a384d4089814e5a07052ab8f01b86..703bde3047f33d89cb8f34bbe250d096de9bec70 100644 --- a/libcef/browser/net_service/incognito_cookie_manager_ohos_impl.h +++ b/libcef/browser/net_service/incognito_cookie_manager_ohos_impl.h @@ -55,12 +55,14 @@ class CefIncognitoCookieManagerImpl : public CefCookieManager { bool VisitUrlCookies(const CefString& url, bool includeHttpOnly, CefRefPtr visitor, - bool is_sync) override; + bool is_sync, + bool is_from_ndk = false) override; bool SetCookie(const CefString& url, const CefCookie& cookie, CefRefPtr callback, bool is_sync, - const CefString& str_cookie) override; + const CefString& str_cookie, + bool includeHttpOnly) override; bool DeleteCookies(const CefString& url, const CefString& cookie_name, bool is_session, @@ -121,12 +123,14 @@ class CefIncognitoCookieManagerImpl : public CefCookieManager { bool VisitUrlCookiesInternal(const GURL& url, bool includeHttpOnly, CefRefPtr visitor, - bool is_sync); + bool is_sync, + bool is_from_ndk); bool SetCookieInternal(const GURL& url, const CefCookie& cookie, CefRefPtr callback, bool is_sync, - const CefString& str_cookie); + const CefString& str_cookie, + bool includeHttpOnly); bool DeleteCookiesInternal(const GURL& url, const CefString& cookie_name, bool is_session, diff --git a/libcef/browser/net_service/login_delegate.cc b/libcef/browser/net_service/login_delegate.cc index e57316f0c7914f7dc3647ee56a9f0cb32a4586c3..0a638bd05dcd980886c5cc05cbdc50122b7a04c3 100644 --- a/libcef/browser/net_service/login_delegate.cc +++ b/libcef/browser/net_service/login_delegate.cc @@ -19,6 +19,7 @@ #if BUILDFLAG(IS_OHOS) #include "libcef/browser/net_database/cef_data_base_impl.h" +#include "third_party/bounds_checking_function/include/securec.h" #endif namespace net_service { @@ -97,11 +98,15 @@ class AuthCallbackImpl : public CefAuthCallback { dataBase->GetHttpAuthCredentials(host_, realm_, username, password, MAX_PWD_LENGTH + 1); if (username.empty() || strlen(password) == 0) { - memset(password, 0, MAX_PWD_LENGTH + 1); + if (memset_s(password, MAX_PWD_LENGTH + 1, 0, MAX_PWD_LENGTH + 1) != EOK) { + return false; + } return false; } CefString passwordCef(password, strlen(password)); - memset(password, 0, MAX_PWD_LENGTH + 1); + if (memset_s(password, MAX_PWD_LENGTH + 1, 0, MAX_PWD_LENGTH + 1) != EOK) { + return false; + } if (!task_runner_->RunsTasksInCurrentSequence()) { task_runner_->PostTask( FROM_HERE, base::BindOnce(&AuthCallbackImpl::Continue, this, username, diff --git a/libcef/browser/net_service/proxy_url_loader_factory.cc b/libcef/browser/net_service/proxy_url_loader_factory.cc index 84faea6f09f1d1479b51431e978f7acdddd8d2e0..528e75e07c7e0112a61bbe7c60df0c7d0eae776c 100644 --- a/libcef/browser/net_service/proxy_url_loader_factory.cc +++ b/libcef/browser/net_service/proxy_url_loader_factory.cc @@ -36,6 +36,10 @@ #include "libcef/browser/res_reporter.h" #include "libcef/common/request_impl.h" #include "net/base/load_flags.h" +#if defined(OHOS_EX_DOWNLOAD) +#include "content/public/browser/download_utils.h" +#include "third_party/blink/public/common/mime_util/mime_util.h" +#endif #endif namespace net_service { @@ -407,6 +411,10 @@ class InterceptedRequest : public network::mojom::URLLoader, StreamReaderURLLoader* stream_loader_ = nullptr; +#if defined(OHOS_EX_DOWNLOAD) + bool is_download_{ false }; +#endif + base::WeakPtrFactory weak_factory_; }; @@ -444,8 +452,8 @@ class InterceptDelegate : public StreamReaderURLLoader::Delegate { return response_->GetResponseData(); } - size_t GetResponseDataBuffer(char* data) override { - return response_->GetResponseDataBuffer(data); + size_t GetResponseDataBuffer(char* data, size_t dest_size) override { + return response_->GetResponseDataBuffer(data, dest_size); } size_t GetResponseDataBufferSize() override { @@ -517,8 +525,17 @@ void InterceptedRequest::Restart() { } } +#if BUILDFLAG(IS_OHOS) + if (request_.method == "OPTIONS") { + current_request_uses_header_client_ = false; + } else { + current_request_uses_header_client_ = + factory_->url_loader_header_client_receiver_.is_bound(); + } +#else current_request_uses_header_client_ = factory_->url_loader_header_client_receiver_.is_bound(); +#endif if (request_.request_initiator && network::cors::ShouldCheckCors(request_.url, request_.request_initiator, @@ -664,6 +681,17 @@ void InterceptedRequest::OnReceiveResponse( current_body_ = std::move(body); current_cached_metadata_ = std::move(cached_metadata); +#if defined(OHOS_EX_DOWNLOAD) + bool must_download = + content::download_utils::MustDownload( + request_.url, current_response_->headers.get(), current_response_->mime_type); + bool known_mime_type = + blink::IsSupportedMimeType(current_response_->mime_type); + is_download_ = + !current_response_->intercepted_by_plugin && + (must_download || !known_mime_type); +#endif + #if BUILDFLAG(IS_OHOS) if (current_response_->headers && current_response_->headers->response_code() >= 400) { @@ -971,6 +999,27 @@ void InterceptedRequest::ContinueAfterInterceptWithOverride( std::unique_ptr response) { // StreamReaderURLLoader will synthesize TrustedHeaderClient callbacks to // avoid having Set-Cookie headers stripped by the IPC layer. +#if BUILDFLAG(IS_OHOS) + if (request_.method == "OPTIONS") { + current_request_uses_header_client_ = false; + + stream_loader_ = new StreamReaderURLLoader( + id_, request_, proxied_client_receiver_.BindNewPipeAndPassRemote(), + mojo::NullRemote(), traffic_annotation_, + std::move(current_cached_metadata_), + std::make_unique(std::move(response), + weak_factory_.GetWeakPtr())); + } else { + current_request_uses_header_client_ = true; + + stream_loader_ = new StreamReaderURLLoader( + id_, request_, proxied_client_receiver_.BindNewPipeAndPassRemote(), + header_client_receiver_.BindNewPipeAndPassRemote(), traffic_annotation_, + std::move(current_cached_metadata_), + std::make_unique(std::move(response), + weak_factory_.GetWeakPtr())); + } +#else current_request_uses_header_client_ = true; stream_loader_ = new StreamReaderURLLoader( @@ -979,6 +1028,7 @@ void InterceptedRequest::ContinueAfterInterceptWithOverride( std::move(current_cached_metadata_), std::make_unique(std::move(response), weak_factory_.GetWeakPtr())); +#endif stream_loader_->Start(); } @@ -1242,17 +1292,8 @@ void InterceptedRequest::OnDestroy() { factory_->request_handler_->OnRequestComplete(id_, request_, status_); -#ifdef OHOS_NETWORK_LOAD - if (request_.method == "OPTIONS") { - delete this; - } else { - // Destroys |this|. - factory_->RemoveRequest(this); - } -#else // Destroys |this|. factory_->RemoveRequest(this); -#endif } void InterceptedRequest::OnProcessRequestHeaders( @@ -1328,12 +1369,14 @@ void InterceptedRequest::CallOnComplete( #if defined(OHOS_EX_DOWNLOAD) void InterceptedRequest::CancelRequest(int error_code) { - // network::URLLoaderCompletionStatus status(error_code); - // status.abort_due_to_cef_browser_destroyed = true; - // SendErrorStatusAndCompleteImmediately(status); // Donn't cancel network requests. Network requests should be canceled by the holder // instead of following the tab, such as serviceworker download, etc. Although the // tab is destroyed, the request still needs to be maintained. + if (!is_download_) { + network::URLLoaderCompletionStatus status(error_code); + status.abort_due_to_cef_browser_destroyed = true; + SendErrorStatusAndCompleteImmediately(status); + } } #endif // OHOS_EX_DOWNLOAD @@ -1648,14 +1691,7 @@ void ProxyURLLoaderFactory::CreateLoaderAndStart( InterceptedRequest* req = new InterceptedRequest( this, request_id, options, request, traffic_annotation, std::move(receiver), std::move(client), std::move(target_factory_clone)); -#ifdef OHOS_NETWORK_LOAD - // Donn't track options request, because the request id for options always 0. - if (request.method != "OPTIONS") { - requests_.insert(std::make_pair(request_id, base::WrapUnique(req))); - } -#else requests_.insert(std::make_pair(request_id, base::WrapUnique(req))); -#endif #if BUILDFLAG(IS_OHOS) req->Restart(false); #else diff --git a/libcef/browser/net_service/resource_handler_wrapper.cc b/libcef/browser/net_service/resource_handler_wrapper.cc index ba159e80caaf1428fb44e3604e9bd0232a466448..f5ec7030332ca2d08503014e11da9fe9f1eab9a7 100644 --- a/libcef/browser/net_service/resource_handler_wrapper.cc +++ b/libcef/browser/net_service/resource_handler_wrapper.cc @@ -515,12 +515,12 @@ class ResourceResponseWrapper : public ResourceResponse { return handler->GetResponseData(); } - size_t GetResponseDataBuffer(char* data) override { + size_t GetResponseDataBuffer(char* data, size_t dest_size) override { auto handler = handler_provider_->handler(); if (!handler) { return 0; } - return handler->GetResponseDataBuffer(data); + return handler->GetResponseDataBuffer(data, dest_size); } size_t GetResponseDataBufferSize() override { diff --git a/libcef/browser/net_service/resource_request_handler_wrapper.cc b/libcef/browser/net_service/resource_request_handler_wrapper.cc index 193ae1e701bdcd3a7ce6c698a6ce3a9aee481826..c3fc799e23ed5f8f3e0b734897baf3ee57a298eb 100644 --- a/libcef/browser/net_service/resource_request_handler_wrapper.cc +++ b/libcef/browser/net_service/resource_request_handler_wrapper.cc @@ -103,6 +103,47 @@ class RequestCallbackWrapper : public CefCallback { IMPLEMENT_REFCOUNTING(RequestCallbackWrapper); }; +#ifdef OHOS_NETWORK_LOAD +class OhosInterceptCallbackWrapper : public CefInterceptCallback { + public: + using ResourceCallback = base::OnceCallback)>; + explicit OhosInterceptCallbackWrapper(ResourceCallback callback) + : callback_(std::move(callback)), + work_thread_task_runner_( + base::SequencedTaskRunner::GetCurrentDefault()) {} + + OhosInterceptCallbackWrapper(const OhosInterceptCallbackWrapper&) = delete; + OhosInterceptCallbackWrapper& operator=(const OhosInterceptCallbackWrapper&) = delete; + + ~OhosInterceptCallbackWrapper() override { + if (!callback_.is_null()) { + // Make sure it executes on the correct thread. + work_thread_task_runner_->PostTask( + FROM_HERE, base::BindOnce(std::move(callback_), nullptr)); + } + } + + void ContinueLoad(CefRefPtr resource_handler) override { + if (!work_thread_task_runner_->RunsTasksInCurrentSequence()) { + work_thread_task_runner_->PostTask( + FROM_HERE, + base::BindOnce(&OhosInterceptCallbackWrapper::ContinueLoad, this, resource_handler)); + return; + } + if (!callback_.is_null()) { + std::move(callback_).Run(resource_handler); + } + } + + private: + ResourceCallback callback_; + + scoped_refptr work_thread_task_runner_; + + IMPLEMENT_REFCOUNTING(OhosInterceptCallbackWrapper); +}; +#endif + #if OHOS_NETWORK_LOAD void OnRequestErrorInUiTask(CefRefPtr browser, CefRefPtr frame, @@ -147,7 +188,7 @@ void ReportITPResultInUiTask(CefRefPtr browser, return; } CefRefPtr load_handler = client->GetLoadHandler(); - if (load_handler) { + if (!load_handler) { LOG(ERROR) << "ReportITPResultInUiTask for load_handler is nullptr"; return; } @@ -677,9 +718,6 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler { CEF_REQUIRE_IOT(); if (!cookie_helper::IsCookieableScheme(request->url, init_state_->cookieable_schemes_) -#if BUILDFLAG(IS_OHOS) - || !net_service::NetHelpers::IsThirdPartyCookieAllowed() -#endif ) { // The scheme does not support cookies. std::move(callback).Run(); @@ -911,48 +949,81 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler { // The request will be handled by the NetworkService. Remove the // "Accept-Language" header here so that it can be re-added in // URLRequestHttpJob::AddExtraHeaders with correct ordering applied. +#if defined(OHOS_SCHEME_HANDLER) + // Get the chunked data pipe remote back. + if (state->pending_request_) { + CefRefPtr post_data_stream = state->pending_request_->GetUploadStream(); + if (post_data_stream && post_data_stream->IsChunked()) { + LOG(INFO) << "scheme_handler get the chunked stream back."; + static_cast(post_data_stream.get()) + ->GetChunkedDataPipeGetter(request->request_body.get()); + } + } +#endif } // Continue the request. std::move(callback).Run(std::move(resource_response)); } - void GetOhosResourceHandlerInUiTask( + void GetOhosResourceHandlerResultInIO(int32_t request_id, + network::ResourceRequest* request, + ShouldInterceptRequestResultCallback callback, + CefRefPtr resource_handler) { + CEF_REQUIRE_IOT(); + GetOhosResourceHandlerResult(request_id, request, resource_handler, std::move(callback)); + } + + void GetOhosResourceHandlerStillInIO( int32_t request_id, network::ResourceRequest* request, ShouldInterceptRequestResultCallback callback) { - CEF_REQUIRE_UIT(); + CEF_REQUIRE_IOT(); RequestState* state = GetState(request_id); - if (!state) { + if (!state || !request) { std::move(callback).Run(nullptr); return; } - CefRefPtr resource_handler; - + CefRefPtr callback_ptr = + new OhosInterceptCallbackWrapper(base::BindOnce( + &InterceptedRequestHandlerWrapper::GetOhosResourceHandlerResultInIO, + weak_ptr_factory_.GetWeakPtr(), + request_id, base::Unretained(request), std::move(callback))); + if (state->handler_) { // Does the client want to handle the request? if (request) { state->pending_request_->SetDestination(request->destination); } - resource_handler = state->handler_->GetResourceHandler( + state->handler_->GetResourceHandlerByIO( init_state_->browser_, init_state_->frame_, - state->pending_request_.get()); + state->pending_request_.get(), callback_ptr, state->scheme_factory_, + request->url.scheme()); + } else { + GetOhosResourceHandlerFromETS(state->scheme_factory_, state->pending_request_.get(), + request->url.scheme(), callback_ptr); } + } - // Try to get scheme handler from ets UI thread. - if (!resource_handler && state->scheme_factory_) { - // Does the scheme factory want to handle the request? - resource_handler = state->scheme_factory_->Create( - init_state_->browser_, init_state_->frame_, request->url.scheme(), - state->pending_request_.get()); + void GetOhosResourceHandlerFromETS(CefRefPtr scheme_factory, + CefRefPtr request, + const CefString& scheme, + CefRefPtr callback) { + if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, + base::BindOnce(&InterceptedRequestHandlerWrapper::GetOhosResourceHandlerFromETS, + weak_ptr_factory_.GetWeakPtr(), + scheme_factory, request, scheme, callback)); + return; } - CEF_POST_TASK( - CEF_IOT, - base::BindOnce( - &InterceptedRequestHandlerWrapper::GetOhosResourceHandlerResult, - weak_ptr_factory_.GetWeakPtr(), request_id, request, - resource_handler, std::move(callback))); + CefRefPtr resource_handler = nullptr; + if (scheme_factory) { + // Does the scheme factory want to handle the request? + resource_handler = scheme_factory->Create( + init_state_->browser_, init_state_->frame_, scheme, request); + } + callback->ContinueLoad(resource_handler); } void GetOhosResourceHandler(int32_t request_id, @@ -977,9 +1048,13 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler { } state->pending_request_->SetFrameUrl(frame_url); } + bool has_user_activation = false; + if (request->trusted_params) { + has_user_activation = request->trusted_params->has_user_activation; + } std::map headers = network::GetFetchMetadataHeaders( - request->url, request->mode, request->has_user_gesture, + request->url, request->mode, has_user_activation, request->destination, request->request_initiator); for (auto& entry : headers) { state->pending_request_->SetHeaderByName(entry.first, entry.second, false); @@ -987,12 +1062,7 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler { state->pending_request_->SetReadOnly(old_flag); } #endif - CEF_POST_TASK( - CEF_UIT, - base::BindOnce( - &InterceptedRequestHandlerWrapper::GetOhosResourceHandlerInUiTask, - weak_ptr_factory_.GetWeakPtr(), request_id, request, - std::move(callback))); + GetOhosResourceHandlerStillInIO(request_id, request, std::move(callback)); } #endif @@ -1210,8 +1280,8 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler { std::move(exec_callback).Run(); return; } - // Clear the headers first. we will get cookie for this redirect. - request->headers.Clear(); + // Clear the cookie first. we will get cookie for this redirect. + request->headers.RemoveHeader(net::HttpRequestHeaders::kCookie); // Get cookies for redirect url. request->url = new_url; MaybeLoadCookies(request_id, state, request, std::move(exec_callback)); @@ -1283,9 +1353,6 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler { if (!cookie_helper::IsCookieableScheme(request->url, init_state_->cookieable_schemes_) -#if BUILDFLAG(IS_OHOS) - || !net_service::NetHelpers::IsThirdPartyCookieAllowed() -#endif ) { // The scheme does not support cookies. std::move(callback).Run(); @@ -1665,12 +1732,12 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler { void ReportITPResult(const network::ResourceRequest& request) { CEF_REQUIRE_IOT(); - LOG(DEBUG) << "ReportITPResult, url: " << request.url.spec(); if (!init_state_ || !request.request_initiator || !request.url.has_host()) { LOG(ERROR) << "ReportITPResult failed for param error"; return; } + LOG(DEBUG) << "ReportITPResult"; CEF_POST_TASK( CEF_UIT, base::BindOnce(&ReportITPResultInUiTask, init_state_->browser_, CefString(request.url.host()), diff --git a/libcef/browser/net_service/stream_reader_url_loader.cc b/libcef/browser/net_service/stream_reader_url_loader.cc index 6f3e00046f8e4c28f2be30d98a936e23321b05c4..91db2d4a6da13bfea38406766c063062482272d3 100644 --- a/libcef/browser/net_service/stream_reader_url_loader.cc +++ b/libcef/browser/net_service/stream_reader_url_loader.cc @@ -19,21 +19,21 @@ #include "base/task/thread_pool.h" #include "base/threading/thread.h" #include "content/public/browser/browser_thread.h" -// #if defined(OHOS_API_PER) #include "net/base/features.h" -// #endif #include "net/base/io_buffer.h" #include "net/http/http_status_code.h" #include "net/http/http_util.h" -// #if defined(OHOS_API_PER) #include "services/network/public/cpp/features.h" -// #endif #include "services/network/public/cpp/url_loader_completion_status.h" namespace net_service { namespace { +#if defined(OHOS_NETWORK_LOAD) +constexpr int32_t NET_STATUS_CODE_400 = 400; +#endif + using OnInputStreamOpenedCallback = base::OnceCallback, std::unique_ptr)>; @@ -687,7 +687,7 @@ void StreamReaderURLLoader::HeadersComplete(int orig_status_code, status_code, status_text, mime_type, charset, content_length, extra_headers, false /* allow_existing_header_override */); #if defined(OHOS_NETWORK_LOAD) - if (status_code >= 400) { + if (status_code >= NET_STATUS_CODE_400) { if (!mime_type.empty()) { headers->SetHeader(net::HttpRequestHeaders::kContentType, mime_type); } @@ -746,10 +746,15 @@ bool StreamReaderURLLoader::TryTransferDataWithSharedMemory() { char* memory = shared_memory_mapping.GetMemoryAs(); - size_t size = response_delegate_->GetResponseDataBuffer(memory); + size_t size = response_delegate_->GetResponseDataBuffer(memory, bufferSize); LOG(DEBUG) << "shared-memory+++ GetResponseDataBuffer buffer size=" << size; + if (size <= 0) { + LOG(ERROR) << "shared-memory GetResponseDataBuffer size <= 0"; + return false; + } - base::ReadOnlySharedMemoryRegion read_only_region = base::WritableSharedMemoryRegion::ConvertToReadOnly(std::move(writable_region)); + base::ReadOnlySharedMemoryRegion read_only_region = + base::WritableSharedMemoryRegion::ConvertToReadOnly(std::move(writable_region)); if (!read_only_region.IsValid()) { LOG(ERROR) << "shared-memory: convert to read only err"; return false; diff --git a/libcef/browser/net_service/stream_reader_url_loader.h b/libcef/browser/net_service/stream_reader_url_loader.h index 53b1196f3b80007b4c4e4357035a501aa4a878b5..0aeaef13bb358247f77845e32ae94cc23f15f3fd 100644 --- a/libcef/browser/net_service/stream_reader_url_loader.h +++ b/libcef/browser/net_service/stream_reader_url_loader.h @@ -99,7 +99,7 @@ class ResourceResponse { #if BUILDFLAG(IS_OHOS) virtual const std::string& GetResponseData() = 0; - virtual size_t GetResponseDataBuffer(char* data) = 0; + virtual size_t GetResponseDataBuffer(char* data, size_t dest_size) = 0; virtual size_t GetResponseDataBufferSize() = 0; #endif }; diff --git a/libcef/browser/ohos_safe_browsing/ohos_sb_block_page.cc b/libcef/browser/ohos_safe_browsing/ohos_sb_block_page.cc index 3a4edd79e2eea6d0d5d9b7055773da2df660b62d..f9b80673186278ba077932fed86aa8ddfc0b14ec 100644 --- a/libcef/browser/ohos_safe_browsing/ohos_sb_block_page.cc +++ b/libcef/browser/ohos_safe_browsing/ohos_sb_block_page.cc @@ -19,7 +19,7 @@ #include "base/strings/string_number_conversions.h" #include "base/values.h" #include "components/grit/components_resources.h" -#include "components/strings/grit/components_strings.h" +#include "ohos_resources/components/string/grit/ohos_components_strings.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/webui/jstemplate_builder.h" diff --git a/libcef/browser/osr/browser_platform_delegate_osr.cc b/libcef/browser/osr/browser_platform_delegate_osr.cc index 5edaa57132459846c9aef65595e214d6173fd5f3..851d4ccd6912a9f031c06e2a888044c38ec7772d 100644 --- a/libcef/browser/osr/browser_platform_delegate_osr.cc +++ b/libcef/browser/osr/browser_platform_delegate_osr.cc @@ -116,12 +116,20 @@ void CefBrowserPlatformDelegateOsr::RenderViewCreated( if (view_osr_) { view_osr_->RenderViewCreated(); } - +#if BUILDFLAG(IS_OHOS) + CefRenderWidgetHostViewOSR* view = GetOSRHostView(); #ifdef OHOS_DISPLAY_CUTOUT - if (CefRenderWidgetHostViewOSR* view = GetOSRHostView()) { + if (view) { view->OnSafeInsetsChange(safe_insets_); } #endif +#ifdef OHOS_FOCUS + if (is_view_focus_failed_ && view) { + view->SetFocus(focus_status_); + is_view_focus_failed_ = false; + } +#endif +#endif } void CefBrowserPlatformDelegateOsr::BrowserCreated( @@ -283,6 +291,7 @@ void CefBrowserPlatformDelegateOsr::SendTouchEvent(const CefTouchEvent& event) { shrink_viewport_height_ = 0; } #endif + view->SetNativeEmbedMode(native_embed_mode_); view->SendTouchEvent(event_adjust); if (event.type == CEF_TET_PRESSED) { @@ -295,9 +304,20 @@ void CefBrowserPlatformDelegateOsr::SendTouchEvent(const CefTouchEvent& event) { void CefBrowserPlatformDelegateOsr::SetFocus(bool setFocus) { CefRenderWidgetHostViewOSR* view = GetOSRHostView(); +#ifdef OHOS_FOCUS + focus_status_ = setFocus; + if (view) { + view->SetFocus(setFocus); + is_view_focus_failed_ = false; + } else { + LOG(DEBUG) << "CefBrowserPlatformDelegateOsr::SetFocus failed."; + is_view_focus_failed_ = true; + } +#else if (view) { view->SetFocus(setFocus); } +#endif } gfx::Point CefBrowserPlatformDelegateOsr::GetScreenPoint( @@ -444,6 +464,9 @@ void CefBrowserPlatformDelegateOsr::NotifyForNextTouchEvent() { return; view->NotifyForNextTouchEvent(); } +void CefBrowserPlatformDelegateOsr::SetNativeEmbedMode(bool flag) { + native_embed_mode_ = flag; +} #endif void CefBrowserPlatformDelegateOsr::NotifyScreenInfoChanged() { @@ -1096,6 +1119,13 @@ void CefBrowserPlatformDelegateOsr::OnNativeEmbedLifecycleChange( view->OnNativeEmbedLifecycleChange(info); } +void CefBrowserPlatformDelegateOsr::OnNativeEmbedVisibilityChange( + const std::string& embed_id, bool visibility){ + CefRenderWidgetHostViewOSR* view = GetOSRHostView(); + if (view) + view->OnNativeEmbedVisibilityChange(embed_id, visibility); +} + void CefBrowserPlatformDelegateOsr::SetScrollable(bool enable) { CefRenderWidgetHostViewOSR* view = GetOSRHostView(); if (view) diff --git a/libcef/browser/osr/browser_platform_delegate_osr.h b/libcef/browser/osr/browser_platform_delegate_osr.h index 7c14033c0184e785eec640bfad49533a8bfb3dbf..83f4fa8cf52e91c717131dbca8d01a7689fd2e1a 100644 --- a/libcef/browser/osr/browser_platform_delegate_osr.h +++ b/libcef/browser/osr/browser_platform_delegate_osr.h @@ -72,6 +72,7 @@ class CefBrowserPlatformDelegateOsr void WasOccluded(bool occluded) override; void SendTouchEventList(const std::vector& event_list) override; void NotifyForNextTouchEvent() override; + void SetNativeEmbedMode(bool flag) override; #endif #if defined(OHOS_INPUT_EVENTS) void ScrollFocusedEditableNodeIntoView() override; @@ -143,6 +144,7 @@ class CefBrowserPlatformDelegateOsr void SetVirtualKeyBoardArg(int32_t width, int32_t height, double keyboard) override; bool ShouldVirtualKeyboardOverlay() override; void OnNativeEmbedLifecycleChange(const CefRenderHandler::CefNativeEmbedData& info) override; + void OnNativeEmbedVisibilityChange(const std::string& embed_id, bool visibility) override; void SetScrollable(bool enable) override; void AdvanceFocusForIME(int focusType) override; #endif @@ -230,10 +232,17 @@ bool WebPageSnapshot(const char* id, int shrink_viewport_height_ = 0; #endif +#ifdef OHOS_FOCUS + // We keep track of the view's focus-capturing logic, and if the view hasn't been created yet, + // we temporarily store the focus-capturing event until RenderViewCreated is created and then re-focus-capturing. + bool is_view_focus_failed_ = false; + bool focus_status_ = false; +#endif + #ifdef OHOS_DISPLAY_CUTOUT gfx::Insets safe_insets_; #endif - + bool native_embed_mode_ = false; // We keep track of the RenderWidgetHost from which the current drag started, // in order to properly route the drag end message to it. base::WeakPtr drag_start_rwh_; diff --git a/libcef/browser/osr/browser_platform_delegate_osr_unittest.cc b/libcef/browser/osr/browser_platform_delegate_osr_unittest.cc new file mode 100644 index 0000000000000000000000000000000000000000..cc01b7985c605f58f6512266618c7338ac273a7e --- /dev/null +++ b/libcef/browser/osr/browser_platform_delegate_osr_unittest.cc @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define protected public +#include "cef/libcef/browser/osr/browser_platform_delegate_osr.h" +#include "gtest/gtest.h" + +namespace { +std::shared_ptr g_platform_delegate; +} + +class CefBrowserPlatformDelegateNativeMock + : public CefBrowserPlatformDelegateNative { + public: + content::NativeWebKeyboardEvent TranslateWebKeyEvent( + const CefKeyEvent& key_event) const override; + blink::WebMouseEvent TranslateWebClickEvent( + const CefMouseEvent& mouse_event, + CefBrowserHost::MouseButtonType type, + bool mouseUp, + int clickCount) const override; + blink::WebMouseEvent TranslateWebMoveEvent(const CefMouseEvent& mouse_event, + bool mouseLeave) const override; + blink::WebMouseWheelEvent TranslateWebWheelEvent( + const CefMouseEvent& mouse_event, + int deltaX, + int deltaY) const override; + blink::WebGestureEvent TranslateTouchpadFlingEvent( + const CefMouseEvent& mouse_event) const override; + CefBrowserPlatformDelegateNativeMock(const CefWindowInfo& window_info, + SkColor background_color) + : CefBrowserPlatformDelegateNative(window_info, background_color) {} + CefBrowserPlatformDelegateNativeMock() = delete; + ~CefBrowserPlatformDelegateNativeMock() {} +}; + +content::NativeWebKeyboardEvent +CefBrowserPlatformDelegateNativeMock::TranslateWebKeyEvent( + const CefKeyEvent& key_event) const { + gfx::NativeEvent native_event = nullptr; + content::NativeWebKeyboardEvent nativewebkeyboard(native_event); + return nativewebkeyboard; +} + +blink::WebMouseEvent +CefBrowserPlatformDelegateNativeMock::TranslateWebClickEvent( + const CefMouseEvent& mouse_event, + CefBrowserHost::MouseButtonType type, + bool mouseUp, + int clickCount) const { + return blink::WebMouseEvent(); +} + +blink::WebMouseEvent +CefBrowserPlatformDelegateNativeMock::TranslateWebMoveEvent( + const CefMouseEvent& mouse_event, + bool mouseLeave) const { + return blink::WebMouseEvent(); +} + +blink::WebMouseWheelEvent +CefBrowserPlatformDelegateNativeMock::TranslateWebWheelEvent( + const CefMouseEvent& mouse_event, + int deltaX, + int deltaY) const { + return blink::WebMouseWheelEvent(); +} + +blink::WebGestureEvent +CefBrowserPlatformDelegateNativeMock::TranslateTouchpadFlingEvent( + const CefMouseEvent& mouse_event) const { + return blink::WebGestureEvent(); +} + +class CefBrowserPlatformDelegateOsrTest : public testing::Test { + public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; +void CefBrowserPlatformDelegateOsrTest::SetUpTestCase(void) {} + +void CefBrowserPlatformDelegateOsrTest::TearDownTestCase(void) {} + +void CefBrowserPlatformDelegateOsrTest::SetUp(void) { + CefWindowInfo window_info; + auto native_delegate = + std::make_unique(window_info, 0); + g_platform_delegate = std::make_shared( + std::move(native_delegate), true, true); +} + +void CefBrowserPlatformDelegateOsrTest::TearDown(void) { + g_platform_delegate = nullptr; +} + +#if defined(OHOS_INPUT_EVENTS) +TEST_F(CefBrowserPlatformDelegateOsrTest, OnNativeEmbedLifecycleChange) { + ASSERT_NE(g_platform_delegate, nullptr); + CefRenderHandler::CefNativeEmbedData data_info; + data_info.status = CREATE; + data_info.surfaceId = ""; + data_info.embedId = ""; + data_info.info.id = ""; + data_info.info.x = 0; + data_info.info.y = 0; + data_info.info.width = 0; + data_info.info.height = 0; + data_info.info.type = ""; + data_info.info.src = ""; + data_info.info.url = ""; + data_info.info.tag = ""; + data_info.info.params = {{"key1", "value1"}, {"key2", "value2"}}; + g_platform_delegate->OnNativeEmbedLifecycleChange(data_info); +} +#endif + +#if defined(OHOS_COMPOSITE_RENDER) +TEST_F(CefBrowserPlatformDelegateOsrTest, SetDrawRect) { + ASSERT_NE(g_platform_delegate, nullptr); + int x = 0; + int y = 0; + int width = 0; + int height = 0; + g_platform_delegate->SetDrawRect(x, y, width, height); +} +#endif + +#if defined(OHOS_SOFTWARE_COMPOSITOR) +TEST_F(CefBrowserPlatformDelegateOsrTest, WebPageSnapshot) { + ASSERT_NE(g_platform_delegate, nullptr); + const char* id = "test_id"; + int width = 1024; + int height = 768; + g_platform_delegate->WebPageSnapshot( + id, width, height, + base::BindOnce([](const char* str, bool is, void* ptr, int a, int b) {})); +} +#endif + +TEST_F(CefBrowserPlatformDelegateOsrTest, SendKeyEvent) { + ASSERT_NE(g_platform_delegate, nullptr); + CefKeyEvent event; + g_platform_delegate->SendKeyEvent(event); +} + +#if defined(OHOS_INPUT_EVENTS) +TEST_F(CefBrowserPlatformDelegateOsrTest, ScrollFocusedEditableNodeIntoView) { + ASSERT_NE(g_platform_delegate, nullptr); + g_platform_delegate->ScrollFocusedEditableNodeIntoView(); +} + +TEST_F(CefBrowserPlatformDelegateOsrTest, SetVirtualKeyBoardArg) { + ASSERT_NE(g_platform_delegate, nullptr); + int32_t width = 1; + int32_t height = 2; + double keyboard = 10; + g_platform_delegate->SetVirtualKeyBoardArg(width, height, keyboard); +} +#endif \ No newline at end of file diff --git a/libcef/browser/osr/motion_event_osr_unittest.cc b/libcef/browser/osr/motion_event_osr_unittest.cc new file mode 100644 index 0000000000000000000000000000000000000000..f1fea79f1496165b9a66fadf922bb29d5ac9d72b --- /dev/null +++ b/libcef/browser/osr/motion_event_osr_unittest.cc @@ -0,0 +1,32 @@ +// Copyright (c) 2024 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 "motion_event_osr.h" +#include +#include "cef/include/internal/cef_types.h" +#include "cef/include/internal/cef_types_wrappers.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace cef { +class MockCefMotionEventOSR : public CefMotionEventOSR {}; + +class CefMotionEventOSRTest : public ::testing::Test { + public: + MockCefMotionEventOSR motionEventOSR; +}; + +TEST_F(CefMotionEventOSRTest, TestOnTouch) { + CefTouchEvent touchEvent; + touchEvent.id = 1; + touchEvent.type = CEF_TET_MOVED; + touchEvent.x = 100; + touchEvent.y = 200; + touchEvent.modifiers = 0; + + bool result = motionEventOSR.OnTouch(touchEvent); + + EXPECT_FALSE(result); +} +} // namespace cef diff --git a/libcef/browser/osr/render_widget_host_view_osr.cc b/libcef/browser/osr/render_widget_host_view_osr.cc index 4a6b0c496c4cafa2f69ec843d3713cddda688bde..641ca61a6a0d9cbf309728de3f26ee22c7f47bad 100644 --- a/libcef/browser/osr/render_widget_host_view_osr.cc +++ b/libcef/browser/osr/render_widget_host_view_osr.cc @@ -353,6 +353,9 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR( if (parent_host_view_) { browser_impl_ = parent_host_view_->browser_impl(); DCHECK(browser_impl_); +#if BUILDFLAG(IS_OHOS) + is_popup_ = true; +#endif } else if (content::RenderViewHost::From(render_widget_host_)) { // AlloyBrowserHostImpl might not be created at this time for popups. browser_impl_ = AlloyBrowserHostImpl::GetBrowserForHost( @@ -394,18 +397,18 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR( #else #if BUILDFLAG(IS_OHOS) LOG(INFO) << "compositor construct, widget = " - << static_cast(browser_impl_->GetAcceleratedWidget()); + << static_cast(browser_impl_->GetAcceleratedWidget(is_popup_)); ui::Compositor* compositor = CefRenderWidgetHostViewOSR::GetCompositor( - browser_impl_->GetAcceleratedWidget()); - accelerate_widget_map_[browser_impl_->GetAcceleratedWidget()]++; + browser_impl_->GetAcceleratedWidget(is_popup_)); + accelerate_widget_map_[browser_impl_->GetAcceleratedWidget(is_popup_)]++; if (!compositor) { compositor = new ui::Compositor( context_factory->AllocateFrameSinkId(), context_factory, base::SingleThreadTaskRunner::GetCurrentDefault(), false /* enable_pixel_canvas */, use_external_begin_frame); - compositor->SetAcceleratedWidget(browser_impl_->GetAcceleratedWidget()); + compositor->SetAcceleratedWidget(browser_impl_->GetAcceleratedWidget(is_popup_)); CefRenderWidgetHostViewOSR::AddCompositor( - browser_impl_->GetAcceleratedWidget(), compositor); + browser_impl_->GetAcceleratedWidget(is_popup_), compositor); UpdateDrawMode(); } #endif // IS_OHOS @@ -473,7 +476,7 @@ void CefRenderWidgetHostViewOSR::ReleaseCompositor() { if (!browser_impl_) { return; } - auto it1 = accelerate_widget_map_.find(browser_impl_->GetAcceleratedWidget()); + auto it1 = accelerate_widget_map_.find(browser_impl_->GetAcceleratedWidget(is_popup_)); if (it1 == accelerate_widget_map_.end()) { return; } @@ -496,20 +499,20 @@ void CefRenderWidgetHostViewOSR::ReleaseCompositor() { #else #ifdef BUILDFLAG(IS_OHOS) LOG(INFO) << "ReleaseCompositor"; - auto com = compositor_map_.find(browser_impl_->GetAcceleratedWidget()); - if (--accelerate_widget_map_[browser_impl_->GetAcceleratedWidget()] == 0) { + auto com = compositor_map_.find(browser_impl_->GetAcceleratedWidget(is_popup_)); + if (--accelerate_widget_map_[browser_impl_->GetAcceleratedWidget(is_popup_)] == 0) { if (!browser_impl_) { return; } LOG(INFO) << "ReleaseCompositor, widget = " - << static_cast(browser_impl_->GetAcceleratedWidget()); + << static_cast(browser_impl_->GetAcceleratedWidget(is_popup_)); if (com != compositor_map_.end()) { if (com->second != nullptr) { delete com->second; } compositor_map_.erase(com); } - accelerate_widget_map_.erase(browser_impl_->GetAcceleratedWidget()); + accelerate_widget_map_.erase(browser_impl_->GetAcceleratedWidget(is_popup_)); } else { if (com != compositor_map_.end()) { if (com->second->delegate() == this) { @@ -602,7 +605,7 @@ void CefRenderWidgetHostViewOSR::ShowWithVisibility( #ifndef DISABLE_GPU auto compositor = CefRenderWidgetHostViewOSR::GetCompositor( - browser_impl_->GetAcceleratedWidget()); + browser_impl_->GetAcceleratedWidget(is_popup_)); compositor->SetDelegate(this); compositor->SetRootLayer(root_layer_.get()); #if !BUILDFLAG(IS_OHOS) @@ -720,9 +723,9 @@ void CefRenderWidgetHostViewOSR::WasOccluded() { } void CefRenderWidgetHostViewOSR::SetEnableLowerFrameRate(bool enabled) { - if (browser_impl_.get() && browser_impl_->GetAcceleratedWidget()) { + if (browser_impl_.get() && browser_impl_->GetAcceleratedWidget(is_popup_)) { ui::Compositor* compositor = CefRenderWidgetHostViewOSR::GetCompositor( - browser_impl_->GetAcceleratedWidget()); + browser_impl_->GetAcceleratedWidget(is_popup_)); if (compositor) { compositor->SetEnableLowerFrameRate(enabled); } @@ -730,9 +733,9 @@ void CefRenderWidgetHostViewOSR::SetEnableLowerFrameRate(bool enabled) { } void CefRenderWidgetHostViewOSR::UpdateVSyncFrequency() { - if (browser_impl_ && browser_impl_->GetAcceleratedWidget()) { + if (browser_impl_ && browser_impl_->GetAcceleratedWidget(is_popup_)) { ui::Compositor* compositor = CefRenderWidgetHostViewOSR::GetCompositor( - browser_impl_->GetAcceleratedWidget()); + browser_impl_->GetAcceleratedWidget(is_popup_)); if (compositor) { compositor->UpdateVSyncFrequency(); } @@ -740,9 +743,9 @@ void CefRenderWidgetHostViewOSR::UpdateVSyncFrequency() { } void CefRenderWidgetHostViewOSR::ResetVSyncFrequency() { - if (browser_impl_ && browser_impl_->GetAcceleratedWidget()) { + if (browser_impl_ && browser_impl_->GetAcceleratedWidget(is_popup_)) { ui::Compositor* compositor = CefRenderWidgetHostViewOSR::GetCompositor( - browser_impl_->GetAcceleratedWidget()); + browser_impl_->GetAcceleratedWidget(is_popup_)); if (compositor) { compositor->ResetVSyncFrequency(); } @@ -757,7 +760,7 @@ void CefRenderWidgetHostViewOSR::SendTouchEventList(const std::vectorGetAcceleratedWidget()); + browser_impl_->GetAcceleratedWidget(is_popup_)); if (compositor) { compositor->SetCurrentFrameSinkId(GetFrameSinkId()); } else { @@ -857,9 +860,9 @@ void CefRenderWidgetHostViewOSR::SendTouchGestureEvent(blink::WebTouchEvent& tou void CefRenderWidgetHostViewOSR::EvictFrameBackBuffers(bool invisible) { TRACE_EVENT1("base", "CefRenderWidgetHostViewOSR::EvictFrameBackBuffers", "invisible", invisible); - if (browser_impl_.get() && browser_impl_->GetAcceleratedWidget()) { + if (browser_impl_.get() && browser_impl_->GetAcceleratedWidget(is_popup_)) { ui::Compositor* compositor = CefRenderWidgetHostViewOSR::GetCompositor( - browser_impl_->GetAcceleratedWidget()); + browser_impl_->GetAcceleratedWidget(is_popup_)); if(compositor) { compositor->EvictFrameBackBuffers(invisible); } @@ -972,7 +975,7 @@ void CefRenderWidgetHostViewOSR::UpdateBackgroundColor() { } #else auto compositor = CefRenderWidgetHostViewOSR::GetCompositor( - browser_impl_->GetAcceleratedWidget()); + browser_impl_->GetAcceleratedWidget(is_popup_)); if (compositor) { compositor->SetBackgroundColor(background_color_); } @@ -1125,40 +1128,46 @@ void CefRenderWidgetHostViewOSR::InitAsPopup( content::RenderWidgetHostView* parent_host_view, const gfx::Rect& bounds, const gfx::Rect& anchor_rect) { - DCHECK_EQ(parent_host_view_, parent_host_view); - DCHECK(browser_impl_); + #if BUILDFLAG(IS_OHOS) + if (base::ohos::IsPcDevice()) { + #endif + DCHECK_EQ(parent_host_view_, parent_host_view); + DCHECK(browser_impl_); - if (parent_host_view_->popup_host_view_) { - // Cancel the previous popup widget. - parent_host_view_->popup_host_view_->CancelWidget(); - } + if (parent_host_view_->popup_host_view_) { + // Cancel the previous popup widget. + parent_host_view_->popup_host_view_->CancelWidget(); + } - parent_host_view_->set_popup_host_view(this); + parent_host_view_->set_popup_host_view(this); - CefRefPtr handler = - browser_impl_->GetClient()->GetRenderHandler(); - CHECK(handler); + CefRefPtr handler = + browser_impl_->GetClient()->GetRenderHandler(); + CHECK(handler); - handler->OnPopupShow(browser_impl_.get(), true); + handler->OnPopupShow(browser_impl_.get(), true); - CefRect view_rect; - handler->GetViewRect(browser_impl_.get(), view_rect); - gfx::Rect client_pos(bounds.x() - view_rect.x, bounds.y() - view_rect.y, - bounds.width(), bounds.height()); + CefRect view_rect; + handler->GetViewRect(browser_impl_.get(), view_rect); + gfx::Rect client_pos(bounds.x() - view_rect.x, bounds.y() - view_rect.y, + bounds.width(), bounds.height()); - popup_position_ = client_pos; + popup_position_ = client_pos; - CefRect widget_pos(client_pos.x(), client_pos.y(), client_pos.width(), - client_pos.height()); + CefRect widget_pos(client_pos.x(), client_pos.y(), client_pos.width(), + client_pos.height()); - if (handler.get()) { - handler->OnPopupSize(browser_impl_.get(), widget_pos); - } + if (handler.get()) { + handler->OnPopupSize(browser_impl_.get(), widget_pos); + } - // The size doesn't change for popups so we need to force the - // initialization. - SetRootLayerSize(true /* force */); - Show(); + // The size doesn't change for popups so we need to force the + // initialization. + SetRootLayerSize(true /* force */); + Show(); + #if BUILDFLAG(IS_OHOS) + } + #endif } void CefRenderWidgetHostViewOSR::UpdateCursor(const ui::Cursor& cursor) {} @@ -1322,7 +1331,7 @@ gfx::Rect CefRenderWidgetHostViewOSR::GetBoundsInRootWindow() { #if BUILDFLAG(IS_OHOS) void CefRenderWidgetHostViewOSR::SendInternalBeginFrame() { auto compositor = CefRenderWidgetHostViewOSR::GetCompositor( - browser_impl_->GetAcceleratedWidget()); + browser_impl_->GetAcceleratedWidget(is_popup_)); if (compositor) { compositor->SendInternalBeginFrame(); } @@ -1330,7 +1339,7 @@ void CefRenderWidgetHostViewOSR::SendInternalBeginFrame() { void CefRenderWidgetHostViewOSR::SetDrawRect(const gfx::Rect& rect) { if (auto compositor = CefRenderWidgetHostViewOSR::GetCompositor( - browser_impl_->GetAcceleratedWidget())) { + browser_impl_->GetAcceleratedWidget(is_popup_))) { compositor->SetDrawRect(rect); UpdateDrawRect(rect); } @@ -1347,7 +1356,7 @@ void CefRenderWidgetHostViewOSR::UpdateDrawRect(const gfx::Rect &rect) void CefRenderWidgetHostViewOSR::SetDrawMode(int mode) { if (auto compositor = CefRenderWidgetHostViewOSR::GetCompositor( - browser_impl_->GetAcceleratedWidget())) { + browser_impl_->GetAcceleratedWidget(is_popup_))) { compositor->SetDrawMode(mode); } } @@ -1359,7 +1368,7 @@ void CefRenderWidgetHostViewOSR::SetFitContentMode(int mode) { void CefRenderWidgetHostViewOSR::UpdateDrawMode() { int mode = browser_impl_->GetDrawMode(); if (auto compositor = CefRenderWidgetHostViewOSR::GetCompositor( - browser_impl_->GetAcceleratedWidget())) { + browser_impl_->GetAcceleratedWidget(is_popup_))) { compositor->SetDrawMode(mode); } } @@ -1529,7 +1538,7 @@ viz::FrameSinkId CefRenderWidgetHostViewOSR::GetRootFrameSinkId() { return compositor_ ? compositor_->frame_sink_id() : viz::FrameSinkId(); #else auto compositor = CefRenderWidgetHostViewOSR::GetCompositor( - browser_impl_->GetAcceleratedWidget()); + browser_impl_->GetAcceleratedWidget(is_popup_)); return compositor ? compositor->frame_sink_id() : viz::FrameSinkId(); #endif } @@ -1643,6 +1652,9 @@ bool CefRenderWidgetHostViewOSR::WebPageSnapshot( height = (std::abs(height) * pageSize.height()) / 100; } + pageSize.Scale(page_scale_factor_); + pageOffsize.Scale(page_scale_factor_); + software_compositor_->DemandDrawSwAsync(id, width, height, pageSize, pageOffsize, std::move(callback)); return true; @@ -1691,6 +1703,12 @@ void CefRenderWidgetHostViewOSR::MouseSelectMenuShow(bool show) { selection_controller_client_->MouseSelectMenuShow(show); } } + +void CefRenderWidgetHostViewOSR::ChangeVisibilityOfQuickMenu() { + if (selection_controller_client_) { + selection_controller_client_->ChangeVisibilityOfQuickMenu(); + } +} #endif void CefRenderWidgetHostViewOSR::OnRenderFrameMetadataChangedAfterActivation( @@ -1796,15 +1814,6 @@ void CefRenderWidgetHostViewOSR::OnRenderFrameMetadataChangedAfterActivation( metadata.selection.end != selection_end_) { selection_start_ = metadata.selection.start; selection_end_ = metadata.selection.end; -#ifdef OHOS_CLIPBOARD - // When all is selected, the right handle coordinates are in front of the left handle. - if (metadata.selection.start.edge_end().y() > metadata.selection.end.edge_end().y()) { - selection_end_.SetEdgeEnd(gfx::PointF(metadata.clipped_selection_bounds.x() + - metadata.clipped_selection_bounds.width(), - metadata.clipped_selection_bounds.y() + - metadata.clipped_selection_bounds.height())); - } -#endif selection_controller_client_->UpdateClientSelectionBounds(selection_start_, selection_end_); } @@ -1838,7 +1847,7 @@ bool CefRenderWidgetHostViewOSR::InstallTransparency() { } #else auto compositor = CefRenderWidgetHostViewOSR::GetCompositor( - browser_impl_->GetAcceleratedWidget()); + browser_impl_->GetAcceleratedWidget(is_popup_)); if (compositor) { compositor->SetBackgroundColor(background_color_); } @@ -1941,7 +1950,7 @@ void CefRenderWidgetHostViewOSR::SynchronizeVisualProperties( #if defined(OHOS_COMPOSITE_RENDER) if (resized && should_wait_) { if (auto compositor = CefRenderWidgetHostViewOSR::GetCompositor( - browser_impl_->GetAcceleratedWidget())) { + browser_impl_->GetAcceleratedWidget(is_popup_))) { compositor->SetShouldFrameSubmissionBeforeDraw(true); } } @@ -2053,7 +2062,7 @@ void CefRenderWidgetHostViewOSR::SendExternalBeginFrame() { compositor_->IssueExternalBeginFrame( #else auto compositor = CefRenderWidgetHostViewOSR::GetCompositor( - browser_impl_->GetAcceleratedWidget()); + browser_impl_->GetAcceleratedWidget(is_popup_)); if (compositor) { compositor->IssueExternalBeginFrame( #endif @@ -2117,11 +2126,15 @@ void CefRenderWidgetHostViewOSR::SendMouseEvent( event.button != blink::WebPointerProperties::Button::kRight) { browser_impl_->CancelContextMenu(); } - +#ifdef OHOS_CLIPBOARD + if (selection_controller_client_ && event.GetType() == blink::WebMouseEvent::Type::kMouseDown) { + selection_controller_client_->CloseQuickMenuAndHideHandles(); + } +#else if (selection_controller_client_) { selection_controller_client_->CloseQuickMenuAndHideHandles(); } - +#endif if (popup_host_view_) { if (popup_host_view_->popup_position_.Contains( event.PositionInWidget().x(), event.PositionInWidget().y())) { @@ -2202,11 +2215,11 @@ void CefRenderWidgetHostViewOSR::SendMouseWheelEvent( if (browser_impl_) { browser_impl_->CancelContextMenu(); } - +#ifndef OHOS_CLIPBOARD if (selection_controller_client_) { selection_controller_client_->CloseQuickMenuAndHideHandles(); } - +#endif if (popup_host_view_) { if (popup_host_view_->popup_position_.Contains( event.PositionInWidget().x(), event.PositionInWidget().y())) { @@ -2290,7 +2303,7 @@ void CefRenderWidgetHostViewOSR::SendTouchEvent(const CefTouchEvent& event) { if (event.type == CEF_TET_PRESSED) { is_editable_node_ = false; auto compositor = CefRenderWidgetHostViewOSR::GetCompositor( - browser_impl_->GetAcceleratedWidget()); + browser_impl_->GetAcceleratedWidget(is_popup_)); if (compositor) { compositor->SetCurrentFrameSinkId(GetFrameSinkId()); } else { @@ -2542,11 +2555,6 @@ void CefRenderWidgetHostViewOSR::OnUpdateTextInputStateCalled( } #if defined(OHOS_INPUT_EVENTS) - if (pointer_state_.GetAction() == ui::MotionEvent::Action::DOWN && - is_editable_node_) { - LOG(INFO) << "The keyboard status is not updated when pressed"; - return; - } CefRefPtr handler = browser_impl_->GetClient()->GetRenderHandler(); @@ -2732,6 +2740,9 @@ void CefRenderWidgetHostViewOSR::SendGestureEvent( selection_controller_->HandleLongPressEvent( web_event.TimeStamp(), web_event.PositionInWidget()); break; + case blink::WebInputEvent::Type::kGestureScrollBegin: + selection_controller_->OnScrollBeginEvent(); + break; default: break; } @@ -2770,12 +2781,21 @@ void CefRenderWidgetHostViewOSR::UpdateFrameRate() { } gfx::Size CefRenderWidgetHostViewOSR::SizeInPixels() { -#ifdef OHOS_EX_TOPCONTROLS - return gfx::ScaleToCeiledSize(GetPhysicalViewBounds().size(), - GetDeviceScaleFactor()); -#else - return gfx::ScaleToCeiledSize(GetViewBounds().size(), GetDeviceScaleFactor()); -#endif + if (IsPopupWidget()) { + return gfx::ScaleToCeiledSize(popup_position_.size(), + GetDeviceScaleFactor()); + } + + CefSize size {}; + if (browser_impl_ && browser_impl_->GetClient()) { + CefRefPtr handler = + browser_impl_->GetClient()->GetRenderHandler(); + CHECK(handler); + handler->GetDevicePixelSize(browser_impl_.get(), size); + } else { + LOG(WARNING) << "cannot get device pixel size, return zero"; + } + return gfx::Size(size.width, size.height); } #if BUILDFLAG(IS_MAC) @@ -2887,7 +2907,7 @@ void CefRenderWidgetHostViewOSR::SetFrameRate() { base::TimeTicks::Now(), base::Microseconds(frame_rate_threshold_us_)); #else auto compositor = CefRenderWidgetHostViewOSR::GetCompositor( - browser_impl_->GetAcceleratedWidget()); + browser_impl_->GetAcceleratedWidget(is_popup_)); if (compositor) { compositor->SetDisplayVSyncParameters( base::TimeTicks::Now(), base::Microseconds(frame_rate_threshold_us_)); @@ -2999,7 +3019,7 @@ bool CefRenderWidgetHostViewOSR::SetRootLayerSize(bool force) { compositor_->SetScaleAndSize( #else auto compositor = CefRenderWidgetHostViewOSR::GetCompositor( - browser_impl_->GetAcceleratedWidget()); + browser_impl_->GetAcceleratedWidget(is_popup_)); if (compositor) { compositor_local_surface_id_allocator_.GenerateId(); compositor->SetScaleAndSize( @@ -3650,6 +3670,16 @@ void CefRenderWidgetHostViewOSR::OnNativeEmbedLifecycleChange(const CefRenderHan } } +void CefRenderWidgetHostViewOSR::OnNativeEmbedVisibilityChange(const std::string& embed_id, bool visibility) { + if (browser_impl_.get()) { + CefRefPtr handler = + browser_impl_->client()->GetRenderHandler(); + CHECK(handler); + handler->OnNativeEmbedVisibilityChange(embed_id, visibility); + + } +} + void CefRenderWidgetHostViewOSR::SetGestureEventResult(bool result) { if (!render_widget_host_) { return; @@ -3658,6 +3688,18 @@ void CefRenderWidgetHostViewOSR::SetGestureEventResult(bool result) { gesture_provider_.SetNativeEmbedEnabled(false); } render_widget_host_->input_router()->SetGestureEventResult(result); + CefRefPtr handler = + browser_impl_->client()->GetRenderHandler(); + if (handler) { + handler->SetGestureEventResult(result); + } +} + +void CefRenderWidgetHostViewOSR::SetNativeEmbedMode(bool flag) { + if (!render_widget_host_) { + return; + } + render_widget_host_->input_router()->SetNativeEmbedMode(flag); } void CefRenderWidgetHostViewOSR::SetScrollable(bool enable) { @@ -3694,7 +3736,7 @@ ui::Compositor* CefRenderWidgetHostViewOSR::GetCompositor() { #else if (browser_impl_) { return CefRenderWidgetHostViewOSR::GetCompositor( - browser_impl_->GetAcceleratedWidget()); + browser_impl_->GetAcceleratedWidget(is_popup_)); } return nullptr; #endif diff --git a/libcef/browser/osr/render_widget_host_view_osr.h b/libcef/browser/osr/render_widget_host_view_osr.h index edc459a24492ade794a536bfb4b3f5ef36d80945..3fcca0fc8aa929ab61de5e88067e6cfa169ca48c 100644 --- a/libcef/browser/osr/render_widget_host_view_osr.h +++ b/libcef/browser/osr/render_widget_host_view_osr.h @@ -154,6 +154,7 @@ class CefRenderWidgetHostViewOSR #endif #if defined(OHOS_CLIPBOARD) void MouseSelectMenuShow(bool show); + void ChangeVisibilityOfQuickMenu(); #endif void EnsureSurfaceSynchronizedForWebTest() override; @@ -226,6 +227,7 @@ class CefRenderWidgetHostViewOSR void SetVirtualKeyBoardArg(int32_t width, int32_t height, double keyboard); void DidNativeEmbedEvent(const blink::mojom::NativeEmbedTouchEventPtr& touchEvent) override; void OnNativeEmbedLifecycleChange(const CefRenderHandler::CefNativeEmbedData& info); + void OnNativeEmbedVisibilityChange(const std::string& embed_id, bool visibility); void SetScrollable(bool enable); void OnDidNavigateMainFrameToNewPage() override; void AdvanceFocusForIME(int focusType); @@ -450,6 +452,7 @@ class CefRenderWidgetHostViewOSR bool need_report); bool NeedPopupInsertTouchHandleQuickMenu(); void SetGestureEventResult(bool result); + void SetNativeEmbedMode(bool flag); #endif #ifdef OHOS_CLIPBOARD @@ -660,6 +663,7 @@ class CefRenderWidgetHostViewOSR bool forward_touch_to_popup_ = false; #if BUILDFLAG(IS_OHOS) + bool is_popup_ = false; gfx::SizeF root_layer_size_; static std::unordered_map compositor_map_; diff --git a/libcef/browser/osr/touch_handle_drawable_osr.cc b/libcef/browser/osr/touch_handle_drawable_osr.cc index d021a2170ecc4f255b860db39382595ee839dda4..6d6a8ba0ea85753ac18e90a54c061b696403b8c5 100644 --- a/libcef/browser/osr/touch_handle_drawable_osr.cc +++ b/libcef/browser/osr/touch_handle_drawable_osr.cc @@ -158,13 +158,13 @@ void CefTouchHandleDrawableOSR::UpdateVisiableBounds() { int handle_width = image_size.width() + 2 * kSelectionHandlePadding; int handle_height = image_size.height() + 2 * kSelectionHandlePadding; if (orientation_ != ui::TouchHandleOrientation::LEFT) { - relative_bounds_ = gfx::RectF(-handle_width / 2.0, 0, - handle_width, handle_height); + relative_bounds_ = gfx::RectF(-handle_width / 2.0, -edge_height_, + handle_width, handle_height + edge_height_); } else { relative_bounds_ = gfx::RectF(-handle_width / 2.0, -edge_height_ - handle_height, - handle_width, handle_height); + handle_width, handle_height + edge_height_); } } #endif // #ifdef OHOS_CLIPBOARD diff --git a/libcef/browser/osr/touch_selection_controller_client_osr.cc b/libcef/browser/osr/touch_selection_controller_client_osr.cc index 902d1b2357f77ea3e723e9f675f8947696e05fa8..57748974db0e8978907f804ee22ed83e2b7d96a5 100644 --- a/libcef/browser/osr/touch_selection_controller_client_osr.cc +++ b/libcef/browser/osr/touch_selection_controller_client_osr.cc @@ -32,7 +32,12 @@ namespace { // Delay before showing the quick menu, in milliseconds. +#ifdef OHOS_DRAG_DROP +constexpr int kQuickMenuDelayInMs = 0; +#else constexpr int kQuickMenuDelayInMs = 100; +#endif + #ifdef OHOS_CLIPBOARD constexpr int kSelectHandleMoveDelayMixInMs = 400; constexpr cef_quick_menu_edit_state_flags_t kMenuCommands[] = { @@ -430,11 +435,11 @@ void CefTouchSelectionControllerClientOSR::ExecuteCommandMouse(int command_id, case QM_EDITFLAG_CAN_ELLIPSIS: MouseSelectMenuShow(false); RunContextMenu(); - host_delegate->ExecuteEditCommand("Unselect", value); + browser->web_contents()->CollapseSelection(); break; default: MouseSelectMenuShow(false); - host_delegate->ExecuteEditCommand("Unselect", value); + browser->web_contents()->CollapseSelection(); break; } } @@ -490,12 +495,17 @@ void CefTouchSelectionControllerClientOSR::MouseSelectMenuShow(bool show) { new CefRunQuickMenuCallbackImpl(base::BindOnce( &CefTouchSelectionControllerClientOSR::ExecuteCommandMouse, weak_ptr_factory_.GetWeakPtr()))); + ui::TouchSelectionController* controller = GetTouchSelectionController(); + bool isLongPressSelectionActive = false; + if (controller) { + isLongPressSelectionActive = controller->IsLongPressDragSelectionActive(); + } if (!handler->RunQuickMenu( browser, browser->GetFocusedFrame(), {0, 0}, {0, 0}, {clipped_selection_bounds_.x(), clipped_selection_bounds_.y(), clipped_selection_bounds_.width(), clipped_selection_bounds_.height()}, static_cast(quickmenuflags), - callbackImpl, true)) { + callbackImpl, true, isLongPressSelectionActive)) { callbackImpl->Disconnect(); auto render = browser->client()->GetRenderHandler(); if (render) { @@ -509,6 +519,21 @@ void CefTouchSelectionControllerClientOSR::MouseSelectMenuShow(bool show) { browser->web_contents()->SetShowingContextMenu(true); } } + +void CefTouchSelectionControllerClientOSR::ChangeVisibilityOfQuickMenu() { + if (!rwhv_) { + return; + } + auto browser = rwhv_->browser_impl(); + if (!browser || !browser->client()) { + return; + } + auto handler = browser->client()->GetContextMenuHandler(); + if (!handler) { + return; + } + handler->ChangeVisibilityOfQuickMenu(); +} #endif void CefTouchSelectionControllerClientOSR::ShowQuickMenu() { @@ -545,6 +570,12 @@ void CefTouchSelectionControllerClientOSR::ShowQuickMenu() { #ifdef OHOS_DRAG_DROP handles_hidden_by_selection_ui_ = false; #endif + ui::TouchSelectionController* controller = GetTouchSelectionController(); + bool isLongPressSelectionActive = false; + if (controller) { + isLongPressSelectionActive = controller->IsLongPressDragSelectionActive(); + LOG(DEBUG)<<"The selection long press active is "<RunQuickMenu( browser, browser->GetFocusedFrame(), {static_cast(std::round(origin.x())), @@ -555,7 +586,7 @@ void CefTouchSelectionControllerClientOSR::ShowQuickMenu() { clipped_selection_bounds_.width(), clipped_selection_bounds_.height()}, static_cast( quickmenuflags), - callbackImpl, false)) { + callbackImpl, false, isLongPressSelectionActive)) { callbackImpl->Disconnect(); if (browser) { if (auto client = browser->client()) { @@ -564,13 +595,34 @@ void CefTouchSelectionControllerClientOSR::ShowQuickMenu() { } } } + if (controller && controller->IsLongPressEvent() && + isLongPressSelectionActive) { + if (auto client = browser->client()) { + if (auto render = client->GetRenderHandler()) { + render->StartVibraFeedback("longPress.light"); + controller->ResetLongPressEvent(); + } + } + } CloseQuickMenu(); #ifdef OHOS_CLIPBOARD } else { LOG(INFO) << "Show Handle Quick Menu Success"; + if (!browser) { + return; + } if (browser->web_contents()) { browser->web_contents()->SetShowingContextMenu(true); } + if (controller && controller->IsLongPressEvent() && + !isLongPressSelectionActive) { + if (auto client = browser->client()) { + if (auto render = client->GetRenderHandler()) { + render->StartVibraFeedback("longPress.light"); + controller->ResetLongPressEvent(); + } + } + } browser->SetTouchInsertHandleMenuShow(false); #endif // #ifdef OHOS_CLIPBOARD } @@ -789,6 +841,9 @@ void CefTouchSelectionControllerClientOSR::OnSelectionEvent( break; case ui::SELECTION_HANDLES_UPDATEMENU: #ifdef OHOS_DRAG_DROP + if (controller) { + controller->ResetLongPressEvent(); + } if (handles_hidden_by_selection_ui_) { LOG(INFO) << "Current Selection Handle Menu Hidden"; return; @@ -988,14 +1043,14 @@ void CefTouchSelectionControllerClientOSR::ExecuteCommand(int command_id, CloseQuickMenu(); RunContextMenu(); #ifdef OHOS_CLIPBOARD - host_delegate->ExecuteEditCommand("Unselect", value); + browser->web_contents()->CollapseSelection(); #endif // #ifdef OHOS_CLIPBOARD break; default: // Invalid command, do nothing. // Also reached when callback is destroyed/cancelled. #ifdef OHOS_CLIPBOARD - host_delegate->ExecuteEditCommand("Unselect", value); + browser->web_contents()->CollapseSelection(); #endif // #ifdef OHOS_CLIPBOARD break; } diff --git a/libcef/browser/osr/touch_selection_controller_client_osr.h b/libcef/browser/osr/touch_selection_controller_client_osr.h index 541e5c52bff0be1731cad98f2966f383f97d101c..691366291fdffdd64be89447b4ae761bc60b5a73 100644 --- a/libcef/browser/osr/touch_selection_controller_client_osr.h +++ b/libcef/browser/osr/touch_selection_controller_client_osr.h @@ -100,6 +100,7 @@ class CefTouchSelectionControllerClientOSR #if defined(OHOS_CLIPBOARD) void MouseSelectMenuShow(bool show); + void ChangeVisibilityOfQuickMenu(); #endif private: class EnvEventObserver; diff --git a/libcef/browser/osr/web_contents_view_osr.cc b/libcef/browser/osr/web_contents_view_osr.cc index 4d8280693636555e7f1b3cef46244e95c4e0086c..a45938e292eab11dce2b47ade237b39e5eed9b55 100644 --- a/libcef/browser/osr/web_contents_view_osr.cc +++ b/libcef/browser/osr/web_contents_view_osr.cc @@ -196,6 +196,13 @@ void CefWebContentsViewOSR::MouseSelectMenuShow(bool show) { rwhv->MouseSelectMenuShow(show); } } + +void CefWebContentsViewOSR::ChangeVisibilityOfQuickMenu() { + auto* rwhv = GetView(); + if (rwhv) { + rwhv->ChangeVisibilityOfQuickMenu(); + } +} #endif void CefWebContentsViewOSR::StartDragging( diff --git a/libcef/browser/osr/web_contents_view_osr.h b/libcef/browser/osr/web_contents_view_osr.h index 21037d0c55302c018d2f14861bb57af3b7190a2d..c984ffd43e96d3838ecab8ba970d1a79d0408ab6 100644 --- a/libcef/browser/osr/web_contents_view_osr.h +++ b/libcef/browser/osr/web_contents_view_osr.h @@ -72,6 +72,7 @@ class CefWebContentsViewOSR : public content::WebContentsView, const content::ContextMenuParams& params) override; #if defined(OHOS_CLIPBOARD) void MouseSelectMenuShow(bool show) override; + void ChangeVisibilityOfQuickMenu() override; #endif void StartDragging(const content::DropData& drop_data, blink::DragOperationsMask allowed_ops, diff --git a/libcef/browser/page_load_metrics/oh_page_load_metrics_observer.cc b/libcef/browser/page_load_metrics/oh_page_load_metrics_observer.cc index f62d6bc946aa4e8916cc98f90ec3e0e2637e331b..75ee2fa6598afbfc6d933bbf0e84a3553b97de23 100644 --- a/libcef/browser/page_load_metrics/oh_page_load_metrics_observer.cc +++ b/libcef/browser/page_load_metrics/oh_page_load_metrics_observer.cc @@ -108,6 +108,37 @@ int64_t OhPageLoadMetricsObserver::GetNavigationStartTime() { return navigation_start_time; } +#ifdef OHOS_BFCACHE +void OhPageLoadMetricsObserver::OnRestoreFromBackForwardCache( + const page_load_metrics::mojom::PageLoadTiming& timing, + content::NavigationHandle* navigation_handle) { + back_forward_cache_navigation_ids_.push_back( + navigation_handle->GetNavigationId()); +} + +page_load_metrics::PageLoadMetricsObserver::ObservePolicy +OhPageLoadMetricsObserver::OnEnterBackForwardCache( + const page_load_metrics::mojom::PageLoadTiming& timing) { + return CONTINUE_OBSERVING; +} + +void OhPageLoadMetricsObserver:: + OnFirstContentfulPaintAfterBackForwardCacheRestoreInPage( + const page_load_metrics::mojom::BackForwardCacheTiming& timing, + size_t index) { + if (index >= back_forward_cache_navigation_ids_.size()) + return; + + int64_t first_contentful_paint_ms = + timing.first_paint_after_back_forward_cache_restore.InMilliseconds(); +#if defined(REPORT_SYS_EVENT) + web_performance_timing_.first_contentful_paint = first_contentful_paint_ms; +#endif + int64_t navigation_start_time = GetNavigationStartTime(); + ReportFirstContentfulPaint(navigation_start_time, first_contentful_paint_ms); +} +#endif + void OhPageLoadMetricsObserver::OnFirstContentfulPaintInPage( const page_load_metrics::mojom::PageLoadTiming& timing) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); diff --git a/libcef/browser/page_load_metrics/oh_page_load_metrics_observer.h b/libcef/browser/page_load_metrics/oh_page_load_metrics_observer.h index 20171f7d96e5ef60b48d28ef0d1d73b8a91cc8a3..791ca75c1247971a3b5e66801a4d97314694ac10 100644 --- a/libcef/browser/page_load_metrics/oh_page_load_metrics_observer.h +++ b/libcef/browser/page_load_metrics/oh_page_load_metrics_observer.h @@ -32,6 +32,11 @@ class OhPageLoadMetricsObserver ObservePolicy OnStart(content::NavigationHandle* navigation_handle, const GURL& currently_committed_url, bool started_in_foreground) override; +#ifdef OHOS_BFCACHE + page_load_metrics::PageLoadMetricsObserver::ObservePolicy + OnEnterBackForwardCache( + const page_load_metrics::mojom::PageLoadTiming& timing) override; +#endif ObservePolicy OnFencedFramesStart( content::NavigationHandle* navigation_handle, const GURL& currently_committed_url) override; @@ -52,6 +57,11 @@ class OhPageLoadMetricsObserver void OnFirstMeaningfulPaintInMainFrameDocument( const page_load_metrics::mojom::PageLoadTiming& timing) override; +#if OHOS_BFCACHE + void OnFirstContentfulPaintAfterBackForwardCacheRestoreInPage( + const page_load_metrics::mojom::BackForwardCacheTiming& timing, size_t index) override; +#endif + #if defined(REPORT_SYS_EVENT) ObservePolicy OnRedirect( content::NavigationHandle* navigation_handle) override; @@ -66,6 +76,13 @@ class OhPageLoadMetricsObserver const page_load_metrics::mojom::PageLoadTiming& timing) override; static void OnNavigationStart(); #endif + +#ifdef OHOS_BFCACHE + void OnRestoreFromBackForwardCache( + const page_load_metrics::mojom::PageLoadTiming& timing, + content::NavigationHandle* navigation_handle) override; +#endif + protected: OhPageLoadMetricsObserver( network::NetworkQualityTracker* network_quality_tracker) @@ -97,6 +114,12 @@ class OhPageLoadMetricsObserver OhWebPerformanceTiming web_performance_timing_; static int64_t navigation_start_timestamp_; #endif + +#ifdef OHOS_BFCACHE + // IDs for the navigations when the page is restored from the back-forward + // cache. + std::vector back_forward_cache_navigation_ids_; +#endif }; #endif // CEF_LIBCEF_BROWSER_PAGE_LOAD_METRICS_OH_PAGE_LOAD_METRICS_OBSERVER_H_ diff --git a/libcef/browser/password/oh_password_manager_client.cc b/libcef/browser/password/oh_password_manager_client.cc index d129165dbfb4b01c52f2cb5d554791ddbe5651db..1d47239d02afb3d2b9113802279658b43b8586ab 100644 --- a/libcef/browser/password/oh_password_manager_client.cc +++ b/libcef/browser/password/oh_password_manager_client.cc @@ -22,6 +22,7 @@ #include "base/metrics/field_trial.h" #include "base/metrics/histogram_functions.h" #include "base/ohos/sys_info_utils.h" +#include "base/strings/utf_string_conversions.h" #include "base/types/optional_util.h" #include "build/branding_buildflags.h" #include "build/build_config.h" @@ -113,6 +114,7 @@ #include "content/public/browser/storage_partition.h" #include "content/public/browser/web_contents.h" #include "content/public/common/content_switches.h" +#include "crypto/sha2.h" #include "extensions/buildflags/buildflags.h" #include "net/base/url_util.h" #include "net/cert/cert_status_flags.h" @@ -127,6 +129,7 @@ #include "libcef/browser/alloy/alloy_browser_context.h" #include "libcef/browser/alloy/alloy_browser_host_impl.h" #include "libcef/browser/autofill/oh_autofill_client.h" +#include "libcef/browser/autofill/oh_autofill_manager.h" #include "libcef/browser/browser_host_base.h" #include "libcef/browser/context.h" #include "libcef/browser/password/oh_password_store_factory.h" @@ -153,6 +156,8 @@ typedef autofill::SavePasswordProgressLogger Logger; namespace { #if defined(OHOS_PASSWORD_AUTOFILL) +const std::string SOURCE = "source"; +const std::string SOURCE_LOGIN = "login"; const std::string EVENT = "event"; const std::string EVENT_SAVE = "save"; const std::string EVENT_FILL = "fill"; @@ -172,6 +177,8 @@ const std::string KEY_IS_OTHER_ACCOUNT = "isOtherAccount"; const std::string KEY_USERNAME = "username"; const std::string KEY_PASSWORD = "password"; + +const std::string HASH_SALT = "OHOS@PASSWORD@AUTOFILL"; #endif } // namespace @@ -281,11 +288,10 @@ bool OhPasswordManagerClient::PromptUserToSaveOrUpdatePassword( return false; } - auto autofill_id = - form_to_save->GetPendingCredentials().password_element_renderer_id; - if (auto_filled_forms_.find(autofill_id) != auto_filled_forms_.end()) { + // If the information used when the user logs in is current site filled in and + // not modified, then do not prompt the user to save. + if (IsLoginInfoConsistentWithFilled(form_to_save->GetPendingCredentials())) { LOG(INFO) << "auto filled password, not save on login"; - auto_filled_forms_.erase(autofill_id); return false; } @@ -299,7 +305,11 @@ bool OhPasswordManagerClient::PromptUserToSaveOrUpdatePassword( PasswordFormToJsonForSave(form_to_save->GetPendingCredentials()); if (json_str.has_value()) { LOG(INFO) << "call autofill for save from system."; - autofill_client->OnAutofillEvent(json_str.value()); + bool result = autofill_client->OnAutofillEvent(json_str.value()); + if (!result) { + LOG(ERROR) << "failed to call autofill for save"; + return false; + } } #endif return false; @@ -720,6 +730,8 @@ OhPasswordManagerClient::GetURLLoaderFactory() { } #if defined(OHOS_PASSWORD_AUTOFILL) +using autofill::mojom::OhosPasswordFormAutofillState; + absl::optional OhPasswordManagerClient::PasswordFormToJsonForRequest( const std::string& event, @@ -745,9 +757,14 @@ OhPasswordManagerClient::PasswordFormToJsonForRequest( float ratio = browser->GetVirtualPixelRatio(); auto offset = content::WebContents::FromRenderFrameHost(rfh)->GetContainerBounds(); + int32_t viewport_height = 0; + if (browser->GetHost()) { + viewport_height = browser->GetHost()->GetShrinkViewportHeight(); + } base::Value::List view_data_list; view_data_list.Append(base::Value::Dict().Set(EVENT, event)); + view_data_list.Append(base::Value::Dict().Set(SOURCE, SOURCE_LOGIN)); view_data_list.Append(base::Value::Dict().Set(KEY_PAGE_URL, page_url.spec())); if (imf_info) { view_data_list.Append( @@ -758,7 +775,6 @@ OhPasswordManagerClient::PasswordFormToJsonForRequest( std::unordered_map fillItem = { {KEY_USERNAME, username_data}, {KEY_PASSWORD, password_data}}; - std::wstring_convert, char16_t> convert; for (auto item : fillItem) { base::Value::List list; list.Append( @@ -768,13 +784,17 @@ OhPasswordManagerClient::PasswordFormToJsonForRequest( static_cast((item.second.bounds.x() + offset.x()) * ratio))); list.Append(base::Value::Dict().Set( KEY_RECT_Y, - static_cast((item.second.bounds.y() + offset.y()) * ratio))); + static_cast((item.second.bounds.y() + offset.y() + viewport_height) * ratio))); list.Append(base::Value::Dict().Set( KEY_RECT_W, static_cast(item.second.bounds.width() * ratio))); list.Append(base::Value::Dict().Set( KEY_RECT_H, static_cast(item.second.bounds.height() * ratio))); + if (base::ohos::IsPcDevice() && item.second.is_focused) { + LOG(INFO) << "autofill request toJson, rect:" + << base::WriteJson(list).value_or("null"); + } list.Append(base::Value::Dict().Set(KEY_VALUE, - convert.to_bytes(item.second.value))); + base::UTF16ToUTF8(item.second.value))); auto dict = base::Value::Dict().Set(item.first, std::move(list)); view_data_list.Append(std::move(dict)); @@ -787,16 +807,16 @@ absl::optional OhPasswordManagerClient::PasswordFormToJsonForSave( const password_manager::PasswordForm& form) { base::Value::List view_data_list; view_data_list.Append(base::Value::Dict().Set(EVENT, EVENT_SAVE)); + view_data_list.Append(base::Value::Dict().Set(SOURCE, SOURCE_LOGIN)); view_data_list.Append(base::Value::Dict().Set( KEY_PAGE_URL, url::Origin::Create(form.url).GetURL().spec())); std::unordered_map saveItem = { {KEY_USERNAME, form.username_value}, {KEY_PASSWORD, form.password_value}}; - std::wstring_convert, char16_t> convert; for (auto item : saveItem) { base::Value::List list; list.Append( - base::Value::Dict().Set(KEY_VALUE, convert.to_bytes(item.second))); + base::Value::Dict().Set(KEY_VALUE, base::UTF16ToUTF8(item.second))); auto dict = base::Value::Dict().Set(item.first, std::move(list)); view_data_list.Append(std::move(dict)); } @@ -806,11 +826,16 @@ absl::optional OhPasswordManagerClient::PasswordFormToJsonForSave( void OhPasswordManagerClient::ProcessAutofillCancel( const std::string& fillContent) { - LOG(INFO) << "autofill process fill cancel"; - if (is_keyboard_supressed_) { - SetShouldSuppressKeyboard(false); + // If it is on the PC platform, or if the request is not sent by me, I will + // not handle the fill cancle event. + if (!is_keyboard_supressed_) { + LOG(INFO) << "don't need to handle the fill cancle event"; + return; } + LOG(INFO) << "autofill handle fill cancel event"; + SetShouldSuppressKeyboard(false); + if (!web_contents()) { LOG(ERROR) << "web_contents is nullptr"; return; @@ -853,8 +878,7 @@ void OhPasswordManagerClient::AutoFillWithIMFEvent(bool is_username, auto username = last_request_fill_username_; auto password = last_request_fill_password_; if (is_username) { - std::wstring_convert, char16_t> convert; - username.value = convert.from_bytes(content); + username.value = base::UTF8ToUTF16(content); } AutofillIMFInfo imf_info = { is_username, @@ -864,12 +888,39 @@ void OhPasswordManagerClient::AutoFillWithIMFEvent(bool is_username, auto json_str = PasswordFormToJsonForRequest(EVENT_FILL, form_to_request_url_, username, password, &imf_info); if (json_str.has_value()) { - LOG(INFO) << "call autofill for save from IMF"; + LOG(INFO) << "call autofill for request from IMF"; + bool result = autofill_client->OnAutofillEvent(json_str.value()); + if (!result) { + LOG(ERROR) << "failed to call autofill for request"; + return; + } SetShouldSuppressKeyboard(true); - autofill_client->OnAutofillEvent(json_str.value()); } } +void OhPasswordManagerClient::FillData(const std::string& page_url, + const std::string& username, + const std::string& password, + bool is_other_account) { + if (is_keyboard_supressed_) { + SetShouldSuppressKeyboard(false); + } + auto username_id = last_request_fill_username_.field_renderer_id; + auto password_id = last_request_fill_password_.field_renderer_id; + auto digest = is_other_account + ? std::string() + : crypto::SHA256HashString(username + HASH_SALT + password); + if (username_id) { + auto_filled_forms_username_[*username_id] = digest; + } + if (password_id) { + auto_filled_forms_password_[*password_id] = digest; + } + + FillAccountSuggestion(GURL(page_url), base::UTF8ToUTF16(username), + base::UTF8ToUTF16(password)); +} + void OhPasswordManagerClient::SetShouldSuppressKeyboard(bool suppress) { if (!web_contents()) { LOG(ERROR) << "web_contents is nullptr"; @@ -886,43 +937,74 @@ void OhPasswordManagerClient::SetShouldSuppressKeyboard(bool suppress) { LOG(ERROR) << "autofill_driver is nullptr"; return; } - LOG(INFO) << "SetShouldSuppressKeyboard=" << (suppress ? "true" : "false"); + LOG(INFO) << "set the keyboard suppressd=" << (suppress ? "true" : "false"); autofill_driver->SetShouldSuppressKeyboardCallback(suppress); is_keyboard_supressed_ = suppress; } +bool OhPasswordManagerClient::IsLoginInfoConsistentWithFilled( + const password_manager::PasswordForm& info) { + auto username_id = info.username_element_renderer_id; + auto password_id = info.password_element_renderer_id; + AutofilledMap::iterator it; + AutofilledMap* auto_filled_forms = nullptr; + LOG(INFO) << "login autosave, username renderer_id:" << username_id + << ", password renderer_id:" << password_id; + if (password_id) { + auto_filled_forms = &auto_filled_forms_password_; + it = auto_filled_forms->find(*password_id); + } else if (username_id) { + auto_filled_forms = &auto_filled_forms_username_; + it = auto_filled_forms->find(*username_id); + } + + if (auto_filled_forms && it != auto_filled_forms->end() && + !it->second.empty()) { + std::string login_digest = crypto::SHA256HashString( + base::UTF16ToUTF8(info.username_value) + HASH_SALT + + base::UTF16ToUTF8(info.password_value)); + if (it->second == login_digest) { + auto_filled_forms->erase(it); + return true; + } + } + return false; +} + void OhPasswordManagerClient::UpdateLastRequestFilledItems( const autofill::InputFillRequestData& username_data, - const autofill::InputFillRequestData& password_data, - autofill::FormRendererId form_id) { + const autofill::InputFillRequestData& password_data) { last_request_fill_username_ = username_data; last_request_fill_password_ = password_data; - last_filled_form_id_ = form_id; - if (last_request_fill_username_.is_focused) { - last_fill_focus_renderer_id_ = - last_request_fill_username_.field_renderer_id; - } else if (last_request_fill_password_.is_focused) { - last_fill_focus_renderer_id_ = - last_request_fill_password_.field_renderer_id; +} + +void OhPasswordManagerClient::NotifyAutofillPopupShow(bool is_show) { + content::RenderFrameHost* rfh = web_contents()->GetFocusedFrame(); + auto driver = autofill::ContentAutofillDriver::GetForRenderFrameHost(rfh); + if (!driver) { + LOG(ERROR) << "autofill_driver is nullptr"; + return; + } + auto autofill_manager = + static_cast(driver->oh_autofill_manager()); + if (!autofill_manager) { + LOG(ERROR) << "autofill_manager is nullptr"; + return; } + autofill_manager->SetPasswordPopupShow(is_show); } void OhPasswordManagerClient::FillAccountSuggestion( const GURL& page_url, const std::u16string& username, const std::u16string& password) { - if (is_keyboard_supressed_) { - SetShouldSuppressKeyboard(false); - } password_manager::ContentPasswordManagerDriver* driver = driver_factory_->GetDriverForFrame(web_contents()->GetFocusedFrame()); if (!driver) { return; } - if (!last_request_fill_password_.field_renderer_id.is_null()) { - auto_filled_forms_.insert(last_request_fill_password_.field_renderer_id); - } + LOG(INFO) << "[Autofill] Try to fill account suggestion."; driver->FillAccountSuggestion(page_url, username, password); } @@ -933,12 +1015,15 @@ void OhPasswordManagerClient::OnRequestAutofill( const autofill::mojom::OhosPasswordFormAutofillState state, const autofill::InputFillRequestData& username_data, const autofill::InputFillRequestData& password_data) { - LOG(INFO) << "On request autofill, state=" << static_cast(state) + LOG(INFO) << "[Autofill] On request autofill" + << ", state=" << static_cast(state) + << ", username.field_renderer_id=" << username_data.field_renderer_id << ", username.bounds=" << username_data.bounds.ToString() << ", username.is_focus=" << username_data.is_focused << ", username.type=" << username_data.type << ", username.autocomplete_attr=" << username_data.autocomplete_attr + << ", password.field_renderer_id=" << password_data.field_renderer_id << ", password.bounds=" << password_data.bounds.ToString() << ", password.is_focus=" << password_data.is_focused << ", password.type=" << password_data.type @@ -951,45 +1036,44 @@ void OhPasswordManagerClient::OnRequestAutofill( LOG(ERROR) << "autofill_client is nullptr"; return; } - if (state == autofill::mojom::OhosPasswordFormAutofillState::kTextChanged) { - auto_filled_forms_.erase(password_data.field_renderer_id); - } form_to_request_url_ = page_url; + last_fill_form_id_ = form_id; + last_fill_focus_renderer_id_ = username_data.is_focused + ? username_data.field_renderer_id + : password_data.field_renderer_id; if (!base::ohos::IsPcDevice()) { - if (state == - autofill::mojom::OhosPasswordFormAutofillState::kNotRequested) { + if (state == OhosPasswordFormAutofillState::kNotRequested) { auto json_str = PasswordFormToJsonForRequest( EVENT_FILL, page_url, username_data, password_data); if (json_str.has_value()) { - SetShouldSuppressKeyboard(true); LOG(INFO) << "call autofill for request from system, form_id=" << form_id; - autofill_client->OnAutofillEvent(json_str.value()); - UpdateLastRequestFilledItems(username_data, password_data, form_id); + bool result = autofill_client->OnAutofillEvent(json_str.value()); + if (!result) { + LOG(ERROR) << "failed to call autofill for request"; + return; + } + SetShouldSuppressKeyboard(true); + UpdateLastRequestFilledItems(username_data, password_data); } } } else { - // The current password coffer does not have a PC UI interface. It can only - // trigger a filling request when it is clicked for the first time. After - // the PC mode is fully supported, it requests filling every time it is - // clicked. - if (state == - autofill::mojom::OhosPasswordFormAutofillState::kHasBeenRequested) { - return; - } - - auto event = - state == autofill::mojom::OhosPasswordFormAutofillState::kTextChanged - ? EVENT_UPDATE - : EVENT_FILL; + auto event = (state == OhosPasswordFormAutofillState::kTextChanged) + ? EVENT_UPDATE + : EVENT_FILL; auto json_str = PasswordFormToJsonForRequest(event, page_url, username_data, password_data); if (json_str.has_value()) { LOG(INFO) << "call autofill for request from system, state=" << static_cast(state); - autofill_client->OnAutofillEvent(json_str.value()); - UpdateLastRequestFilledItems(username_data, password_data, form_id); + bool result = autofill_client->OnAutofillEvent(json_str.value()); + if (!result) { + LOG(ERROR) << "failed to call autofill for request"; + return; + } + NotifyAutofillPopupShow(true); + UpdateLastRequestFilledItems(username_data, password_data); } } } diff --git a/libcef/browser/password/oh_password_manager_client.h b/libcef/browser/password/oh_password_manager_client.h index c7f5fe13d833b91b8d2b4b9b4e8210d6366d9e36..1190d41176fe92446088b2946854705b931cec5d 100644 --- a/libcef/browser/password/oh_password_manager_client.h +++ b/libcef/browser/password/oh_password_manager_client.h @@ -170,16 +170,6 @@ class OhPasswordManagerClient bool is_new_password = false; }; - absl::optional PasswordFormToJsonForRequest( - const std::string& event, - const GURL& page_url, - const autofill::InputFillRequestData& username_data, - const autofill::InputFillRequestData& password_data, - AutofillIMFInfo* imf_info = nullptr); - - absl::optional PasswordFormToJsonForSave( - const password_manager::PasswordForm& form); - void ProcessAutofillCancel(const std::string& fillContent); void AutoFillWithIMFEvent(bool is_username, @@ -187,15 +177,13 @@ class OhPasswordManagerClient bool is_new_password, const std::string& content); - void SetShouldSuppressKeyboard(bool suppress); - - void UpdateLastRequestFilledItems( - const autofill::InputFillRequestData& username_data, - const autofill::InputFillRequestData& password_data, - autofill::FormRendererId form_id); + void FillData(const std::string& page_url, + const std::string& username, + const std::string& password, + bool is_other_account); bool IsUsernamePasswordForm(autofill::FormRendererId form_id) { - return form_id == last_filled_form_id_; + return form_id == last_fill_form_id_; } bool IsUsernamePasswordField(autofill::FieldRendererId field_id) { @@ -333,6 +321,29 @@ class OhPasswordManagerClient content::RenderFrameHost* frame_host, const gfx::RectF& bounds_in_frame_coordinates); +#if defined(OHOS_PASSWORD_AUTOFILL) + absl::optional PasswordFormToJsonForRequest( + const std::string& event, + const GURL& page_url, + const autofill::InputFillRequestData& username_data, + const autofill::InputFillRequestData& password_data, + AutofillIMFInfo* imf_info = nullptr); + + absl::optional PasswordFormToJsonForSave( + const password_manager::PasswordForm& form); + + void SetShouldSuppressKeyboard(bool suppress); + + bool IsLoginInfoConsistentWithFilled( + const password_manager::PasswordForm& info); + + void UpdateLastRequestFilledItems( + const autofill::InputFillRequestData& username_data, + const autofill::InputFillRequestData& password_data); + + void NotifyAutofillPopupShow(bool is_show); +#endif + content::BrowserContext* const context_; password_manager::PasswordManager password_manager_; @@ -373,12 +384,15 @@ class OhPasswordManagerClient bool was_on_paste_called_ = false; #if defined(OHOS_PASSWORD_AUTOFILL) + using AutofilledMap = std::unordered_map; + GURL form_to_request_url_; - autofill::FormRendererId last_filled_form_id_; + autofill::FormRendererId last_fill_form_id_; autofill::FieldRendererId last_fill_focus_renderer_id_; - std::set auto_filled_forms_; + AutofilledMap auto_filled_forms_username_; + AutofilledMap auto_filled_forms_password_; autofill::InputFillRequestData last_request_fill_username_; autofill::InputFillRequestData last_request_fill_password_; diff --git a/libcef/browser/predictors/loading_predictor.cc b/libcef/browser/predictors/loading_predictor.cc index 5505b6cd64a4ea8f9eb64342fd204a76d9b694ea..c24c5d08179c9ee13b2c9bbb6f961e6314f61960 100644 --- a/libcef/browser/predictors/loading_predictor.cc +++ b/libcef/browser/predictors/loading_predictor.cc @@ -17,6 +17,7 @@ #include "services/network/public/cpp/resource_request.h" #include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/mojom/url_response_head.mojom.h" +#include "third_party/bounds_checking_function/include/securec.h" #include "url/gurl.h" #include "url/origin.h" @@ -74,7 +75,9 @@ class PredictorResourceHandler : public CefResourceHandler { // Copy the next block of data info the buffer. int transfer_size = std::min(bytes_to_read, static_cast(data_.length() - offset_)); - memcpy(data_out, data_.c_str() + offset_, transfer_size); + if (memcpy_s(data_out, bytes_to_read, data_.c_str() + offset_, transfer_size) != EOK) { + return false; + } offset_ += transfer_size; bytes_read = transfer_size; diff --git a/libcef/browser/prefs/renderer_prefs.cc b/libcef/browser/prefs/renderer_prefs.cc index 8d1af2370e2ef7e6f35ee0c0635bf6ee3b7cfed0..2fa3d04aa8de693dad1d818a945ccf6eba37ff44 100755 --- a/libcef/browser/prefs/renderer_prefs.cc +++ b/libcef/browser/prefs/renderer_prefs.cc @@ -244,13 +244,14 @@ bool UpdatePreferredColorScheme(blink::web_pref::WebPreferences* web_prefs, void SetCefSpecialPrefs(content::RenderViewHost* rvh, CefRefPtr browser, blink::web_pref::WebPreferences& web) { - auto frame = browser->GetMainFrame(); - if (frame && frame->IsValid() && - (browser->settings().text_size_percent > 0)) { + if (browser->settings().text_size_percent > 0) { web.force_enable_zoom = false; - static_cast(frame.get()) - ->PutZoomingForTextFactor(browser->settings().text_size_percent / - 100.0f); + web.text_zoom_factor = browser->settings().text_size_percent / 100.0f; + auto frame = browser->GetMainFrame(); + if (frame && frame->IsValid()) { + static_cast(frame.get()) + ->PutZoomingForTextFactor(web.text_zoom_factor); + } } if (!rvh) { return; @@ -421,6 +422,7 @@ void SetCefPrefs(const CefBrowserSettings& cef, web.embed_tag_type = CefString(&cef.embed_tag_type); web.draw_mode = cef.draw_mode; SET_STATE(cef.text_autosizing_enabled, web.text_autosizing_enabled); + web.force_zero_layout_height = cef.force_zero_layout_height; #if defined(OHOS_DARKMODE) if (cef.dark_prefer_color_scheme_enabled == STATE_ENABLED) { web.preferred_color_scheme = blink::mojom::PreferredColorScheme::kDark; diff --git a/libcef/browser/printing/ohos_print_manager.cc b/libcef/browser/printing/ohos_print_manager.cc index 5c3fa8c11890bea7ebb03933fffd334bac42b272..1cfdc8bf71544305b9d386b304e25e3f93350e2c 100755 --- a/libcef/browser/printing/ohos_print_manager.cc +++ b/libcef/browser/printing/ohos_print_manager.cc @@ -533,7 +533,9 @@ void OhosPrintManager::RunPrintRequestedCallbackImpl(const std::string& jobId) { is_pdf_print_ = false; return; } - std::move(printRequestedCallback_).Run(); + if (printRequestedCallback_) { + std::move(printRequestedCallback_).Run(); + } } void OhosPrintManager::PrintPdfRequested() { diff --git a/libcef/browser/printing/print_util.cc b/libcef/browser/printing/print_util.cc index c6a1527cd7ce82123f74077b7a47edf31d1dbfb1..ba86f4c6972f890ca426cbb93d2077442d37140f 100644 --- a/libcef/browser/printing/print_util.cc +++ b/libcef/browser/printing/print_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights +// Copyright (c) 2022-2024 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. @@ -49,6 +49,20 @@ void OnPDFCreated(const CefString& path, base::BindOnce(&SavePdfFile, path, callback, std::move(data))); } +void OnCreatedPDF(CefRefPtr callback, + print_to_pdf::PdfPrintResult print_result, + scoped_refptr data) { + if (print_result != print_to_pdf::PdfPrintResult::kPrintSuccess) { + LOG(ERROR) << "PrintToPDF failed with error: " + << print_to_pdf::PdfPrintResultToString(print_result); + callback->OnReceiveValue(nullptr, 0); + return; + } + + callback->OnReceiveValue(reinterpret_cast(data->data()), + data->size()); +} + } // namespace void Print(content::WebContents* web_contents, bool print_preview_disabled) { @@ -146,4 +160,85 @@ void PrintToPDF(content::WebContents* web_contents, callback->OnPdfPrintFinished(CefString(), false); } +void CreateToPDF(content::WebContents* web_contents, + const CefPdfPrintSettings& settings, + CefRefPtr callback) { + const bool display_header_footer = !!settings.display_header_footer; + + // Defaults to no header/footer. + absl::optional header_template, footer_template; + if (display_header_footer) { + if (settings.header_template.length > 0) { + header_template = CefString(&settings.header_template); + } + if (settings.footer_template.length > 0) { + footer_template = CefString(&settings.footer_template); + } + } + + // Defaults to 1.0. + absl::optional scale; + if (settings.scale > 0) { + scale = settings.scale; + } + + // Defaults to letter size. + absl::optional paper_width, paper_height; + if (settings.paper_width > 0 && settings.paper_height > 0) { + paper_width = settings.paper_width; + paper_height = settings.paper_height; + } + + // Defaults to kDefaultMarginInInches. + absl::optional margin_top, margin_bottom, margin_left, margin_right; + if (settings.margin_type == PDF_PRINT_MARGIN_NONE) { + margin_top = 0; + margin_bottom = 0; + margin_left = 0; + margin_right = 0; + } else if (settings.margin_type == PDF_PRINT_MARGIN_CUSTOM) { + if (settings.margin_top >= 0) { + margin_top = settings.margin_top; + } + if (settings.margin_bottom >= 0) { + margin_bottom = settings.margin_bottom; + } + if (settings.margin_left >= 0) { + margin_left = settings.margin_left; + } + if (settings.margin_right >= 0) { + margin_right = settings.margin_right; + } + } + + absl::variant + print_pages_params = print_to_pdf::GetPrintPagesParams( + web_contents->GetPrimaryMainFrame()->GetLastCommittedURL(), + !!settings.landscape, display_header_footer, + !!settings.print_background, scale, paper_width, paper_height, + margin_top, margin_bottom, margin_left, margin_right, + CefString(&settings.header_template), + CefString(&settings.footer_template), + !!settings.prefer_css_page_size); + + if (absl::holds_alternative(print_pages_params)) { + LOG(ERROR) << "PrintToPDF failed with error: " + << absl::get(print_pages_params); + callback->OnReceiveValue(nullptr, 0); + return; + } + + DCHECK(absl::holds_alternative( + print_pages_params)); + + if (auto* print_manager = + printing::PrintViewManager::FromWebContents(web_contents)) { + print_manager->PrintToPdf( + web_contents->GetPrimaryMainFrame(), CefString(&settings.page_ranges), + std::move(absl::get( + print_pages_params)), + base::BindOnce(&OnCreatedPDF, callback)); + } +} + } // namespace print_util diff --git a/libcef/browser/printing/print_util.h b/libcef/browser/printing/print_util.h index fe12ec5451a678d95f114a08fe8826fb2927c7df..c5fc0d18a724577d43737426d8b8a3ad519e4cb2 100644 --- a/libcef/browser/printing/print_util.h +++ b/libcef/browser/printing/print_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights +// Copyright (c) 2022-2024 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. @@ -23,6 +23,10 @@ void PrintToPDF(content::WebContents* web_contents, const CefPdfPrintSettings& settings, CefRefPtr callback); +void CreateToPDF(content::WebContents* web_contents, + const CefPdfPrintSettings& settings, + CefRefPtr callback); + } // namespace print_util #endif // CEF_LIBCEF_BROWSER_PRINTING_PRINT_UTIL_H_ diff --git a/libcef/browser/report_manager.cc b/libcef/browser/report_manager.cc index a529fadc2ef6a55150fe024f31e95ee2408f5f34..a3ba6c3e5111a250c0d21f5fb3422628200ef53e 100644 --- a/libcef/browser/report_manager.cc +++ b/libcef/browser/report_manager.cc @@ -25,7 +25,6 @@ void CefReportManager::ExposeInterfacesToRenderer( service_manager::BinderRegistry* registry, blink::AssociatedInterfaceRegistry*associated_registry, content::RenderProcessHost* host) { - registry->AddInterface(base::BindRepeating( [](int render_process_id, mojo::PendingReceiver receiver) { @@ -37,7 +36,9 @@ void CefReportManager::ExposeInterfacesToRenderer( } void CefReportManager::ReportKeyThread(int status, int process_id, int thread_id, int role) { - LOG(DEBUG) << "ReportKeyThread process_id:" << process_id << ", thread_id:" << thread_id << ", render_process_id:" << render_process_id_; + LOG(DEBUG) << "ReportKeyThread process_id:" << process_id + << ", thread_id:" << thread_id + << ", render_process_id:" << render_process_id_; OHOS::NWeb::ResSchedClientAdapter::ReportKeyThread( static_cast(status), diff --git a/libcef/common/app_manager.cc b/libcef/common/app_manager.cc index 24f9b13cd4b76d2b945e24a35fac74c719f7f86c..cd75aff4c79e37078a7808a38c09516a67e740af 100644 --- a/libcef/common/app_manager.cc +++ b/libcef/common/app_manager.cc @@ -121,6 +121,48 @@ void CefAppManager::AddAdditionalSchemes( #endif #ifdef OHOS_NETWORK_LOAD + RenderAddCustomSchemes(); +#endif + + scheme::AddInternalSchemes(schemes); + scheme_info_list_locked_ = true; +} + +#if BUILDFLAG(IS_WIN) +const wchar_t* CefAppManager::GetResourceDllName() { + static wchar_t file_path[MAX_PATH + 1] = {0}; + + if (file_path[0] == 0) { + // Retrieve the module path (usually libcef.dll). + base::FilePath module; + base::PathService::Get(base::FILE_MODULE, &module); + const std::wstring wstr = module.value(); + size_t count = std::min(static_cast(MAX_PATH), wstr.size()); + wcsncpy(file_path, wstr.c_str(), count); + file_path[count] = 0; + } + + return file_path; +} +#endif // BUILDFLAG(IS_WIN) + +#ifdef OHOS_NETWORK_LOAD +std::vector CefAppManager::CustomSchemeCmdLineSplit( + std::string str, + const char split) { + std::istringstream inStream(str); + std::vector ret; + std::string token; + while (getline(inStream, token, split)) { + if (!token.empty()) { + ret.push_back(token); + token.clear(); + } + } + return ret; +} + +void CefAppManager::RenderAddCustomSchemes() { CefRefPtr cmdLine = CefCommandLine::GetGlobalCommandLine(); if (cmdLine->HasSwitch(switches::kProcessType)) { LOG(INFO) << "render Add custom schemes"; @@ -165,44 +207,5 @@ void CefAppManager::AddAdditionalSchemes( } } } -#endif - - scheme::AddInternalSchemes(schemes); - - scheme_info_list_locked_ = true; -} - -#if BUILDFLAG(IS_WIN) -const wchar_t* CefAppManager::GetResourceDllName() { - static wchar_t file_path[MAX_PATH + 1] = {0}; - - if (file_path[0] == 0) { - // Retrieve the module path (usually libcef.dll). - base::FilePath module; - base::PathService::Get(base::FILE_MODULE, &module); - const std::wstring wstr = module.value(); - size_t count = std::min(static_cast(MAX_PATH), wstr.size()); - wcsncpy(file_path, wstr.c_str(), count); - file_path[count] = 0; - } - - return file_path; -} -#endif // BUILDFLAG(IS_WIN) - -#ifdef OHOS_NETWORK_LOAD -std::vector CefAppManager::CustomSchemeCmdLineSplit( - std::string str, - const char split) { - std::istringstream inStream(str); - std::vector ret; - std::string token; - while (getline(inStream, token, split)) { - if (!token.empty()) { - ret.push_back(token); - token.clear(); - } - } - return ret; } #endif diff --git a/libcef/common/app_manager.h b/libcef/common/app_manager.h index a1192e075e928c1660f2125ca17882baff062cdb..391230da2c6d065f87e5a01b0a0c867d9efb2f74 100644 --- a/libcef/common/app_manager.h +++ b/libcef/common/app_manager.h @@ -75,6 +75,7 @@ class CefAppManager { #ifdef OHOS_NETWORK_LOAD std::vector CustomSchemeCmdLineSplit(std::string str, const char split); + void RenderAddCustomSchemes(); #endif // Custom schemes handled by the client. diff --git a/libcef/common/mojom/cef.mojom b/libcef/common/mojom/cef.mojom index 72250a8493b0d889fea12792b1795cca80c30ae5..043b82d8f38ae968b1805125ab23474e6e79c584 100644 --- a/libcef/common/mojom/cef.mojom +++ b/libcef/common/mojom/cef.mojom @@ -142,6 +142,9 @@ interface RenderFrame { ScrollPageUpDown(bool is_up, bool move_half, float view_height); // #endif OHOS_PAGE_UP_DOWN + [EnableIf=ohos_get_scroll_offset, Sync] + GetScrollOffset() => (float offset_x, float offset_y); + // #if defined(OHOS_INPUT_EVENTS) [EnableIf=ohos_input_events] ScrollTo(float x, float y); @@ -164,6 +167,9 @@ interface RenderFrame { [EnableIf=ohos_input_events] SetOverscrollMode(int32 mode); + [EnableIf=ohos_get_scroll_offset, Sync] + GetOverScrollOffset() => (float offset_x, float offset_y); + [EnableIf=is_ohos] TerminateRenderProcess(); diff --git a/libcef/common/request_impl.cc b/libcef/common/request_impl.cc index e172463c6467f80cdf64a72cf0d1d8f0b2e378b2..cd05d902061559fe4ae0a3d2b7980774db7b583c 100644 --- a/libcef/common/request_impl.cc +++ b/libcef/common/request_impl.cc @@ -46,7 +46,6 @@ #if defined(OHOS_SCHEME_HANDLER) #include "base/datashare_uri_utils.h" -#include "base/task/thread_pool.h" #include "base/files/file.h" #include "net/base/io_buffer.h" #include "services/network/chunked_data_pipe_upload_data_stream.h" @@ -225,7 +224,7 @@ std::unique_ptr CreateUploadDataStream( const bool has_null_source = element.read_only_once().value(); auto upload_data_stream = std::make_unique( - body, element.ReleaseChunkedDataPipeGetter(), has_null_source); + body, element.ReleaseChunkedDataPipeGetter(), has_null_source, true); if (element.read_only_once()) { upload_data_stream->EnableCache(); } @@ -1066,6 +1065,9 @@ CefPostDataStreamImpl::CefPostDataStreamImpl() { } CefPostDataStreamImpl::~CefPostDataStreamImpl() { + if (is_data_pipe_ && upload_stream_) { + content::GetIOThreadTaskRunner({})->DeleteSoon(FROM_HERE, std::move(upload_stream_)); + } } void CefPostDataStreamImpl::Reset() { @@ -1073,6 +1075,17 @@ void CefPostDataStreamImpl::Reset() { init_callback_ = nullptr; } +void CefPostDataStreamImpl::GetChunkedDataPipeGetter( + network::ResourceRequestBody* body) { + LOG(INFO) << "scheme_handler get chunked data pip getter initialated_: " << initialated_; + if (body && upload_stream_ && !initialated_) { + body->SetToChunkedDataPipe( + static_cast(upload_stream_.get()) + ->ReleaseChunkedDataPipeGetter(), + network::ResourceRequestBody::ReadOnlyOnce(HasNullSource())); + } +} + void CefPostDataStreamImpl::Set(network::ResourceRequestBody* body) { std::vector open_files; if (body) { @@ -1083,6 +1096,11 @@ void CefPostDataStreamImpl::Set(network::ResourceRequestBody* body) { LOG(INFO) << "scheme_handler file path: " << file_element.path() << " real path: " << real_path; open_files.push_back(base::File(base::FilePath(real_path), base::File::FLAG_OPEN | base::File::FLAG_READ)); } + + if (element.type() == network::DataElement::Tag::kDataPipe || + element.type() == network::DataElement::Tag::kChunkedDataPipe) { + is_data_pipe_ = true; + } } scoped_refptr task_runner = base::ThreadPool::CreateSequencedTaskRunner( @@ -1105,6 +1123,7 @@ void CefPostDataStreamImpl::OnStreamInitialized(int rv) { } void CefPostDataStreamImpl::Init(CefRefPtr init_callback) { + initialated_ = true; init_callback_ = init_callback; if (upload_stream_) { int rv = upload_stream_->Init( @@ -1120,7 +1139,31 @@ void CefPostDataStreamImpl::Init(CefRefPtr init_c } } -void CefPostDataStreamImpl::Read( +void CefPostDataStreamImpl::ReadOnTaskRunner( + void* buffer, + int buf_len, + base::WaitableEvent* event) { + scoped_refptr upload_buffer = + base::MakeRefCounted( + reinterpret_cast(buffer)); + if (upload_stream_) { + int rv = upload_stream_->Read( + upload_buffer.get(),buf_len, + base::BindOnce(&CefPostDataStreamImpl::OnStreamRead, + base::Unretained(this), upload_buffer, event)); + if (rv == net::ERR_IO_PENDING) { + last_read_rv_ = rv; + return; + } + last_read_rv_ = rv; + event->Signal(); + } else { + last_read_rv_ = -2; + event->Signal(); + } +} + +void CefPostDataStreamImpl::ReadAsync( void* buffer, int buf_len, CefRefPtr read_callback) { @@ -1130,23 +1173,54 @@ void CefPostDataStreamImpl::Read( if (upload_stream_) { int rv = upload_stream_->Read( upload_buffer.get(),buf_len, - base::BindOnce(&CefPostDataStreamImpl::OnStreamRead, + base::BindOnce(&CefPostDataStreamImpl::OnStreamReadAsync, base::Unretained(this), upload_buffer, read_callback)); - if (rv == net::ERR_IO_PENDING) + if (rv == net::ERR_IO_PENDING) { return; - OnStreamRead(upload_buffer, read_callback, rv); + } + OnStreamReadAsync(upload_buffer, read_callback, rv); } else { - OnStreamRead(upload_buffer, read_callback, -2); + OnStreamReadAsync(upload_buffer, read_callback, -2); } } -void CefPostDataStreamImpl::OnStreamRead( +void CefPostDataStreamImpl::Read( + void* buffer, + int buf_len, + CefRefPtr read_callback) { + if (base::SequencedTaskRunner::HasCurrentDefault() || IsInMemory() || IsChunked()) { + ReadAsync(buffer, buf_len, read_callback); + } else { + if (sequenced_task_runner_) { + base::WaitableEvent* completion = new base::WaitableEvent(); + sequenced_task_runner_->PostTask( + FROM_HERE, base::BindOnce(&CefPostDataStreamImpl::ReadOnTaskRunner, + this, buffer, buf_len, completion)); + completion->Wait(); + delete completion; + read_callback->OnReadComplete((char*)buffer, last_read_rv_); + } else { + read_callback->OnReadComplete((char*)buffer, -2); + } + } +} + +void CefPostDataStreamImpl::OnStreamReadAsync( scoped_refptr buffer, - CefRefPtr read_callback, int rv) { - LOG(INFO) << "scheme_handler CefPostDataStreamImpl::OnStreamRead rv: " << rv; - + CefRefPtr read_callback, + int rv) { if (read_callback) { - read_callback->OnReadComplete(buffer->data(), rv); + read_callback->OnReadComplete(buffer->data(), rv); + } +} + +void CefPostDataStreamImpl::OnStreamRead( + scoped_refptr buffer, + base::WaitableEvent* event, + int rv) { + last_read_rv_ = rv; + if (event) { + event->Signal(); } } diff --git a/libcef/common/request_impl.h b/libcef/common/request_impl.h index f24d58f332f5cbf1cb18d0ffb18811ecb27e6b4b..23dd69063d515bfafdb8647d098b50d5d34540ee 100644 --- a/libcef/common/request_impl.h +++ b/libcef/common/request_impl.h @@ -19,8 +19,12 @@ #include "url/gurl.h" #if defined(OHOS_SCHEME_HANDLER) +#include "base/synchronization/waitable_event.h" +#include "base/task/thread_pool.h" #include "net/base/io_buffer.h" #include "net/base/upload_data_stream.h" +#include "services/network/chunked_data_pipe_upload_data_stream.h" +#include "services/network/public/mojom/chunked_data_pipe_getter.mojom.h" #endif namespace blink { @@ -230,17 +234,32 @@ class CefPostDataStreamImpl : public CefPostDataStream { void Set(network::ResourceRequestBody* body); void Reset() override; + void GetChunkedDataPipeGetter(network::ResourceRequestBody* body); + private: void OnStreamInitialized(int rv); void OnStreamRead(scoped_refptr buffer, - CefRefPtr read_callback, + base::WaitableEvent* event, int rv); + void ReadAsync(void* buffer, + int buf_len, + CefRefPtr read_callback); + void OnStreamReadAsync(scoped_refptr buffer, + CefRefPtr read_callback, + int rv); + void ReadOnTaskRunner(void* buffer, + int buf_len, + base::WaitableEvent* event); CefRefPtr read_callback_; CefRefPtr init_callback_; std::unique_ptr upload_stream_; - + bool initialated_{false}; + bool is_data_pipe_{false}; + scoped_refptr sequenced_task_runner_ = + base::ThreadPool::CreateSequencedTaskRunner({}); + int last_read_rv_ = -2; mutable base::Lock lock_; IMPLEMENT_REFCOUNTING(CefPostDataStreamImpl); }; diff --git a/libcef/common/response_impl.cc b/libcef/common/response_impl.cc index 2127045e69fb3a68f0435f91c0be6884e71634e7..0dc331316416e396d1e53effa3745446d8cd54b7 100644 --- a/libcef/common/response_impl.cc +++ b/libcef/common/response_impl.cc @@ -120,6 +120,11 @@ void CefResponseImpl::SetHeaderByName(const CefString& name, std::string nameLower = name; HttpHeaderUtils::MakeASCIILower(&nameLower); + if (!overwrite) { + header_map_.insert(std::make_pair(name, value)); + return; + } + // There may be multiple values, so remove any first. for (auto it = header_map_.begin(); it != header_map_.end();) { if (base::EqualsCaseInsensitiveASCII(it->first.ToString(), nameLower)) { diff --git a/libcef/common/scheme_registrar_impl.cc b/libcef/common/scheme_registrar_impl.cc index 5d6746c477ddb093962eae3cd250403922d76863..fc3fbef2c1cadaa6cede5a872ff80ad1a57986bb 100644 --- a/libcef/common/scheme_registrar_impl.cc +++ b/libcef/common/scheme_registrar_impl.cc @@ -44,8 +44,7 @@ bool CefSchemeRegistrarImpl::AddCustomScheme(const CefString& scheme_name, const bool is_csp_bypassing = options & CEF_SCHEME_OPTION_CSP_BYPASSING; const bool is_fetch_enabled = options & CEF_SCHEME_OPTION_FETCH_ENABLED; #if BUILDFLAG(IS_OHOS) - const bool is_code_cache_enabled = - options & CEF_SCHEME_OPTION_CODE_CACHE_ENABLED; + const bool is_code_cache_enabled = options & CEF_SCHEME_OPTION_CODE_CACHE_ENABLED; #endif // The |is_display_isolated| value is excluded here because it's registered @@ -70,14 +69,8 @@ bool CefSchemeRegistrarImpl::AddCustomScheme(const CefString& scheme_name, #endif CefSchemeInfo scheme_info = { - scheme, - is_standard, - is_local, - is_display_isolated, - is_secure, - is_cors_enabled, - is_csp_bypassing, - is_fetch_enabled + scheme, is_standard, is_local, is_display_isolated, + is_secure, is_cors_enabled, is_csp_bypassing, is_fetch_enabled #if BUILDFLAG(IS_OHOS) , is_code_cache_enabled diff --git a/libcef/common/soc_perf_util.cc b/libcef/common/soc_perf_util.cc index 18e41108adfc4b45e180f5784d4ff270f08f707d..05790db512753a4b39306af9d5f1a9ef23bc41af 100644 --- a/libcef/common/soc_perf_util.cc +++ b/libcef/common/soc_perf_util.cc @@ -23,7 +23,6 @@ const int MAX_BOOST_RUN_TIME_IN_SECOND = 10; const int REST_TIME_IN_SECOND = 2; } // namespace -// #if defined(OHOS_PERFORMANCE_INC_FREQ) void SocPerUtil::EnableFlingBoost() { TRACE_EVENT0("power", "SocPerUtil::EnableFlingBoost"); OHOS::NWeb::OhosAdapterHelper::GetInstance() @@ -36,7 +35,6 @@ void SocPerUtil::DisableFlingBoost() { .CreateSocPerfClientAdapter() ->ApplySocPerfConfigByIdEx(SOC_PERF_WEB_GUSTURE_ID, false); } -// #endif OHOS_PERFORMANCE_INC_FREQ void SocPerUtil::TryRunSocPerf() { if ((base::Time().Now() - first_time_boost_timestamp).InSeconds() >= diff --git a/libcef/common/soc_perf_util.h b/libcef/common/soc_perf_util.h index a58db41ef66538565b81be856f0f3c7132c115a9..3e0bc185d18d850977410b644722a29735593c85 100644 --- a/libcef/common/soc_perf_util.h +++ b/libcef/common/soc_perf_util.h @@ -12,10 +12,8 @@ namespace soc_perf { class SocPerUtil { public: - // #if defined(OHOS_PERFORMANCE_INC_FREQ) static void EnableFlingBoost(); static void DisableFlingBoost(); - // #endif static void StartBoost(); private: diff --git a/libcef/renderer/alloy/alloy_content_renderer_client.cc b/libcef/renderer/alloy/alloy_content_renderer_client.cc index 9f35ac3148bae6f0f6676dd469c5650697772fdf..63f36ddade18e7c69d0152104d3fa1f519333d92 100644 --- a/libcef/renderer/alloy/alloy_content_renderer_client.cc +++ b/libcef/renderer/alloy/alloy_content_renderer_client.cc @@ -994,13 +994,6 @@ void AlloyContentRendererClient::TriggerElementHidingInFrame(int routing_id) { return; } - blink::WebDocument document = web_frame->GetDocument(); - if (!document.Url().ProtocolIs("https") && - !document.Url().ProtocolIs("http")) { - LOG(ERROR) << "[AdBlock] TriggerElementHidingInFrame scheme error"; - return; - } - blink::WebDocumentSubresourceFilter* filter = web_frame->GetDocumentLoader()->GetWebSubresourceFilter(); if (!filter) { @@ -1008,6 +1001,13 @@ void AlloyContentRendererClient::TriggerElementHidingInFrame(int routing_id) { return; } + blink::WebDocument document = web_frame->GetDocument(); + if (!document.Url().ProtocolIs("https") && + !document.Url().ProtocolIs("http")) { + LOG(ERROR) << "[AdBlock] TriggerElementHidingInFrame scheme error"; + return; + } + if (web_frame->GetHasDocumentTypeOption()) { LOG(WARNING) << "[AdBlock] Match $document for " << document.Url().GetString().Utf8(); diff --git a/libcef/renderer/browser_impl.cc b/libcef/renderer/browser_impl.cc index 4c026df600ee8259dde3af6e286f913ac8f7ee3a..6bf1361d01caec3c94bad332d32a44707dbf4588 100644 --- a/libcef/renderer/browser_impl.cc +++ b/libcef/renderer/browser_impl.cc @@ -502,15 +502,22 @@ void CefBrowserImpl::DidCommitCompositorFrame() { blink::WebFrame* main_frame = GetWebView()->MainFrame(); blink::WebLocalFrame* web_local_frame = main_frame->ToWebLocalFrame(); - gfx::Size contents_size = blink_glue::GetContentSize(web_local_frame); + gfx::Size contents_size = main_frame->ToWebLocalFrame()->DocumentSize(); + + if (contents_size.IsEmpty()) { + contents_size = GetWebView()->ContentsPreferredMinimumSize(); + } + int content_width = contents_size.width(); int content_height = contents_size.height(); gfx::Size viewport_size = blink_glue::GetVisualViewportSize(web_local_frame); - if (content_width != content_width_ || content_height != content_height_) { + if (content_width != content_width_ || content_height != content_height_ || viewport_size.width() != viewport_width_ || viewport_size.height() != viewport_height_) { content_width_ = content_width; content_height_ = content_height; + viewport_width_ = viewport_size.width(); + viewport_height_ = viewport_size.height(); CefRefPtr message = CefProcessMessage::Create(CONTENT_SIZE_MESSAGE); message->GetArgumentList()->SetInt(0, content_width_); message->GetArgumentList()->SetInt(1, content_height_); diff --git a/libcef/renderer/browser_impl.h b/libcef/renderer/browser_impl.h index 5ed5af4b1077a12aaabf094b699c25530f2fb71e..e02943cf7e5fe82fb12d8e13fc777cd31ccb2d6c 100644 --- a/libcef/renderer/browser_impl.h +++ b/libcef/renderer/browser_impl.h @@ -214,6 +214,8 @@ class CefBrowserImpl : public CefBrowser, public blink::WebViewObserver { int content_width_ = 0; int content_height_ = 0; bool needs_contents_size_update_ = true; + int viewport_width_ = 0; + int viewport_height_ = 0; #endif IMPLEMENT_REFCOUNTING(CefBrowserImpl); diff --git a/libcef/renderer/frame_impl.cc b/libcef/renderer/frame_impl.cc index e8f781fa2a1059e3856b6f12ea1231ff0e329b9c..0e5ee53996ef19f774b539095b91d9300bdacf4e 100644 --- a/libcef/renderer/frame_impl.cc +++ b/libcef/renderer/frame_impl.cc @@ -1084,12 +1084,14 @@ void CefFrameImpl::GetImageForContextNode() { cef::mojom::GetImageForContextNodeParamsPtr params = cef::mojom::GetImageForContextNodeParams::New(); - blink::WebNode context_node = frame_->ContextMenuImageNode(); + blink::WebNode context_node = frame_->ContextMenuNode(); std::vector image_data; gfx::Size original_size; std::string image_extension; - if (context_node.IsNull() || !context_node.IsElementNode()) { + if (context_node.IsNull() || !context_node.IsElementNode() || + context_node.To().ImageContents().drawsNothing()) { + LOG(WARNING) << "Context node is null or is not element node, or image draws nothing"; SendToBrowserFrame(__FUNCTION__, base::BindOnce( [](cef::mojom::GetImageForContextNodeParamsPtr data, @@ -1105,11 +1107,18 @@ void CefFrameImpl::GetImageForContextNode() { SkBitmap image = web_element.ImageContents(); SkBitmap resize_image = Downscale(image, total_mem_); + if (resize_image.drawsNothing()) { + LOG(ERROR) << "GetImageForContextNode fail, image is null or image is empty"; + return; + } + image_extension = "." + web_element.ImageExtension(); params->width = resize_image.width(); params->height = resize_image.height(); params->image = resize_image; params->image_extension = image_extension; + LOG(DEBUG) << "GetImageForContextNode, image width: " << resize_image.width() + << ", height: " << resize_image.height(); SendToBrowserFrame( __FUNCTION__, base::BindOnce( @@ -1289,6 +1298,21 @@ void CefFrameImpl::ScrollPageUpDown(bool is_up, webview->SmoothScroll(scroll_offset.x(), scroll_offset.y() + dy, base::Milliseconds(computeDurationInMilliSec(0, dy))); } + +#ifdef OHOS_GET_SCROLL_OFFSET +void CefFrameImpl::GetScrollOffset( + cef::mojom::RenderFrame::GetScrollOffsetCallback callback) { + auto render_frame = content::RenderFrame::FromWebFrame(frame_); + DCHECK(render_frame->IsMainFrame()); + blink::WebView* webView = render_frame->GetWebView(); + if (!webView) { + LOG(ERROR) << "GetScrollOffset get webView failed"; + return; + } + auto scroll_offset = webView->GetScrollOffset(); + std::move(callback).Run(scroll_offset.x(), scroll_offset.y()); +} +#endif #endif // #ifdef OHOS_PAGE_UP_DOWN @@ -1395,6 +1419,17 @@ void CefFrameImpl::ScrollByWithAnime(float delta_x, float delta_y, int32_t durat delta_y + scroll_offset.y(), base::Milliseconds(duration)); } + +#if defined(OHOS_GET_SCROLL_OFFSET) +void CefFrameImpl::GetOverScrollOffset( + cef::mojom::RenderFrame::GetOverScrollOffsetCallback callback) { + auto render_frame = content::RenderFrame::FromWebFrame(frame_); + DCHECK(render_frame->IsMainFrame()); + + auto overScroll_offset = render_frame->GetOverScrollOffset(); + std::move(callback).Run(overScroll_offset.x(), overScroll_offset.y()); +} +#endif #endif // defined(OHOS_INPUT_EVENTS) bool CefFrameImpl::ShouldOverrideUrlLoading(const CefString& url, diff --git a/libcef/renderer/frame_impl.h b/libcef/renderer/frame_impl.h index 1352bffbc36eda9573d8ac8e739483c5c9da4505..435b3aaeee7b3b0266c9d60e26872bc1635ee1bf 100644 --- a/libcef/renderer/frame_impl.h +++ b/libcef/renderer/frame_impl.h @@ -212,6 +212,10 @@ class CefFrameImpl void RemoveCache() override; #ifdef OHOS_PAGE_UP_DOWN void ScrollPageUpDown(bool is_up, bool is_half, float view_height) override; +#ifdef OHOS_GET_SCROLL_OFFSET + void GetScrollOffset( + cef::mojom::RenderFrame::GetScrollOffsetCallback callback) override; +#endif #endif // #ifdef OHOS_PAGE_UP_DOWN #if defined(OHOS_INPUT_EVENTS) @@ -232,6 +236,10 @@ class CefFrameImpl void UpdateDrawRect() override; void ScrollToWithAnime(float x, float y, int32_t duration) override; void ScrollByWithAnime(float delta_x, float delta_y, int32_t duration) override; +#if defined(OHOS_GET_SCROLL_OFFSET) + void GetOverScrollOffset( + cef::mojom::RenderFrame::GetOverScrollOffsetCallback callback) override; +#endif #endif // defined(OHOS_INPUT_EVENTS) GURL GetAbsoluteUrl(const blink::WebNode& node, diff --git a/libcef/renderer/javascript/oh_gin_javascript_bridge_dispatcher.cc b/libcef/renderer/javascript/oh_gin_javascript_bridge_dispatcher.cc index 9f36947ab631a7330e9a799a389af9f150810e6c..5d7d7a75162d39f8d784d46ebbdfe3049b5d59cd 100644 --- a/libcef/renderer/javascript/oh_gin_javascript_bridge_dispatcher.cc +++ b/libcef/renderer/javascript/oh_gin_javascript_bridge_dispatcher.cc @@ -267,14 +267,14 @@ std::vector OhGinJavascriptBridgeDispatcher::GetH5ObjectMethodNames v8::Isolate* isolate = blink::MainThreadIsolate(); v8::HandleScope handle_scope(isolate); - if(!render_frame() || !render_frame()->GetWebFrame()) { + if (!render_frame() || !render_frame()->GetWebFrame()) { LOG(ERROR) << "OhGinJavascriptBridgeDispatcher::GetH5ObjectMethodNames frame null"; return std::vector(); } v8::Local context = render_frame()->GetWebFrame()->MainWorldScriptContext(); - if(context.IsEmpty()) { + if (context.IsEmpty()) { LOG(ERROR) << "OhGinJavascriptBridgeDispatcher::GetH5ObjectMethodNames context empty"; return std::vector(); } @@ -288,13 +288,11 @@ std::vector OhGinJavascriptBridgeDispatcher::GetH5ObjectMethodNames } v8::Local annotate_string = - v8::String::NewFromUtf8(isolate, "methodNameListForJsProxy") - .ToLocalChecked(); + v8::String::NewFromUtf8(isolate, "methodNameListForJsProxy").ToLocalChecked(); v8::Local value; v8::TryCatch try_catch(isolate); - v8::MaybeLocal maybe_value = - object->Get(context, annotate_string); + v8::MaybeLocal maybe_value = object->Get(context, annotate_string); if (try_catch.HasCaught() || !maybe_value.ToLocal(&value)) { LOG(ERROR) << "OhGinJavascriptBridgeDispatcher::GetH5ObjectMethodNames Getter property fail"; return std::vector(); @@ -302,7 +300,7 @@ std::vector OhGinJavascriptBridgeDispatcher::GetH5ObjectMethodNames v8::Local keys = value.As(); v8::Local key; for (uint32_t i = 0; i < keys->Length(); ++i) { - if(!keys->Get(context, i).ToLocal(&key)) { + if (!keys->Get(context, i).ToLocal(&key)) { LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::GetH5ObjectMethodNames key error"; continue; } @@ -314,9 +312,7 @@ std::vector OhGinJavascriptBridgeDispatcher::GetH5ObjectMethodNames } char* buf = new char[len]; - key.As()->WriteUtf8( - isolate, buf, len, nullptr, - v8::String::REPLACE_INVALID_UTF8); + key.As()->WriteUtf8(isolate, buf, len, nullptr, v8::String::REPLACE_INVALID_UTF8); std::string method_name(buf, len); LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::GetH5ObjectMethodNames method_name = " << method_name; H5ObjectMethodsMap_[h5_object_id].push_back(method_name); @@ -333,22 +329,20 @@ bool OhGinJavascriptBridgeDispatcher::HasH5ObjectMethod( v8::Isolate* isolate = blink::MainThreadIsolate(); v8::HandleScope handle_scope(isolate); if (!render_frame() || !render_frame()->GetWebFrame()) { - LOG(ERROR) - << "OhGinJavascriptBridgeDispatcher::HasH5ObjectMethod frame null"; + LOG(ERROR) << "OhGinJavascriptBridgeDispatcher::HasH5ObjectMethod frame null"; return false; } - v8::Local context = - render_frame()->GetWebFrame()->MainWorldScriptContext(); + v8::Local context = render_frame()->GetWebFrame()->MainWorldScriptContext(); if (context.IsEmpty()) { - LOG(ERROR) - << "OhGinJavascriptBridgeDispatcher::HasH5ObjectMethod context empty"; + LOG(ERROR) << "OhGinJavascriptBridgeDispatcher::HasH5ObjectMethod context empty"; return false; } v8::Context::Scope context_scope(context); v8::Local keys; - v8::Local key, value; + v8::Local key; + v8::Local value; LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::HasH5ObjectMethod called"; if (!object->GetOwnPropertyNames(context).ToLocal(&keys)) { LOG(ERROR) << "OhGinJavascriptBridgeDispatcher::HasH5ObjectMethod " @@ -358,8 +352,7 @@ bool OhGinJavascriptBridgeDispatcher::HasH5ObjectMethod( for (uint32_t i = 0; i < keys->Length(); ++i) { if (!keys->Get(context, i).ToLocal(&key)) { - LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::GetH5ObjectMethodNames " - "key error"; + LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::GetH5ObjectMethodNames key error"; continue; } @@ -382,13 +375,11 @@ bool OhGinJavascriptBridgeDispatcher::HasH5ObjectMethod( } if (value->IsArray()) { - LOG(DEBUG) - << "OhGinJavascriptBridgeDispatcher::HasH5ObjectMethod return true"; + LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::HasH5ObjectMethod return true"; return true; } } - LOG(DEBUG) - << "OhGinJavascriptBridgeDispatcher::HasH5ObjectMethod return false"; + LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::HasH5ObjectMethod return false"; return false; } @@ -457,47 +448,7 @@ void OhGinJavascriptBridgeDispatcher::OnDoCallAnonymousH5Function( v8_args = new v8::Local[size]; } - for (int i = 0; i < size; ++i) { - const base::Value& base_arg = args[i]; - if (!base_arg.is_blob()) { - LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::" - "OnDoCallAnonymousH5Function not blob"; - v8_args[i] = converter_->ToV8Value(&base_arg, context); - continue; - } - - std::unique_ptr gin_value = - OhGinJavascriptBridgeValue::FromValue(&base_arg); - if (gin_value->IsType(OhGinJavascriptBridgeValue::TYPE_OBJECT_ID)) { - OhGinJavascriptBridgeObject* object_result = NULL; - OhGinJavascriptBridgeDispatcher::ObjectID object_id; - if (gin_value->GetAsObjectID(&object_id)) { - LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::" - "OnDoCallAnonymousH5Function blob"; - object_result = GetObject(object_id); - } - if (object_result) { - LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::" - "OnDoCallAnonymousH5Function object_result ok"; - gin::Handle controller = - gin::CreateHandle(isolate, object_result); - if (controller.IsEmpty()) { - LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::" - "OnDoCallAnonymousH5Function controller empty"; - v8_args[i] = v8::Undefined(isolate); - continue; - } - v8_args[i] = controller.ToV8(); - continue; - } - } else if (gin_value->IsType(OhGinJavascriptBridgeValue::TYPE_NONFINITE)) { - float float_value; - gin_value->GetAsNonFinite(&float_value); - v8_args[i] = v8::Number::New(isolate, float_value); - continue; - } - v8_args[i] = v8::Undefined(isolate); - } + convertToV8Value(args, v8_args); v8::Local func = v8::Local::Cast(object); v8::MaybeLocal function_call_result = @@ -519,7 +470,7 @@ void OhGinJavascriptBridgeDispatcher::convertToV8Value( v8::Isolate* isolate = blink::MainThreadIsolate(); v8::HandleScope handle_scope(isolate); - if (!v8_value || !render_frame() || !render_frame()->GetWebFrame()) { + if (!v8_value) { return; } @@ -534,35 +485,37 @@ void OhGinJavascriptBridgeDispatcher::convertToV8Value( for (int i = 0; i < size; ++i) { const base::Value& base_arg = base_value[i]; if (!base_arg.is_blob()) { + LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::convertToV8Value not blob"; v8_value[i] = converter_->ToV8Value(&base_arg, context); continue; } + v8_value[i] = v8::Undefined(isolate); std::unique_ptr gin_value = OhGinJavascriptBridgeValue::FromValue(&base_arg); if (gin_value->IsType(OhGinJavascriptBridgeValue::TYPE_OBJECT_ID)) { OhGinJavascriptBridgeObject* object_result = NULL; OhGinJavascriptBridgeDispatcher::ObjectID object_id; if (gin_value->GetAsObjectID(&object_id)) { + LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::convertToV8Value blob"; object_result = GetObject(object_id); } - if (object_result) { - gin::Handle controller = - gin::CreateHandle(isolate, object_result); - if (controller.IsEmpty()) { - v8_value[i] = v8::Undefined(isolate); - continue; - } - v8_value[i] = controller.ToV8(); + if (!object_result) { + continue; + } + LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::convertToV8Value object_result ok"; + gin::Handle controller = + gin::CreateHandle(isolate, object_result); + if (controller.IsEmpty()) { + LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::convertToV8Value controller empty"; continue; } + v8_value[i] = controller.ToV8(); } else if (gin_value->IsType(OhGinJavascriptBridgeValue::TYPE_NONFINITE)) { float float_value; gin_value->GetAsNonFinite(&float_value); v8_value[i] = v8::Number::New(isolate, float_value); - continue; } - v8_value[i] = v8::Undefined(isolate); } } @@ -580,35 +533,25 @@ void OhGinJavascriptBridgeDispatcher::OnDoCallH5Function( base::AutoLock locker(h5_objects_lock_); iter = h5_object_map_.find(h5_object_id); if (iter == h5_object_map_.end() || !(iter->second)) { - LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::OnDoCallH5Function obj " - "id not found"; + LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::OnDoCallH5Function obj id not found"; return; } } - if (method_name - .empty()) { // IF h5_method_name empty, call anonymous function + if (method_name.empty()) { // IF h5_method_name empty, call anonymous function OnDoCallAnonymousH5Function(h5_object_id, args); } v8::Isolate* isolate = blink::MainThreadIsolate(); v8::HandleScope handle_scope(isolate); + + v8::Local context = render_frame()->GetWebFrame()->MainWorldScriptContext(); + v8::Context::Scope context_scope(context); - if (!render_frame() || !render_frame()->GetWebFrame()) { - LOG(ERROR) - << "OhGinJavascriptBridgeDispatcher::OnDoCallH5Function frame null"; - return; - } - - v8::Local context = - render_frame()->GetWebFrame()->MainWorldScriptContext(); - - if (context.IsEmpty()) { - LOG(ERROR) - << "OhGinJavascriptBridgeDispatcher::OnDoCallH5Function context empty"; + if (!render_frame() || !render_frame()->GetWebFrame() || context.IsEmpty()) { + LOG(ERROR) << "OhGinJavascriptBridgeDispatcher::OnDoCallH5Function frame null or context empty"; return; } - v8::Context::Scope context_scope(context); if (!HasH5ObjectMethod(h5_object_id, method_name)) { return; @@ -616,70 +559,24 @@ void OhGinJavascriptBridgeDispatcher::OnDoCallH5Function( v8::Local object = v8::Local::New( isolate, *reinterpret_cast*>(iter->second)); - v8::Local key = - v8::String::NewFromUtf8(isolate, method_name.c_str()).ToLocalChecked(); + v8::Local key = v8::String::NewFromUtf8(isolate, method_name.c_str()).ToLocalChecked(); v8::Local* v8_args = nullptr; int size = args.size(); if (size > 0) { - LOG(DEBUG) - << "OhGinJavascriptBridgeDispatcher::OnDoCallH5Function args size = " - << size; + LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::OnDoCallH5Function args size = " << size; v8_args = new v8::Local[size]; } - for (int i = 0; i < size; ++i) { - const base::Value& base_arg = args[i]; - if (!base_arg.is_blob()) { - LOG(DEBUG) - << "OhGinJavascriptBridgeDispatcher::OnDoCallH5Function not blob"; - v8_args[i] = converter_->ToV8Value(&base_arg, context); - continue; - } - - std::unique_ptr gin_value = - OhGinJavascriptBridgeValue::FromValue(&base_arg); - if (gin_value->IsType(OhGinJavascriptBridgeValue::TYPE_OBJECT_ID)) { - OhGinJavascriptBridgeObject* object_result = NULL; - OhGinJavascriptBridgeDispatcher::ObjectID object_id; - if (gin_value->GetAsObjectID(&object_id)) { - LOG(DEBUG) - << "OhGinJavascriptBridgeDispatcher::OnDoCallH5Function blob"; - object_result = GetObject(object_id); - } - if (object_result) { - LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::OnDoCallH5Function " - "object_result ok"; - gin::Handle controller = - gin::CreateHandle(isolate, object_result); - if (controller.IsEmpty()) { - LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::OnDoCallH5Function " - "controller empty"; - v8_args[i] = v8::Undefined(isolate); - continue; - } - v8_args[i] = controller.ToV8(); - continue; - } - } else if (gin_value->IsType(OhGinJavascriptBridgeValue::TYPE_NONFINITE)) { - float float_value; - gin_value->GetAsNonFinite(&float_value); - v8_args[i] = v8::Number::New(isolate, float_value); - continue; - } - v8_args[i] = v8::Undefined(isolate); - } + convertToV8Value(args, v8_args); v8::TryCatch try_catch(isolate); v8::MaybeLocal result_value = object->Get(context, key); if (!try_catch.HasCaught() && !result_value.IsEmpty()) { - v8::Local value = result_value.ToLocalChecked(); - v8::Local func = v8::Local::Cast(value); - v8::MaybeLocal function_call_result = - func->Call(context, object, size, v8_args); - LOG(DEBUG) - << "OhGinJavascriptBridgeDispatcher::OnDoCallH5Function func call end"; + v8::Local func = v8::Local::Cast(result_value.ToLocalChecked()); + v8::MaybeLocal function_call_result = func->Call(context, object, size, v8_args); + LOG(DEBUG) << "OhGinJavascriptBridgeDispatcher::OnDoCallH5Function func call end"; if (!function_call_result.IsEmpty()) { function_call_result.ToLocalChecked(); } diff --git a/libcef/renderer/javascript/oh_gin_javascript_function_invocation_helper.cc b/libcef/renderer/javascript/oh_gin_javascript_function_invocation_helper.cc index 23b9c87ba16a40277191acf755e3239068022f5e..792dc32a02a2d625b0cf117a042bf1d8b794be7e 100644 --- a/libcef/renderer/javascript/oh_gin_javascript_function_invocation_helper.cc +++ b/libcef/renderer/javascript/oh_gin_javascript_function_invocation_helper.cc @@ -17,11 +17,7 @@ #include "ohos_adapter_helper.h" #include "v8/include/v8-exception.h" -#define MAX_FLOWBUF_DATA_SIZE 52428800 /* 50 MB */ -#define MAX_ENTRIES 10 -#define HEADER_SIZE (MAX_ENTRIES * 8) /* 10 * (int position + int length) */ -#define INDEX_SIZE 2 -#define DEFAULT_ID 1073741824 +#include "third_party/bounds_checking_function/include/securec.h" namespace { @@ -37,6 +33,11 @@ const char kMethodInvocationErrorMessage[] = namespace NWEB { int32_t OhGinJavascriptFunctionInvocationHelper::maxFdNum_ = -1; std::atomic OhGinJavascriptFunctionInvocationHelper::usedFd_ {0}; +const int MAX_FLOWBUF_DATA_SIZE = 52428800; /* 50 MB */ +const int MAX_ENTRIES = 10; +const int HEADER_SIZE = (MAX_ENTRIES * 8); /* 10 * (int position + int length) */ +const int INDEX_SIZE = 2; +const int DEFAULT_ID = 1073741824; OhGinJavascriptFunctionInvocationHelper:: OhGinJavascriptFunctionInvocationHelper( @@ -81,7 +82,10 @@ bool OhGinJavascriptFunctionInvocationHelper::StoreString(int index, void* mem, int* newEntry = static_cast(mem) + (i * INDEX_SIZE); *(newEntry) = index; *(newEntry + 1) = static_cast(strlen(str) + 1); - memcpy(dataMem + dataPos, str, strlen(str) + 1); + if (memcpy_s(dataMem + dataPos, MAX_FLOWBUF_DATA_SIZE - dataPos, str, strlen(str) + 1) != EOK) { + LOG(DEBUG) << "Flowbuf memcpy fail, cannot store more strings"; + return false; + } return true; } @@ -206,7 +210,7 @@ OhGinJavascriptFunctionInvocationHelper::InvokeJavascriptMethodFlowbuf( gin::Arguments* args, OhGinJavascriptBridgeObject* object) { if (dispatcher_->IsAsyncMethod(object->object_id(), method_name_)) { - return dispatcher_->InvokeJavascriptMethodAsync(object->object_id(), method_name_, arguments); + return InvokeJavascriptMethod(arguments, error, args, object); } auto flowbufferAdapter = OHOS::NWeb::OhosAdapterHelper::GetInstance().CreateFlowbufferAdapter(); diff --git a/libcef/renderer/render_manager.cc b/libcef/renderer/render_manager.cc index c89f92d3a01749664e88e2e4573ae388ba1c7081..530cebf7751281bd02c100dd256ade85a5b9e2aa 100644 --- a/libcef/renderer/render_manager.cc +++ b/libcef/renderer/render_manager.cc @@ -253,11 +253,8 @@ void CefRenderManager::WebKitInitialized() { } #if BUILDFLAG(IS_OHOS) if (info.is_code_cache_enabled) { - LOG(DEBUG) << "Render manager register the scheme:" - << info.scheme_name.c_str() << " supported code cache."; - blink::SchemeRegistry:: - RegisterURLSchemeAsSupportingCodeCacheWithResponseTime( - String(info.scheme_name)); + LOG(DEBUG) << "Render manager register the scheme:" << info.scheme_name.c_str() << " supported code cache."; + blink::SchemeRegistry::RegisterURLSchemeAsSupportingCodeCacheWithResponseTime(String(info.scheme_name)); } #endif } diff --git a/libcef/resources/cef_strings.grd b/libcef/resources/cef_strings.grd index a3d59a2d79017ca0183266972b72f92f7c4a759b..9d57f771147f94377a0951bf7252677e4bbf0d41 100644 --- a/libcef/resources/cef_strings.grd +++ b/libcef/resources/cef_strings.grd @@ -105,6 +105,11 @@ need to be translated for each locale.--> + + + + + diff --git a/libcef_dll/cpptoc/browser_host_cpptoc.cc b/libcef_dll/cpptoc/browser_host_cpptoc.cc index 905c8ed972be668b5ce2163068abd2ae3005adee..a76b14328a62b54427a7f743ed352b802c9b10b5 100644 --- a/libcef_dll/cpptoc/browser_host_cpptoc.cc +++ b/libcef_dll/cpptoc/browser_host_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=c65f621ede0901406dcd1c82e1bbd1e326e7094f$ +// $hash=92efe881ed6302e2099b2768bd33b9e59cd61b25$ // #include "libcef_dll/cpptoc/browser_host_cpptoc.h" @@ -30,6 +30,7 @@ #include "libcef_dll/ctocpp/java_script_result_callback_ctocpp.h" #include "libcef_dll/ctocpp/navigation_entry_visitor_ctocpp.h" #include "libcef_dll/ctocpp/pdf_print_callback_ctocpp.h" +#include "libcef_dll/ctocpp/pdf_value_callback_ctocpp.h" #include "libcef_dll/ctocpp/precompile_callback_ctocpp.h" #include "libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h" #include "libcef_dll/ctocpp/set_lock_callback_ctocpp.h" @@ -2205,7 +2206,7 @@ browser_host_destroy_all_web_message_ports(struct _cef_browser_host_t* self) { void CEF_CALLBACK browser_host_post_port_message(struct _cef_browser_host_t* self, - cef_string_t* port_handle, + const cef_string_t* port_handle, struct _cef_value_t* message) { shutdown_checker::AssertNotShutdown(); @@ -2236,7 +2237,7 @@ browser_host_post_port_message(struct _cef_browser_host_t* self, void CEF_CALLBACK browser_host_set_port_message_callback(struct _cef_browser_host_t* self, - cef_string_t* port_handle, + const cef_string_t* port_handle, cef_web_message_receiver_t* callback) { shutdown_checker::AssertNotShutdown(); @@ -3118,7 +3119,8 @@ browser_host_get_print_background(struct _cef_browser_host_t* self) { } void CEF_CALLBACK browser_host_set_scrollable(struct _cef_browser_host_t* self, - int enable) { + int enable, + int scrollType) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -3129,7 +3131,8 @@ void CEF_CALLBACK browser_host_set_scrollable(struct _cef_browser_host_t* self, } // Execute - CefBrowserHostCppToC::Get(self)->SetScrollable(enable ? true : false); + CefBrowserHostCppToC::Get(self)->SetScrollable(enable ? true : false, + scrollType); } void CEF_CALLBACK browser_host_start_camera(struct _cef_browser_host_t* self) { @@ -3441,6 +3444,21 @@ browser_host_set_fit_content_mode(struct _cef_browser_host_t* self, int mode) { CefBrowserHostCppToC::Get(self)->SetFitContentMode(mode); } +void CEF_CALLBACK +browser_host_set_native_embed_mode(struct _cef_browser_host_t* self, int flag) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) { + return; + } + + // Execute + CefBrowserHostCppToC::Get(self)->SetNativeEmbedMode(flag ? true : false); +} + void CEF_CALLBACK browser_host_update_draw_rect(struct _cef_browser_host_t* self) { shutdown_checker::AssertNotShutdown(); @@ -3534,11 +3552,10 @@ browser_host_advance_focus_for_ime(struct _cef_browser_host_t* self, } void CEF_CALLBACK -browser_host_on_safe_insets_change(struct _cef_browser_host_t* self, - int left, - int top, - int right, - int bottom) { +browser_host_scroll_to_with_anime(struct _cef_browser_host_t* self, + float x, + float y, + int32_t duration) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -3549,11 +3566,14 @@ browser_host_on_safe_insets_change(struct _cef_browser_host_t* self, } // Execute - CefBrowserHostCppToC::Get(self)->OnSafeInsetsChange(left, top, right, bottom); + CefBrowserHostCppToC::Get(self)->ScrollToWithAnime(x, y, duration); } void CEF_CALLBACK -browser_host_notify_for_next_touch_event(struct _cef_browser_host_t* self) { +browser_host_scroll_by_with_anime(struct _cef_browser_host_t* self, + float delta_x, + float delta_y, + int32_t duration) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -3564,12 +3584,14 @@ browser_host_notify_for_next_touch_event(struct _cef_browser_host_t* self) { } // Execute - CefBrowserHostCppToC::Get(self)->NotifyForNextTouchEvent(); + CefBrowserHostCppToC::Get(self)->ScrollByWithAnime(delta_x, delta_y, + duration); } void CEF_CALLBACK -browser_host_set_grant_file_access_dirs(struct _cef_browser_host_t* self, - cef_string_list_t dir_list) { +browser_host_get_scroll_offset(struct _cef_browser_host_t* self, + float* offset_x, + float* offset_y) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -3578,24 +3600,54 @@ browser_host_set_grant_file_access_dirs(struct _cef_browser_host_t* self, if (!self) { return; } - // Verify param: dir_list; type: string_vec_byref_const - DCHECK(dir_list); - if (!dir_list) { + // Verify param: offset_x; type: simple_byaddr + DCHECK(offset_x); + if (!offset_x) { + return; + } + // Verify param: offset_y; type: simple_byaddr + DCHECK(offset_y); + if (!offset_y) { return; } - // Translate param: dir_list; type: string_vec_byref_const - std::vector dir_listList; - transfer_string_list_contents(dir_list, dir_listList); + // Execute + CefBrowserHostCppToC::Get(self)->GetScrollOffset(offset_x, offset_y); +} + +void CEF_CALLBACK +browser_host_get_over_scroll_offset(struct _cef_browser_host_t* self, + float* offset_x, + float* offset_y) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) { + return; + } + // Verify param: offset_x; type: simple_byaddr + DCHECK(offset_x); + if (!offset_x) { + return; + } + // Verify param: offset_y; type: simple_byaddr + DCHECK(offset_y); + if (!offset_y) { + return; + } // Execute - CefBrowserHostCppToC::Get(self)->SetGrantFileAccessDirs(dir_listList); + CefBrowserHostCppToC::Get(self)->GetOverScrollOffset(offset_x, offset_y); } -void CEF_CALLBACK browser_host_scroll_to_with_anime(struct _cef_browser_host_t* self, - float x, - float y, - int32_t duration) { +void CEF_CALLBACK +browser_host_on_safe_insets_change(struct _cef_browser_host_t* self, + int left, + int top, + int right, + int bottom) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -3606,13 +3658,11 @@ void CEF_CALLBACK browser_host_scroll_to_with_anime(struct _cef_browser_host_t* } // Execute - CefBrowserHostCppToC::Get(self)->ScrollToWithAnime(x, y, duration); + CefBrowserHostCppToC::Get(self)->OnSafeInsetsChange(left, top, right, bottom); } -void CEF_CALLBACK browser_host_scroll_by_with_anime(struct _cef_browser_host_t* self, - float delta_x, - float delta_y, - int32_t duration) { +void CEF_CALLBACK +browser_host_notify_for_next_touch_event(struct _cef_browser_host_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -3623,7 +3673,32 @@ void CEF_CALLBACK browser_host_scroll_by_with_anime(struct _cef_browser_host_t* } // Execute - CefBrowserHostCppToC::Get(self)->ScrollByWithAnime(delta_x, delta_y, duration); + CefBrowserHostCppToC::Get(self)->NotifyForNextTouchEvent(); +} + +void CEF_CALLBACK +browser_host_set_grant_file_access_dirs(struct _cef_browser_host_t* self, + cef_string_list_t dir_list) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) { + return; + } + // Verify param: dir_list; type: string_vec_byref_const + DCHECK(dir_list); + if (!dir_list) { + return; + } + + // Translate param: dir_list; type: string_vec_byref_const + std::vector dir_listList; + transfer_string_list_contents(dir_list, dir_listList); + + // Execute + CefBrowserHostCppToC::Get(self)->SetGrantFileAccessDirs(dir_listList); } void CEF_CALLBACK @@ -3670,8 +3745,8 @@ browser_host_fill_autofill_data(struct _cef_browser_host_t* self, CefValueCppToC::Unwrap(message)); } -void CEF_CALLBACK -browser_host_scroll_focused_editable_node_into_view(struct _cef_browser_host_t* self) { +void CEF_CALLBACK browser_host_scroll_focused_editable_node_into_view( + struct _cef_browser_host_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -3732,6 +3807,60 @@ browser_host_auto_fill_with_imfevent(struct _cef_browser_host_t* self, is_new_password ? true : false, content); } +void CEF_CALLBACK +browser_host_create_to_pdf(struct _cef_browser_host_t* self, + const struct _cef_pdf_print_settings_t* settings, + cef_pdf_value_callback_t* callback) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) { + return; + } + // Verify param: settings; type: struct_byref_const + DCHECK(settings); + if (!settings) { + return; + } + if (!template_util::has_valid_size(settings)) { + DCHECK(false) << "invalid settings->[base.]size"; + return; + } + // Verify param: callback; type: refptr_diff + DCHECK(callback); + if (!callback) { + return; + } + + // Translate param: settings; type: struct_byref_const + CefPdfPrintSettings settingsObj; + if (settings) { + settingsObj.Set(*settings, false); + } + + // Execute + CefBrowserHostCppToC::Get(self)->CreateToPDF( + settingsObj, CefPdfValueCallbackCToCpp::Wrap(callback)); +} + +void CEF_CALLBACK +browser_host_set_popup_window(struct _cef_browser_host_t* self, + cef_native_window_t window) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) { + return; + } + + // Execute + CefBrowserHostCppToC::Get(self)->SetPopupWindow(window); +} + } // namespace // CONSTRUCTOR - Do not edit by hand. @@ -3927,24 +4056,29 @@ CefBrowserHostCppToC::CefBrowserHostCppToC() { GetStruct()->send_touchpad_fling_event = browser_host_send_touchpad_fling_event; GetStruct()->set_fit_content_mode = browser_host_set_fit_content_mode; + GetStruct()->set_native_embed_mode = browser_host_set_native_embed_mode; GetStruct()->update_draw_rect = browser_host_update_draw_rect; GetStruct()->on_text_selected = browser_host_on_text_selected; GetStruct()->get_page_scale_factor = browser_host_get_page_scale_factor; GetStruct()->web_page_snapshot = browser_host_web_page_snapshot; GetStruct()->advance_focus_for_ime = browser_host_advance_focus_for_ime; + GetStruct()->scroll_to_with_anime = browser_host_scroll_to_with_anime; + GetStruct()->scroll_by_with_anime = browser_host_scroll_by_with_anime; + GetStruct()->get_scroll_offset = browser_host_get_scroll_offset; + GetStruct()->get_over_scroll_offset = browser_host_get_over_scroll_offset; GetStruct()->on_safe_insets_change = browser_host_on_safe_insets_change; GetStruct()->notify_for_next_touch_event = browser_host_notify_for_next_touch_event; GetStruct()->set_grant_file_access_dirs = browser_host_set_grant_file_access_dirs; - GetStruct()->scroll_to_with_anime = browser_host_scroll_to_with_anime; - GetStruct()->scroll_by_with_anime = browser_host_scroll_by_with_anime; GetStruct()->set_autofill_callback = browser_host_set_autofill_callback; GetStruct()->fill_autofill_data = browser_host_fill_autofill_data; GetStruct()->scroll_focused_editable_node_into_view = browser_host_scroll_focused_editable_node_into_view; GetStruct()->process_autofill_cancel = browser_host_process_autofill_cancel; GetStruct()->auto_fill_with_imfevent = browser_host_auto_fill_with_imfevent; + GetStruct()->create_to_pdf = browser_host_create_to_pdf; + GetStruct()->set_popup_window = browser_host_set_popup_window; } // DESTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/cpptoc/context_menu_handler_cpptoc.cc b/libcef_dll/cpptoc/context_menu_handler_cpptoc.cc index c02a8b391686170df3a5679e0b47c8657b02bf48..7b91b72059491d693553c6e3741349acd8f55126 100644 --- a/libcef_dll/cpptoc/context_menu_handler_cpptoc.cc +++ b/libcef_dll/cpptoc/context_menu_handler_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=99e06c226ae9d3f395e491860ccc367f9f0f6d84$ +// $hash=712ad34ae5f0261d1701516832b15493b4b3213c$ // #include "libcef_dll/cpptoc/context_menu_handler_cpptoc.h" @@ -196,7 +196,8 @@ int CEF_CALLBACK context_menu_handler_run_quick_menu( const cef_rect_t* select_bounds, cef_quick_menu_edit_state_flags_t edit_state_flags, cef_run_quick_menu_callback_t* callback, - int is_mouse_trigger) { + int is_mouse_trigger, + int is_long_press_actived) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -248,7 +249,8 @@ int CEF_CALLBACK context_menu_handler_run_quick_menu( CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), locationVal, sizeVal, select_boundsVal, edit_state_flags, CefRunQuickMenuCallbackCToCpp::Wrap(callback), - is_mouse_trigger ? true : false); + is_mouse_trigger ? true : false, + is_long_press_actived ? true : false); // Return type: bool return _retval; @@ -427,6 +429,21 @@ void CEF_CALLBACK context_menu_handler_hide_handle_and_quick_menu_if_necessary( hide ? true : false); } +void CEF_CALLBACK context_menu_handler_change_visibility_of_quick_menu( + struct _cef_context_menu_handler_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) { + return; + } + + // Execute + CefContextMenuHandlerCppToC::Get(self)->ChangeVisibilityOfQuickMenu(); +} + } // namespace // CONSTRUCTOR - Do not edit by hand. @@ -452,6 +469,8 @@ CefContextMenuHandlerCppToC::CefContextMenuHandlerCppToC() { context_menu_handler_on_get_image_from_cache; GetStruct()->hide_handle_and_quick_menu_if_necessary = context_menu_handler_hide_handle_and_quick_menu_if_necessary; + GetStruct()->change_visibility_of_quick_menu = + context_menu_handler_change_visibility_of_quick_menu; } // DESTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/cpptoc/cookie_manager_cpptoc.cc b/libcef_dll/cpptoc/cookie_manager_cpptoc.cc index 29b6000bf52813a5ef04e8ee1a1844ab9ba81523..cbaba7d80bfbf59c94887e26b92f8aff8da64e63 100644 --- a/libcef_dll/cpptoc/cookie_manager_cpptoc.cc +++ b/libcef_dll/cpptoc/cookie_manager_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=4b0eca82f55ca385ac508407f7a23a509162fa5e$ +// $hash=264110687f50cf8d451265b7c74c1be904d6c43d$ // #include "libcef_dll/cpptoc/cookie_manager_cpptoc.h" @@ -21,8 +21,8 @@ // GLOBAL FUNCTIONS - Body may be edited by hand. -CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager( - cef_completion_callback_t* callback) { +CEF_EXPORT cef_cookie_manager_t * +cef_cookie_manager_get_global_manager(cef_completion_callback_t *callback) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Unverified params: callback @@ -35,9 +35,9 @@ CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager( return CefCookieManagerCppToC::Wrap(_retval); } -CEF_EXPORT cef_cookie_manager_t* +CEF_EXPORT cef_cookie_manager_t * cef_cookie_manager_get_global_incognito_manager( - cef_completion_callback_t* callback) { + cef_completion_callback_t *callback) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Unverified params: callback @@ -51,10 +51,10 @@ cef_cookie_manager_get_global_incognito_manager( return CefCookieManagerCppToC::Wrap(_retval); } -CEF_EXPORT int cef_cookie_manager_create_cef_cookie( - const cef_string_t* url, - const cef_string_t* value, - struct _cef_cookie_t* cef_cookie) { +CEF_EXPORT int +cef_cookie_manager_create_cef_cookie(const cef_string_t *url, + const cef_string_t *value, + struct _cef_cookie_t *cef_cookie) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Verify param: url; type: string_byref_const @@ -100,10 +100,9 @@ namespace { // MEMBER FUNCTIONS - Body may be edited by hand. -int CEF_CALLBACK -cookie_manager_visit_all_cookies(struct _cef_cookie_manager_t* self, - struct _cef_cookie_visitor_t* visitor, - int is_sync) { +int CEF_CALLBACK cookie_manager_visit_all_cookies( + struct _cef_cookie_manager_t *self, struct _cef_cookie_visitor_t *visitor, + int is_sync) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -124,12 +123,10 @@ cookie_manager_visit_all_cookies(struct _cef_cookie_manager_t* self, return _retval; } -int CEF_CALLBACK -cookie_manager_visit_url_cookies(struct _cef_cookie_manager_t* self, - const cef_string_t* url, - int includeHttpOnly, - struct _cef_cookie_visitor_t* visitor, - int is_sync) { +int CEF_CALLBACK cookie_manager_visit_url_cookies( + struct _cef_cookie_manager_t *self, const cef_string_t *url, + int includeHttpOnly, struct _cef_cookie_visitor_t *visitor, int is_sync, + int is_from_ndk) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -150,19 +147,18 @@ cookie_manager_visit_url_cookies(struct _cef_cookie_manager_t* self, // Execute bool _retval = CefCookieManagerCppToC::Get(self)->VisitUrlCookies( CefString(url), includeHttpOnly ? true : false, - CefCookieVisitorCToCpp::Wrap(visitor), is_sync ? true : false); + CefCookieVisitorCToCpp::Wrap(visitor), is_sync ? true : false, + is_from_ndk ? true : false); // Return type: bool return _retval; } -int CEF_CALLBACK -cookie_manager_set_cookie(struct _cef_cookie_manager_t* self, - const cef_string_t* url, - const struct _cef_cookie_t* cookie, - struct _cef_set_cookie_callback_t* callback, - int is_sync, - const cef_string_t* str_cookie) { +int CEF_CALLBACK cookie_manager_set_cookie( + struct _cef_cookie_manager_t *self, const cef_string_t *url, + const struct _cef_cookie_t *cookie, + struct _cef_set_cookie_callback_t *callback, int is_sync, + const cef_string_t *str_cookie, int includeHttpOnly) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -199,19 +195,17 @@ cookie_manager_set_cookie(struct _cef_cookie_manager_t* self, // Execute bool _retval = CefCookieManagerCppToC::Get(self)->SetCookie( CefString(url), cookieObj, CefSetCookieCallbackCToCpp::Wrap(callback), - is_sync ? true : false, CefString(str_cookie)); + is_sync ? true : false, CefString(str_cookie), + includeHttpOnly ? true : false); // Return type: bool return _retval; } -int CEF_CALLBACK -cookie_manager_delete_cookies(struct _cef_cookie_manager_t* self, - const cef_string_t* url, - const cef_string_t* cookie_name, - int is_session, - struct _cef_delete_cookies_callback_t* callback, - int is_sync) { +int CEF_CALLBACK cookie_manager_delete_cookies( + struct _cef_cookie_manager_t *self, const cef_string_t *url, + const cef_string_t *cookie_name, int is_session, + struct _cef_delete_cookies_callback_t *callback, int is_sync) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -229,9 +223,8 @@ cookie_manager_delete_cookies(struct _cef_cookie_manager_t* self, return _retval; } -int CEF_CALLBACK -cookie_manager_flush_store(struct _cef_cookie_manager_t* self, - cef_completion_callback_t* callback) { +int CEF_CALLBACK cookie_manager_flush_store( + struct _cef_cookie_manager_t *self, cef_completion_callback_t *callback) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -249,7 +242,7 @@ cookie_manager_flush_store(struct _cef_cookie_manager_t* self, } int CEF_CALLBACK -cookie_manager_is_accept_cookie_allowed(struct _cef_cookie_manager_t* self) { +cookie_manager_is_accept_cookie_allowed(struct _cef_cookie_manager_t *self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -264,9 +257,8 @@ cookie_manager_is_accept_cookie_allowed(struct _cef_cookie_manager_t* self) { return _retval; } -void CEF_CALLBACK -cookie_manager_put_accept_cookie_enabled(struct _cef_cookie_manager_t* self, - int accept) { +void CEF_CALLBACK cookie_manager_put_accept_cookie_enabled( + struct _cef_cookie_manager_t *self, int accept) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -280,7 +272,7 @@ cookie_manager_put_accept_cookie_enabled(struct _cef_cookie_manager_t* self, } int CEF_CALLBACK cookie_manager_is_third_party_cookie_allowed( - struct _cef_cookie_manager_t* self) { + struct _cef_cookie_manager_t *self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -296,8 +288,7 @@ int CEF_CALLBACK cookie_manager_is_third_party_cookie_allowed( } void CEF_CALLBACK cookie_manager_put_accept_third_party_cookie_enabled( - struct _cef_cookie_manager_t* self, - int accept) { + struct _cef_cookie_manager_t *self, int accept) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -311,7 +302,7 @@ void CEF_CALLBACK cookie_manager_put_accept_third_party_cookie_enabled( } int CEF_CALLBACK cookie_manager_is_file_urlscheme_cookies_allowed( - struct _cef_cookie_manager_t* self) { + struct _cef_cookie_manager_t *self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -328,8 +319,7 @@ int CEF_CALLBACK cookie_manager_is_file_urlscheme_cookies_allowed( } void CEF_CALLBACK cookie_manager_put_accept_file_urlscheme_cookies_enabled( - struct _cef_cookie_manager_t* self, - int allow) { + struct _cef_cookie_manager_t *self, int allow) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -342,7 +332,7 @@ void CEF_CALLBACK cookie_manager_put_accept_file_urlscheme_cookies_enabled( allow ? true : false); } -} // namespace +} // namespace // CONSTRUCTOR - Do not edit by hand. @@ -371,17 +361,16 @@ CefCookieManagerCppToC::CefCookieManagerCppToC() { CefCookieManagerCppToC::~CefCookieManagerCppToC() {} template <> -CefRefPtr CefCppToCRefCounted< - CefCookieManagerCppToC, - CefCookieManager, - cef_cookie_manager_t>::UnwrapDerived(CefWrapperType type, - cef_cookie_manager_t* s) { +CefRefPtr +CefCppToCRefCounted::UnwrapDerived(CefWrapperType type, + cef_cookie_manager_t + *s) { DCHECK(false) << "Unexpected class type: " << type; return nullptr; } template <> -CefWrapperType CefCppToCRefCounted::kWrapperType = WT_COOKIE_MANAGER; diff --git a/libcef_dll/cpptoc/pdf_value_callback_cpptoc.cc b/libcef_dll/cpptoc/pdf_value_callback_cpptoc.cc new file mode 100644 index 0000000000000000000000000000000000000000..e84a040481b4b980eb0e4da0ce3f004d08f5847d --- /dev/null +++ b/libcef_dll/cpptoc/pdf_value_callback_cpptoc.cc @@ -0,0 +1,72 @@ +// Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// +// $hash=edabed84af7808924725a679be488490d66b6ff4$ +// + +#include "libcef_dll/cpptoc/pdf_value_callback_cpptoc.h" +#include "libcef_dll/shutdown_checker.h" + +namespace { + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK +pdf_value_callback_on_receive_value(struct _cef_pdf_value_callback_t* self, + const char* value, + const long size) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) { + return; + } + // Verify param: value; type: simple_byaddr + DCHECK(value); + if (!value) { + return; + } + + // Execute + CefPdfValueCallbackCppToC::Get(self)->OnReceiveValue(value, size); +} + +} // namespace + +// CONSTRUCTOR - Do not edit by hand. + +CefPdfValueCallbackCppToC::CefPdfValueCallbackCppToC() { + GetStruct()->on_receive_value = pdf_value_callback_on_receive_value; +} + +// DESTRUCTOR - Do not edit by hand. + +CefPdfValueCallbackCppToC::~CefPdfValueCallbackCppToC() { + shutdown_checker::AssertNotShutdown(); +} + +template <> +CefRefPtr CefCppToCRefCounted< + CefPdfValueCallbackCppToC, + CefPdfValueCallback, + cef_pdf_value_callback_t>::UnwrapDerived(CefWrapperType type, + cef_pdf_value_callback_t* s) { + DCHECK(false) << "Unexpected class type: " << type; + return nullptr; +} + +template <> +CefWrapperType CefCppToCRefCounted::kWrapperType = + WT_PDF_VALUE_CALLBACK; \ No newline at end of file diff --git a/libcef_dll/cpptoc/pdf_value_callback_cpptoc.h b/libcef_dll/cpptoc/pdf_value_callback_cpptoc.h new file mode 100644 index 0000000000000000000000000000000000000000..eedfd8d7823173e0e8349c63ee1b3080c147803d --- /dev/null +++ b/libcef_dll/cpptoc/pdf_value_callback_cpptoc.h @@ -0,0 +1,40 @@ +// Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// +// $hash=12de2bf400957fe8a178d467940fab42b8f51788$ +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_PDF_VALUE_CALLBACK_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_PDF_VALUE_CALLBACK_CPPTOC_H_ +#pragma once + +#if !defined(WRAPPING_CEF_SHARED) +#error This file can be included wrapper-side only +#endif + +#include "include/capi/cef_browser_capi.h" +#include "include/capi/cef_client_capi.h" +#include "include/cef_browser.h" +#include "include/cef_client.h" +#include "libcef_dll/cpptoc/cpptoc_ref_counted.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefPdfValueCallbackCppToC + : public CefCppToCRefCounted { + public: + CefPdfValueCallbackCppToC(); + virtual ~CefPdfValueCallbackCppToC(); +}; + +#endif // CEF_LIBCEF_DLL_CPPTOC_PDF_VALUE_CALLBACK_CPPTOC_H_ \ No newline at end of file diff --git a/libcef_dll/cpptoc/render_handler_cpptoc.cc b/libcef_dll/cpptoc/render_handler_cpptoc.cc index 9afcea4a7fbb223b883890a75c3f882d9ca1af26..caf29d25bf43d62d4893c6db6adccbf74f007f85 100644 --- a/libcef_dll/cpptoc/render_handler_cpptoc.cc +++ b/libcef_dll/cpptoc/render_handler_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=b1d7d47349a7b507f118dad1960b2f6fab6eb280$ +// $hash=20b366e5920d32479114e6a5d57f5eae0deeb7d6$ // #include "libcef_dll/cpptoc/render_handler_cpptoc.h" @@ -1092,9 +1092,12 @@ void CEF_CALLBACK render_handler_on_update_text_input_state_called( compositon_rangeVal); } -void CEF_CALLBACK render_handler_get_word_selection( - struct _cef_render_handler_t *self, cef_browser_t *browser, - const cef_string_t *text, int8_t offset, cef_point_t *select) { +void CEF_CALLBACK +render_handler_get_word_selection(struct _cef_render_handler_t* self, + cef_browser_t* browser, + const cef_string_t* text, + int8_t offset, + cef_point_t* select) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -1257,7 +1260,7 @@ void CEF_CALLBACK render_handler_send_dynamic_frame_loss_event(struct _cef_render_handler_t* self, cef_browser_t* browser, const cef_string_t* sceneId, - bool isStart) { + int isStart) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -1271,7 +1274,7 @@ render_handler_send_dynamic_frame_loss_event(struct _cef_render_handler_t* self, if (!browser) { return; } - // Verify param: cef_screen_rect; type: simple_byref_const + // Verify param: sceneId; type: string_byref_const DCHECK(sceneId); if (!sceneId) { return; @@ -1279,7 +1282,8 @@ render_handler_send_dynamic_frame_loss_event(struct _cef_render_handler_t* self, // Execute CefRenderHandlerCppToC::Get(self)->SendDynamicFrameLossEvent( - CefBrowserCToCpp::Wrap(browser), CefString(sceneId), isStart); + CefBrowserCToCpp::Wrap(browser), CefString(sceneId), + isStart ? true : false); } void CEF_CALLBACK @@ -1325,6 +1329,80 @@ render_handler_set_fill_content(struct _cef_render_handler_t* self, CefRenderHandlerCppToC::Get(self)->SetFillContent(content); } +void CEF_CALLBACK +render_handler_set_gesture_event_result(struct _cef_render_handler_t* self, + const int result) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) { + return; + } + + // Execute + CefRenderHandlerCppToC::Get(self)->SetGestureEventResult(result ? true + : false); +} + +void CEF_CALLBACK +render_handler_start_vibra_feedback(struct _cef_render_handler_t* self, + const char* vibratorType) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) { + return; + } + // Verify param: vibratorType; type: std_string_byref_const + DCHECK(vibratorType); + if (!vibratorType) { + return; + } + + // Execute + CefRenderHandlerCppToC::Get(self)->StartVibraFeedback(vibratorType); +} + +void CEF_CALLBACK +render_handler_get_device_pixel_size(struct _cef_render_handler_t* self, + cef_browser_t* browser, + cef_size_t* size) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) { + return; + } + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) { + return; + } + // Verify param: size; type: simple_byref + DCHECK(size); + if (!size) { + return; + } + + // Translate param: size; type: simple_byref + CefSize sizeVal = size ? *size : CefSize(); + + // Execute + CefRenderHandlerCppToC::Get(self)->GetDevicePixelSize( + CefBrowserCToCpp::Wrap(browser), sizeVal); + + // Restore param: size; type: simple_byref + if (size) { + *size = sizeVal; + } +} + } // namespace // CONSTRUCTOR - Do not edit by hand. @@ -1389,6 +1467,10 @@ CefRenderHandlerCppToC::CefRenderHandlerCppToC() { GetStruct()->on_resize_scrollable_viewport = render_handler_on_resize_scrollable_viewport; GetStruct()->set_fill_content = render_handler_set_fill_content; + GetStruct()->set_gesture_event_result = + render_handler_set_gesture_event_result; + GetStruct()->start_vibra_feedback = render_handler_start_vibra_feedback; + GetStruct()->get_device_pixel_size = render_handler_get_device_pixel_size; } // DESTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/cpptoc/web_message_receiver_cpptoc.cc b/libcef_dll/cpptoc/web_message_receiver_cpptoc.cc index 678b7af4460df8a7cf3b2d8844a18bf92978b58f..e9f2af6f0cf2360c569274a6578afb520344ef31 100644 --- a/libcef_dll/cpptoc/web_message_receiver_cpptoc.cc +++ b/libcef_dll/cpptoc/web_message_receiver_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=ec39ac275cf279faf1056b8ec45fc17031663a0e$ +// $hash=3c8ad723d8efd0975398aa07f0f08171104fbe86$ // #include "libcef_dll/cpptoc/web_message_receiver_cpptoc.h" @@ -42,12 +42,40 @@ web_message_receiver_on_message(struct _cef_web_message_receiver_t* self, CefValueCToCpp::Wrap(message)); } +int CEF_CALLBACK web_message_receiver_on_message_with_bool_result( + struct _cef_web_message_receiver_t* self, + struct _cef_value_t* message) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) { + return 0; + } + // Verify param: message; type: refptr_diff + DCHECK(message); + if (!message) { + return 0; + } + + // Execute + bool _retval = + CefWebMessageReceiverCppToC::Get(self)->OnMessageWithBoolResult( + CefValueCToCpp::Wrap(message)); + + // Return type: bool + return _retval; +} + } // namespace // CONSTRUCTOR - Do not edit by hand. CefWebMessageReceiverCppToC::CefWebMessageReceiverCppToC() { GetStruct()->on_message = web_message_receiver_on_message; + GetStruct()->on_message_with_bool_result = + web_message_receiver_on_message_with_bool_result; } // DESTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/ctocpp/browser_ctocpp.cc b/libcef_dll/ctocpp/browser_ctocpp.cc index 1ad8ead6f2c50b7d99927f12e6085c5c4e819160..7e08a3669dfbbabd83fdf1271b676479a53b7ad1 100644 --- a/libcef_dll/ctocpp/browser_ctocpp.cc +++ b/libcef_dll/ctocpp/browser_ctocpp.cc @@ -9,24 +9,24 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=e4857340f5dbf8d395dc910816182a61f1b4658c$ +// $hash=359bac132f6ec31b8d06616809e23cec83a19688$ // #include "libcef_dll/ctocpp/browser_ctocpp.h" +#include #include "libcef_dll/ctocpp/browser_host_ctocpp.h" #include "libcef_dll/ctocpp/browser_permission_request_delegate_ctocpp.h" #include "libcef_dll/ctocpp/frame_ctocpp.h" #include "libcef_dll/ctocpp/geolocation_acess_ctocpp.h" #include "libcef_dll/shutdown_checker.h" #include "libcef_dll/transfer_util.h" -#include // VIRTUAL METHODS - Body may be edited by hand. NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::IsValid() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, is_valid)) { return false; } @@ -43,7 +43,7 @@ NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::IsValid() { NO_SANITIZE("cfi-icall") CefRefPtr CefBrowserCToCpp::GetHost() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_host)) { return nullptr; } @@ -51,7 +51,7 @@ NO_SANITIZE("cfi-icall") CefRefPtr CefBrowserCToCpp::GetHost() { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Execute - cef_browser_host_t *_retval = _struct->get_host(_struct); + cef_browser_host_t* _retval = _struct->get_host(_struct); // Return type: refptr_same return CefBrowserHostCToCpp::Wrap(_retval); @@ -60,7 +60,7 @@ NO_SANITIZE("cfi-icall") CefRefPtr CefBrowserCToCpp::GetHost() { NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::CanGoBack() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, can_go_back)) { return false; } @@ -77,7 +77,7 @@ NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::CanGoBack() { NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::GoBack() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, go_back)) { return; } @@ -91,7 +91,7 @@ NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::GoBack() { NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::CanGoForward() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, can_go_forward)) { return false; } @@ -108,7 +108,7 @@ NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::CanGoForward() { NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::GoForward() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, go_forward)) { return; } @@ -122,7 +122,7 @@ NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::GoForward() { NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::IsLoading() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, is_loading)) { return false; } @@ -139,7 +139,7 @@ NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::IsLoading() { NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::Reload() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, reload)) { return; } @@ -153,7 +153,7 @@ NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::Reload() { NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::ReloadIgnoreCache() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, reload_ignore_cache)) { return; } @@ -167,7 +167,7 @@ NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::ReloadIgnoreCache() { NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::StopLoad() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, stop_load)) { return; } @@ -181,7 +181,7 @@ NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::StopLoad() { NO_SANITIZE("cfi-icall") int CefBrowserCToCpp::GetIdentifier() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_identifier)) { return 0; } @@ -199,7 +199,7 @@ NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::IsSame(CefRefPtr that) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, is_same)) { return false; } @@ -222,7 +222,7 @@ bool CefBrowserCToCpp::IsSame(CefRefPtr that) { NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::IsPopup() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, is_popup)) { return false; } @@ -239,7 +239,7 @@ NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::IsPopup() { NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::HasDocument() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, has_document)) { return false; } @@ -256,7 +256,7 @@ NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::HasDocument() { NO_SANITIZE("cfi-icall") CefRefPtr CefBrowserCToCpp::GetMainFrame() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_main_frame)) { return nullptr; } @@ -264,7 +264,7 @@ NO_SANITIZE("cfi-icall") CefRefPtr CefBrowserCToCpp::GetMainFrame() { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Execute - cef_frame_t *_retval = _struct->get_main_frame(_struct); + cef_frame_t* _retval = _struct->get_main_frame(_struct); // Return type: refptr_same return CefFrameCToCpp::Wrap(_retval); @@ -274,7 +274,7 @@ NO_SANITIZE("cfi-icall") CefRefPtr CefBrowserCToCpp::GetFocusedFrame() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_focused_frame)) { return nullptr; } @@ -282,7 +282,7 @@ CefRefPtr CefBrowserCToCpp::GetFocusedFrame() { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Execute - cef_frame_t *_retval = _struct->get_focused_frame(_struct); + cef_frame_t* _retval = _struct->get_focused_frame(_struct); // Return type: refptr_same return CefFrameCToCpp::Wrap(_retval); @@ -292,7 +292,7 @@ NO_SANITIZE("cfi-icall") CefRefPtr CefBrowserCToCpp::GetFrame(int64 identifier) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_frame_byident)) { return nullptr; } @@ -300,17 +300,17 @@ CefRefPtr CefBrowserCToCpp::GetFrame(int64 identifier) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Execute - cef_frame_t *_retval = _struct->get_frame_byident(_struct, identifier); + cef_frame_t* _retval = _struct->get_frame_byident(_struct, identifier); // Return type: refptr_same return CefFrameCToCpp::Wrap(_retval); } NO_SANITIZE("cfi-icall") -CefRefPtr CefBrowserCToCpp::GetFrame(const CefString &name) { +CefRefPtr CefBrowserCToCpp::GetFrame(const CefString& name) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_frame)) { return nullptr; } @@ -320,7 +320,7 @@ CefRefPtr CefBrowserCToCpp::GetFrame(const CefString &name) { // Unverified params: name // Execute - cef_frame_t *_retval = _struct->get_frame(_struct, name.GetStruct()); + cef_frame_t* _retval = _struct->get_frame(_struct, name.GetStruct()); // Return type: refptr_same return CefFrameCToCpp::Wrap(_retval); @@ -329,7 +329,7 @@ CefRefPtr CefBrowserCToCpp::GetFrame(const CefString &name) { NO_SANITIZE("cfi-icall") size_t CefBrowserCToCpp::GetFrameCount() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_frame_count)) { return 0; } @@ -344,10 +344,10 @@ NO_SANITIZE("cfi-icall") size_t CefBrowserCToCpp::GetFrameCount() { } NO_SANITIZE("cfi-icall") -void CefBrowserCToCpp::GetFrameIdentifiers(std::vector &identifiers) { +void CefBrowserCToCpp::GetFrameIdentifiers(std::vector& identifiers) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_frame_identifiers)) { return; } @@ -357,7 +357,7 @@ void CefBrowserCToCpp::GetFrameIdentifiers(std::vector &identifiers) { // Translate param: identifiers; type: simple_vec_byref size_t identifiersSize = identifiers.size(); size_t identifiersCount = std::max(GetFrameCount(), identifiersSize); - int64 *identifiersList = NULL; + int64* identifiersList = NULL; if (identifiersCount > 0) { identifiersList = new int64[identifiersCount]; DCHECK(identifiersList); @@ -385,10 +385,10 @@ void CefBrowserCToCpp::GetFrameIdentifiers(std::vector &identifiers) { } NO_SANITIZE("cfi-icall") -void CefBrowserCToCpp::GetFrameNames(std::vector &names) { +void CefBrowserCToCpp::GetFrameNames(std::vector& names) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_frame_names)) { return; } @@ -418,7 +418,7 @@ CefRefPtr CefBrowserCToCpp:: GetPermissionRequestDelegate() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_permission_request_delegate)) { return nullptr; } @@ -426,7 +426,7 @@ CefRefPtr CefBrowserCToCpp:: // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Execute - cef_browser_permission_request_delegate_t *_retval = + cef_browser_permission_request_delegate_t* _retval = _struct->get_permission_request_delegate(_struct); // Return type: refptr_same @@ -437,7 +437,7 @@ NO_SANITIZE("cfi-icall") CefRefPtr CefBrowserCToCpp::GetGeolocationPermissions() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_geolocation_permissions)) { return nullptr; } @@ -445,7 +445,7 @@ CefRefPtr CefBrowserCToCpp::GetGeolocationPermissions() { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Execute - cef_geolocation_acess_t *_retval = + cef_geolocation_acess_t* _retval = _struct->get_geolocation_permissions(_struct); // Return type: refptr_same @@ -456,7 +456,7 @@ NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::CanGoBackOrForward(int num_steps) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, can_go_back_or_forward)) { return false; } @@ -473,7 +473,7 @@ bool CefBrowserCToCpp::CanGoBackOrForward(int num_steps) { NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::GoBackOrForward(int num_steps) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, go_back_or_forward)) { return; } @@ -487,7 +487,7 @@ NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::GoBackOrForward(int num_steps) { NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::DeleteHistory() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, delete_history)) { return; } @@ -501,7 +501,7 @@ NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::DeleteHistory() { NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::SelectAndCopy() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, select_and_copy)) { return; } @@ -515,7 +515,7 @@ NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::SelectAndCopy() { NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::ShouldShowFreeCopy() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, should_show_free_copy)) { return false; } @@ -533,7 +533,7 @@ NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::PasswordSuggestionSelected(int list_index) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, password_suggestion_selected)) { return; } @@ -545,11 +545,12 @@ void CefBrowserCToCpp::PasswordSuggestionSelected(int list_index) { } NO_SANITIZE("cfi-icall") -void CefBrowserCToCpp::UpdateBrowserControlsState(int constraints, int current, +void CefBrowserCToCpp::UpdateBrowserControlsState(int constraints, + int current, bool animate) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, update_browser_controls_state)) { return; } @@ -565,7 +566,7 @@ NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::UpdateBrowserControlsHeight(int height, bool animate) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, update_browser_controls_height)) { return; } @@ -577,11 +578,11 @@ void CefBrowserCToCpp::UpdateBrowserControlsHeight(int height, bool animate) { } NO_SANITIZE("cfi-icall") -void CefBrowserCToCpp::PrefetchPage(CefString &url, - CefString &additionalHttpHeaders) { +void CefBrowserCToCpp::PrefetchPage(CefString& url, + CefString& additionalHttpHeaders) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, prefetch_page)) { return; } @@ -596,7 +597,7 @@ void CefBrowserCToCpp::PrefetchPage(CefString &url, NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::ReloadOriginalUrl() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, reload_original_url)) { return; } @@ -610,7 +611,7 @@ NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::ReloadOriginalUrl() { NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::CanStoreWebArchive() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, can_store_web_archive)) { return false; } @@ -625,10 +626,10 @@ NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::CanStoreWebArchive() { } NO_SANITIZE("cfi-icall") -void CefBrowserCToCpp::SetBrowserUserAgentString(const CefString &user_agent) { +void CefBrowserCToCpp::SetBrowserUserAgentString(const CefString& user_agent) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, set_browser_user_agent_string)) { return; } @@ -648,7 +649,7 @@ void CefBrowserCToCpp::SetBrowserUserAgentString(const CefString &user_agent) { NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::ShouldShowLoadingUI() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, should_show_loading_ui)) { return false; } @@ -666,7 +667,7 @@ NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::SetForceEnableZoom(bool forceEnableZoom) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, set_force_enable_zoom)) { return; } @@ -680,7 +681,7 @@ void CefBrowserCToCpp::SetForceEnableZoom(bool forceEnableZoom) { NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::GetForceEnableZoom() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_force_enable_zoom)) { return false; } @@ -697,7 +698,7 @@ NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::GetForceEnableZoom() { NO_SANITIZE("cfi-icall") int CefBrowserCToCpp::GetNWebId() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_nweb_id)) { return 0; } @@ -716,7 +717,7 @@ void CefBrowserCToCpp::SetEnableBlankTargetPopupIntercept( bool enableBlankTargetPopup) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, set_enable_blank_target_popup_intercept)) { return; } @@ -731,7 +732,7 @@ void CefBrowserCToCpp::SetEnableBlankTargetPopupIntercept( NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::GetSavePasswordAutomatically() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_save_password_automatically)) { return false; } @@ -749,7 +750,7 @@ NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::SetSavePasswordAutomatically(bool enable) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, set_save_password_automatically)) { return; } @@ -764,7 +765,7 @@ NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::SaveOrUpdatePassword(bool is_update) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, save_or_update_password)) { return; } @@ -778,7 +779,7 @@ void CefBrowserCToCpp::SaveOrUpdatePassword(bool is_update) { NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::GetSavePassword() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_save_password)) { return false; } @@ -795,7 +796,7 @@ NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::GetSavePassword() { NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::SetSavePassword(bool enable) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, set_save_password)) { return; } @@ -809,7 +810,7 @@ NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::SetSavePassword(bool enable) { NO_SANITIZE("cfi-icall") int CefBrowserCToCpp::GetSecurityLevel() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_security_level)) { return 0; } @@ -827,7 +828,7 @@ NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::EnableSafeBrowsing(bool enable) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, enable_safe_browsing)) { return; } @@ -841,7 +842,7 @@ void CefBrowserCToCpp::EnableSafeBrowsing(bool enable) { NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::IsSafeBrowsingEnabled() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, is_safe_browsing_enabled)) { return false; } @@ -859,7 +860,7 @@ NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::EnableIntelligentTrackingPrevention(bool enable) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, enable_intelligent_tracking_prevention)) { return; } @@ -874,7 +875,7 @@ NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::IsIntelligentTrackingPreventionEnabled() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, is_intelligent_tracking_prevention_enabled)) { return false; } @@ -891,7 +892,7 @@ bool CefBrowserCToCpp::IsIntelligentTrackingPreventionEnabled() { NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::IsAdsBlockEnabled() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, is_ads_block_enabled)) { return false; } @@ -908,7 +909,7 @@ NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::IsAdsBlockEnabled() { NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::IsAdsBlockEnabledForCurPage() { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, is_ads_block_enabled_for_cur_page)) { return false; } @@ -925,7 +926,7 @@ NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::IsAdsBlockEnabledForCurPage() { NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::EnableAdsBlock(bool enable) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, enable_ads_block)) { return; } @@ -937,11 +938,19 @@ NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::EnableAdsBlock(bool enable) { } NO_SANITIZE("cfi-icall") -int CefBrowserCToCpp::SetUrlTrustListWithErrMsg(const CefString &urlTrustList, - CefString &detailErrMsg) { +int CefBrowserCToCpp::SetUrlTrustListWithErrMsg(const CefString& urlTrustList, + CefString& detailErrMsg) { +// WARNING - CHANGED ATTRIBUTES +// REMOVED: CefString &detailErrMsg +// REMOVED: const CefString &urlTrustList +// ADDED: const CefString& urlTrustList +// ADDED: CefString& detailErrMsg +#pragma message("Warning: " __FILE__ \ + ": SetUrlTrustListWithErrMsg prototype has changed") + shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, set_url_trust_list_with_err_msg)) { return -1; } @@ -956,7 +965,7 @@ void CefBrowserCToCpp::SetBackForwardCacheOptions(int32_t size, int32_t timeToLive) { shutdown_checker::AssertNotShutdown(); - cef_browser_t *_struct = GetStruct(); + cef_browser_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, set_back_forward_cache_options)) { return; } @@ -973,16 +982,20 @@ CefBrowserCToCpp::CefBrowserCToCpp() {} // DESTRUCTOR - Do not edit by hand. -CefBrowserCToCpp::~CefBrowserCToCpp() { shutdown_checker::AssertNotShutdown(); } +CefBrowserCToCpp::~CefBrowserCToCpp() { + shutdown_checker::AssertNotShutdown(); +} template <> -cef_browser_t * +cef_browser_t* CefCToCppRefCounted::UnwrapDerived( - CefWrapperType type, CefBrowser *c) { + CefWrapperType type, + CefBrowser* c) { DCHECK(false) << "Unexpected class type: " << type; return nullptr; } template <> -CefWrapperType CefCToCppRefCounted::kWrapperType = WT_BROWSER; \ No newline at end of file +CefWrapperType CefCToCppRefCounted::kWrapperType = WT_BROWSER; diff --git a/libcef_dll/ctocpp/browser_host_ctocpp.cc b/libcef_dll/ctocpp/browser_host_ctocpp.cc index 4df5e340dfe1ce4fb39b2194201acb2b168f1754..179d7a4e2e7b56f2a7d1489847561be33c24a7a2 100644 --- a/libcef_dll/ctocpp/browser_host_ctocpp.cc +++ b/libcef_dll/ctocpp/browser_host_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=8e01fb9e7e62314e7a74e50edbe9ddbc210914b9$ +// $hash=223c76e1d9f6cdf0e9620d77d091626920516617$ // #include "libcef_dll/ctocpp/browser_host_ctocpp.h" @@ -19,6 +19,7 @@ #include "libcef_dll/cpptoc/java_script_result_callback_cpptoc.h" #include "libcef_dll/cpptoc/navigation_entry_visitor_cpptoc.h" #include "libcef_dll/cpptoc/pdf_print_callback_cpptoc.h" +#include "libcef_dll/cpptoc/pdf_value_callback_cpptoc.h" #include "libcef_dll/cpptoc/precompile_callback_cpptoc.h" #include "libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h" #include "libcef_dll/cpptoc/set_lock_callback_cpptoc.h" @@ -1975,7 +1976,7 @@ void CefBrowserHostCToCpp::DestroyAllWebMessagePorts() { } NO_SANITIZE("cfi-icall") -void CefBrowserHostCToCpp::PostPortMessage(CefString& port_handle, +void CefBrowserHostCToCpp::PostPortMessage(const CefString& port_handle, CefRefPtr message) { shutdown_checker::AssertNotShutdown(); @@ -1993,13 +1994,13 @@ void CefBrowserHostCToCpp::PostPortMessage(CefString& port_handle, } // Execute - _struct->post_port_message(_struct, port_handle.GetWritableStruct(), + _struct->post_port_message(_struct, port_handle.GetStruct(), CefValueCToCpp::Unwrap(message)); } NO_SANITIZE("cfi-icall") void CefBrowserHostCToCpp::SetPortMessageCallback( - CefString& port_handle, + const CefString& port_handle, CefRefPtr callback) { shutdown_checker::AssertNotShutdown(); @@ -2018,7 +2019,7 @@ void CefBrowserHostCToCpp::SetPortMessageCallback( // Execute _struct->set_port_message_callback( - _struct, port_handle.GetWritableStruct(), + _struct, port_handle.GetStruct(), CefWebMessageReceiverCppToC::Wrap(callback)); } @@ -2841,7 +2842,8 @@ NO_SANITIZE("cfi-icall") bool CefBrowserHostCToCpp::GetPrintBackground() { return _retval ? true : false; } -NO_SANITIZE("cfi-icall") void CefBrowserHostCToCpp::SetScrollable(bool enable) { +NO_SANITIZE("cfi-icall") +void CefBrowserHostCToCpp::SetScrollable(bool enable, int scrollType) { shutdown_checker::AssertNotShutdown(); cef_browser_host_t* _struct = GetStruct(); @@ -2852,7 +2854,7 @@ NO_SANITIZE("cfi-icall") void CefBrowserHostCToCpp::SetScrollable(bool enable) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Execute - _struct->set_scrollable(_struct, enable); + _struct->set_scrollable(_struct, enable, scrollType); } NO_SANITIZE("cfi-icall") void CefBrowserHostCToCpp::StartCamera() { @@ -3157,6 +3159,21 @@ void CefBrowserHostCToCpp::SetFitContentMode(int mode) { _struct->set_fit_content_mode(_struct, mode); } +NO_SANITIZE("cfi-icall") +void CefBrowserHostCToCpp::SetNativeEmbedMode(bool flag) { + shutdown_checker::AssertNotShutdown(); + + cef_browser_host_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_native_embed_mode)) { + return; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_native_embed_mode(_struct, flag); +} + NO_SANITIZE("cfi-icall") void CefBrowserHostCToCpp::UpdateDrawRect() { shutdown_checker::AssertNotShutdown(); @@ -3247,93 +3264,150 @@ void CefBrowserHostCToCpp::AdvanceFocusForIME(int focusType) { } NO_SANITIZE("cfi-icall") -void CefBrowserHostCToCpp::OnSafeInsetsChange(int left, - int top, - int right, - int bottom) { +void CefBrowserHostCToCpp::ScrollToWithAnime(float x, + float y, + int32_t duration) { shutdown_checker::AssertNotShutdown(); cef_browser_host_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, on_safe_insets_change)) { + if (CEF_MEMBER_MISSING(_struct, scroll_to_with_anime)) { return; } // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Execute - _struct->on_safe_insets_change(_struct, left, top, right, bottom); + _struct->scroll_to_with_anime(_struct, x, y, duration); } -NO_SANITIZE("cfi-icall") void CefBrowserHostCToCpp::NotifyForNextTouchEvent() { +NO_SANITIZE("cfi-icall") +void CefBrowserHostCToCpp::ScrollByWithAnime(float delta_x, + float delta_y, + int32_t duration) { shutdown_checker::AssertNotShutdown(); cef_browser_host_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, notify_for_next_touch_event)) { + if (CEF_MEMBER_MISSING(_struct, scroll_by_with_anime)) { return; } // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Execute - _struct->notify_for_next_touch_event(_struct); + _struct->scroll_by_with_anime(_struct, delta_x, delta_y, duration); } NO_SANITIZE("cfi-icall") -void CefBrowserHostCToCpp::SetGrantFileAccessDirs( - const std::vector& dir_list) { +void CefBrowserHostCToCpp::GetScrollOffset(float* offset_x, float* offset_y) { shutdown_checker::AssertNotShutdown(); cef_browser_host_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, set_grant_file_access_dirs)) { + if (CEF_MEMBER_MISSING(_struct, get_scroll_offset)) { return; } // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Translate param: dir_list; type: string_vec_byref_const - cef_string_list_t dir_listList = cef_string_list_alloc(); - DCHECK(dir_listList); - if (dir_listList) { - transfer_string_list_contents(dir_list, dir_listList); + // Verify param: offset_x; type: simple_byaddr + DCHECK(offset_x); + if (!offset_x) { + return; + } + // Verify param: offset_y; type: simple_byaddr + DCHECK(offset_y); + if (!offset_y) { + return; } // Execute - _struct->set_grant_file_access_dirs(_struct, dir_listList); + _struct->get_scroll_offset(_struct, offset_x, offset_y); +} - // Restore param:dir_list; type: string_vec_byref_const - if (dir_listList) { - cef_string_list_free(dir_listList); +NO_SANITIZE("cfi-icall") +void CefBrowserHostCToCpp::GetOverScrollOffset(float* offset_x, + float* offset_y) { + shutdown_checker::AssertNotShutdown(); + + cef_browser_host_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_over_scroll_offset)) { + return; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: offset_x; type: simple_byaddr + DCHECK(offset_x); + if (!offset_x) { + return; + } + // Verify param: offset_y; type: simple_byaddr + DCHECK(offset_y); + if (!offset_y) { + return; } + + // Execute + _struct->get_over_scroll_offset(_struct, offset_x, offset_y); } -NO_SANITIZE("cfi-icall") -void CefBrowserHostCToCpp::ScrollToWithAnime(float x, float y, int32_t duration) { +NO_SANITIZE("cfi-icall") +void CefBrowserHostCToCpp::OnSafeInsetsChange(int left, + int top, + int right, + int bottom) { shutdown_checker::AssertNotShutdown(); cef_browser_host_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, scroll_to)) { + if (CEF_MEMBER_MISSING(_struct, on_safe_insets_change)) { return; } // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Execute - _struct->scroll_to_with_anime(_struct, x, y, duration); + _struct->on_safe_insets_change(_struct, left, top, right, bottom); +} + +NO_SANITIZE("cfi-icall") void CefBrowserHostCToCpp::NotifyForNextTouchEvent() { + shutdown_checker::AssertNotShutdown(); + + cef_browser_host_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, notify_for_next_touch_event)) { + return; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->notify_for_next_touch_event(_struct); } NO_SANITIZE("cfi-icall") -void CefBrowserHostCToCpp::ScrollByWithAnime(float delta_x, float delta_y, int32_t duration) { +void CefBrowserHostCToCpp::SetGrantFileAccessDirs( + const std::vector& dir_list) { shutdown_checker::AssertNotShutdown(); cef_browser_host_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, scroll_by)) { + if (CEF_MEMBER_MISSING(_struct, set_grant_file_access_dirs)) { return; } // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + // Translate param: dir_list; type: string_vec_byref_const + cef_string_list_t dir_listList = cef_string_list_alloc(); + DCHECK(dir_listList); + if (dir_listList) { + transfer_string_list_contents(dir_list, dir_listList); + } + // Execute - _struct->scroll_by_with_anime(_struct, delta_x, delta_y, duration); + _struct->set_grant_file_access_dirs(_struct, dir_listList); + + // Restore param:dir_list; type: string_vec_byref_const + if (dir_listList) { + cef_string_list_free(dir_listList); + } } NO_SANITIZE("cfi-icall") @@ -3342,7 +3416,7 @@ void CefBrowserHostCToCpp::SetAutofillCallback( shutdown_checker::AssertNotShutdown(); cef_browser_host_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, set_grant_file_access_dirs)) { + if (CEF_MEMBER_MISSING(_struct, set_autofill_callback)) { return; } @@ -3364,7 +3438,7 @@ void CefBrowserHostCToCpp::FillAutofillData(CefRefPtr message) { shutdown_checker::AssertNotShutdown(); cef_browser_host_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, set_grant_file_access_dirs)) { + if (CEF_MEMBER_MISSING(_struct, fill_autofill_data)) { return; } @@ -3442,6 +3516,45 @@ void CefBrowserHostCToCpp::AutoFillWithIMFEvent(bool is_username, is_new_password, content.c_str()); } +NO_SANITIZE("cfi-icall") +void CefBrowserHostCToCpp::CreateToPDF( + const CefPdfPrintSettings& settings, + CefRefPtr callback) { + shutdown_checker::AssertNotShutdown(); + + cef_browser_host_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, create_to_pdf)) { + return; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: callback; type: refptr_diff + DCHECK(callback.get()); + if (!callback.get()) { + return; + } + + // Execute + _struct->create_to_pdf(_struct, &settings, + CefPdfValueCallbackCppToC::Wrap(callback)); +} + +NO_SANITIZE("cfi-icall") +void CefBrowserHostCToCpp::SetPopupWindow(cef_native_window_t window) { + shutdown_checker::AssertNotShutdown(); + + cef_browser_host_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_popup_window)) { + return; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_popup_window(_struct, window); +} + // CONSTRUCTOR - Do not edit by hand. CefBrowserHostCToCpp::CefBrowserHostCToCpp() {} diff --git a/libcef_dll/ctocpp/browser_host_ctocpp.h b/libcef_dll/ctocpp/browser_host_ctocpp.h index 8af01f4d5a637664ea6e17e0c4b93a70455a568c..7b653d620b12c61aff1f7d1faff2f006d38e908a 100644 --- a/libcef_dll/ctocpp/browser_host_ctocpp.h +++ b/libcef_dll/ctocpp/browser_host_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=1226c94fcbb06fb654cc597f5cd6793951cef504$ +// $hash=2d8db2d91b19b596ac6cb2045ba01b41769d85d1$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_ @@ -189,10 +189,10 @@ class CefBrowserHostCToCpp : public CefCToCppRefCounted message) override; void SetPortMessageCallback( - CefString& port_handle, + const CefString& port_handle, CefRefPtr callback) override; void GetHitData(int& type, CefString& extra_data) override; void SetInitialScale(float scale) override; @@ -247,6 +247,7 @@ class CefBrowserHostCToCpp : public CefCToCppRefCounted& script_rules) override; void RemoveJavaScriptOnDocumentEnd() override; + void SetNativeEmbedMode(bool flag) override; void SetDrawRect(int x, int y, int width, int height) override; void SetDrawMode(int mode) override; void CreateWebPrintDocumentAdapter(const CefString& jobName, @@ -259,7 +260,7 @@ class CefBrowserHostCToCpp : public CefCToCppRefCounted& dir_list) override; - void ScrollToWithAnime(float x, float y, int32_t duration) override; - void ScrollByWithAnime(float delta_x, float delta_y, int32_t duration) override; void SetAutofillCallback(CefRefPtr callback) override; void FillAutofillData(CefRefPtr message) override; void ScrollFocusedEditableNodeIntoView() override; @@ -306,6 +311,9 @@ class CefBrowserHostCToCpp : public CefCToCppRefCounted callback) override; + void SetPopupWindow(cef_native_window_t window) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/context_menu_handler_ctocpp.cc b/libcef_dll/ctocpp/context_menu_handler_ctocpp.cc index 9f517761598a25c97646a592aba846b57244fa3c..cff99e30f61ae38e875be3f604e81808647491e7 100644 --- a/libcef_dll/ctocpp/context_menu_handler_ctocpp.cc +++ b/libcef_dll/ctocpp/context_menu_handler_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=a74c5b939b0e9b587206cdd2e6c30d50127b3858$ +// $hash=1c1560e569d453c573beb6379f76aff05a31bed9$ // #include "libcef_dll/ctocpp/context_menu_handler_ctocpp.h" @@ -198,7 +198,8 @@ bool CefContextMenuHandlerCToCpp::RunQuickMenu( const CefRect& select_bounds, QuickMenuEditStateFlags edit_state_flags, CefRefPtr callback, - bool is_mouse_trigger) { + bool is_mouse_trigger, + bool is_long_press_actived) { shutdown_checker::AssertNotShutdown(); cef_context_menu_handler_t* _struct = GetStruct(); @@ -228,7 +229,7 @@ bool CefContextMenuHandlerCToCpp::RunQuickMenu( int _retval = _struct->run_quick_menu( _struct, CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame), &location, &size, &select_bounds, edit_state_flags, - CefRunQuickMenuCallbackCppToC::Wrap(callback), is_mouse_trigger); + CefRunQuickMenuCallbackCppToC::Wrap(callback), is_mouse_trigger, is_long_press_actived); // Return type: bool return _retval ? true : false; @@ -330,7 +331,8 @@ void CefContextMenuHandlerCToCpp::OnQuickMenuDismissed( // Execute _struct->on_quick_menu_dismissed(_struct, CefBrowserCppToC::Wrap(browser), - CefFrameCppToC::Wrap(frame), is_mouse_trigger); + CefFrameCppToC::Wrap(frame), + is_mouse_trigger); } NO_SANITIZE("cfi-icall") @@ -385,8 +387,7 @@ void CefContextMenuHandlerCToCpp::OnGetImageFromCache( } NO_SANITIZE("cfi-icall") -void CefContextMenuHandlerCToCpp::HideHandleAndQuickMenuIfNecessary( - bool hide) { +void CefContextMenuHandlerCToCpp::HideHandleAndQuickMenuIfNecessary(bool hide) { shutdown_checker::AssertNotShutdown(); cef_context_menu_handler_t* _struct = GetStruct(); @@ -400,6 +401,21 @@ void CefContextMenuHandlerCToCpp::HideHandleAndQuickMenuIfNecessary( _struct->hide_handle_and_quick_menu_if_necessary(_struct, hide); } +NO_SANITIZE("cfi-icall") +void CefContextMenuHandlerCToCpp::ChangeVisibilityOfQuickMenu() { + shutdown_checker::AssertNotShutdown(); + + cef_context_menu_handler_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, change_visibility_of_quick_menu)) { + return; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->change_visibility_of_quick_menu(_struct); +} + // CONSTRUCTOR - Do not edit by hand. CefContextMenuHandlerCToCpp::CefContextMenuHandlerCToCpp() {} diff --git a/libcef_dll/ctocpp/context_menu_handler_ctocpp.h b/libcef_dll/ctocpp/context_menu_handler_ctocpp.h index 17227834d361ad863c18105deed893cc3f4e3733..83b14c38dcc40456c6348b757f6270f8d7e548b6 100644 --- a/libcef_dll/ctocpp/context_menu_handler_ctocpp.h +++ b/libcef_dll/ctocpp/context_menu_handler_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=daa7f5e7ef35f3b104fc5d8a1990aa44dbd8c0a6$ +// $hash=12b01516d5e4cf877063602d4ab0779d7b8fbf41$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_CONTEXT_MENU_HANDLER_CTOCPP_H_ @@ -58,7 +58,8 @@ class CefContextMenuHandlerCToCpp const CefRect& select_bounds, QuickMenuEditStateFlags edit_state_flags, CefRefPtr callback, - bool is_mouse_trigger) override; + bool is_mouse_trigger, + bool is_long_press_actived) override; bool UpdateClippedSelectionBounds(CefRefPtr browser, CefRefPtr frame, const CefRect& select_bounds) override; @@ -73,6 +74,7 @@ class CefContextMenuHandlerCToCpp CefRefPtr image) override; void OnGetImageFromCache(CefRefPtr image) override; void HideHandleAndQuickMenuIfNecessary(bool hide) override; + void ChangeVisibilityOfQuickMenu() override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_CONTEXT_MENU_HANDLER_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/cookie_manager_ctocpp.cc b/libcef_dll/ctocpp/cookie_manager_ctocpp.cc index bdb22faa8acaaa996c4683a29c3814b302fec292..043570ff98eb694bea8f9fc1314f54051bbb8243 100644 --- a/libcef_dll/ctocpp/cookie_manager_ctocpp.cc +++ b/libcef_dll/ctocpp/cookie_manager_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=5c57059464bb94fa6aef835e9bfa26eaf6b53991$ +// $hash=c626571a0ba732f4f984023f2e9ff5bfa2cafc9b$ // #include "libcef_dll/ctocpp/cookie_manager_ctocpp.h" @@ -28,7 +28,7 @@ CefRefPtr CefCookieManager::GetGlobalManager( // Unverified params: callback // Execute - cef_cookie_manager_t* _retval = cef_cookie_manager_get_global_manager( + cef_cookie_manager_t *_retval = cef_cookie_manager_get_global_manager( CefCompletionCallbackCppToC::Wrap(callback)); // Return type: refptr_same @@ -43,7 +43,7 @@ CefRefPtr CefCookieManager::GetGlobalIncognitoManager( // Unverified params: callback // Execute - cef_cookie_manager_t* _retval = + cef_cookie_manager_t *_retval = cef_cookie_manager_get_global_incognito_manager( CefCompletionCallbackCppToC::Wrap(callback)); @@ -52,9 +52,9 @@ CefRefPtr CefCookieManager::GetGlobalIncognitoManager( } NO_SANITIZE("cfi-icall") -bool CefCookieManager::CreateCefCookie(const CefString& url, - const CefString& value, - CefCookie& cef_cookie) { +bool CefCookieManager::CreateCefCookie(const CefString &url, + const CefString &value, + CefCookie &cef_cookie) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Verify param: url; type: string_byref_const @@ -80,9 +80,8 @@ bool CefCookieManager::CreateCefCookie(const CefString& url, NO_SANITIZE("cfi-icall") bool CefCookieManagerCToCpp::VisitAllCookies( - CefRefPtr visitor, - bool is_sync) { - cef_cookie_manager_t* _struct = GetStruct(); + CefRefPtr visitor, bool is_sync) { + cef_cookie_manager_t *_struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, visit_all_cookies)) { return false; } @@ -105,11 +104,11 @@ bool CefCookieManagerCToCpp::VisitAllCookies( NO_SANITIZE("cfi-icall") bool CefCookieManagerCToCpp::VisitUrlCookies( - const CefString& url, - bool includeHttpOnly, + const CefString &url, bool includeHttpOnly, CefRefPtr visitor, - bool is_sync) { - cef_cookie_manager_t* _struct = GetStruct(); + bool is_sync, + bool is_from_ndk) { + cef_cookie_manager_t *_struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, visit_url_cookies)) { return false; } @@ -130,19 +129,20 @@ bool CefCookieManagerCToCpp::VisitUrlCookies( // Execute int _retval = _struct->visit_url_cookies( _struct, url.GetStruct(), includeHttpOnly, - CefCookieVisitorCppToC::Wrap(visitor), is_sync); + CefCookieVisitorCppToC::Wrap(visitor), is_sync, is_from_ndk); // Return type: bool return _retval ? true : false; } NO_SANITIZE("cfi-icall") -bool CefCookieManagerCToCpp::SetCookie(const CefString& url, - const CefCookie& cookie, +bool CefCookieManagerCToCpp::SetCookie(const CefString &url, + const CefCookie &cookie, CefRefPtr callback, bool is_sync, - const CefString& str_cookie) { - cef_cookie_manager_t* _struct = GetStruct(); + const CefString &str_cookie, + bool includeHttpOnly) { + cef_cookie_manager_t *_struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, set_cookie)) { return false; } @@ -162,9 +162,10 @@ bool CefCookieManagerCToCpp::SetCookie(const CefString& url, // Unverified params: callback // Execute - int _retval = _struct->set_cookie(_struct, url.GetStruct(), &cookie, - CefSetCookieCallbackCppToC::Wrap(callback), - is_sync, str_cookie.GetStruct()); + int _retval = + _struct->set_cookie(_struct, url.GetStruct(), &cookie, + CefSetCookieCallbackCppToC::Wrap(callback), is_sync, + str_cookie.GetStruct(), includeHttpOnly); // Return type: bool return _retval ? true : false; @@ -172,12 +173,9 @@ bool CefCookieManagerCToCpp::SetCookie(const CefString& url, NO_SANITIZE("cfi-icall") bool CefCookieManagerCToCpp::DeleteCookies( - const CefString& url, - const CefString& cookie_name, - bool is_session, - CefRefPtr callback, - bool is_sync) { - cef_cookie_manager_t* _struct = GetStruct(); + const CefString &url, const CefString &cookie_name, bool is_session, + CefRefPtr callback, bool is_sync) { + cef_cookie_manager_t *_struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, delete_cookies)) { return false; } @@ -198,7 +196,7 @@ bool CefCookieManagerCToCpp::DeleteCookies( NO_SANITIZE("cfi-icall") bool CefCookieManagerCToCpp::FlushStore( CefRefPtr callback) { - cef_cookie_manager_t* _struct = GetStruct(); + cef_cookie_manager_t *_struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, flush_store)) { return false; } @@ -216,7 +214,7 @@ bool CefCookieManagerCToCpp::FlushStore( } NO_SANITIZE("cfi-icall") bool CefCookieManagerCToCpp::IsAcceptCookieAllowed() { - cef_cookie_manager_t* _struct = GetStruct(); + cef_cookie_manager_t *_struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, is_accept_cookie_allowed)) { return false; } @@ -232,7 +230,7 @@ NO_SANITIZE("cfi-icall") bool CefCookieManagerCToCpp::IsAcceptCookieAllowed() { NO_SANITIZE("cfi-icall") void CefCookieManagerCToCpp::PutAcceptCookieEnabled(bool accept) { - cef_cookie_manager_t* _struct = GetStruct(); + cef_cookie_manager_t *_struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, put_accept_cookie_enabled)) { return; } @@ -245,7 +243,7 @@ void CefCookieManagerCToCpp::PutAcceptCookieEnabled(bool accept) { NO_SANITIZE("cfi-icall") bool CefCookieManagerCToCpp::IsThirdPartyCookieAllowed() { - cef_cookie_manager_t* _struct = GetStruct(); + cef_cookie_manager_t *_struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, is_third_party_cookie_allowed)) { return false; } @@ -261,7 +259,7 @@ bool CefCookieManagerCToCpp::IsThirdPartyCookieAllowed() { NO_SANITIZE("cfi-icall") void CefCookieManagerCToCpp::PutAcceptThirdPartyCookieEnabled(bool accept) { - cef_cookie_manager_t* _struct = GetStruct(); + cef_cookie_manager_t *_struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, put_accept_third_party_cookie_enabled)) { return; } @@ -274,7 +272,7 @@ void CefCookieManagerCToCpp::PutAcceptThirdPartyCookieEnabled(bool accept) { NO_SANITIZE("cfi-icall") bool CefCookieManagerCToCpp::IsFileURLSchemeCookiesAllowed() { - cef_cookie_manager_t* _struct = GetStruct(); + cef_cookie_manager_t *_struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, is_file_urlscheme_cookies_allowed)) { return false; } @@ -290,7 +288,7 @@ bool CefCookieManagerCToCpp::IsFileURLSchemeCookiesAllowed() { NO_SANITIZE("cfi-icall") void CefCookieManagerCToCpp::PutAcceptFileURLSchemeCookiesEnabled(bool allow) { - cef_cookie_manager_t* _struct = GetStruct(); + cef_cookie_manager_t *_struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, put_accept_file_urlscheme_cookies_enabled)) { return; } @@ -310,17 +308,15 @@ CefCookieManagerCToCpp::CefCookieManagerCToCpp() {} CefCookieManagerCToCpp::~CefCookieManagerCToCpp() {} template <> -cef_cookie_manager_t* -CefCToCppRefCounted::UnwrapDerived(CefWrapperType type, - CefCookieManager* c) { + CefCookieManager *c) { DCHECK(false) << "Unexpected class type: " << type; return nullptr; } template <> -CefWrapperType CefCToCppRefCounted::kWrapperType = WT_COOKIE_MANAGER; diff --git a/libcef_dll/ctocpp/cookie_manager_ctocpp.h b/libcef_dll/ctocpp/cookie_manager_ctocpp.h index 9f200e7512e92c440f963a4a52c50b7143283d65..f55b0ce9001fe8c3de277b7ac43515699f2b2838 100644 --- a/libcef_dll/ctocpp/cookie_manager_ctocpp.h +++ b/libcef_dll/ctocpp/cookie_manager_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=7460fa1f38e0e6d4296dba0deadc50a7ca5ef639$ +// $hash=e4359ad07b108653e62ec907b034b9dd4db907de$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_COOKIE_MANAGER_CTOCPP_H_ @@ -27,27 +27,23 @@ // Wrap a C structure with a C++ class. // This class may be instantiated and accessed wrapper-side only. class CefCookieManagerCToCpp - : public CefCToCppRefCounted { - public: +public: CefCookieManagerCToCpp(); virtual ~CefCookieManagerCToCpp(); // CefCookieManager methods. bool VisitAllCookies(CefRefPtr visitor, bool is_sync) override; - bool VisitUrlCookies(const CefString& url, - bool includeHttpOnly, + bool VisitUrlCookies(const CefString &url, bool includeHttpOnly, CefRefPtr visitor, - bool is_sync) override; - bool SetCookie(const CefString& url, - const CefCookie& cookie, - CefRefPtr callback, - bool is_sync, - const CefString& str_cookie) override; - bool DeleteCookies(const CefString& url, - const CefString& cookie_name, + bool is_sync, + bool is_from_ndk) override; + bool SetCookie(const CefString &url, const CefCookie &cookie, + CefRefPtr callback, bool is_sync, + const CefString &str_cookie, bool includeHttpOnly) override; + bool DeleteCookies(const CefString &url, const CefString &cookie_name, bool is_session, CefRefPtr callback, bool is_sync) override; @@ -60,4 +56,4 @@ class CefCookieManagerCToCpp void PutAcceptFileURLSchemeCookiesEnabled(bool allow) override; }; -#endif // CEF_LIBCEF_DLL_CTOCPP_COOKIE_MANAGER_CTOCPP_H_ +#endif // CEF_LIBCEF_DLL_CTOCPP_COOKIE_MANAGER_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/pdf_value_callback_ctocpp.cc b/libcef_dll/ctocpp/pdf_value_callback_ctocpp.cc new file mode 100644 index 0000000000000000000000000000000000000000..3bb2fe22f63c042830ec560dc5136395088594cd --- /dev/null +++ b/libcef_dll/ctocpp/pdf_value_callback_ctocpp.cc @@ -0,0 +1,66 @@ +// Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// +// $hash=29af672c7851a15b1940bdbf0724420a5925c477$ +// + +#include "libcef_dll/ctocpp/pdf_value_callback_ctocpp.h" +#include "libcef_dll/shutdown_checker.h" + +// VIRTUAL METHODS - Body may be edited by hand. + +NO_SANITIZE("cfi-icall") +void CefPdfValueCallbackCToCpp::OnReceiveValue(const char* value, + const long size) { + shutdown_checker::AssertNotShutdown(); + + cef_pdf_value_callback_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, on_receive_value)) { + return; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: value; type: simple_byaddr + DCHECK(value); + if (!value) { + return; + } + + // Execute + _struct->on_receive_value(_struct, value, size); +} + +// CONSTRUCTOR - Do not edit by hand. + +CefPdfValueCallbackCToCpp::CefPdfValueCallbackCToCpp() {} + +// DESTRUCTOR - Do not edit by hand. + +CefPdfValueCallbackCToCpp::~CefPdfValueCallbackCToCpp() { + shutdown_checker::AssertNotShutdown(); +} + +template <> +cef_pdf_value_callback_t* CefCToCppRefCounted< + CefPdfValueCallbackCToCpp, + CefPdfValueCallback, + cef_pdf_value_callback_t>::UnwrapDerived(CefWrapperType type, + CefPdfValueCallback* c) { + DCHECK(false) << "Unexpected class type: " << type; + return nullptr; +} + +template <> +CefWrapperType CefCToCppRefCounted::kWrapperType = + WT_PDF_VALUE_CALLBACK; \ No newline at end of file diff --git a/libcef_dll/ctocpp/pdf_value_callback_ctocpp.h b/libcef_dll/ctocpp/pdf_value_callback_ctocpp.h new file mode 100644 index 0000000000000000000000000000000000000000..978fc9f6a43b7aef2530e2f1b107c141bfae5926 --- /dev/null +++ b/libcef_dll/ctocpp/pdf_value_callback_ctocpp.h @@ -0,0 +1,43 @@ +// Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// +// $hash=1585a825a26ff97f506027ee22032e37c59cd8a9$ +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_PDF_VALUE_CALLBACK_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_PDF_VALUE_CALLBACK_CTOCPP_H_ +#pragma once + +#if !defined(BUILDING_CEF_SHARED) +#error This file can be included DLL-side only +#endif + +#include "include/capi/cef_browser_capi.h" +#include "include/capi/cef_client_capi.h" +#include "include/cef_browser.h" +#include "include/cef_client.h" +#include "libcef_dll/ctocpp/ctocpp_ref_counted.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefPdfValueCallbackCToCpp + : public CefCToCppRefCounted { + public: + CefPdfValueCallbackCToCpp(); + virtual ~CefPdfValueCallbackCToCpp(); + + // CefPdfValueCallback methods. + void OnReceiveValue(const char* value, const long size) override; +}; + +#endif // CEF_LIBCEF_DLL_CTOCPP_PDF_VALUE_CALLBACK_CTOCPP_H_ \ No newline at end of file diff --git a/libcef_dll/ctocpp/render_handler_ctocpp.cc b/libcef_dll/ctocpp/render_handler_ctocpp.cc index 80984800a67c0c49cbf3c279db3706e9519916fa..e61a94a875335345fbd750a9abe289170160e851 100644 --- a/libcef_dll/ctocpp/render_handler_ctocpp.cc +++ b/libcef_dll/ctocpp/render_handler_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=4ff2fb2de475a091839858d008c7babd10266501$ +// $hash=1342d3dc9ce2016e6792d06fe6541e9d0bc9e8c6$ // #include "libcef_dll/ctocpp/render_handler_ctocpp.h" @@ -1033,9 +1033,10 @@ void CefRenderHandlerCToCpp::GetVisibleViewportRect( } NO_SANITIZE("cfi-icall") -void CefRenderHandlerCToCpp::SendDynamicFrameLossEvent(CefRefPtr browser, - const CefString& sceneId, - bool isStart) { +void CefRenderHandlerCToCpp::SendDynamicFrameLossEvent( + CefRefPtr browser, + const CefString& sceneId, + bool isStart) { shutdown_checker::AssertNotShutdown(); cef_render_handler_t* _struct = GetStruct(); @@ -1045,19 +1046,20 @@ void CefRenderHandlerCToCpp::SendDynamicFrameLossEvent(CefRefPtr bro // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - // Verify param: text; type: string_byref_const - DCHECK(!sceneId.empty()); - if (sceneId.empty()) { - return; - } // Verify param: browser; type: refptr_diff DCHECK(browser.get()); if (!browser.get()) { return; } + // Verify param: sceneId; type: string_byref_const + DCHECK(!sceneId.empty()); + if (sceneId.empty()) { + return; + } // Execute - _struct->send_dynamic_frame_loss_event(_struct, CefBrowserCppToC::Wrap(browser), sceneId.GetStruct(), isStart); + _struct->send_dynamic_frame_loss_event( + _struct, CefBrowserCppToC::Wrap(browser), sceneId.GetStruct(), isStart); } NO_SANITIZE("cfi-icall") @@ -1079,7 +1081,8 @@ void CefRenderHandlerCToCpp::OnResizeScrollableViewport( } // Execute - _struct->on_resize_scrollable_viewport(_struct, CefBrowserCppToC::Wrap(browser)); + _struct->on_resize_scrollable_viewport(_struct, + CefBrowserCppToC::Wrap(browser)); } NO_SANITIZE("cfi-icall") @@ -1103,6 +1106,66 @@ void CefRenderHandlerCToCpp::SetFillContent(const std::string& content) { _struct->set_fill_content(_struct, content.c_str()); } +NO_SANITIZE("cfi-icall") +void CefRenderHandlerCToCpp::SetGestureEventResult(const bool result) { + shutdown_checker::AssertNotShutdown(); + + cef_render_handler_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_gesture_event_result)) { + return; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_gesture_event_result(_struct, result); +} + +NO_SANITIZE("cfi-icall") +void CefRenderHandlerCToCpp::StartVibraFeedback( + const std::string& vibratorType) { + shutdown_checker::AssertNotShutdown(); + + cef_render_handler_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, start_vibra_feedback)) { + return; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: vibratorType; type: std_string_byref_const + DCHECK(!vibratorType.empty()); + if (vibratorType.empty()) { + return; + } + + // Execute + _struct->start_vibra_feedback(_struct, vibratorType.c_str()); +} + +NO_SANITIZE("cfi-icall") +void CefRenderHandlerCToCpp::GetDevicePixelSize(CefRefPtr browser, + CefSize& size) { + shutdown_checker::AssertNotShutdown(); + + cef_render_handler_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_device_pixel_size)) { + return; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) { + return; + } + + // Execute + _struct->get_device_pixel_size(_struct, CefBrowserCppToC::Wrap(browser), + &size); +} + // CONSTRUCTOR - Do not edit by hand. CefRenderHandlerCToCpp::CefRenderHandlerCToCpp() {} diff --git a/libcef_dll/ctocpp/render_handler_ctocpp.h b/libcef_dll/ctocpp/render_handler_ctocpp.h index e29d09de259451c2eeff3d82814d5f6edffc99c2..4a4cb890defdcf0583f1890b5c7c42be13eeb568 100644 --- a/libcef_dll/ctocpp/render_handler_ctocpp.h +++ b/libcef_dll/ctocpp/render_handler_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=8f65b4436a0c28a5a9f716e45d2c0a19a9ac5bc3$ +// $hash=2f396ebe673e7b5cdf869cba023fabea354eb9ba$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_RENDER_HANDLER_CTOCPP_H_ @@ -143,6 +143,10 @@ class CefRenderHandlerCToCpp bool isStart) override; void OnResizeScrollableViewport(CefRefPtr browser) override; void SetFillContent(const std::string& content) override; + void SetGestureEventResult(const bool result) override; + void StartVibraFeedback(const std::string& vibratorType) override; + void GetDevicePixelSize(CefRefPtr browser, + CefSize& size) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_RENDER_HANDLER_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/web_message_receiver_ctocpp.cc b/libcef_dll/ctocpp/web_message_receiver_ctocpp.cc index 04b3df3ca0db2d1b3897419afa6c5f0a970d1b85..977d8502cf604d2a604ed4e2b93482c0f384bb56 100644 --- a/libcef_dll/ctocpp/web_message_receiver_ctocpp.cc +++ b/libcef_dll/ctocpp/web_message_receiver_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=7b86f31130ffff682546303df29d3fd46ded8b9d$ +// $hash=b7374d8ff6c27458586d4ab064947b2bbb353ed7$ // #include "libcef_dll/ctocpp/web_message_receiver_ctocpp.h" @@ -39,6 +39,32 @@ void CefWebMessageReceiverCToCpp::OnMessage(CefRefPtr message) { _struct->on_message(_struct, CefValueCppToC::Wrap(message)); } +NO_SANITIZE("cfi-icall") +bool CefWebMessageReceiverCToCpp::OnMessageWithBoolResult( + CefRefPtr message) { + shutdown_checker::AssertNotShutdown(); + + cef_web_message_receiver_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, on_message_with_bool_result)) { + return false; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: message; type: refptr_diff + DCHECK(message.get()); + if (!message.get()) { + return false; + } + + // Execute + int _retval = _struct->on_message_with_bool_result( + _struct, CefValueCppToC::Wrap(message)); + + // Return type: bool + return _retval ? true : false; +} + // CONSTRUCTOR - Do not edit by hand. CefWebMessageReceiverCToCpp::CefWebMessageReceiverCToCpp() {} diff --git a/libcef_dll/ctocpp/web_message_receiver_ctocpp.h b/libcef_dll/ctocpp/web_message_receiver_ctocpp.h index 715f8d2a16632e69d9e320452ea7278db8becc67..98857064d77ddfe51a8fb5f22c3c2612b367fbf9 100644 --- a/libcef_dll/ctocpp/web_message_receiver_ctocpp.h +++ b/libcef_dll/ctocpp/web_message_receiver_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=3b5e9726c583668eb1ab69c7a7337c7f8993b002$ +// $hash=32d8a2d5e6e5880fdbdda1cd513ad77021a58803$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_WEB_MESSAGE_RECEIVER_CTOCPP_H_ @@ -38,6 +38,7 @@ class CefWebMessageReceiverCToCpp // CefWebMessageReceiver methods. void OnMessage(CefRefPtr message) override; + bool OnMessageWithBoolResult(CefRefPtr message) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_WEB_MESSAGE_RECEIVER_CTOCPP_H_ diff --git a/libcef_dll/wrapper_types.h b/libcef_dll/wrapper_types.h index 7c8f51c53ba5c496cd25c154150c06a6e4a1ddb4..f8f3db1473002b3cef0cc9930dbb2053ef55d874 100644 --- a/libcef_dll/wrapper_types.h +++ b/libcef_dll/wrapper_types.h @@ -115,6 +115,7 @@ enum CefWrapperType { WT_PANEL, WT_PANEL_DELEGATE, WT_PDF_PRINT_CALLBACK, + WT_PDF_VALUE_CALLBACK, WT_PERMISSION_HANDLER, WT_PERMISSION_PROMPT_CALLBACK, WT_PERMISSION_REQUEST,