From 29938f9cb08848378fec254df3c0c6c0738ca5d7 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Wed, 4 Oct 2023 19:46:45 -0400 Subject: [PATCH] Add new CanZoom/Zoom API (fixes #3284) Add a simpler CanZoom/Zoom API as an alternative to the more error-prone SetZoomLevel/GetZoomLevel API. Both APIs are now implemented for both runtimes. With the Chrome runtime a zoom notification bubble will be displayed unless CefBrowserSettings.chrome_zoom_bubble is set to STATE_DISABLED. To test: - Run cefclient and select zoom entries from the Tests menu. - chrome: Run cefclient with `--hide-chrome-bubbles` command-line flag to hide the zoom notification bubble. --- include/capi/cef_browser_capi.h | 35 +++++- include/cef_api_hash.h | 8 +- include/cef_browser.h | 33 +++++- include/internal/cef_types.h | 15 +++ include/internal/cef_types_wrappers.h | 1 + .../browser/alloy/alloy_browser_host_impl.cc | 32 +----- .../browser/alloy/alloy_browser_host_impl.h | 3 +- .../alloy/browser_platform_delegate_alloy.cc | 6 +- libcef/browser/browser_host_base.cc | 105 ++++++++++++++++++ libcef/browser/browser_host_base.h | 5 + .../chrome/chrome_browser_host_impl.cc | 9 -- .../browser/chrome/chrome_browser_host_impl.h | 2 - .../browser_platform_delegate_chrome_views.cc | 28 ++++- libcef_dll/cpptoc/browser_host_cpptoc.cc | 56 +++++++++- libcef_dll/ctocpp/browser_host_ctocpp.cc | 52 ++++++++- libcef_dll/ctocpp/browser_host_ctocpp.h | 5 +- tests/cefclient/browser/main_context_impl.cc | 3 +- tests/cefclient/browser/test_runner.cc | 16 +-- tests/shared/common/client_switches.cc | 2 +- tests/shared/common/client_switches.h | 2 +- 20 files changed, 338 insertions(+), 80 deletions(-) diff --git a/include/capi/cef_browser_capi.h b/include/capi/cef_browser_capi.h index 1fee098c3..11f90d9e0 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=683d7bff8da04826eee83c7e23cf9c5a701ae265$ +// $hash=db4fce1215cb4f69346ef2d048974ba34187b2b1$ // #ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_ @@ -365,16 +365,39 @@ typedef struct _cef_browser_host_t { 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. + /// Returns true (1) if this browser can execute the specified zoom command. + /// This function can only be called on the UI thread. + /// + int(CEF_CALLBACK* can_zoom)(struct _cef_browser_host_t* self, + cef_zoom_command_t command); + + /// + /// Execute a zoom command in this browser. 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* zoom)(struct _cef_browser_host_t* self, + cef_zoom_command_t command); + + /// + /// Get the default zoom level. This value will be 0.0 by default but can be + /// configured with the Chrome runtime. This function can only be called on + /// the UI thread. + /// + double(CEF_CALLBACK* get_default_zoom_level)( + struct _cef_browser_host_t* self); + + /// + /// Get the current zoom level. This function can only be called on the UI + /// thread. /// 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 - /// zoom level. If called on the UI thread the change will be applied - /// immediately. Otherwise, the change will be applied asynchronously on the - /// UI thread. + /// zoom level to the default. 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_zoom_level)(struct _cef_browser_host_t* self, double zoomLevel); diff --git a/include/cef_api_hash.h b/include/cef_api_hash.h index ac9b5960c..9784d937b 100644 --- a/include/cef_api_hash.h +++ b/include/cef_api_hash.h @@ -42,13 +42,13 @@ // way that may cause binary incompatibility with other builds. The universal // hash value will change if any platform is affected whereas the platform hash // values will change only if that particular platform is affected. -#define CEF_API_HASH_UNIVERSAL "fb95812349ecedc56374e2d195b4af712f6f9ab3" +#define CEF_API_HASH_UNIVERSAL "abeac9ee5411570f5e39d9242cba575a19439f86" #if defined(OS_WIN) -#define CEF_API_HASH_PLATFORM "4b12d27bf02871c32719580c1be18d686e20bc84" +#define CEF_API_HASH_PLATFORM "85fba672bea98e3687ccfc28c4a509ca70240990" #elif defined(OS_MAC) -#define CEF_API_HASH_PLATFORM "e6b30ef107ccb6ba9af40bd6498ad4cef247a171" +#define CEF_API_HASH_PLATFORM "3c960598536b6e112d3857d19d01f05e49474f86" #elif defined(OS_LINUX) -#define CEF_API_HASH_PLATFORM "a4ec73cc821ea2d1681c7f8271f0a7d3e3cea33a" +#define CEF_API_HASH_PLATFORM "821845ef5f7ea8618f7425a4096702205f4b346b" #endif #ifdef __cplusplus diff --git a/include/cef_browser.h b/include/cef_browser.h index 3d8b809a3..051a1e078 100644 --- a/include/cef_browser.h +++ b/include/cef_browser.h @@ -396,17 +396,40 @@ class CefBrowserHost : public virtual CefBaseRefCounted { virtual CefRefPtr GetRequestContext() = 0; /// - /// Get the current zoom level. The default zoom level is 0.0. This method can - /// only be called on the UI thread. + /// Returns true if this browser can execute the specified zoom command. This + /// method can only be called on the UI thread. + /// + /*--cef()--*/ + virtual bool CanZoom(cef_zoom_command_t command) = 0; + + /// + /// Execute a zoom command in this browser. If called on the UI thread the + /// change will be applied immediately. Otherwise, the change will be applied + /// asynchronously on the UI thread. + /// + /*--cef()--*/ + virtual void Zoom(cef_zoom_command_t command) = 0; + + /// + /// Get the default zoom level. This value will be 0.0 by default but can be + /// configured with the Chrome runtime. This method can only be called on the + /// UI thread. + /// + /*--cef()--*/ + virtual double GetDefaultZoomLevel() = 0; + + /// + /// Get the current zoom level. This method can only be called on the UI + /// thread. /// /*--cef()--*/ virtual double GetZoomLevel() = 0; /// /// Change the zoom level to the specified value. Specify 0.0 to reset the - /// zoom level. If called on the UI thread the change will be applied - /// immediately. Otherwise, the change will be applied asynchronously on the - /// UI thread. + /// zoom level to the default. If called on the UI thread the change will be + /// applied immediately. Otherwise, the change will be applied asynchronously + /// on the UI thread. /// /*--cef()--*/ virtual void SetZoomLevel(double zoomLevel) = 0; diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h index 144488a40..2ff399a9c 100644 --- a/include/internal/cef_types.h +++ b/include/internal/cef_types.h @@ -687,6 +687,12 @@ typedef struct _cef_browser_settings_t { /// https://www.chromium.org/user-experience/status-bubble/ /// cef_state_t chrome_status_bubble; + + /// + /// Controls whether the Chrome zoom bubble will be shown when zooming. Only + /// supported with the Chrome runtime. + /// + cef_state_t chrome_zoom_bubble; } cef_browser_settings_t; /// @@ -3660,6 +3666,15 @@ typedef enum { CEF_GESTURE_COMMAND_FORWARD, } cef_gesture_command_t; +/// +/// Specifies the zoom commands supported by CefBrowserHost::Zoom. +/// +typedef enum { + CEF_ZOOM_COMMAND_OUT, + CEF_ZOOM_COMMAND_RESET, + CEF_ZOOM_COMMAND_IN, +} cef_zoom_command_t; + #ifdef __cplusplus } #endif diff --git a/include/internal/cef_types_wrappers.h b/include/internal/cef_types_wrappers.h index 611937549..33a367044 100644 --- a/include/internal/cef_types_wrappers.h +++ b/include/internal/cef_types_wrappers.h @@ -541,6 +541,7 @@ struct CefBrowserSettingsTraits { &target->accept_language_list, copy); target->chrome_status_bubble = src->chrome_status_bubble; + target->chrome_zoom_bubble = src->chrome_zoom_bubble; } }; diff --git a/libcef/browser/alloy/alloy_browser_host_impl.cc b/libcef/browser/alloy/alloy_browser_host_impl.cc index 6f27e5fde..3072dd062 100644 --- a/libcef/browser/alloy/alloy_browser_host_impl.cc +++ b/libcef/browser/alloy/alloy_browser_host_impl.cc @@ -34,10 +34,10 @@ #include "base/functional/callback_helpers.h" #include "chrome/browser/file_select_helper.h" #include "chrome/browser/picture_in_picture/picture_in_picture_window_manager.h" +#include "components/zoom/page_zoom.h" #include "content/browser/gpu/compositor_util.h" #include "content/public/browser/desktop_media_id.h" #include "content/public/browser/file_select_listener.h" -#include "content/public/browser/host_zoom_map.h" #include "content/public/browser/keyboard_event_processing_result.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_handle.h" @@ -330,31 +330,6 @@ CefWindowHandle AlloyBrowserHostImpl::GetOpenerWindowHandle() { return opener_; } -double AlloyBrowserHostImpl::GetZoomLevel() { - // Verify that this method is being called on the UI thread. - if (!CEF_CURRENTLY_ON_UIT()) { - DCHECK(false) << "called on invalid thread"; - return 0; - } - - if (web_contents()) { - return content::HostZoomMap::GetZoomLevel(web_contents()); - } - - return 0; -} - -void AlloyBrowserHostImpl::SetZoomLevel(double zoomLevel) { - if (CEF_CURRENTLY_ON_UIT()) { - if (web_contents()) { - content::HostZoomMap::SetZoomLevel(web_contents(), zoomLevel); - } - } else { - CEF_POST_TASK(CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::SetZoomLevel, - this, zoomLevel)); - } -} - void AlloyBrowserHostImpl::Find(const CefString& searchText, bool forward, bool matchCase, @@ -1118,6 +1093,11 @@ bool AlloyBrowserHostImpl::DidAddMessageToConsole( line_no, source_id); } +void AlloyBrowserHostImpl::ContentsZoomChange(bool zoom_in) { + zoom::PageZoom::Zoom( + web_contents(), zoom_in ? content::PAGE_ZOOM_IN : content::PAGE_ZOOM_OUT); +} + void AlloyBrowserHostImpl::BeforeUnloadFired(content::WebContents* source, bool proceed, bool* proceed_to_fire_unload) { diff --git a/libcef/browser/alloy/alloy_browser_host_impl.h b/libcef/browser/alloy/alloy_browser_host_impl.h index 6aa3bfbaa..d43b6cf41 100644 --- a/libcef/browser/alloy/alloy_browser_host_impl.h +++ b/libcef/browser/alloy/alloy_browser_host_impl.h @@ -80,8 +80,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase, bool TryCloseBrowser() override; CefWindowHandle GetWindowHandle() override; CefWindowHandle GetOpenerWindowHandle() override; - double GetZoomLevel() override; - void SetZoomLevel(double zoomLevel) override; void Find(const CefString& searchText, bool forward, bool matchCase, @@ -204,6 +202,7 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase, const std::u16string& message, int32_t line_no, const std::u16string& source_id) override; + void ContentsZoomChange(bool zoom_in) override; void BeforeUnloadFired(content::WebContents* source, bool proceed, bool* proceed_to_fire_unload) override; diff --git a/libcef/browser/alloy/browser_platform_delegate_alloy.cc b/libcef/browser/alloy/browser_platform_delegate_alloy.cc index 0d9f8cb3b..57a96d673 100644 --- a/libcef/browser/alloy/browser_platform_delegate_alloy.cc +++ b/libcef/browser/alloy/browser_platform_delegate_alloy.cc @@ -171,11 +171,7 @@ void CefBrowserPlatformDelegateAlloy::BrowserCreated( permissions::PermissionRequestManager::CreateForWebContents(web_contents_); PrefsTabHelper::CreateForWebContents(web_contents_); printing::PrintViewManager::CreateForWebContents(web_contents_); - - if (extensions::ExtensionsEnabled()) { - // Used by the tabs extension API. - zoom::ZoomController::CreateForWebContents(web_contents_); - } + zoom::ZoomController::CreateForWebContents(web_contents_); javascript_dialogs::TabModalDialogManager::CreateForWebContents( web_contents_, diff --git a/libcef/browser/browser_host_base.cc b/libcef/browser/browser_host_base.cc index 4c339772a..d1c922baa 100644 --- a/libcef/browser/browser_host_base.cc +++ b/libcef/browser/browser_host_base.cc @@ -20,8 +20,10 @@ #include "chrome/browser/platform_util.h" #include "chrome/browser/spellchecker/spellcheck_factory.h" #include "chrome/browser/spellchecker/spellcheck_service.h" +#include "chrome/browser/ui/browser_commands.cc" #include "components/favicon/core/favicon_url.h" #include "components/spellcheck/common/spellcheck_features.h" +#include "components/zoom/page_zoom.h" #include "content/browser/renderer_host/render_frame_host_impl.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/download_manager.h" @@ -236,6 +238,109 @@ CefRefPtr CefBrowserHostBase::GetRequestContext() { return request_context_; } +bool CefBrowserHostBase::CanZoom(cef_zoom_command_t command) { + // Verify that this method is being called on the UI thread. + if (!CEF_CURRENTLY_ON_UIT()) { + DCHECK(false) << "called on invalid thread"; + return false; + } + + if (auto web_contents = GetWebContents()) { + switch (command) { + case CEF_ZOOM_COMMAND_OUT: + return chrome::CanZoomOut(web_contents); + case CEF_ZOOM_COMMAND_RESET: + return chrome::CanResetZoom(web_contents); + case CEF_ZOOM_COMMAND_IN: + return chrome::CanZoomIn(web_contents); + } + } + + return false; +} + +void CefBrowserHostBase::Zoom(cef_zoom_command_t command) { + if (!CEF_CURRENTLY_ON_UIT()) { + CEF_POST_TASK(CEF_UIT, + base::BindOnce(&CefBrowserHostBase::Zoom, this, command)); + return; + } + + if (auto web_contents = GetWebContents()) { + const content::PageZoom page_zoom = [command]() { + switch (command) { + case CEF_ZOOM_COMMAND_OUT: + return content::PAGE_ZOOM_OUT; + case CEF_ZOOM_COMMAND_RESET: + return content::PAGE_ZOOM_RESET; + case CEF_ZOOM_COMMAND_IN: + return content::PAGE_ZOOM_IN; + } + }(); + + // Same implementation as chrome::Zoom(), but explicitly specifying the + // WebContents. + zoom::PageZoom::Zoom(web_contents, page_zoom); + } +} + +double CefBrowserHostBase::GetDefaultZoomLevel() { + // Verify that this method is being called on the UI thread. + if (!CEF_CURRENTLY_ON_UIT()) { + DCHECK(false) << "called on invalid thread"; + return 0.0; + } + + if (auto web_contents = GetWebContents()) { + zoom::ZoomController* zoom_controller = + zoom::ZoomController::FromWebContents(web_contents); + if (zoom_controller) { + return zoom_controller->GetDefaultZoomLevel(); + } + } + + return 0.0; +} + +double CefBrowserHostBase::GetZoomLevel() { + // Verify that this method is being called on the UI thread. + if (!CEF_CURRENTLY_ON_UIT()) { + DCHECK(false) << "called on invalid thread"; + return 0.0; + } + + if (auto web_contents = GetWebContents()) { + zoom::ZoomController* zoom_controller = + zoom::ZoomController::FromWebContents(web_contents); + if (zoom_controller) { + return zoom_controller->GetZoomLevel(); + } + } + + return 0.0; +} + +void CefBrowserHostBase::SetZoomLevel(double zoomLevel) { + if (!CEF_CURRENTLY_ON_UIT()) { + CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostBase::SetZoomLevel, + this, zoomLevel)); + return; + } + + if (auto web_contents = GetWebContents()) { + zoom::ZoomController* zoom_controller = + zoom::ZoomController::FromWebContents(web_contents); + if (zoom_controller) { + if (zoomLevel == 0.0) { + // Same logic as PageZoom::Zoom(PAGE_ZOOM_RESET). + zoomLevel = zoom_controller->GetDefaultZoomLevel(); + web_contents->SetPageScale(1.f); + } + zoom_controller->SetZoomLevel(zoomLevel); + } + } +} + bool CefBrowserHostBase::HasView() { return is_views_hosted_; } diff --git a/libcef/browser/browser_host_base.h b/libcef/browser/browser_host_base.h index faa81ad3d..9c968a413 100644 --- a/libcef/browser/browser_host_base.h +++ b/libcef/browser/browser_host_base.h @@ -169,6 +169,11 @@ class CefBrowserHostBase : public CefBrowserHost, CefRefPtr GetBrowser() override; CefRefPtr GetClient() override; CefRefPtr GetRequestContext() override; + bool CanZoom(cef_zoom_command_t command) override; + void Zoom(cef_zoom_command_t command) override; + double GetDefaultZoomLevel() override; + double GetZoomLevel() override; + void SetZoomLevel(double zoomLevel) override; bool HasView() override; void SetFocus(bool focus) override; void RunFileDialog(FileDialogMode mode, diff --git a/libcef/browser/chrome/chrome_browser_host_impl.cc b/libcef/browser/chrome/chrome_browser_host_impl.cc index 8d6f95105..47d4bceb3 100644 --- a/libcef/browser/chrome/chrome_browser_host_impl.cc +++ b/libcef/browser/chrome/chrome_browser_host_impl.cc @@ -179,15 +179,6 @@ CefWindowHandle ChromeBrowserHostImpl::GetOpenerWindowHandle() { return kNullWindowHandle; } -double ChromeBrowserHostImpl::GetZoomLevel() { - NOTIMPLEMENTED(); - return 0.0; -} - -void ChromeBrowserHostImpl::SetZoomLevel(double zoomLevel) { - NOTIMPLEMENTED(); -} - void ChromeBrowserHostImpl::Find(const CefString& searchText, bool forward, bool matchCase, diff --git a/libcef/browser/chrome/chrome_browser_host_impl.h b/libcef/browser/chrome/chrome_browser_host_impl.h index 1d7d0bbb0..d6c27c96a 100644 --- a/libcef/browser/chrome/chrome_browser_host_impl.h +++ b/libcef/browser/chrome/chrome_browser_host_impl.h @@ -67,8 +67,6 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase { bool TryCloseBrowser() override; CefWindowHandle GetWindowHandle() override; CefWindowHandle GetOpenerWindowHandle() override; - double GetZoomLevel() override; - void SetZoomLevel(double zoomLevel) override; void Find(const CefString& searchText, bool forward, bool matchCase, diff --git a/libcef/browser/chrome/views/browser_platform_delegate_chrome_views.cc b/libcef/browser/chrome/views/browser_platform_delegate_chrome_views.cc index b6ac634b4..78f1d8491 100644 --- a/libcef/browser/chrome/views/browser_platform_delegate_chrome_views.cc +++ b/libcef/browser/chrome/views/browser_platform_delegate_chrome_views.cc @@ -7,7 +7,9 @@ #include "include/views/cef_window.h" #include "libcef/browser/views/window_impl.h" +#include "chrome/browser/devtools/devtools_window.h" #include "chrome/browser/ui/browser.h" +#include "components/zoom/zoom_controller.h" #include "ui/views/widget/widget.h" namespace { @@ -77,8 +79,30 @@ void CefBrowserPlatformDelegateChromeViews::BrowserCreated( } void CefBrowserPlatformDelegateChromeViews::NotifyBrowserCreated() { - if (browser_view_->delegate()) { - browser_view_->delegate()->OnBrowserCreated(browser_view_, browser_); + if (auto delegate = browser_view_->delegate()) { + delegate->OnBrowserCreated(browser_view_, browser_); + + // DevTools windows hide the notification bubble by default. However, we + // don't currently have the ability to intercept WebContents creation via + // DevToolsWindow::Create(), so |show_by_default| will always be true here. + const bool show_by_default = + !DevToolsWindow::IsDevToolsWindow(web_contents_); + + bool show_zoom_bubble = show_by_default; + const auto& state = browser_->settings().chrome_zoom_bubble; + if (show_by_default && state == STATE_DISABLED) { + show_zoom_bubble = false; + } else if (!show_by_default && state == STATE_ENABLED) { + show_zoom_bubble = true; + } + + if (show_zoom_bubble != show_by_default) { + // We may be called before TabHelpers::AttachTabHelpers(), so create + // the ZoomController if necessary. + zoom::ZoomController::CreateForWebContents(web_contents_); + zoom::ZoomController::FromWebContents(web_contents_) + ->SetShowsNotificationBubble(show_zoom_bubble); + } } } diff --git a/libcef_dll/cpptoc/browser_host_cpptoc.cc b/libcef_dll/cpptoc/browser_host_cpptoc.cc index 6f29439ce..7811734f5 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=6a2ebf843d929371a15e34792b6900c0ab622877$ +// $hash=497607653318fe0245cbe18c8911e39867e16249$ // #include "libcef_dll/cpptoc/browser_host_cpptoc.h" @@ -298,6 +298,57 @@ browser_host_get_request_context(struct _cef_browser_host_t* self) { return CefRequestContextCppToC::Wrap(_retval); } +int CEF_CALLBACK browser_host_can_zoom(struct _cef_browser_host_t* self, + cef_zoom_command_t command) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) { + return 0; + } + + // Execute + bool _retval = CefBrowserHostCppToC::Get(self)->CanZoom(command); + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK browser_host_zoom(struct _cef_browser_host_t* self, + cef_zoom_command_t command) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) { + return; + } + + // Execute + CefBrowserHostCppToC::Get(self)->Zoom(command); +} + +double CEF_CALLBACK +browser_host_get_default_zoom_level(struct _cef_browser_host_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) { + return 0; + } + + // Execute + double _retval = CefBrowserHostCppToC::Get(self)->GetDefaultZoomLevel(); + + // Return type: simple + return _retval; +} + double CEF_CALLBACK browser_host_get_zoom_level(struct _cef_browser_host_t* self) { shutdown_checker::AssertNotShutdown(); @@ -1398,6 +1449,9 @@ CefBrowserHostCppToC::CefBrowserHostCppToC() { GetStruct()->has_view = browser_host_has_view; GetStruct()->get_client = browser_host_get_client; GetStruct()->get_request_context = browser_host_get_request_context; + GetStruct()->can_zoom = browser_host_can_zoom; + GetStruct()->zoom = browser_host_zoom; + GetStruct()->get_default_zoom_level = browser_host_get_default_zoom_level; GetStruct()->get_zoom_level = browser_host_get_zoom_level; GetStruct()->set_zoom_level = browser_host_set_zoom_level; GetStruct()->run_file_dialog = browser_host_run_file_dialog; diff --git a/libcef_dll/ctocpp/browser_host_ctocpp.cc b/libcef_dll/ctocpp/browser_host_ctocpp.cc index 0fc4ba13b..e2d78a16b 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=02a6c45f14489fd5548eb61210ba453de05bcd2d$ +// $hash=cd4e4aa1670f0c887090e23f5e7e3a01e5de9d13$ // #include "libcef_dll/ctocpp/browser_host_ctocpp.h" @@ -234,6 +234,56 @@ CefRefPtr CefBrowserHostCToCpp::GetRequestContext() { return CefRequestContextCToCpp::Wrap(_retval); } +NO_SANITIZE("cfi-icall") +bool CefBrowserHostCToCpp::CanZoom(cef_zoom_command_t command) { + shutdown_checker::AssertNotShutdown(); + + cef_browser_host_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, can_zoom)) { + return false; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->can_zoom(_struct, command); + + // Return type: bool + return _retval ? true : false; +} + +NO_SANITIZE("cfi-icall") +void CefBrowserHostCToCpp::Zoom(cef_zoom_command_t command) { + shutdown_checker::AssertNotShutdown(); + + cef_browser_host_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, zoom)) { + return; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->zoom(_struct, command); +} + +NO_SANITIZE("cfi-icall") double CefBrowserHostCToCpp::GetDefaultZoomLevel() { + shutdown_checker::AssertNotShutdown(); + + cef_browser_host_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_default_zoom_level)) { + return 0; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + double _retval = _struct->get_default_zoom_level(_struct); + + // Return type: simple + return _retval; +} + NO_SANITIZE("cfi-icall") double CefBrowserHostCToCpp::GetZoomLevel() { shutdown_checker::AssertNotShutdown(); diff --git a/libcef_dll/ctocpp/browser_host_ctocpp.h b/libcef_dll/ctocpp/browser_host_ctocpp.h index 03829b895..32d852d6d 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=4700b3b409abf624334f9f6ecf9c1c20131e4849$ +// $hash=b4e11c91197cd5d6ccbe3a0d96aaae3792a6e05c$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_ @@ -46,6 +46,9 @@ class CefBrowserHostCToCpp : public CefCToCppRefCounted GetClient() override; CefRefPtr GetRequestContext() override; + bool CanZoom(cef_zoom_command_t command) override; + void Zoom(cef_zoom_command_t command) override; + double GetDefaultZoomLevel() override; double GetZoomLevel() override; void SetZoomLevel(double zoomLevel) override; void RunFileDialog(FileDialogMode mode, diff --git a/tests/cefclient/browser/main_context_impl.cc b/tests/cefclient/browser/main_context_impl.cc index d540b7f03..30286c35e 100644 --- a/tests/cefclient/browser/main_context_impl.cc +++ b/tests/cefclient/browser/main_context_impl.cc @@ -224,8 +224,9 @@ void MainContextImpl::PopulateBrowserSettings(CefBrowserSettings* settings) { } if (use_chrome_runtime_ && - command_line_->HasSwitch(switches::kHideChromeStatusBubble)) { + command_line_->HasSwitch(switches::kHideChromeBubbles)) { settings->chrome_status_bubble = STATE_DISABLED; + settings->chrome_zoom_bubble = STATE_DISABLED; } } diff --git a/tests/cefclient/browser/test_runner.cc b/tests/cefclient/browser/test_runner.cc index b702bd978..f63fcf78e 100644 --- a/tests/cefclient/browser/test_runner.cc +++ b/tests/cefclient/browser/test_runner.cc @@ -160,16 +160,6 @@ void RunDialogWindowTest(CefRefPtr browser) { std::move(config)); } -void ModifyZoom(CefRefPtr browser, double delta) { - if (!CefCurrentlyOn(TID_UI)) { - // Execute on the UI thread. - CefPostTask(TID_UI, base::BindOnce(&ModifyZoom, browser, delta)); - return; - } - - browser->GetHost()->SetZoomLevel(browser->GetHost()->GetZoomLevel() + delta); -} - const char kPrompt[] = "Prompt."; const char kPromptFPS[] = "FPS"; const char kPromptDSF[] = "DSF"; @@ -569,13 +559,13 @@ void RunTest(CefRefPtr browser, int id) { RunRequestTest(browser); break; case ID_TESTS_ZOOM_IN: - ModifyZoom(browser, 0.5); + browser->GetHost()->Zoom(CEF_ZOOM_COMMAND_IN); break; case ID_TESTS_ZOOM_OUT: - ModifyZoom(browser, -0.5); + browser->GetHost()->Zoom(CEF_ZOOM_COMMAND_OUT); break; case ID_TESTS_ZOOM_RESET: - browser->GetHost()->SetZoomLevel(0.0); + browser->GetHost()->Zoom(CEF_ZOOM_COMMAND_RESET); break; case ID_TESTS_OSR_FPS: PromptFPS(browser); diff --git a/tests/shared/common/client_switches.cc b/tests/shared/common/client_switches.cc index 0cb37debe..822a73833 100644 --- a/tests/shared/common/client_switches.cc +++ b/tests/shared/common/client_switches.cc @@ -49,7 +49,6 @@ const char kNoActivate[] = "no-activate"; const char kEnableChromeRuntime[] = "enable-chrome-runtime"; const char kShowChromeToolbar[] = "show-chrome-toolbar"; const char kInitialShowState[] = "initial-show-state"; -const char kHideChromeStatusBubble[] = "hide-chrome-status-bubble"; const char kUseDefaultPopup[] = "use-default-popup"; const char kUseClientDialogs[] = "use-client-dialogs"; const char kUseTestHttpServer[] = "use-test-http-server"; @@ -57,6 +56,7 @@ const char kShowWindowButtons[] = "show-window-buttons"; const char kUseWindowModalDialog[] = "use-window-modal-dialog"; const char kUseBottomControls[] = "use-bottom-controls"; const char kHidePipFrame[] = "hide-pip-frame"; +const char kHideChromeBubbles[] = "hide-chrome-bubbles"; } // namespace switches } // namespace client diff --git a/tests/shared/common/client_switches.h b/tests/shared/common/client_switches.h index 84af2e15c..63e43e043 100644 --- a/tests/shared/common/client_switches.h +++ b/tests/shared/common/client_switches.h @@ -43,7 +43,6 @@ extern const char kNoActivate[]; extern const char kEnableChromeRuntime[]; extern const char kShowChromeToolbar[]; extern const char kInitialShowState[]; -extern const char kHideChromeStatusBubble[]; extern const char kUseDefaultPopup[]; extern const char kUseClientDialogs[]; extern const char kUseTestHttpServer[]; @@ -51,6 +50,7 @@ extern const char kShowWindowButtons[]; extern const char kUseWindowModalDialog[]; extern const char kUseBottomControls[]; extern const char kHidePipFrame[]; +extern const char kHideChromeBubbles[]; } // namespace switches } // namespace client