diff --git a/BUILD.gn b/BUILD.gn index dca75f5e9f17551010b1c1469235fd15bc49a2f2..933c50736754a9c4ceee27a992cb4773748d89a0 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -945,6 +945,8 @@ source_set("libcef_static") { "libcef/renderer/alloy/alloy_content_renderer_client.h", "libcef/renderer/alloy/alloy_render_thread_observer.cc", "libcef/renderer/alloy/alloy_render_thread_observer.h", + "libcef/renderer/alloy/alloy_safe_browsing_error_page_controller_delegate_impl.cc", + "libcef/renderer/alloy/alloy_safe_browsing_error_page_controller_delegate_impl.h", "libcef/renderer/alloy/url_loader_throttle_provider_impl.cc", "libcef/renderer/alloy/url_loader_throttle_provider_impl.h", "libcef/renderer/browser_impl.cc", @@ -1014,6 +1016,17 @@ source_set("libcef_static") { "libcef/browser/autofill/oh_autofill_provider.h", "libcef/renderer/alloy/alloy_content_settings_client.cc", "libcef/renderer/alloy/alloy_content_settings_client.h", + "libcef/browser/safe_browsing/safe_browsing_tab_helper.cc", + "libcef/browser/safe_browsing/safe_browsing_tab_helper.h", + "libcef/browser/safe_browsing/safe_browsing_response.h", + "libcef/browser/safe_browsing/sb_block_page.cc", + "libcef/browser/safe_browsing/sb_block_page.h", + "libcef/browser/safe_browsing/sb_client.cc", + "libcef/browser/safe_browsing/sb_client.h", + "libcef/browser/safe_browsing/sb_controller_client.cc", + "libcef/browser/safe_browsing/sb_controller_client.h", + "libcef/browser/safe_browsing/sb_prefs.cc", + "libcef/browser/safe_browsing/sb_prefs.h", ] } @@ -1356,6 +1369,10 @@ source_set("libcef_static") { deps += [ "//components/js_injection/browser", "//components/js_injection/renderer", + "//components/security_interstitials/content:proto", + "//components/security_interstitials/content:security_interstitial_page", + "//components/security_interstitials/core", + "//components/safe_browsing/core/common:safe_browsing_prefs", "//ui/events", "//ui/strings", "//ui/views", diff --git a/include/capi/cef_browser_capi.h b/include/capi/cef_browser_capi.h index 0f2a84bd005b1cb13d4191772ba354c09e3ea232..b181db4e26e670cb10989681bbc301ccecba32b0 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=ce118696a637bbd106704f2f13d20358c0082aef$ +// $hash=8f66caacc6e081cce74f9838f8be8e67fc9cc3f7$ // #ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_ @@ -72,9 +72,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; /// @@ -92,9 +92,9 @@ 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; /// @@ -110,8 +110,8 @@ 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); } cef_web_message_receiver_t; /// @@ -130,77 +130,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 @@ -211,188 +211,206 @@ 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, + int enable); + + /// + /// Get whether checking website security risks is enabled. + /// + int(CEF_CALLBACK* is_safe_browsing_enabled)(struct _cef_browser_t* self); } cef_browser_t; /// @@ -410,8 +428,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; @@ -432,9 +450,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; /// @@ -452,8 +472,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; /// @@ -472,10 +494,11 @@ 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; /// @@ -493,8 +516,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 @@ -506,7 +529,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); /// @@ -518,12 +541,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 @@ -531,8 +554,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 @@ -540,31 +563,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 @@ -572,7 +595,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); /// @@ -590,17 +613,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 @@ -614,15 +639,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 @@ -630,10 +658,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 @@ -644,14 +673,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); /// @@ -663,22 +695,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 @@ -713,8 +746,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); /// @@ -730,9 +763,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 @@ -740,9 +775,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 @@ -750,28 +785,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 @@ -779,21 +815,21 @@ 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); /// @@ -804,45 +840,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); /// @@ -853,27 +890,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 @@ -882,8 +920,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 @@ -893,8 +931,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 @@ -921,10 +960,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 @@ -935,9 +977,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); /// @@ -946,15 +988,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 @@ -965,9 +1008,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 @@ -975,8 +1020,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); /// @@ -984,7 +1030,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 @@ -993,8 +1039,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 @@ -1005,8 +1051,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); /// @@ -1017,15 +1064,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 @@ -1052,7 +1099,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); /// @@ -1060,265 +1107,275 @@ 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); /// /// GetOrCreateRootBrowserAccessibilityManager /// - void(CEF_CALLBACK *get_or_create_root_browser_accessibility_manager)( - struct _cef_browser_host_t *self, void **manager); + void(CEF_CALLBACK* get_or_create_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 cef_string_t *code, - struct _cef_java_script_result_callback_t *callback, int extention); + void(CEF_CALLBACK* execute_java_script)( + struct _cef_browser_host_t* self, + const cef_string_t* code, + 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); /// /// RegisterArkJSfunction /// - void(CEF_CALLBACK *register_ark_jsfunction)(struct _cef_browser_host_t *self, - const cef_string_t *object_name, + void(CEF_CALLBACK* register_ark_jsfunction)(struct _cef_browser_host_t* self, + const cef_string_t* object_name, cef_string_list_t method_list, int32_t object_id); /// /// 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, + 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, + 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 @@ -1328,209 +1385,236 @@ 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); /// /// 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); + /// - // Set the embed mode enable of web + /// Set the embed mode enable of web /// - void(CEF_CALLBACK* set_embed_mode)(struct _cef_browser_host_t* self, - bool mode); + void(CEF_CALLBACK* set_native_embed_mode_enabled)( + 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); } cef_browser_host_t; @@ -1545,10 +1629,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|. @@ -1558,14 +1644,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_ +#endif // CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_ diff --git a/include/capi/cef_load_handler_capi.h b/include/capi/cef_load_handler_capi.h index 3a2adda0118f37fced6d0fe6d47351e4616b92c3..4f478f1a7c34bc384e7f2a8d7698d744b093b9fb 100644 --- a/include/capi/cef_load_handler_capi.h +++ b/include/capi/cef_load_handler_capi.h @@ -33,7 +33,7 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // -// $hash=fa957b91c4ce09792785ca1c57004bce89622b70$ +// $hash=6ebc9a4d08972aa862e6ed24dbeab98fb3231ca1$ // #ifndef CEF_INCLUDE_CAPI_CEF_LOAD_HANDLER_CAPI_H_ @@ -182,6 +182,13 @@ typedef struct _cef_load_handler_t { void(CEF_CALLBACK* on_navigation_entry_committed)( struct _cef_load_handler_t* self, struct _cef_load_committed_details_t* details); + + /// + /// Called when received website security risk check result. + /// + void(CEF_CALLBACK* on_safe_browsing_check_result)( + struct _cef_load_handler_t* self, + int threat_type); } cef_load_handler_t; #ifdef __cplusplus diff --git a/include/cef_api_hash.h b/include/cef_api_hash.h index 0f356fc1e6c85b1d120a3adb6c8d6eab0b8cf544..2f45ab312f9f58a8c38255f4227df13903b0ea77 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 "41a52f198f19bd756cbcc4ec9000c7456f6b6d75" +#define CEF_API_HASH_UNIVERSAL "6fc422c4fcee80eda01e2f2c6539691bbabaecba" #if defined(OS_WIN) -#define CEF_API_HASH_PLATFORM "399ff433c9b2705dc8594b92dc84f70bf3b2f8b8" +#define CEF_API_HASH_PLATFORM "91d3aad1da046087a64412c82d91bc7b2ad7a078" #elif defined(OS_MAC) -#define CEF_API_HASH_PLATFORM "bcaddf89ce1d1c3c05e1a25ee71fbc1384f271f4" +#define CEF_API_HASH_PLATFORM "4cefc84eb3620ee611be1c50c1ae123d68ad4427" #elif defined(OS_LINUX) -#define CEF_API_HASH_PLATFORM "511b93aeabf036384f4f173c426bcb966949b78d" +#define CEF_API_HASH_PLATFORM "78289a69987bf713cbbe42579eb2d93b17c64200" #elif defined(OS_OHOS) -#define CEF_API_HASH_PLATFORM "511b93aeabf036384f4f173c426bcb966949b78d" +#define CEF_API_HASH_PLATFORM "78289a69987bf713cbbe42579eb2d93b17c64200" #endif #ifdef __cplusplus diff --git a/include/cef_browser.h b/include/cef_browser.h index 1c6b9d341b0fbe84fb18fe419235aec71af560c7..4f22d7bdd2eb54b142b4d461bdc7a42c731f1fd7 100644 --- a/include/cef_browser.h +++ b/include/cef_browser.h @@ -407,6 +407,18 @@ class CefBrowser : public virtual CefBaseRefCounted { /*--cef()--*/ virtual int GetSecurityLevel() = 0; + /// + /// Enable the ability to check website security risks. + /// + /*--cef()--*/ + virtual void EnableSafeBrowsing(bool enable) = 0; + + /// + /// Get whether checking website security risks is enabled. + /// + /*--cef()--*/ + virtual bool IsSafeBrowsingEnabled() = 0; + /* ---------- ohos_nweb_ex add end --------- */ #endif // BUILDFLAG(IS_OHOS) }; @@ -1610,7 +1622,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { #ifdef BUILDFLAG(IS_OHOS) /// - // Set the embed mode enable of web + /// Set the embed mode enable of web /// /*--cef()--*/ virtual void SetNativeEmbedModeEnabled(bool mode) = 0; diff --git a/include/cef_load_handler.h b/include/cef_load_handler.h index f9e29d626a030870fb80cbfd33b8c79d156367e9..4a02ed7eb3ec11addb67708f8d0367a7228321eb 100644 --- a/include/cef_load_handler.h +++ b/include/cef_load_handler.h @@ -178,6 +178,13 @@ class CefLoadHandler : public virtual CefBaseRefCounted { /*--cef()--*/ virtual void OnNavigationEntryCommitted( CefRefPtr details) {} + + + /// + /// Called when received website security risk check result. + /// + /*--cef()--*/ + virtual void OnSafeBrowsingCheckResult(int threat_type) {} #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 da8ca498e2b84fcb991387f9e8d4665cbdb25b09..57537cb5dfa38e3088ef075afee4cfda03beaf0f 100644 --- a/libcef/browser/alloy/alloy_browser_host_impl.cc +++ b/libcef/browser/alloy/alloy_browser_host_impl.cc @@ -93,6 +93,8 @@ #include "libcef/browser/alloy/alloy_off_the_record_browser_context.h" #endif +#include "libcef/browser/safe_browsing/safe_browsing_tab_helper.h" + using content::KeyboardEventProcessingResult; namespace { @@ -1930,6 +1932,9 @@ AlloyBrowserHostImpl::AlloyBrowserHostImpl( // Make sure RenderFrameCreated is called at least one time. RenderFrameCreated(web_contents->GetPrimaryMainFrame()); +#if BUILDFLAG(IS_OHOS) + ohos_safe_browsing::SafeBrowsingTabHelper::CreateForWebContents(web_contents, this); +#endif #ifdef OHOS_EX_GET_ZOOM_LEVEL if (base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kForBrowser)) { diff --git a/libcef/browser/alloy/alloy_content_browser_client.cc b/libcef/browser/alloy/alloy_content_browser_client.cc index d710d797a05c04ae5851e61848ce04d0c3fb5484..fc5af1ff72dceb186f541ec8764e1188e4272c61 100644 --- a/libcef/browser/alloy/alloy_content_browser_client.cc +++ b/libcef/browser/alloy/alloy_content_browser_client.cc @@ -272,6 +272,8 @@ using extensions::mojom::APIPermissionID; #include "libcef/browser/alloy/alloy_off_the_record_browser_context.h" #endif +#include "components/security_interstitials/content/security_interstitial_tab_helper.h" + namespace { #if BUILDFLAG(IS_OHOS) void TransferVector(const std::vector& source, @@ -1768,6 +1770,16 @@ void AlloyContentBrowserClient:: }, &render_frame_host)); #endif // defined(OHOS_PRINT) + + associated_registry.AddInterface( + base::BindRepeating( + [](content::RenderFrameHost* render_frame_host, + mojo::PendingAssociatedReceiver< + security_interstitials::mojom::InterstitialCommands> receiver) { + security_interstitials::SecurityInterstitialTabHelper:: + BindInterstitialCommands(std::move(receiver), render_frame_host); + }, + &render_frame_host)); } std::vector> diff --git a/libcef/browser/browser_host_base.cc b/libcef/browser/browser_host_base.cc index bda2c47577f4c4bf71413950b669f63f10dfae4f..3d2fff9bd0950ebcfab7a846bd2f6d3d88ca9196 100644 --- a/libcef/browser/browser_host_base.cc +++ b/libcef/browser/browser_host_base.cc @@ -3183,6 +3183,25 @@ void CefBrowserHostBase::PasswordSuggestionSelected(int list_index) { #endif } +#if BUILDFLAG(IS_OHOS) + bool CefBrowserHostBase::IsSafeBrowsingEnabled() { + if (!GetWebContents()) { + return false; + } + + return GetWebContents()->IsSafeBrowsingEnabled(); + } + + void CefBrowserHostBase::EnableSafeBrowsing(bool enable) { + if (!GetWebContents()) { + return; + } + + LOG(INFO) << "enable safe browsing" << enable; + GetWebContents()->EnableSafeBrowsing(enable); + } +#endif + bool CefBrowserHostBase::GetSavePassword() { #if defined(OHOS_EX_PASSWORD) if (!GetWebContents()) { diff --git a/libcef/browser/browser_host_base.h b/libcef/browser/browser_host_base.h index 420faf609881c5673e6f28c74f4ffd3edb359855..a0d54a5addf8de4fda445aa120c307c4899c3d17 100644 --- a/libcef/browser/browser_host_base.h +++ b/libcef/browser/browser_host_base.h @@ -453,6 +453,11 @@ class CefBrowserHostBase : public CefBrowserHost, // #endif // defined(OHOS_EX_PASSWORD) // #endif // defined(OHOS_NWEB_EX) +#if BUILDFLAG(IS_OHOS) + bool IsSafeBrowsingEnabled() override; + void EnableSafeBrowsing(bool enable) override; +#endif + // CefBrowserContentsDelegate::Observer methods: void OnStateChanged(CefBrowserContentsState state_changed) override; void OnWebContentsDestroyed(content::WebContents* web_contents) override; diff --git a/libcef/browser/prefs/browser_prefs.cc b/libcef/browser/prefs/browser_prefs.cc index e019bb8e6ac3d82575b7fdc5e58e5df0d1e69f85..535e7df6344b0706b2236381a7dbca4de40cec86 100644 --- a/libcef/browser/prefs/browser_prefs.cc +++ b/libcef/browser/prefs/browser_prefs.cc @@ -99,6 +99,9 @@ #include "chrome/browser/ui/webui/extensions/extensions_ui.h" #include "extensions/browser/permissions_manager.h" #endif + +#include "libcef/browser/safe_browsing/sb_prefs.h" + namespace browser_prefs { namespace { @@ -318,6 +321,9 @@ std::unique_ptr CreatePrefService(Profile* profile, ExtensionWebUI::RegisterProfilePrefs(registry.get()); preinstalled_apps::RegisterProfilePrefs(registry.get()); #endif +#if BUILDFLAG(IS_OHOS) + ohos_safe_browsing::RegisterProfilePrefs(registry.get()); + #endif HostContentSettingsMap::RegisterProfilePrefs(registry.get()); language::LanguagePrefs::RegisterProfilePrefs(registry.get()); media_router::RegisterProfilePrefs(registry.get()); diff --git a/libcef/browser/safe_browsing/safe_browsing_response.h b/libcef/browser/safe_browsing/safe_browsing_response.h new file mode 100644 index 0000000000000000000000000000000000000000..0677d5e6881eec19cbd10223da034941877ce09f --- /dev/null +++ b/libcef/browser/safe_browsing/safe_browsing_response.h @@ -0,0 +1,215 @@ +// Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CEF_LIBCEF_BROWSER_SAFE_BROWSING_SAFE_BROWSING_RESPONSE_H_ +#define CEF_LIBCEF_BROWSER_SAFE_BROWSING_SAFE_BROWSING_RESPONSE_H_ + +#include + +#include "base/json/json_value_converter.h" +#include "base/values.h" + +namespace { +const int kCloudControlVectorMaxSize = 10000; +} + +namespace ohos_safe_browsing { +static bool ParseString(const base::Value* value, std::string* field) { + if (!value->is_string()) { + *field = ""; + } else { + *field = value->GetString(); + } + return true; +} + +static bool ParseInteger(const base::Value* value, int* field) { + if (!value->is_int()) { + *field = -1; + } else { + *field = value->GetInt(); + } + return true; +} + +static bool ParseStringVector(const base::Value* value, + std::vector* result) { + if (result && value && value->is_list()) { + result->clear(); + for (size_t i = 0; i < value->GetList().size(); i++) { + const auto& element = value->GetList()[i]; + if (!element.is_string()) { + LOG(WARNING) << "ParseStringVector, value of the list is not a string."; + return false; + } + result->emplace_back(element.GetString()); + if (result->size() >= kCloudControlVectorMaxSize) { + LOG(WARNING) << "ParseStringVector, only use the first " + << kCloudControlVectorMaxSize + << " items, the last element is " << element.GetString(); + break; + } + } + } + return true; +} + +struct VendorInfo { + std::string vendor_id; + std::string code; + int hw_code; + + VendorInfo() { + vendor_id = ""; + code = ""; + hw_code = -1; + } + ~VendorInfo() = default; + + static void RegisterJSONConverter( + base::JSONValueConverter* converter) { + converter->RegisterCustomValueField( + "vendorID", &VendorInfo::vendor_id, &ParseString); + converter->RegisterCustomValueField("code", &VendorInfo::code, + &ParseString); + converter->RegisterCustomValueField("hwCode", &VendorInfo::hw_code, + &ParseInteger); + } +}; + +template +static bool ParseCustomValueResult(const base::Value* value, T* result) { + if (!value->is_none()) { + base::JSONValueConverter converter; + if (!converter.Convert(*value, result)) { + return false; + } + } + return true; +} + +struct SafeBrowsingUrlCheckResult { + std::string url; + int policy = -1; + std::string notification; + VendorInfo vendor_info; + std::vector jump_url; + std::string mapping_type; + + SafeBrowsingUrlCheckResult() = default; + ~SafeBrowsingUrlCheckResult() = default; + + static void RegisterJSONConverter( + base::JSONValueConverter* converter) { + converter->RegisterCustomValueField( + "url", &SafeBrowsingUrlCheckResult::url, &ParseString); + converter->RegisterCustomValueField( + "policy", &SafeBrowsingUrlCheckResult::policy, &ParseInteger); + converter->RegisterCustomValueField( + "notification", &SafeBrowsingUrlCheckResult::notification, + &ParseString); + converter->RegisterCustomValueField( + "vendorInfo", &SafeBrowsingUrlCheckResult::vendor_info, + &ParseCustomValueResult); + converter->RegisterCustomValueField>( + "jumpUrls", &SafeBrowsingUrlCheckResult::jump_url, &ParseStringVector); + converter->RegisterCustomValueField( + "mappingType", &SafeBrowsingUrlCheckResult::mapping_type, &ParseString); + } +}; + +struct SingleHashResult { + std::string url_hash; + std::string hw_code; + int policy = -1; + std::vector jump_url; + + SingleHashResult() = default; + ~SingleHashResult() = default; + + static void RegisterJSONConverter( + base::JSONValueConverter* converter) { + converter->RegisterCustomValueField( + "urlHash", &SingleHashResult::url_hash, &ParseString); + converter->RegisterCustomValueField( + "hwCode", &SingleHashResult::hw_code, &ParseString); + converter->RegisterCustomValueField( + "policy", &SingleHashResult::policy, &ParseInteger); + converter->RegisterCustomValueField>( + "jumpUrls", &SingleHashResult::jump_url, &ParseStringVector); + } +}; + +template +static bool ParseCustomValueVector(const base::Value* value, + std::vector* result) { + if (result && value && value->is_list()) { + result->clear(); + for (size_t i = 0; i < value->GetList().size(); i++) { + const auto& element = value->GetList()[i]; + base::JSONValueConverter converter; + T single_item; + if (!converter.Convert(element, &single_item)) { + return false; + } + + result->emplace_back(single_item); + if (result->size() >= kCloudControlVectorMaxSize) { + LOG(WARNING) << "ParseConfigVector reach the limit size."; + break; + } + } + } + return true; +} + +struct SafeBrowsingHashCheckResult { + std::string mapping_type; + std::vector hash_result_list; + + SafeBrowsingHashCheckResult() = default; + ~SafeBrowsingHashCheckResult() = default; + + static void RegisterJSONConverter( + base::JSONValueConverter* converter) { + converter->RegisterCustomValueField( + "mappingType", &SafeBrowsingHashCheckResult::mapping_type, + &ParseString); + converter->RegisterCustomValueField>( + "fullUrlHashlist", &SafeBrowsingHashCheckResult::hash_result_list, + &ParseCustomValueVector); + } +}; + +struct SafeBrowsingResponse { + std::string status; + int code = -1; + std::string reason; + SafeBrowsingUrlCheckResult url_check_result; + std::vector hash_check_result; + + SafeBrowsingResponse() = default; + ~SafeBrowsingResponse() = default; + + static void RegisterJSONConverter( + base::JSONValueConverter* converter) { + converter->RegisterCustomValueField( + "status", &SafeBrowsingResponse::status, &ParseString); + converter->RegisterCustomValueField( + "code", &SafeBrowsingResponse::code, &ParseInteger); + converter->RegisterCustomValueField( + "reason", &SafeBrowsingResponse::reason, &ParseString); + converter->RegisterCustomValueField( + "urlCheckResult", &SafeBrowsingResponse::url_check_result, + &ParseCustomValueResult); + converter + ->RegisterCustomValueField>( + "hasCheckResult", &SafeBrowsingResponse::hash_check_result, + &ParseCustomValueVector); + } +}; + +} // namespace ohos_safe_browsing + +#endif // CEF_LIBCEF_BROWSER_SAFE_BROWSING_SAFE_BROWSING_RESPONSE_H_ diff --git a/libcef/browser/safe_browsing/safe_browsing_tab_helper.cc b/libcef/browser/safe_browsing/safe_browsing_tab_helper.cc new file mode 100644 index 0000000000000000000000000000000000000000..35ece69c469a7b33bd76f53b9bd1c5fe2ba3257a --- /dev/null +++ b/libcef/browser/safe_browsing/safe_browsing_tab_helper.cc @@ -0,0 +1,328 @@ +// Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "libcef/browser/safe_browsing/safe_browsing_tab_helper.h" + +#include "base/json/json_reader.h" +#include "base/json/json_string_value_serializer.h" +#include "base/json/json_writer.h" +#include "components/user_prefs/user_prefs.h" +#include "content/public/browser/browser_context.h" +#include "content/public/browser/navigation_handle.h" +#include "crypto/sha2.h" +#include "libcef/browser/browser_context.h" +#include "libcef/browser/net_service/url_loader_factory_getter.h" +#include "libcef/browser/safe_browsing/safe_browsing_response.h" +#include "libcef/browser/safe_browsing/sb_threat_type.h" +#include "services/network/public/cpp/resource_request.h" +#include "services/network/public/cpp/shared_url_loader_factory.h" +#include "services/network/public/cpp/simple_url_loader.h" +#include "services/network/public/mojom/url_response_head.mojom.h" +#include "url/gurl.h" + +#include "libcef/browser/alloy/alloy_browser_host_impl.h" +#include "libcef/browser/safe_browsing/sb_prefs.h" +#include "net/base/net_errors.h" +#include "net/base/registry_controlled_domains/registry_controlled_domain.h" +#include "net/http/http_status_code.h" + +namespace ohos_safe_browsing { + +namespace { +constexpr size_t kHashPrefixLength = 6; // bytes +constexpr char kPackageName[] = "packageName"; +constexpr char kUrl[] = "url"; +constexpr char kDomain[] = "domain"; +constexpr char kUrlHashPrefix[] = "urlHashPrefix"; +constexpr char kTpCheckSwitch[] = "tpCheckSwitch"; +constexpr char kContentTypeJSON[] = "application/json"; +constexpr char kXHwGrsAttrGroupHeader[] = "X-HW-GRS-ATTR-GROUP"; +constexpr char kSerLocation[] = "ser-location=CN"; + +const char kSafeSearchApiUrl[] = + "https://lfbrowserdev.hwcloudtest.cn:8443/security/v1/oh/securityurls"; +const char kReplaceStr[] = "***"; + +constexpr net::NetworkTrafficAnnotationTag kSafeBrowsingTrafficAnnotationTag = + net::DefineNetworkTrafficAnnotation("ohos-safe-browsing", R"( + semantics { + sender: "ohos-safe-browsing check" + description: + "" + trigger: + "" + data: "" + destination: OTHER + } + policy { + cookies_allowed: YES + setting: + "" + policy_exception_justification: + "" + })"); + +content::BrowserContext* GetBrowserContext() { + std::vector browser_context_all = + CefBrowserContext::GetAll(); + if (browser_context_all.size() > 0) { + return browser_context_all[0]->AsBrowserContext(); + } + return nullptr; +} + +std::string GenerateHashPrefix(const GURL& gurl) { + std::string url = gurl.spec(); + if (base::StartsWith(url, "https://")) { + url = url.substr(8); + } else if (base::StartsWith(url, "http://")) { + url = url.substr(7); + } + if (base::EndsWith(url, "/")) { + url = url.substr(0, url.rfind("/")); + } + + std::string full_hash = crypto::SHA256HashString(url); + std::string hash_prefix_string = + base::HexEncode(full_hash.data(), full_hash.size()) + .substr(0, kHashPrefixLength); + return base::ToLowerASCII(hash_prefix_string); +} + +OHSBThreatType TransformMappingType(std::string mapping_type) { + if (mapping_type == "THREAT_ILLEGAL") { + return OHSBThreatType::THREAT_ILLEGAL; + } + if (mapping_type == "THREAT_FRAUD") { + return OHSBThreatType::THREAT_FRAUD; + } + if (mapping_type == "THREAT_RISK") { + return OHSBThreatType::THREAT_RISK; + } + if (mapping_type == "THREAT_WARNING") { + return OHSBThreatType::THREAT_WARNING; + } + return OHSBThreatType::THREAT_DEFAULT; +} + +std::string ConvertUrlQuery(const std::string& url) { + if (url.length() == 0) { + return url; + } + url::Parsed parsed; + url::ParseStandardURL(url.data(), url.length(), &parsed); + std::string converted; + url::Component& part = parsed.query; + + if (parsed.path.is_valid()) { + converted.append(url, parsed.path.begin, + parsed.path.end() - parsed.path.begin); + } + if (!part.is_valid()) { + return converted; + } + converted.append("?"); + + int i = 0; + int appendStart = part.begin; + bool replaceFlag = false; + for (i = part.begin; i < part.end(); i++) { + if ('=' == url[i]) { + converted.append(url, appendStart, i - appendStart + 1); + appendStart = part.end(); + replaceFlag = true; + continue; + } + + if ('&' == url[i]) { + if (replaceFlag) { + converted.append(kReplaceStr); + replaceFlag = false; + } + appendStart = i; + } + } + + if (replaceFlag) { + converted.append(kReplaceStr); + } else if (appendStart < part.end()) { + converted.append(url, appendStart, part.end() - appendStart + 1); + } + return converted; +} + +} // namespace + +struct SafeBrowsingTabHelper::SBCheck { + SBCheck(const GURL& url, + std::unique_ptr simple_url_loader); + ~SBCheck(); + + GURL url; + std::unique_ptr simple_url_loader; + base::TimeTicks start_time; +}; + +SafeBrowsingTabHelper::SBCheck::SBCheck( + const GURL& url, + std::unique_ptr simple_url_loader) + : url(url), + simple_url_loader(std::move(simple_url_loader)), + start_time(base::TimeTicks::Now()) {} + +SafeBrowsingTabHelper::SBCheck::~SBCheck() = default; + +SafeBrowsingTabHelper::SafeBrowsingTabHelper(content::WebContents* web_contents, + CefBrowserHostBase* browser) + : content::WebContentsObserver(web_contents), + content::WebContentsUserData(*web_contents) { + content::BrowserContext* browser_context = GetBrowserContext(); + if (!browser_context) { + return; + } + + if (!browser) { + return; + } + PrefService* pref_service = user_prefs::UserPrefs::Get(browser_context); + if (!pref_service) { + return; + } + is_safe_browsing_enabled_ = browser->IsSafeBrowsingEnabled(); + sb_client_.reset(new SbClient(web_contents, pref_service)); + browser_ = browser; +} + +SafeBrowsingTabHelper::~SafeBrowsingTabHelper() = default; + +void SafeBrowsingTabHelper::DidStartNavigation( + content::NavigationHandle* navigation_handle) { + scoped_refptr loader_factory_getter; + loader_factory_getter = + net_service::URLLoaderFactoryGetter::Create(nullptr, GetBrowserContext()); + if (!loader_factory_getter) { + LOG(ERROR) << "SafeBrowsing loader factory getter is null"; + return; + } + + std::string url = is_safe_browsing_enabled_ + ? ConvertUrlQuery(navigation_handle->GetURL().spec()) + : ""; + std::string domain = net::registry_controlled_domains::GetDomainAndRegistry( + navigation_handle->GetURL(), + net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); + std::string url_hash_prefix = GenerateHashPrefix(navigation_handle->GetURL()); + int tp_check_switch = is_safe_browsing_enabled_ ? 1 : 0; + + base::Value::Dict request_data; + request_data.Set(kPackageName, ""); + request_data.Set(kUrl, url); + request_data.Set(kDomain, domain); + request_data.Set(kUrlHashPrefix, url_hash_prefix); + request_data.Set(kTpCheckSwitch, tp_check_switch); + std::string request_string; + base::JSONWriter::Write(request_data, &request_string); + auto resource_request = std::make_unique(); + resource_request->url = GURL(kSafeSearchApiUrl); + resource_request->method = "POST"; + resource_request->credentials_mode = network::mojom::CredentialsMode::kOmit; + resource_request->headers.SetHeader(kXHwGrsAttrGroupHeader, kSerLocation); + std::unique_ptr simple_url_loader = + network::SimpleURLLoader::Create(std::move(resource_request), + kSafeBrowsingTrafficAnnotationTag); + + simple_url_loader->SetAllowHttpErrorResults(true); + simple_url_loader->AttachStringForUpload(request_string, kContentTypeJSON); + + checks_running_.push_front(std::make_unique( + navigation_handle->GetURL(), std::move(simple_url_loader))); + auto it = checks_running_.begin(); + scoped_refptr url_loader_factory = + loader_factory_getter->GetURLLoaderFactory(); + network::SimpleURLLoader* loader = it->get()->simple_url_loader.get(); + loader->DownloadToStringOfUnboundedSizeUntilCrashAndDie( + url_loader_factory.get(), + base::BindOnce(&SafeBrowsingTabHelper::OnSimpleLoaderComplete, + base::Unretained(this), it, navigation_handle->GetURL())); +} + +void SafeBrowsingTabHelper::OnSimpleLoaderComplete( + SBCheckList::iterator it, + const GURL& url, + std::unique_ptr response_body) { + std::unique_ptr check = std::move(*it); + checks_running_.erase(it); + + int response_code = -1; // Invalid response code. + int net_error = check->simple_url_loader->NetError(); + + if (check->simple_url_loader->ResponseInfo() && + check->simple_url_loader->ResponseInfo()->headers) { + response_code = + check->simple_url_loader->ResponseInfo()->headers->response_code(); + } + if (!response_body || response_body->empty() || *response_body == "{}") { + LOG(INFO) << "OnSimpleLoaderComplete response_body null response_code:" + << response_code << ", net_error:" << net_error; + return; + } + + LOG(INFO) << "OnSimpleLoaderComplete response_body:" << *response_body; + absl::optional parsed_json = + base::JSONReader::Read(*response_body); + if (!parsed_json || !parsed_json->is_dict()) { + LOG(ERROR) << "JSONReader failed reading safe browsing response body : " + << *response_body; + return; + } + SafeBrowsingResponse response; + base::JSONValueConverter converter; + converter.Convert(*parsed_json, &response); + + std::string check_result_url = response.url_check_result.url; + int policy = response.url_check_result.policy; + int hw_code = response.url_check_result.vendor_info.hw_code; + std::string mapping_type = response.url_check_result.mapping_type; + if (hw_code < 0 || policy < OHSBPolicyType::POLICY_NO_PROMPT || + policy > OHSBPolicyType::POLICY_HALF_POPUP) { + return; + } + if (url.spec() == check_result_url) { + sb_client_->SetEvilUrlPolicyAndHwCode( + url, policy, TransformMappingType(mapping_type), hw_code, GURL("")); + return; + } + + for (auto& check_result : response.hash_check_result) { + for (auto& hash_result : check_result.hash_result_list) { + if (hash_result.url_hash == GenerateHashPrefix(url)) { + std::string hash_mapping_type = check_result.mapping_type; + int hash_policy = hash_result.policy; + int hash_hw_code = std::stoi(hash_result.hw_code); + if (hash_hw_code < 0 || + hash_policy < OHSBPolicyType::POLICY_NO_PROMPT || + hash_policy > OHSBPolicyType::POLICY_HALF_POPUP) { + return; + } + sb_client_->SetEvilUrlPolicyAndHwCode( + url, hash_policy, TransformMappingType(hash_mapping_type), + hash_hw_code, GURL("")); + + return; + } + } + } +} + +void SafeBrowsingTabHelper::DidFinishNavigation( + content::NavigationHandle* navigation_handle) {} + +void SafeBrowsingTabHelper::NavigationStopped() {} + +void SafeBrowsingTabHelper::OnConnectionChanged( + network::mojom::ConnectionType type) {} + +WEB_CONTENTS_USER_DATA_KEY_IMPL(SafeBrowsingTabHelper); + +} // namespace ohos_safe_browsing diff --git a/libcef/browser/safe_browsing/safe_browsing_tab_helper.h b/libcef/browser/safe_browsing/safe_browsing_tab_helper.h new file mode 100644 index 0000000000000000000000000000000000000000..fd8eeb435218ed772cd42497dcc9681cc719b29f --- /dev/null +++ b/libcef/browser/safe_browsing/safe_browsing_tab_helper.h @@ -0,0 +1,72 @@ +// Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CEF_LIBCEF_BROWSER_SAFE_BROWSING_SAFE_BROWSING_TAB_HELPER_H_ +#define CEF_LIBCEF_BROWSER_SAFE_BROWSING_SAFE_BROWSING_TAB_HELPER_H_ + +#include "content/public/browser/web_contents_observer.h" +#include "content/public/browser/web_contents_user_data.h" +#include "libcef/browser/browser_host_base.h" +#include "libcef/browser/safe_browsing/sb_client.h" +#include "net/traffic_annotation/network_traffic_annotation.h" +#include "services/data_decoder/public/cpp/data_decoder.h" +#include "services/network/public/cpp/network_connection_tracker.h" +#include "services/network/public/cpp/simple_url_loader.h" + +namespace content { +class NavigationHandle; +class WebContents; +} // namespace content + +namespace ohos_safe_browsing { + +using SBCheckCallback = base::OnceCallback; + +class SafeBrowsingTabHelper + : public content::WebContentsObserver, + public content::WebContentsUserData, + public network::NetworkConnectionTracker::NetworkConnectionObserver { + public: + SafeBrowsingTabHelper(const SafeBrowsingTabHelper&) = delete; + SafeBrowsingTabHelper& operator=(const SafeBrowsingTabHelper&) = delete; + ~SafeBrowsingTabHelper() override; + + // content::WebContentsObserver: + void DidStartNavigation( + content::NavigationHandle* navigation_handle) override; + void DidFinishNavigation( + content::NavigationHandle* navigation_handle) override; + void NavigationStopped() override; + + // network::NetworkConnectionTracker::NetworkConnectionObserver: + void OnConnectionChanged(network::mojom::ConnectionType type) override; + + private: + struct SBCheck; + using SBCheckList = std::list>; + + friend class content::WebContentsUserData; + + explicit SafeBrowsingTabHelper(content::WebContents* web_contents, + CefBrowserHostBase* browser); + + void OnSimpleLoaderComplete(SBCheckList::iterator it, + const GURL& url, + std::unique_ptr response_body); + + raw_ptr connection_tracker_; + SBCheckList checks_running_; + std::unique_ptr sb_client_; + CefBrowserHostBase* browser_{nullptr}; + + bool is_safe_browsing_enabled_{false}; + + base::WeakPtrFactory weak_ptr_factory_{this}; + + WEB_CONTENTS_USER_DATA_KEY_DECL(); +}; + +} // namespace ohos_safe_browsing + +#endif // CEF_LIBCEF_BROWSER_SAFE_BROWSING_SAFE_BROWSING_TAB_HELPER_H_ diff --git a/libcef/browser/safe_browsing/sb_block_page.cc b/libcef/browser/safe_browsing/sb_block_page.cc new file mode 100644 index 0000000000000000000000000000000000000000..3af6f80ca2c2cfba4a5537b23cfc376bb6c7c8fb --- /dev/null +++ b/libcef/browser/safe_browsing/sb_block_page.cc @@ -0,0 +1,115 @@ +// Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "libcef/browser/safe_browsing/sb_block_page.h" + +#include "base/i18n/rtl.h" +#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 "ui/base/l10n/l10n_util.h" +#include "ui/base/resource/resource_bundle.h" +#include "ui/base/webui/jstemplate_builder.h" +#include "ui/base/webui/web_ui_util.h" + +namespace ohos_safe_browsing { + +SbBlockPage::SbBlockPage( + content::WebContents* web_contents, + const GURL& request_url, + int policy, + OHSBThreatType block_type, + std::unique_ptr controller) + : SecurityInterstitialPage(web_contents, + request_url, + std::move(controller)), + block_type_(block_type), + policy_(policy) {} + +SbBlockPage::~SbBlockPage() = default; + +std::string SbBlockPage::GetHTMLContents() { + base::Value::Dict load_time_data; + PopulateInterstitialStrings(load_time_data); + webui::SetLoadTimeDataDefaults(controller()->GetApplicationLocale(), + &load_time_data); + std::string html = + ui::ResourceBundle::GetSharedInstance().LoadDataResourceString( + IDR_BLOCK_ERROR_OHOS_HTML); + + webui::AppendWebUiCssTextDefaults(&html); + return webui::GetI18nTemplateHtml(html, load_time_data); +} + +void SbBlockPage::CommandReceived(const std::string& command) { + if (command == "\"pageLoadComplete\"") { + // content::WaitForRenderFrameReady sends this message when the page + // load completes. Ignore it. + return; + } + + int cmd = 0; + bool retval = base::StringToInt(command, &cmd); + DCHECK(retval); + HandleCommand( + static_cast(cmd)); +} + +void SbBlockPage::HandleCommand( + security_interstitials::SecurityInterstitialCommand command) { + // CMD_DONT_PROCEED + if (command == security_interstitials::CMD_DONT_PROCEED) { + controller()->GoBack(); + } + + // CMD_PROCEED + if (command == security_interstitials::CMD_PROCEED) { + controller()->Reload(); + } +} + +void SbBlockPage::OnInterstitialClosing() {} + +bool SbBlockPage::ShouldDisplayURL() const { + return false; +} + +void SbBlockPage::PopulateInterstitialStrings( + base::Value::Dict& load_time_data) { + load_time_data.Set("policy", std::to_string(policy_)); + load_time_data.Set("title", + l10n_util::GetStringUTF8(IDS_OHOS_BLOCK_PAGE_TITLE)); + if (block_type_ == OHSBThreatType::THREAT_ILLEGAL || + block_type_ == OHSBThreatType::THREAT_RISK) { + load_time_data.Set("block_info_title", l10n_util::GetStringUTF8( + IDS_OHOS_BLOCK_PAGE_INFO_TITLE)); + } else { + load_time_data.Set( + "block_info_title", + l10n_util::GetStringUTF8(IDS_OHOS_BLOCK_PAGE_FRAUD_INFO_TITLE)); + } + + if (block_type_ == OHSBThreatType::THREAT_ILLEGAL) { + load_time_data.Set( + "block_info_body", + l10n_util::GetStringUTF8(IDS_OHOS_BLOCK_PAGE_ILLEGAL_INFO_BODY)); + } else { + load_time_data.Set("block_info_body", + l10n_util::GetStringUTF8(IDS_OHOS_BLOCK_PAGE_INFO_BODY)); + } + + if (base::i18n::IsRTL()) { + load_time_data.Set("page_direction", "rtl"); + } else { + load_time_data.Set("page_direction", "ltr"); + } + + load_time_data.Set("dontproceed", l10n_util::GetStringUTF8( + IDS_OHOS_BLOCK_PAGE_DONT_PROCEED)); + load_time_data.Set("proceed", + l10n_util::GetStringUTF8(IDS_OHOS_BLOCK_PAGE_PROCEED)); +} + +} // namespace ohos_safe_browsing diff --git a/libcef/browser/safe_browsing/sb_block_page.h b/libcef/browser/safe_browsing/sb_block_page.h new file mode 100644 index 0000000000000000000000000000000000000000..b72bca6246e3fe2243e069aaa81734533fbe09ae --- /dev/null +++ b/libcef/browser/safe_browsing/sb_block_page.h @@ -0,0 +1,59 @@ +// Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CEF_LIBCEF_BROWSER_SAFE_BROWSING_SB_BLOCK_PAGE_H_ +#define CEF_LIBCEF_BROWSER_SAFE_BROWSING_SB_BLOCK_PAGE_H_ + +#include + +#include "components/security_interstitials/content/security_interstitial_controller_client.h" +#include "components/security_interstitials/content/security_interstitial_page.h" +#include "components/security_interstitials/core/metrics_helper.h" +#include "content/public/browser/web_contents.h" +#include "url/gurl.h" + +#include "libcef/browser/safe_browsing/sb_controller_client.h" +#include "libcef/browser/safe_browsing/sb_threat_type.h" + +namespace ohos_safe_browsing { + +using security_interstitials::MetricsHelper; +using security_interstitials::SecurityInterstitialControllerClient; +using security_interstitials::SecurityInterstitialPage; + +class SbBlockPage : public SecurityInterstitialPage { + public: + SbBlockPage( + content::WebContents* web_contents, + const GURL& request_url, + int policy, + OHSBThreatType block_type, + std::unique_ptr controller_client); + ~SbBlockPage() override; + + // DISALLOW_COPY_AND_ASSIGN + SbBlockPage(const SbBlockPage&) = delete; + SbBlockPage& operator=(const SbBlockPage&) = delete; + + std::string GetHTMLContents() override; + void OnInterstitialClosing() override; + + bool ShouldDisplayURL() const override; + + void CommandReceived(const std::string& command) override; + + void PopulateInterstitialStrings(base::Value::Dict& load_time_data) override; + + private: + static std::unique_ptr GetMetricsHelper(const GURL& url); + + void HandleCommand(security_interstitials::SecurityInterstitialCommand command); + + OHSBThreatType block_type_; + int policy_; +}; + +} // namespace ohos_safe_browsing + +#endif // CEF_LIBCEF_BROWSER_SAFE_BROWSING_SB_BLOCK_PAGE_H_ \ No newline at end of file diff --git a/libcef/browser/safe_browsing/sb_client.cc b/libcef/browser/safe_browsing/sb_client.cc new file mode 100644 index 0000000000000000000000000000000000000000..8f1a478b106a405003d0723ad192044ff352a6e4 --- /dev/null +++ b/libcef/browser/safe_browsing/sb_client.cc @@ -0,0 +1,238 @@ +// Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "libcef/browser/safe_browsing/sb_client.h" + +#include "base/i18n/rtl.h" +#include "base/logging.h" +#include "base/values.h" +#include "components/security_interstitials/content/security_interstitial_tab_helper.h" +#include "content/public/browser/navigation_details.h" +#include "content/public/browser/navigation_entry.h" +#include "content/public/common/page_type.h" +#include "content/public/common/referrer.h" + +#include "libcef/browser/alloy/alloy_browser_host_impl.h" +#include "libcef/browser/safe_browsing/sb_controller_client.h" +#include "libcef/browser/safe_browsing/sb_prefs.h" + +namespace ohos_safe_browsing { + +SbClient::SbClient(content::WebContents* web_contents, PrefService* prefs) + : content::WebContentsObserver(web_contents), prefs_(prefs) {} + +SbClient::~SbClient() = default; + +// static +bool SbClient::InMaliciousAllowlist(const PrefService* prefs, + const std::string& url) { + if (!prefs) { + return false; + } + + const base::Value::List& list = prefs->GetList(kMaliciousAllowList); + + for (const base::Value& value : list) { + if (value.GetString() == url) { + return true; + } + } + return false; +} + +void SbClient::NavigationEntryCommitted( + const content::LoadCommittedDetails& load_details) { + if (!web_contents() || web_contents()->IsBeingDestroyed()) { + return; + } + + if (!load_details.is_main_frame) { + return; + } + + if (load_details.is_same_document) { + return; + } + + BlockingPageInfo* blocking_page_info = + BlockingPageInfo::FromWebContents(web_contents()); + + if (!blocking_page_info) { + return; + } + + int policy = blocking_page_info->GetPolicy(); + OHSBThreatType last_block_type = blocking_page_info->GetThreatType(); + int last_hw_code = blocking_page_info->GetHwCode(); + GURL last_report_url = blocking_page_info->GetBlockingUrl(); + GURL redirect_url = blocking_page_info->GetBlockingRedirectUrl(); + ShowBlockingPage(last_report_url, policy, last_block_type, last_hw_code, + "zh-CN", redirect_url); +} + +void SbClient::ShowBlockingPage(const GURL& url, + int policy, + OHSBThreatType block_type, + int hw_code, + const std::string& app_locale, + const GURL& redirect_url) { + if (block_type == OHSBThreatType::THREAT_DEFAULT) { + return; + } + + if (!web_contents() || web_contents()->IsBeingDestroyed()) { + return; + } + + content::NavigationEntry* visible_entry = + web_contents()->GetController().GetVisibleEntry(); + + if (!visible_entry) { + LOG(WARNING) << "SafeBrowsing no visible entry, skip."; + return; + } + + bool hit_virtual_url = (visible_entry->GetVirtualURL() == url); + bool hit_redirect_chain = false; + std::vector redirect_chain = visible_entry->GetRedirectChain(); + std::vector::iterator it = + std::find(redirect_chain.begin(), redirect_chain.end(), url); + if (it != redirect_chain.end()) { + hit_redirect_chain = true; + } + + if (!hit_virtual_url && !hit_redirect_chain) { + LOG(WARNING) << "SafeBrowsing hit nothing."; + return; + } + + if ((policy == OHSBPolicyType::POLICY_POPUP_AND_DANGER || + policy == OHSBPolicyType::POLICY_FORBIDDEN_PROHIBIT_ACCESS) && + block_type != OHSBThreatType::THREAT_WARNING) { + NotifySafeBrowsingCheckResult(block_type); + } + + if (block_type == OHSBThreatType::THREAT_WARNING && + policy == OHSBPolicyType::POLICY_HALF_POPUP) { + NotifySafeBrowsingCheckResult(block_type); + } + + if (InMaliciousAllowlist(prefs_, url.has_host() ? url.host() : url.spec())) { + LOG(WARNING) << "SafeBrowsing in malicious allowlist."; + return; + } + + if (visible_entry->GetPageType() == content::PAGE_TYPE_NORMAL) { + DisplayBlockingPage(url, policy, block_type, app_locale); + } +} + +void SbClient::SetEvilUrlPolicyAndHwCode(const GURL& url, + int policy, + OHSBThreatType block_type, + int hw_code, + const GURL& redirect_url) { + BlockingPageInfo::SetBlockingPageInfo(web_contents(), url, policy, block_type, + hw_code, redirect_url); + content::NavigationEntry* pending_entry = + web_contents()->GetController().GetPendingEntry(); + if (!pending_entry && !web_contents()->IsWaitingForResponse()) { + ShowBlockingPage(url, policy, block_type, hw_code, "zh-CN", redirect_url); + } +} + +SbClient::BlockingPageInfo::BlockingPageInfo(content::WebContents* web_contents) + : content::WebContentsUserData(*web_contents) {} + +// static +void SbClient::BlockingPageInfo::SetBlockingPageInfo( + content::WebContents* web_contents, + const GURL& url, + int policy, + OHSBThreatType block_type, + int hw_code, + const GURL& redirect_url) { + BlockingPageInfo::CreateForWebContents(web_contents); + BlockingPageInfo* blocking_page_info = + BlockingPageInfo::FromWebContents(web_contents); + blocking_page_info->url_ = url; + blocking_page_info->policy_ = policy; + blocking_page_info->block_type_ = block_type; + blocking_page_info->hw_code_ = hw_code; + blocking_page_info->redirect_url_ = redirect_url; +} + +const GURL& SbClient::BlockingPageInfo::GetBlockingUrl() const { + return url_; +} + +OHSBThreatType SbClient::BlockingPageInfo::GetThreatType() const { + return block_type_; +} + +int SbClient::BlockingPageInfo::GetPolicy() const { + return policy_; +} + +int SbClient::BlockingPageInfo::GetHwCode() const { + return hw_code_; +} + +const GURL& SbClient::BlockingPageInfo::GetBlockingRedirectUrl() const { + return redirect_url_; +} + +void SbClient::DisplayBlockingPage(const GURL& url, + int policy, + OHSBThreatType block_type, + const std::string& app_locale) { + LOG(INFO) << "SafeBrowsing " << __func__ << " url: " << url.spec() + << ", type: " << block_type; + auto controller = std::make_unique(web_contents(), prefs_, + url, app_locale); + std::unique_ptr blocking_page = std::make_unique( + web_contents(), url, policy, block_type, std::move(controller)); + base::WeakPtr error_page_navigation_handle = + web_contents()->GetController().LoadPostCommitErrorPage( + web_contents()->GetPrimaryMainFrame(), url, + blocking_page->GetHTMLContents(), net::ERR_BLOCKED_BY_CLIENT); + if (error_page_navigation_handle.get()) { + security_interstitials::SecurityInterstitialTabHelper:: + AssociateBlockingPage(error_page_navigation_handle.get(), + std::move(blocking_page)); + } +} + +bool SbClient::IsBlockPageShowing() { + security_interstitials::SecurityInterstitialTabHelper* + security_interstitial_tab_helper = security_interstitials:: + SecurityInterstitialTabHelper::FromWebContents(web_contents()); + return security_interstitial_tab_helper && + security_interstitial_tab_helper->IsDisplayingInterstitial(); +} + +void SbClient::NotifySafeBrowsingCheckResult(OHSBThreatType threat_type) { + if (!web_contents()) { + return; + } + CefRefPtr browser = + AlloyBrowserHostImpl::GetBrowserForContents(web_contents()); + if (!browser.get()) { + return; + } + CefRefPtr client = browser->GetClient(); + if (!client.get()) { + return; + } + CefRefPtr load_handler = client->GetLoadHandler(); + if (!load_handler.get()) { + return; + } + int type = static_cast(threat_type); + load_handler->OnSafeBrowsingCheckResult(type); +} + +WEB_CONTENTS_USER_DATA_KEY_IMPL(SbClient::BlockingPageInfo); + +} // namespace ohos_safe_browsing diff --git a/libcef/browser/safe_browsing/sb_client.h b/libcef/browser/safe_browsing/sb_client.h new file mode 100644 index 0000000000000000000000000000000000000000..211dd9ff364ed12f17d101453a949b11e09aeed0 --- /dev/null +++ b/libcef/browser/safe_browsing/sb_client.h @@ -0,0 +1,103 @@ +// Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CEF_LIBCEF_BROWSER_SAFE_BROWSING_SB_CLIENT_H_ +#define CEF_LIBCEF_BROWSER_SAFE_BROWSING_SB_CLIENT_H_ + +#include + +#include "components/prefs/pref_service.h" +#include "content/browser/renderer_host/navigation_entry_impl.h" +#include "content/public/browser/navigation_handle.h" +#include "content/public/browser/web_contents_observer.h" +#include "content/public/browser/web_contents_user_data.h" + +#include "libcef/browser/safe_browsing/sb_block_page.h" +#include "libcef/browser/safe_browsing/sb_threat_type.h" + +namespace ohos_safe_browsing { + +class SbClient : public content::WebContentsObserver { + public: + explicit SbClient(content::WebContents* web_contents, PrefService* prefs); + ~SbClient() override; + + // DISALLOW_COPY_AND_ASSIGN + SbClient(const SbClient&) = delete; + SbClient& operator=(const SbClient&) = delete; + + class BlockingPageInfo + : public content::WebContentsUserData { + public: + ~BlockingPageInfo() override = default; + + BlockingPageInfo(const BlockingPageInfo&) = delete; + BlockingPageInfo& operator=(const BlockingPageInfo&) = delete; + + static void SetBlockingPageInfo( + content::WebContents* web_contents, + const GURL& url, + int policy, + OHSBThreatType block_type, + int hw_code, + const GURL& redirect_url); + + const GURL& GetBlockingUrl() const; + + int GetPolicy() const; + + OHSBThreatType GetThreatType() const; + + int GetHwCode() const; + + const GURL& GetBlockingRedirectUrl() const; + + private: + explicit BlockingPageInfo(content::WebContents* web_contents); + friend class content::WebContentsUserData; + + GURL url_ = GURL(""); + int policy_{0}; + OHSBThreatType block_type_ = OHSBThreatType::THREAT_DEFAULT; + int hw_code_{0}; + GURL redirect_url_ = GURL(""); + + WEB_CONTENTS_USER_DATA_KEY_DECL(); + }; + + void ShowBlockingPage(const GURL& url, + int policy, + OHSBThreatType block_type, + int hw_code, + const std::string& app_locale, + const GURL& redirect_url); + + bool IsBlockPageShowing(); + + void SetEvilUrlPolicyAndHwCode(const GURL& url, + int policy, + OHSBThreatType block_type, + int hw_code, + const GURL& redirect_url); + + static bool InMaliciousAllowlist(const PrefService* prefs, + const std::string& url); + private: + // WebContentsObserver implementation + void NavigationEntryCommitted( + const content::LoadCommittedDetails& load_details) override; + + void DisplayBlockingPage(const GURL& url, + int policy, + OHSBThreatType block_type, + const std::string& app_locale); + + void NotifySafeBrowsingCheckResult(OHSBThreatType threat_type); + + PrefService* prefs_; +}; + +} // namespace ohos_safe_browsing + +#endif // CEF_LIBCEF_BROWSER_SAFE_BROWSING_SB_CLIENT_H_ diff --git a/libcef/browser/safe_browsing/sb_controller_client.cc b/libcef/browser/safe_browsing/sb_controller_client.cc new file mode 100644 index 0000000000000000000000000000000000000000..7a29232f4d6ea232268b27efcf37f11dfcbe656c --- /dev/null +++ b/libcef/browser/safe_browsing/sb_controller_client.cc @@ -0,0 +1,77 @@ +// Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "libcef/browser/safe_browsing/sb_controller_client.h" + +#include "components/prefs/scoped_user_pref_update.h" +#include "components/safe_browsing/core/common/safe_browsing_prefs.h" +#include "components/security_interstitials/content/settings_page_helper.h" +#include "components/security_interstitials/core/metrics_helper.h" +#include "content/browser/renderer_host/navigation_controller_impl.h" +#include "content/public/browser/web_contents.h" +#include "content/public/common/referrer.h" +#include "libcef/browser/safe_browsing/sb_prefs.h" + + +constexpr char kDefaultPageUrl[] = "about:blank"; + +SbControllerClient::SbControllerClient(content::WebContents* web_contents, + PrefService* prefs, + const GURL& url, + const std::string& app_locale) + : SecurityInterstitialControllerClient(web_contents, + GetMetricsHelper(url), + prefs, + app_locale, + GURL(kDefaultPageUrl), + /*settings_page_helper=*/nullptr), + web_contents_ {web_contents}, + prefs_(prefs), + app_locale_{app_locale}, + url_(url) {} + +SbControllerClient::~SbControllerClient() {} + +// static +std::unique_ptr SbControllerClient::GetMetricsHelper( + const GURL& url) { + MetricsHelper::ReportDetails settings; + settings.metric_prefix = "oh.safe_browsing"; + + return std::make_unique(url, settings, nullptr); +} + +void SbControllerClient::GoBack() { + SecurityInterstitialControllerClient::GoBackAfterNavigationCommitted(); + return; +} + +void SbControllerClient::Proceed() { + // With committed interstitials the site has already + // been added to the allowlist, so reload will proceed. + Reload(); + return; +} + +void SbControllerClient::Reload() { + if (!web_contents_) + return; + + ScopedListPrefUpdate(prefs_, ohos_safe_browsing::kMaliciousAllowList) + ->Append(url_.has_host()? url_.host() : url_.spec()); + web_contents_->GetController().Reload(content::ReloadType::NORMAL, true); +} + +PrefService* SbControllerClient::GetPrefService() { + return prefs_; +} + +const std::string& SbControllerClient::GetApplicationLocale() const { + return app_locale_; +} + +const std::string SbControllerClient::GetExtendedReportingPrefName() const { + return std::string(); +} + diff --git a/libcef/browser/safe_browsing/sb_controller_client.h b/libcef/browser/safe_browsing/sb_controller_client.h new file mode 100644 index 0000000000000000000000000000000000000000..254e6a924c8f6370374a1efbe9d58133034fa5ff --- /dev/null +++ b/libcef/browser/safe_browsing/sb_controller_client.h @@ -0,0 +1,57 @@ +// Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CEF_LIBCEF_BROWSER_SAFE_BROWSING_SB_CONTROLLER_CLIENT_H_ +#define CEF_LIBCEF_BROWSER_SAFE_BROWSING_SB_CONTROLLER_CLIENT_H_ + +#include +#include + +#include "components/prefs/pref_service.h" +#include "components/security_interstitials/content/security_interstitial_controller_client.h" +#include "content/browser/renderer_host/navigation_entry_impl.h" + +#include "url/gurl.h" + +namespace content { +class WebContents; +} // namespace content + +namespace security_interstitials { +class MetricsHelper; +class SettingsPageHelper; +} // namespace security_interstitials + + +using security_interstitials::MetricsHelper; +using security_interstitials::SecurityInterstitialControllerClient; + +class SbControllerClient : public SecurityInterstitialControllerClient { + public: + SbControllerClient(content::WebContents* web_contents, + PrefService* prefs, + const GURL& url, + const std::string& app_locale); + + ~SbControllerClient() override; + + void Proceed() override; + void Reload() override; + void GoBack() override; + PrefService* GetPrefService() override; + const std::string& GetApplicationLocale() const override; + +protected: + const std::string GetExtendedReportingPrefName() const override; + content::WebContents* web_contents_; + +private: + static std::unique_ptr GetMetricsHelper(const GURL& url); + + PrefService* prefs_; + const std::string app_locale_; + GURL url_; +}; + +#endif // CEF_LIBCEF_BROWSER_SAFE_BROWSING_SB_CONTROLLER_CLIENT_H_ diff --git a/libcef/browser/safe_browsing/sb_prefs.cc b/libcef/browser/safe_browsing/sb_prefs.cc new file mode 100644 index 0000000000000000000000000000000000000000..27b1c91bd0e86b072588e82633f4e9e7e9fd86bc --- /dev/null +++ b/libcef/browser/safe_browsing/sb_prefs.cc @@ -0,0 +1,17 @@ +// Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "libcef/browser/safe_browsing/sb_prefs.h" + +#include "components/prefs/pref_registry_simple.h" + +namespace ohos_safe_browsing { + +const char kMaliciousAllowList[] = "oh.safe_browsing.malicious_allowlist"; + +void RegisterProfilePrefs(PrefRegistrySimple* registry) { + registry->RegisterListPref(kMaliciousAllowList); +} + +} // namespace ohos_safe_browsing diff --git a/libcef/browser/safe_browsing/sb_prefs.h b/libcef/browser/safe_browsing/sb_prefs.h new file mode 100644 index 0000000000000000000000000000000000000000..f3018aa26c0f1e104b4fb9dd19a1c46f17ff8bb1 --- /dev/null +++ b/libcef/browser/safe_browsing/sb_prefs.h @@ -0,0 +1,18 @@ +// Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CEF_LIBCEF_BROWSER_SAFE_BROWSING_SB_PREFS_H_ +#define CEF_LIBCEF_BROWSER_SAFE_BROWSING_SB_PREFS_H_ + +#include "components/prefs/pref_registry_simple.h" + +namespace ohos_safe_browsing { + +extern const char kMaliciousAllowList[]; + +void RegisterProfilePrefs(PrefRegistrySimple* registry); + +} // namespace ohos_safe_browsing + +#endif // CEF_LIBCEF_BROWSER_SAFE_BROWSING_SB_PREFS_H_ diff --git a/libcef/browser/safe_browsing/sb_threat_type.h b/libcef/browser/safe_browsing/sb_threat_type.h new file mode 100644 index 0000000000000000000000000000000000000000..4dcea2f22676f14c18d91717c4421b0d9f7ac5d1 --- /dev/null +++ b/libcef/browser/safe_browsing/sb_threat_type.h @@ -0,0 +1,31 @@ +// Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CEF_LIBCEF_BROWSER_SAFE_BROWSING_SB_THREAT_TYPE_H_ +#define CEF_LIBCEF_BROWSER_SAFE_BROWSING_SB_THREAT_TYPE_H_ + +namespace ohos_safe_browsing { + +// The type of block page +enum OHSBThreatType { + THREAT_DEFAULT = -1, + THREAT_ILLEGAL = 0, + THREAT_FRAUD = 1, + THREAT_RISK = 2, + THREAT_WARNING = 3, +}; + +enum OHSBPolicyType { + POLICY_NO_PROMPT = 0, + POLICY_DANGER_LABEL = 1, + POLICY_POPUP_AND_DANGER = 2, + POLICY_FORBIDDEN_PROHIBIT_ACCESS = 3, + POLICY_CHILD_MODE_PROHIBIT_ACCESS = 4, + POLICY_CUSTOMIZE_JUMP = 5, + POLICY_HALF_POPUP = 6, +}; + +} // namespace ohos_safe_browsing + +#endif // CEF_LIBCEF_BROWSER_SAFE_BROWSING_SB_THREAT_TYPE_H_ diff --git a/libcef/renderer/alloy/alloy_content_renderer_client.cc b/libcef/renderer/alloy/alloy_content_renderer_client.cc index e696e527e971b5c1016049263fdafb825a326bb3..3803d6d0c4d3d687c21a381607399b44756a76af 100644 --- a/libcef/renderer/alloy/alloy_content_renderer_client.cc +++ b/libcef/renderer/alloy/alloy_content_renderer_client.cc @@ -141,6 +141,8 @@ #include "printing/metafile_agent.h" #endif +#include "libcef/renderer/alloy/alloy_safe_browsing_error_page_controller_delegate_impl.h" + AlloyContentRendererClient::AlloyContentRendererClient() : main_entry_time_(base::TimeTicks::Now()), render_manager_(new CefRenderManager) { @@ -339,6 +341,7 @@ void AlloyContentRendererClient::RenderFrameCreated( #if BUILDFLAG(IS_OHOS) new js_injection::JsCommunication(render_frame); new AlloyContentSettingsClient(render_frame); + new AlloySafeBrowsingErrorPageControllerDelegateImpl(render_frame); #endif auto render_frame_observer = new CefRenderFrameObserver(render_frame); diff --git a/libcef/renderer/alloy/alloy_safe_browsing_error_page_controller_delegate_impl.cc b/libcef/renderer/alloy/alloy_safe_browsing_error_page_controller_delegate_impl.cc new file mode 100644 index 0000000000000000000000000000000000000000..50f444eee4404a729f90770a170e7e9b5b8ef8b0 --- /dev/null +++ b/libcef/renderer/alloy/alloy_safe_browsing_error_page_controller_delegate_impl.cc @@ -0,0 +1,38 @@ +// Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "libcef/renderer/alloy/alloy_safe_browsing_error_page_controller_delegate_impl.h" + +#include "content/public/renderer/render_frame.h" + +AlloySafeBrowsingErrorPageControllerDelegateImpl:: + AlloySafeBrowsingErrorPageControllerDelegateImpl( + content::RenderFrame* render_frame) + : content::RenderFrameObserver(render_frame), + content::RenderFrameObserverTracker< + AlloySafeBrowsingErrorPageControllerDelegateImpl>(render_frame) {} + +AlloySafeBrowsingErrorPageControllerDelegateImpl:: + ~AlloySafeBrowsingErrorPageControllerDelegateImpl() = default; + +void AlloySafeBrowsingErrorPageControllerDelegateImpl::PrepareForErrorPage() { + pending_error_ = true; +} + +void AlloySafeBrowsingErrorPageControllerDelegateImpl::OnDestruct() { + delete this; +} + +void AlloySafeBrowsingErrorPageControllerDelegateImpl::DidCommitProvisionalLoad( + ui::PageTransition transition) { + committed_error_ = pending_error_; + pending_error_ = false; +} + +void AlloySafeBrowsingErrorPageControllerDelegateImpl::DidFinishLoad() { + if (committed_error_) { + security_interstitials::SecurityInterstitialPageController::Install( + render_frame()); + } +} \ No newline at end of file diff --git a/libcef/renderer/alloy/alloy_safe_browsing_error_page_controller_delegate_impl.h b/libcef/renderer/alloy/alloy_safe_browsing_error_page_controller_delegate_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..f52aa58c75798ea45dc92cb983046ce5f35b7024 --- /dev/null +++ b/libcef/renderer/alloy/alloy_safe_browsing_error_page_controller_delegate_impl.h @@ -0,0 +1,44 @@ +// Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/security_interstitials/content/renderer/security_interstitial_page_controller.h" +#include "components/security_interstitials/core/controller_client.h" +#include "content/public/renderer/render_frame_observer.h" +#include "content/public/renderer/render_frame_observer_tracker.h" + +namespace content { +class RenderFrame; +} // namespace content + +class AlloySafeBrowsingErrorPageControllerDelegateImpl + : public content::RenderFrameObserver, + public content::RenderFrameObserverTracker< + AlloySafeBrowsingErrorPageControllerDelegateImpl> { + public: + explicit AlloySafeBrowsingErrorPageControllerDelegateImpl( + content::RenderFrame* render_frame); + + // Disallow copy and assign + AlloySafeBrowsingErrorPageControllerDelegateImpl( + const AlloySafeBrowsingErrorPageControllerDelegateImpl&) = delete; + AlloySafeBrowsingErrorPageControllerDelegateImpl& operator=( + const AlloySafeBrowsingErrorPageControllerDelegateImpl&) = delete; + + ~AlloySafeBrowsingErrorPageControllerDelegateImpl() override; + + // Notifies us that a navigation error has occurred and will be committed + void PrepareForErrorPage(); + + // content::RenderFrameObserver: + void OnDestruct() override; + void DidCommitProvisionalLoad(ui::PageTransition transition) override; + void DidFinishLoad() override; + + private: + // Whether there is an error page pending to be committed. + bool pending_error_ = false; + + // Whether the committed page is an error page. + bool committed_error_ = false; +}; \ No newline at end of file diff --git a/libcef/renderer/browser_impl.h b/libcef/renderer/browser_impl.h index 614462624beb41382700bf40fdc50681d0a95228..bfe09e041faa55f9bf7b129fbcdce4080de7fe63 100644 --- a/libcef/renderer/browser_impl.h +++ b/libcef/renderer/browser_impl.h @@ -131,6 +131,11 @@ class CefBrowserImpl : public CefBrowser, public blink::WebViewObserver { // #endif #endif +#if BUILDFLAG(IS_OHOS) + bool IsSafeBrowsingEnabled() override{ return false; } + void EnableSafeBrowsing(bool enable) override{} +#endif + // #if defined(OHOS_NWEB_EX) // NOTE: Keep the previous line commented, add NWebEx APIs below. bool ShouldShowLoadingUI() override; diff --git a/libcef_dll/cpptoc/browser_cpptoc.cc b/libcef_dll/cpptoc/browser_cpptoc.cc index 01a2c6dae09219dfd0017eb24077cd2624437549..f0dfc9b22ed9637a87c0fe8a4d2082fd73206af9 100644 --- a/libcef_dll/cpptoc/browser_cpptoc.cc +++ b/libcef_dll/cpptoc/browser_cpptoc.cc @@ -9,23 +9,23 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=9c830290435800c80133057cf3ae0b9629f2ae5b$ +// $hash=028ec9917a30ce35c12572d0b5c61d9608c5f4c8$ // #include "libcef_dll/cpptoc/browser_cpptoc.h" +#include #include "libcef_dll/cpptoc/browser_host_cpptoc.h" #include "libcef_dll/cpptoc/browser_permission_request_delegate_cpptoc.h" #include "libcef_dll/cpptoc/frame_cpptoc.h" #include "libcef_dll/cpptoc/geolocation_acess_cpptoc.h" #include "libcef_dll/shutdown_checker.h" #include "libcef_dll/transfer_util.h" -#include namespace { // MEMBER FUNCTIONS - Body may be edited by hand. -int CEF_CALLBACK browser_is_valid(struct _cef_browser_t *self) { +int CEF_CALLBACK browser_is_valid(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -42,8 +42,8 @@ int CEF_CALLBACK browser_is_valid(struct _cef_browser_t *self) { return _retval; } -struct _cef_browser_host_t *CEF_CALLBACK -browser_get_host(struct _cef_browser_t *self) { +struct _cef_browser_host_t* CEF_CALLBACK +browser_get_host(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -60,7 +60,7 @@ browser_get_host(struct _cef_browser_t *self) { return CefBrowserHostCppToC::Wrap(_retval); } -int CEF_CALLBACK browser_can_go_back(struct _cef_browser_t *self) { +int CEF_CALLBACK browser_can_go_back(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -77,7 +77,7 @@ int CEF_CALLBACK browser_can_go_back(struct _cef_browser_t *self) { return _retval; } -void CEF_CALLBACK browser_go_back(struct _cef_browser_t *self) { +void CEF_CALLBACK browser_go_back(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -91,7 +91,7 @@ void CEF_CALLBACK browser_go_back(struct _cef_browser_t *self) { CefBrowserCppToC::Get(self)->GoBack(); } -int CEF_CALLBACK browser_can_go_forward(struct _cef_browser_t *self) { +int CEF_CALLBACK browser_can_go_forward(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -108,7 +108,7 @@ int CEF_CALLBACK browser_can_go_forward(struct _cef_browser_t *self) { return _retval; } -void CEF_CALLBACK browser_go_forward(struct _cef_browser_t *self) { +void CEF_CALLBACK browser_go_forward(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -122,7 +122,7 @@ void CEF_CALLBACK browser_go_forward(struct _cef_browser_t *self) { CefBrowserCppToC::Get(self)->GoForward(); } -int CEF_CALLBACK browser_is_loading(struct _cef_browser_t *self) { +int CEF_CALLBACK browser_is_loading(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -139,7 +139,7 @@ int CEF_CALLBACK browser_is_loading(struct _cef_browser_t *self) { return _retval; } -void CEF_CALLBACK browser_reload(struct _cef_browser_t *self) { +void CEF_CALLBACK browser_reload(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -153,7 +153,7 @@ void CEF_CALLBACK browser_reload(struct _cef_browser_t *self) { CefBrowserCppToC::Get(self)->Reload(); } -void CEF_CALLBACK browser_reload_ignore_cache(struct _cef_browser_t *self) { +void CEF_CALLBACK browser_reload_ignore_cache(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -167,7 +167,7 @@ void CEF_CALLBACK browser_reload_ignore_cache(struct _cef_browser_t *self) { CefBrowserCppToC::Get(self)->ReloadIgnoreCache(); } -void CEF_CALLBACK browser_stop_load(struct _cef_browser_t *self) { +void CEF_CALLBACK browser_stop_load(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -181,7 +181,7 @@ void CEF_CALLBACK browser_stop_load(struct _cef_browser_t *self) { CefBrowserCppToC::Get(self)->StopLoad(); } -int CEF_CALLBACK browser_get_identifier(struct _cef_browser_t *self) { +int CEF_CALLBACK browser_get_identifier(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -198,8 +198,8 @@ int CEF_CALLBACK browser_get_identifier(struct _cef_browser_t *self) { return _retval; } -int CEF_CALLBACK browser_is_same(struct _cef_browser_t *self, - struct _cef_browser_t *that) { +int CEF_CALLBACK browser_is_same(struct _cef_browser_t* self, + struct _cef_browser_t* that) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -222,7 +222,7 @@ int CEF_CALLBACK browser_is_same(struct _cef_browser_t *self, return _retval; } -int CEF_CALLBACK browser_is_popup(struct _cef_browser_t *self) { +int CEF_CALLBACK browser_is_popup(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -239,7 +239,7 @@ int CEF_CALLBACK browser_is_popup(struct _cef_browser_t *self) { return _retval; } -int CEF_CALLBACK browser_has_document(struct _cef_browser_t *self) { +int CEF_CALLBACK browser_has_document(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -256,8 +256,8 @@ int CEF_CALLBACK browser_has_document(struct _cef_browser_t *self) { return _retval; } -struct _cef_frame_t *CEF_CALLBACK -browser_get_main_frame(struct _cef_browser_t *self) { +struct _cef_frame_t* CEF_CALLBACK +browser_get_main_frame(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -274,8 +274,8 @@ browser_get_main_frame(struct _cef_browser_t *self) { return CefFrameCppToC::Wrap(_retval); } -struct _cef_frame_t *CEF_CALLBACK -browser_get_focused_frame(struct _cef_browser_t *self) { +struct _cef_frame_t* CEF_CALLBACK +browser_get_focused_frame(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -292,8 +292,8 @@ browser_get_focused_frame(struct _cef_browser_t *self) { return CefFrameCppToC::Wrap(_retval); } -struct _cef_frame_t *CEF_CALLBACK -browser_get_frame_byident(struct _cef_browser_t *self, int64 identifier) { +struct _cef_frame_t* CEF_CALLBACK +browser_get_frame_byident(struct _cef_browser_t* self, int64 identifier) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -311,8 +311,8 @@ browser_get_frame_byident(struct _cef_browser_t *self, int64 identifier) { return CefFrameCppToC::Wrap(_retval); } -struct _cef_frame_t *CEF_CALLBACK browser_get_frame(struct _cef_browser_t *self, - const cef_string_t *name) { +struct _cef_frame_t* CEF_CALLBACK browser_get_frame(struct _cef_browser_t* self, + const cef_string_t* name) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -331,7 +331,7 @@ struct _cef_frame_t *CEF_CALLBACK browser_get_frame(struct _cef_browser_t *self, return CefFrameCppToC::Wrap(_retval); } -size_t CEF_CALLBACK browser_get_frame_count(struct _cef_browser_t *self) { +size_t CEF_CALLBACK browser_get_frame_count(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -348,9 +348,9 @@ size_t CEF_CALLBACK browser_get_frame_count(struct _cef_browser_t *self) { return _retval; } -void CEF_CALLBACK browser_get_frame_identifiers(struct _cef_browser_t *self, - size_t *identifiersCount, - int64 *identifiers) { +void CEF_CALLBACK browser_get_frame_identifiers(struct _cef_browser_t* self, + size_t* identifiersCount, + int64* identifiers) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -387,7 +387,7 @@ void CEF_CALLBACK browser_get_frame_identifiers(struct _cef_browser_t *self, } } -void CEF_CALLBACK browser_get_frame_names(struct _cef_browser_t *self, +void CEF_CALLBACK browser_get_frame_names(struct _cef_browser_t* self, cef_string_list_t names) { shutdown_checker::AssertNotShutdown(); @@ -415,8 +415,8 @@ void CEF_CALLBACK browser_get_frame_names(struct _cef_browser_t *self, transfer_string_list_contents(namesList, names); } -struct _cef_browser_permission_request_delegate_t *CEF_CALLBACK -browser_get_permission_request_delegate(struct _cef_browser_t *self) { +struct _cef_browser_permission_request_delegate_t* CEF_CALLBACK +browser_get_permission_request_delegate(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -434,8 +434,8 @@ browser_get_permission_request_delegate(struct _cef_browser_t *self) { return CefBrowserPermissionRequestDelegateCppToC::Wrap(_retval); } -struct _cef_geolocation_acess_t *CEF_CALLBACK -browser_get_geolocation_permissions(struct _cef_browser_t *self) { +struct _cef_geolocation_acess_t* CEF_CALLBACK +browser_get_geolocation_permissions(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -453,7 +453,7 @@ browser_get_geolocation_permissions(struct _cef_browser_t *self) { return CefGeolocationAcessCppToC::Wrap(_retval); } -int CEF_CALLBACK browser_can_go_back_or_forward(struct _cef_browser_t *self, +int CEF_CALLBACK browser_can_go_back_or_forward(struct _cef_browser_t* self, int num_steps) { shutdown_checker::AssertNotShutdown(); @@ -471,7 +471,7 @@ int CEF_CALLBACK browser_can_go_back_or_forward(struct _cef_browser_t *self, return _retval; } -void CEF_CALLBACK browser_go_back_or_forward(struct _cef_browser_t *self, +void CEF_CALLBACK browser_go_back_or_forward(struct _cef_browser_t* self, int num_steps) { shutdown_checker::AssertNotShutdown(); @@ -486,7 +486,7 @@ void CEF_CALLBACK browser_go_back_or_forward(struct _cef_browser_t *self, CefBrowserCppToC::Get(self)->GoBackOrForward(num_steps); } -void CEF_CALLBACK browser_delete_history(struct _cef_browser_t *self) { +void CEF_CALLBACK browser_delete_history(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -500,7 +500,7 @@ void CEF_CALLBACK browser_delete_history(struct _cef_browser_t *self) { CefBrowserCppToC::Get(self)->DeleteHistory(); } -void CEF_CALLBACK browser_select_and_copy(struct _cef_browser_t *self) { +void CEF_CALLBACK browser_select_and_copy(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -514,7 +514,7 @@ void CEF_CALLBACK browser_select_and_copy(struct _cef_browser_t *self) { CefBrowserCppToC::Get(self)->SelectAndCopy(); } -int CEF_CALLBACK browser_should_show_free_copy(struct _cef_browser_t *self) { +int CEF_CALLBACK browser_should_show_free_copy(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -531,8 +531,9 @@ int CEF_CALLBACK browser_should_show_free_copy(struct _cef_browser_t *self) { return _retval; } -void CEF_CALLBACK browser_password_suggestion_selected( - struct _cef_browser_t *self, int list_index) { +void CEF_CALLBACK +browser_password_suggestion_selected(struct _cef_browser_t* self, + int list_index) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -546,8 +547,11 @@ void CEF_CALLBACK browser_password_suggestion_selected( CefBrowserCppToC::Get(self)->PasswordSuggestionSelected(list_index); } -void CEF_CALLBACK browser_update_browser_controls_state( - struct _cef_browser_t *self, int constraints, int current, int animate) { +void CEF_CALLBACK +browser_update_browser_controls_state(struct _cef_browser_t* self, + int constraints, + int current, + int animate) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -562,8 +566,10 @@ void CEF_CALLBACK browser_update_browser_controls_state( constraints, current, animate ? true : false); } -void CEF_CALLBACK browser_update_browser_controls_height( - struct _cef_browser_t *self, int height, int animate) { +void CEF_CALLBACK +browser_update_browser_controls_height(struct _cef_browser_t* self, + int height, + int animate) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -578,9 +584,9 @@ void CEF_CALLBACK browser_update_browser_controls_height( height, animate ? true : false); } -void CEF_CALLBACK browser_prefetch_page(struct _cef_browser_t *self, - cef_string_t *url, - cef_string_t *additionalHttpHeaders) { +void CEF_CALLBACK browser_prefetch_page(struct _cef_browser_t* self, + cef_string_t* url, + cef_string_t* additionalHttpHeaders) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -609,7 +615,7 @@ void CEF_CALLBACK browser_prefetch_page(struct _cef_browser_t *self, CefBrowserCppToC::Get(self)->PrefetchPage(urlStr, additionalHttpHeadersStr); } -void CEF_CALLBACK browser_reload_original_url(struct _cef_browser_t *self) { +void CEF_CALLBACK browser_reload_original_url(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -623,7 +629,7 @@ void CEF_CALLBACK browser_reload_original_url(struct _cef_browser_t *self) { CefBrowserCppToC::Get(self)->ReloadOriginalUrl(); } -int CEF_CALLBACK browser_can_store_web_archive(struct _cef_browser_t *self) { +int CEF_CALLBACK browser_can_store_web_archive(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -640,8 +646,9 @@ int CEF_CALLBACK browser_can_store_web_archive(struct _cef_browser_t *self) { return _retval; } -void CEF_CALLBACK browser_set_browser_user_agent_string( - struct _cef_browser_t *self, const cef_string_t *user_agent) { +void CEF_CALLBACK +browser_set_browser_user_agent_string(struct _cef_browser_t* self, + const cef_string_t* user_agent) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -660,7 +667,7 @@ void CEF_CALLBACK browser_set_browser_user_agent_string( CefBrowserCppToC::Get(self)->SetBrowserUserAgentString(CefString(user_agent)); } -int CEF_CALLBACK browser_should_show_loading_ui(struct _cef_browser_t *self) { +int CEF_CALLBACK browser_should_show_loading_ui(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -677,7 +684,7 @@ int CEF_CALLBACK browser_should_show_loading_ui(struct _cef_browser_t *self) { return _retval; } -void CEF_CALLBACK browser_set_force_enable_zoom(struct _cef_browser_t *self, +void CEF_CALLBACK browser_set_force_enable_zoom(struct _cef_browser_t* self, int forceEnableZoom) { shutdown_checker::AssertNotShutdown(); @@ -693,7 +700,7 @@ void CEF_CALLBACK browser_set_force_enable_zoom(struct _cef_browser_t *self, : false); } -int CEF_CALLBACK browser_get_force_enable_zoom(struct _cef_browser_t *self) { +int CEF_CALLBACK browser_get_force_enable_zoom(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -710,7 +717,7 @@ int CEF_CALLBACK browser_get_force_enable_zoom(struct _cef_browser_t *self) { return _retval; } -int CEF_CALLBACK browser_get_nweb_id(struct _cef_browser_t *self) { +int CEF_CALLBACK browser_get_nweb_id(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -727,8 +734,9 @@ int CEF_CALLBACK browser_get_nweb_id(struct _cef_browser_t *self) { return _retval; } -void CEF_CALLBACK browser_set_enable_blank_target_popup_intercept( - struct _cef_browser_t *self, int enableBlankTargetPopup) { +void CEF_CALLBACK +browser_set_enable_blank_target_popup_intercept(struct _cef_browser_t* self, + int enableBlankTargetPopup) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -744,7 +752,7 @@ void CEF_CALLBACK browser_set_enable_blank_target_popup_intercept( } int CEF_CALLBACK -browser_get_save_password_automatically(struct _cef_browser_t *self) { +browser_get_save_password_automatically(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -761,8 +769,9 @@ browser_get_save_password_automatically(struct _cef_browser_t *self) { return _retval; } -void CEF_CALLBACK browser_set_save_password_automatically( - struct _cef_browser_t *self, int enable) { +void CEF_CALLBACK +browser_set_save_password_automatically(struct _cef_browser_t* self, + int enable) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -777,7 +786,7 @@ void CEF_CALLBACK browser_set_save_password_automatically( : false); } -void CEF_CALLBACK browser_save_or_update_password(struct _cef_browser_t *self, +void CEF_CALLBACK browser_save_or_update_password(struct _cef_browser_t* self, int is_update) { shutdown_checker::AssertNotShutdown(); @@ -792,7 +801,7 @@ void CEF_CALLBACK browser_save_or_update_password(struct _cef_browser_t *self, CefBrowserCppToC::Get(self)->SaveOrUpdatePassword(is_update ? true : false); } -int CEF_CALLBACK browser_get_save_password(struct _cef_browser_t *self) { +int CEF_CALLBACK browser_get_save_password(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -809,7 +818,7 @@ int CEF_CALLBACK browser_get_save_password(struct _cef_browser_t *self) { return _retval; } -void CEF_CALLBACK browser_set_save_password(struct _cef_browser_t *self, +void CEF_CALLBACK browser_set_save_password(struct _cef_browser_t* self, int enable) { shutdown_checker::AssertNotShutdown(); @@ -824,7 +833,7 @@ void CEF_CALLBACK browser_set_save_password(struct _cef_browser_t *self, CefBrowserCppToC::Get(self)->SetSavePassword(enable ? true : false); } -int CEF_CALLBACK browser_get_security_level(struct _cef_browser_t *self) { +int CEF_CALLBACK browser_get_security_level(struct _cef_browser_t* self) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -841,7 +850,39 @@ int CEF_CALLBACK browser_get_security_level(struct _cef_browser_t *self) { return _retval; } -} // namespace +void CEF_CALLBACK browser_enable_safe_browsing(struct _cef_browser_t* self, + int enable) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) { + return; + } + + // Execute + CefBrowserCppToC::Get(self)->EnableSafeBrowsing(enable ? true : false); +} + +int CEF_CALLBACK browser_is_safe_browsing_enabled(struct _cef_browser_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) { + return 0; + } + + // Execute + bool _retval = CefBrowserCppToC::Get(self)->IsSafeBrowsingEnabled(); + + // Return type: bool + return _retval; +} + +} // namespace // CONSTRUCTOR - Do not edit by hand. @@ -901,20 +942,26 @@ CefBrowserCppToC::CefBrowserCppToC() { GetStruct()->get_save_password = browser_get_save_password; GetStruct()->set_save_password = browser_set_save_password; GetStruct()->get_security_level = browser_get_security_level; + GetStruct()->enable_safe_browsing = browser_enable_safe_browsing; + GetStruct()->is_safe_browsing_enabled = browser_is_safe_browsing_enabled; } // DESTRUCTOR - Do not edit by hand. -CefBrowserCppToC::~CefBrowserCppToC() { shutdown_checker::AssertNotShutdown(); } +CefBrowserCppToC::~CefBrowserCppToC() { + shutdown_checker::AssertNotShutdown(); +} template <> CefRefPtr CefCppToCRefCounted::UnwrapDerived( - CefWrapperType type, cef_browser_t *s) { + CefWrapperType type, + cef_browser_t* s) { DCHECK(false) << "Unexpected class type: " << type; return nullptr; } template <> -CefWrapperType CefCppToCRefCounted::kWrapperType = WT_BROWSER; diff --git a/libcef_dll/cpptoc/browser_host_cpptoc.cc b/libcef_dll/cpptoc/browser_host_cpptoc.cc index 5771d05e3ebc2a945d3aa663be89ab0823ead789..0ba43d6bb81ff33908086fc623c0bad7c1499dcb 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=b0a94c3f6b5fac77536545c09cac5ecc96eced4e$ +// $hash=85746e2dd526a03a4daaa64d528786e82fc4c9d1$ // #include "libcef_dll/cpptoc/browser_host_cpptoc.h" @@ -2785,6 +2785,23 @@ browser_host_set_overscroll_mode(struct _cef_browser_host_t* self, int mode) { CefBrowserHostCppToC::Get(self)->SetOverscrollMode(mode); } +void CEF_CALLBACK +browser_host_set_native_embed_mode_enabled(struct _cef_browser_host_t* self, + int mode) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) { + return; + } + + // Execute + CefBrowserHostCppToC::Get(self)->SetNativeEmbedModeEnabled(mode ? true + : false); +} + int CEF_CALLBACK browser_host_discard(struct _cef_browser_host_t* self) { shutdown_checker::AssertNotShutdown(); @@ -2991,6 +3008,8 @@ CefBrowserHostCppToC::CefBrowserHostCppToC() { GetStruct()->create_web_print_document_adapter = browser_host_create_web_print_document_adapter; GetStruct()->set_overscroll_mode = browser_host_set_overscroll_mode; + GetStruct()->set_native_embed_mode_enabled = + browser_host_set_native_embed_mode_enabled; GetStruct()->discard = browser_host_discard; GetStruct()->restore = browser_host_restore; GetStruct()->set_browser_zoom_level = browser_host_set_browser_zoom_level; diff --git a/libcef_dll/cpptoc/load_handler_cpptoc.cc b/libcef_dll/cpptoc/load_handler_cpptoc.cc index d82ebb85297f87f29c3dfba686aad7e6f52ef6ec..2019317129cf889e769d402766230a2235193140 100644 --- a/libcef_dll/cpptoc/load_handler_cpptoc.cc +++ b/libcef_dll/cpptoc/load_handler_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=82acc13b1a3c86b905a8ad18830a1a98193bdcb3$ +// $hash=16ee4c651071d882c6893f401ebf9e622cdff451$ // #include "libcef_dll/cpptoc/load_handler_cpptoc.h" @@ -339,6 +339,22 @@ void CEF_CALLBACK load_handler_on_navigation_entry_committed( CefLoadCommittedDetailsCToCpp::Wrap(details)); } +void CEF_CALLBACK +load_handler_on_safe_browsing_check_result(struct _cef_load_handler_t* self, + int threat_type) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) { + return; + } + + // Execute + CefLoadHandlerCppToC::Get(self)->OnSafeBrowsingCheckResult(threat_type); +} + } // namespace // CONSTRUCTOR - Do not edit by hand. @@ -359,6 +375,8 @@ CefLoadHandlerCppToC::CefLoadHandlerCppToC() { load_handler_on_first_contentful_paint; GetStruct()->on_navigation_entry_committed = load_handler_on_navigation_entry_committed; + GetStruct()->on_safe_browsing_check_result = + load_handler_on_safe_browsing_check_result; } // DESTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/ctocpp/browser_ctocpp.cc b/libcef_dll/ctocpp/browser_ctocpp.cc index cde22c5e065b5fb944b030fabaf8e44437e9796e..a481733dd75baf3861233caa3f36cf448656502e 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=d0d1d1b76e91a9c6732de8c5e9709fa30fb7084e$ +// $hash=6ba64a0a065c6b3f7e052240cf4ed2efe3216ffb$ // #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; } @@ -823,22 +824,58 @@ NO_SANITIZE("cfi-icall") int CefBrowserCToCpp::GetSecurityLevel() { return _retval; } +NO_SANITIZE("cfi-icall") +void CefBrowserCToCpp::EnableSafeBrowsing(bool enable) { + shutdown_checker::AssertNotShutdown(); + + cef_browser_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, enable_safe_browsing)) { + return; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->enable_safe_browsing(_struct, enable); +} + +NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::IsSafeBrowsingEnabled() { + shutdown_checker::AssertNotShutdown(); + + cef_browser_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, is_safe_browsing_enabled)) { + return false; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->is_safe_browsing_enabled(_struct); + + // Return type: bool + return _retval ? true : false; +} + // CONSTRUCTOR - Do not edit by hand. 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; diff --git a/libcef_dll/ctocpp/browser_ctocpp.h b/libcef_dll/ctocpp/browser_ctocpp.h index 2559d7fb6868636ec6d5a806a6dfac8cfc37d34f..364c78461f72d89fd1fa5d9d8fd273304803b98a 100644 --- a/libcef_dll/ctocpp/browser_ctocpp.h +++ b/libcef_dll/ctocpp/browser_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=b9a2c937dc5b3b5614de81754a739bd8f691bd22$ +// $hash=c8024f8cfa314f6165daeef7a42c83e0837ae821$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_CTOCPP_H_ @@ -20,18 +20,18 @@ #error This file can be included wrapper-side only #endif +#include #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" -#include // Wrap a C structure with a C++ class. // This class may be instantiated and accessed wrapper-side only. class CefBrowserCToCpp : public CefCToCppRefCounted { -public: + public: CefBrowserCToCpp(); virtual ~CefBrowserCToCpp(); @@ -53,12 +53,12 @@ public: CefRefPtr GetMainFrame() override; CefRefPtr GetFocusedFrame() override; CefRefPtr GetFrame(int64 identifier) override; - CefRefPtr GetFrame(const CefString &name) override; + CefRefPtr GetFrame(const CefString& name) override; size_t GetFrameCount() override; - void GetFrameIdentifiers(std::vector &identifiers) override; - void GetFrameNames(std::vector &names) override; - CefRefPtr - GetPermissionRequestDelegate() override; + void GetFrameIdentifiers(std::vector& identifiers) override; + void GetFrameNames(std::vector& names) override; + CefRefPtr GetPermissionRequestDelegate() + override; CefRefPtr GetGeolocationPermissions() override; bool CanGoBackOrForward(int num_steps) override; void GoBackOrForward(int num_steps) override; @@ -66,13 +66,14 @@ public: void SelectAndCopy() override; bool ShouldShowFreeCopy() override; void PasswordSuggestionSelected(int list_index) override; - void UpdateBrowserControlsState(int constraints, int current, + void UpdateBrowserControlsState(int constraints, + int current, bool animate) override; void UpdateBrowserControlsHeight(int height, bool animate) override; - void PrefetchPage(CefString &url, CefString &additionalHttpHeaders) override; + void PrefetchPage(CefString& url, CefString& additionalHttpHeaders) override; void ReloadOriginalUrl() override; bool CanStoreWebArchive() override; - void SetBrowserUserAgentString(const CefString &user_agent) override; + void SetBrowserUserAgentString(const CefString& user_agent) override; bool ShouldShowLoadingUI() override; void SetForceEnableZoom(bool forceEnableZoom) override; bool GetForceEnableZoom() override; @@ -84,6 +85,8 @@ public: bool GetSavePassword() override; void SetSavePassword(bool enable) override; int GetSecurityLevel() override; + void EnableSafeBrowsing(bool enable) override; + bool IsSafeBrowsingEnabled() override; }; -#endif // CEF_LIBCEF_DLL_CTOCPP_BROWSER_CTOCPP_H_ +#endif // CEF_LIBCEF_DLL_CTOCPP_BROWSER_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/browser_host_ctocpp.cc b/libcef_dll/ctocpp/browser_host_ctocpp.cc index d8814159a59c3a825e287e47a946a9b0548da4a5..a1bb03c7537c18b36b7c216fcbcc3a4c1734a0ec 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=e01e515bcb7477865e6aea62bc86909bb535b4df$ +// $hash=4c10ea959864744af0c19747e1026c86f4f63a78$ // #include "libcef_dll/ctocpp/browser_host_ctocpp.h" @@ -2518,13 +2518,14 @@ void CefBrowserHostCToCpp::SetNativeEmbedModeEnabled(bool mode) { shutdown_checker::AssertNotShutdown(); cef_browser_host_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, set_embed_mode)) + if (CEF_MEMBER_MISSING(_struct, set_native_embed_mode_enabled)) { return; + } // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Execute - _struct->set_embed_mode(_struct, mode); + _struct->set_native_embed_mode_enabled(_struct, mode); } NO_SANITIZE("cfi-icall") bool CefBrowserHostCToCpp::Discard() { diff --git a/libcef_dll/ctocpp/browser_host_ctocpp.h b/libcef_dll/ctocpp/browser_host_ctocpp.h index 3877330d08a477d498a27f2261cea1b059f9ac97..012ad837df50bd89fb0300ffc9beb31f4906390c 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=cc88ca436bcdb22c54b82121d76235637260e396$ +// $hash=23a0ab81fad2e29a409edcd5b7876c4d2dfb8afa$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/load_handler_ctocpp.cc b/libcef_dll/ctocpp/load_handler_ctocpp.cc index ce1c68f8beae1926341ebee1bec96936729a60a8..6d4757d29f843b0fedd6727307d9b6cddad8c11d 100644 --- a/libcef_dll/ctocpp/load_handler_ctocpp.cc +++ b/libcef_dll/ctocpp/load_handler_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=0b117b7ffb454b1cd032a4fd3917f086394dced9$ +// $hash=98f4991c1e20d4f5dc0e4607700a58e6a01cd9c0$ // #include "libcef_dll/ctocpp/load_handler_ctocpp.h" @@ -341,6 +341,21 @@ void CefLoadHandlerCToCpp::OnNavigationEntryCommitted( _struct, CefLoadCommittedDetailsCppToC::Wrap(details)); } +NO_SANITIZE("cfi-icall") +void CefLoadHandlerCToCpp::OnSafeBrowsingCheckResult(int threat_type) { + shutdown_checker::AssertNotShutdown(); + + cef_load_handler_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, on_safe_browsing_check_result)) { + return; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->on_safe_browsing_check_result(_struct, threat_type); +} + // CONSTRUCTOR - Do not edit by hand. CefLoadHandlerCToCpp::CefLoadHandlerCToCpp() {} diff --git a/libcef_dll/ctocpp/load_handler_ctocpp.h b/libcef_dll/ctocpp/load_handler_ctocpp.h index 14d20f51fd7a010f9f03789e7bb42b5956602ae8..a7c0e30d7776412627a65af46ca107ea9b7987e1 100644 --- a/libcef_dll/ctocpp/load_handler_ctocpp.h +++ b/libcef_dll/ctocpp/load_handler_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=0bdf9a99247c735d9dd75ae5c1b3730decd614dc$ +// $hash=ebf8fcd244312d5843ae51ff9486c1be26c4a8a4$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_LOAD_HANDLER_CTOCPP_H_ @@ -72,6 +72,7 @@ class CefLoadHandlerCToCpp : public CefCToCppRefCounted details) override; + void OnSafeBrowsingCheckResult(int threat_type) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_LOAD_HANDLER_CTOCPP_H_