mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
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.
This commit is contained in:
@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=683d7bff8da04826eee83c7e23cf9c5a701ae265$
|
// $hash=db4fce1215cb4f69346ef2d048974ba34187b2b1$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
|
||||||
@ -365,16 +365,39 @@ typedef struct _cef_browser_host_t {
|
|||||||
struct _cef_browser_host_t* self);
|
struct _cef_browser_host_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get the current zoom level. The default zoom level is 0.0. This function
|
/// Returns true (1) if this browser can execute the specified zoom command.
|
||||||
/// can only be called on the UI thread.
|
/// 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);
|
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
|
/// 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
|
/// zoom level to the default. If called on the UI thread the change will be
|
||||||
/// immediately. Otherwise, the change will be applied asynchronously on the
|
/// applied immediately. Otherwise, the change will be applied asynchronously
|
||||||
/// UI thread.
|
/// 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);
|
double zoomLevel);
|
||||||
|
@ -42,13 +42,13 @@
|
|||||||
// way that may cause binary incompatibility with other builds. The universal
|
// way that may cause binary incompatibility with other builds. The universal
|
||||||
// hash value will change if any platform is affected whereas the platform hash
|
// hash value will change if any platform is affected whereas the platform hash
|
||||||
// values will change only if that particular platform is affected.
|
// 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)
|
#if defined(OS_WIN)
|
||||||
#define CEF_API_HASH_PLATFORM "4b12d27bf02871c32719580c1be18d686e20bc84"
|
#define CEF_API_HASH_PLATFORM "85fba672bea98e3687ccfc28c4a509ca70240990"
|
||||||
#elif defined(OS_MAC)
|
#elif defined(OS_MAC)
|
||||||
#define CEF_API_HASH_PLATFORM "e6b30ef107ccb6ba9af40bd6498ad4cef247a171"
|
#define CEF_API_HASH_PLATFORM "3c960598536b6e112d3857d19d01f05e49474f86"
|
||||||
#elif defined(OS_LINUX)
|
#elif defined(OS_LINUX)
|
||||||
#define CEF_API_HASH_PLATFORM "a4ec73cc821ea2d1681c7f8271f0a7d3e3cea33a"
|
#define CEF_API_HASH_PLATFORM "821845ef5f7ea8618f7425a4096702205f4b346b"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -396,17 +396,40 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
|
|||||||
virtual CefRefPtr<CefRequestContext> GetRequestContext() = 0;
|
virtual CefRefPtr<CefRequestContext> GetRequestContext() = 0;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get the current zoom level. The default zoom level is 0.0. This method can
|
/// Returns true if this browser can execute the specified zoom command. This
|
||||||
/// only be called on the UI thread.
|
/// 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()--*/
|
/*--cef()--*/
|
||||||
virtual double GetZoomLevel() = 0;
|
virtual double GetZoomLevel() = 0;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Change the zoom level to the specified value. Specify 0.0 to reset the
|
/// 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
|
/// zoom level to the default. If called on the UI thread the change will be
|
||||||
/// immediately. Otherwise, the change will be applied asynchronously on the
|
/// applied immediately. Otherwise, the change will be applied asynchronously
|
||||||
/// UI thread.
|
/// on the UI thread.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual void SetZoomLevel(double zoomLevel) = 0;
|
virtual void SetZoomLevel(double zoomLevel) = 0;
|
||||||
|
@ -687,6 +687,12 @@ typedef struct _cef_browser_settings_t {
|
|||||||
/// https://www.chromium.org/user-experience/status-bubble/
|
/// https://www.chromium.org/user-experience/status-bubble/
|
||||||
///
|
///
|
||||||
cef_state_t chrome_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;
|
} cef_browser_settings_t;
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -3660,6 +3666,15 @@ typedef enum {
|
|||||||
CEF_GESTURE_COMMAND_FORWARD,
|
CEF_GESTURE_COMMAND_FORWARD,
|
||||||
} cef_gesture_command_t;
|
} 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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -541,6 +541,7 @@ struct CefBrowserSettingsTraits {
|
|||||||
&target->accept_language_list, copy);
|
&target->accept_language_list, copy);
|
||||||
|
|
||||||
target->chrome_status_bubble = src->chrome_status_bubble;
|
target->chrome_status_bubble = src->chrome_status_bubble;
|
||||||
|
target->chrome_zoom_bubble = src->chrome_zoom_bubble;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,10 +34,10 @@
|
|||||||
#include "base/functional/callback_helpers.h"
|
#include "base/functional/callback_helpers.h"
|
||||||
#include "chrome/browser/file_select_helper.h"
|
#include "chrome/browser/file_select_helper.h"
|
||||||
#include "chrome/browser/picture_in_picture/picture_in_picture_window_manager.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/browser/gpu/compositor_util.h"
|
||||||
#include "content/public/browser/desktop_media_id.h"
|
#include "content/public/browser/desktop_media_id.h"
|
||||||
#include "content/public/browser/file_select_listener.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/keyboard_event_processing_result.h"
|
||||||
#include "content/public/browser/navigation_controller.h"
|
#include "content/public/browser/navigation_controller.h"
|
||||||
#include "content/public/browser/navigation_handle.h"
|
#include "content/public/browser/navigation_handle.h"
|
||||||
@ -330,31 +330,6 @@ CefWindowHandle AlloyBrowserHostImpl::GetOpenerWindowHandle() {
|
|||||||
return opener_;
|
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,
|
void AlloyBrowserHostImpl::Find(const CefString& searchText,
|
||||||
bool forward,
|
bool forward,
|
||||||
bool matchCase,
|
bool matchCase,
|
||||||
@ -1118,6 +1093,11 @@ bool AlloyBrowserHostImpl::DidAddMessageToConsole(
|
|||||||
line_no, source_id);
|
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,
|
void AlloyBrowserHostImpl::BeforeUnloadFired(content::WebContents* source,
|
||||||
bool proceed,
|
bool proceed,
|
||||||
bool* proceed_to_fire_unload) {
|
bool* proceed_to_fire_unload) {
|
||||||
|
@ -80,8 +80,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
|||||||
bool TryCloseBrowser() override;
|
bool TryCloseBrowser() override;
|
||||||
CefWindowHandle GetWindowHandle() override;
|
CefWindowHandle GetWindowHandle() override;
|
||||||
CefWindowHandle GetOpenerWindowHandle() override;
|
CefWindowHandle GetOpenerWindowHandle() override;
|
||||||
double GetZoomLevel() override;
|
|
||||||
void SetZoomLevel(double zoomLevel) override;
|
|
||||||
void Find(const CefString& searchText,
|
void Find(const CefString& searchText,
|
||||||
bool forward,
|
bool forward,
|
||||||
bool matchCase,
|
bool matchCase,
|
||||||
@ -204,6 +202,7 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
|||||||
const std::u16string& message,
|
const std::u16string& message,
|
||||||
int32_t line_no,
|
int32_t line_no,
|
||||||
const std::u16string& source_id) override;
|
const std::u16string& source_id) override;
|
||||||
|
void ContentsZoomChange(bool zoom_in) override;
|
||||||
void BeforeUnloadFired(content::WebContents* source,
|
void BeforeUnloadFired(content::WebContents* source,
|
||||||
bool proceed,
|
bool proceed,
|
||||||
bool* proceed_to_fire_unload) override;
|
bool* proceed_to_fire_unload) override;
|
||||||
|
@ -171,11 +171,7 @@ void CefBrowserPlatformDelegateAlloy::BrowserCreated(
|
|||||||
permissions::PermissionRequestManager::CreateForWebContents(web_contents_);
|
permissions::PermissionRequestManager::CreateForWebContents(web_contents_);
|
||||||
PrefsTabHelper::CreateForWebContents(web_contents_);
|
PrefsTabHelper::CreateForWebContents(web_contents_);
|
||||||
printing::PrintViewManager::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(
|
javascript_dialogs::TabModalDialogManager::CreateForWebContents(
|
||||||
web_contents_,
|
web_contents_,
|
||||||
|
@ -20,8 +20,10 @@
|
|||||||
#include "chrome/browser/platform_util.h"
|
#include "chrome/browser/platform_util.h"
|
||||||
#include "chrome/browser/spellchecker/spellcheck_factory.h"
|
#include "chrome/browser/spellchecker/spellcheck_factory.h"
|
||||||
#include "chrome/browser/spellchecker/spellcheck_service.h"
|
#include "chrome/browser/spellchecker/spellcheck_service.h"
|
||||||
|
#include "chrome/browser/ui/browser_commands.cc"
|
||||||
#include "components/favicon/core/favicon_url.h"
|
#include "components/favicon/core/favicon_url.h"
|
||||||
#include "components/spellcheck/common/spellcheck_features.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/browser/renderer_host/render_frame_host_impl.h"
|
||||||
#include "content/public/browser/browser_context.h"
|
#include "content/public/browser/browser_context.h"
|
||||||
#include "content/public/browser/download_manager.h"
|
#include "content/public/browser/download_manager.h"
|
||||||
@ -236,6 +238,109 @@ CefRefPtr<CefRequestContext> CefBrowserHostBase::GetRequestContext() {
|
|||||||
return request_context_;
|
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() {
|
bool CefBrowserHostBase::HasView() {
|
||||||
return is_views_hosted_;
|
return is_views_hosted_;
|
||||||
}
|
}
|
||||||
|
@ -169,6 +169,11 @@ class CefBrowserHostBase : public CefBrowserHost,
|
|||||||
CefRefPtr<CefBrowser> GetBrowser() override;
|
CefRefPtr<CefBrowser> GetBrowser() override;
|
||||||
CefRefPtr<CefClient> GetClient() override;
|
CefRefPtr<CefClient> GetClient() override;
|
||||||
CefRefPtr<CefRequestContext> GetRequestContext() override;
|
CefRefPtr<CefRequestContext> 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;
|
bool HasView() override;
|
||||||
void SetFocus(bool focus) override;
|
void SetFocus(bool focus) override;
|
||||||
void RunFileDialog(FileDialogMode mode,
|
void RunFileDialog(FileDialogMode mode,
|
||||||
|
@ -179,15 +179,6 @@ CefWindowHandle ChromeBrowserHostImpl::GetOpenerWindowHandle() {
|
|||||||
return kNullWindowHandle;
|
return kNullWindowHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
double ChromeBrowserHostImpl::GetZoomLevel() {
|
|
||||||
NOTIMPLEMENTED();
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeBrowserHostImpl::SetZoomLevel(double zoomLevel) {
|
|
||||||
NOTIMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeBrowserHostImpl::Find(const CefString& searchText,
|
void ChromeBrowserHostImpl::Find(const CefString& searchText,
|
||||||
bool forward,
|
bool forward,
|
||||||
bool matchCase,
|
bool matchCase,
|
||||||
|
@ -67,8 +67,6 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
|
|||||||
bool TryCloseBrowser() override;
|
bool TryCloseBrowser() override;
|
||||||
CefWindowHandle GetWindowHandle() override;
|
CefWindowHandle GetWindowHandle() override;
|
||||||
CefWindowHandle GetOpenerWindowHandle() override;
|
CefWindowHandle GetOpenerWindowHandle() override;
|
||||||
double GetZoomLevel() override;
|
|
||||||
void SetZoomLevel(double zoomLevel) override;
|
|
||||||
void Find(const CefString& searchText,
|
void Find(const CefString& searchText,
|
||||||
bool forward,
|
bool forward,
|
||||||
bool matchCase,
|
bool matchCase,
|
||||||
|
@ -7,7 +7,9 @@
|
|||||||
#include "include/views/cef_window.h"
|
#include "include/views/cef_window.h"
|
||||||
#include "libcef/browser/views/window_impl.h"
|
#include "libcef/browser/views/window_impl.h"
|
||||||
|
|
||||||
|
#include "chrome/browser/devtools/devtools_window.h"
|
||||||
#include "chrome/browser/ui/browser.h"
|
#include "chrome/browser/ui/browser.h"
|
||||||
|
#include "components/zoom/zoom_controller.h"
|
||||||
#include "ui/views/widget/widget.h"
|
#include "ui/views/widget/widget.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -77,8 +79,30 @@ void CefBrowserPlatformDelegateChromeViews::BrowserCreated(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateChromeViews::NotifyBrowserCreated() {
|
void CefBrowserPlatformDelegateChromeViews::NotifyBrowserCreated() {
|
||||||
if (browser_view_->delegate()) {
|
if (auto delegate = browser_view_->delegate()) {
|
||||||
browser_view_->delegate()->OnBrowserCreated(browser_view_, browser_);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=6a2ebf843d929371a15e34792b6900c0ab622877$
|
// $hash=497607653318fe0245cbe18c8911e39867e16249$
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "libcef_dll/cpptoc/browser_host_cpptoc.h"
|
#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);
|
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
|
double CEF_CALLBACK
|
||||||
browser_host_get_zoom_level(struct _cef_browser_host_t* self) {
|
browser_host_get_zoom_level(struct _cef_browser_host_t* self) {
|
||||||
shutdown_checker::AssertNotShutdown();
|
shutdown_checker::AssertNotShutdown();
|
||||||
@ -1398,6 +1449,9 @@ CefBrowserHostCppToC::CefBrowserHostCppToC() {
|
|||||||
GetStruct()->has_view = browser_host_has_view;
|
GetStruct()->has_view = browser_host_has_view;
|
||||||
GetStruct()->get_client = browser_host_get_client;
|
GetStruct()->get_client = browser_host_get_client;
|
||||||
GetStruct()->get_request_context = browser_host_get_request_context;
|
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()->get_zoom_level = browser_host_get_zoom_level;
|
||||||
GetStruct()->set_zoom_level = browser_host_set_zoom_level;
|
GetStruct()->set_zoom_level = browser_host_set_zoom_level;
|
||||||
GetStruct()->run_file_dialog = browser_host_run_file_dialog;
|
GetStruct()->run_file_dialog = browser_host_run_file_dialog;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=02a6c45f14489fd5548eb61210ba453de05bcd2d$
|
// $hash=cd4e4aa1670f0c887090e23f5e7e3a01e5de9d13$
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "libcef_dll/ctocpp/browser_host_ctocpp.h"
|
#include "libcef_dll/ctocpp/browser_host_ctocpp.h"
|
||||||
@ -234,6 +234,56 @@ CefRefPtr<CefRequestContext> CefBrowserHostCToCpp::GetRequestContext() {
|
|||||||
return CefRequestContextCToCpp::Wrap(_retval);
|
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() {
|
NO_SANITIZE("cfi-icall") double CefBrowserHostCToCpp::GetZoomLevel() {
|
||||||
shutdown_checker::AssertNotShutdown();
|
shutdown_checker::AssertNotShutdown();
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=4700b3b409abf624334f9f6ecf9c1c20131e4849$
|
// $hash=b4e11c91197cd5d6ccbe3a0d96aaae3792a6e05c$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_
|
#ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_
|
||||||
@ -46,6 +46,9 @@ class CefBrowserHostCToCpp : public CefCToCppRefCounted<CefBrowserHostCToCpp,
|
|||||||
bool HasView() override;
|
bool HasView() override;
|
||||||
CefRefPtr<CefClient> GetClient() override;
|
CefRefPtr<CefClient> GetClient() override;
|
||||||
CefRefPtr<CefRequestContext> GetRequestContext() override;
|
CefRefPtr<CefRequestContext> GetRequestContext() override;
|
||||||
|
bool CanZoom(cef_zoom_command_t command) override;
|
||||||
|
void Zoom(cef_zoom_command_t command) override;
|
||||||
|
double GetDefaultZoomLevel() override;
|
||||||
double GetZoomLevel() override;
|
double GetZoomLevel() override;
|
||||||
void SetZoomLevel(double zoomLevel) override;
|
void SetZoomLevel(double zoomLevel) override;
|
||||||
void RunFileDialog(FileDialogMode mode,
|
void RunFileDialog(FileDialogMode mode,
|
||||||
|
@ -224,8 +224,9 @@ void MainContextImpl::PopulateBrowserSettings(CefBrowserSettings* settings) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (use_chrome_runtime_ &&
|
if (use_chrome_runtime_ &&
|
||||||
command_line_->HasSwitch(switches::kHideChromeStatusBubble)) {
|
command_line_->HasSwitch(switches::kHideChromeBubbles)) {
|
||||||
settings->chrome_status_bubble = STATE_DISABLED;
|
settings->chrome_status_bubble = STATE_DISABLED;
|
||||||
|
settings->chrome_zoom_bubble = STATE_DISABLED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,16 +160,6 @@ void RunDialogWindowTest(CefRefPtr<CefBrowser> browser) {
|
|||||||
std::move(config));
|
std::move(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModifyZoom(CefRefPtr<CefBrowser> 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 kPrompt[] = "Prompt.";
|
||||||
const char kPromptFPS[] = "FPS";
|
const char kPromptFPS[] = "FPS";
|
||||||
const char kPromptDSF[] = "DSF";
|
const char kPromptDSF[] = "DSF";
|
||||||
@ -569,13 +559,13 @@ void RunTest(CefRefPtr<CefBrowser> browser, int id) {
|
|||||||
RunRequestTest(browser);
|
RunRequestTest(browser);
|
||||||
break;
|
break;
|
||||||
case ID_TESTS_ZOOM_IN:
|
case ID_TESTS_ZOOM_IN:
|
||||||
ModifyZoom(browser, 0.5);
|
browser->GetHost()->Zoom(CEF_ZOOM_COMMAND_IN);
|
||||||
break;
|
break;
|
||||||
case ID_TESTS_ZOOM_OUT:
|
case ID_TESTS_ZOOM_OUT:
|
||||||
ModifyZoom(browser, -0.5);
|
browser->GetHost()->Zoom(CEF_ZOOM_COMMAND_OUT);
|
||||||
break;
|
break;
|
||||||
case ID_TESTS_ZOOM_RESET:
|
case ID_TESTS_ZOOM_RESET:
|
||||||
browser->GetHost()->SetZoomLevel(0.0);
|
browser->GetHost()->Zoom(CEF_ZOOM_COMMAND_RESET);
|
||||||
break;
|
break;
|
||||||
case ID_TESTS_OSR_FPS:
|
case ID_TESTS_OSR_FPS:
|
||||||
PromptFPS(browser);
|
PromptFPS(browser);
|
||||||
|
@ -49,7 +49,6 @@ const char kNoActivate[] = "no-activate";
|
|||||||
const char kEnableChromeRuntime[] = "enable-chrome-runtime";
|
const char kEnableChromeRuntime[] = "enable-chrome-runtime";
|
||||||
const char kShowChromeToolbar[] = "show-chrome-toolbar";
|
const char kShowChromeToolbar[] = "show-chrome-toolbar";
|
||||||
const char kInitialShowState[] = "initial-show-state";
|
const char kInitialShowState[] = "initial-show-state";
|
||||||
const char kHideChromeStatusBubble[] = "hide-chrome-status-bubble";
|
|
||||||
const char kUseDefaultPopup[] = "use-default-popup";
|
const char kUseDefaultPopup[] = "use-default-popup";
|
||||||
const char kUseClientDialogs[] = "use-client-dialogs";
|
const char kUseClientDialogs[] = "use-client-dialogs";
|
||||||
const char kUseTestHttpServer[] = "use-test-http-server";
|
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 kUseWindowModalDialog[] = "use-window-modal-dialog";
|
||||||
const char kUseBottomControls[] = "use-bottom-controls";
|
const char kUseBottomControls[] = "use-bottom-controls";
|
||||||
const char kHidePipFrame[] = "hide-pip-frame";
|
const char kHidePipFrame[] = "hide-pip-frame";
|
||||||
|
const char kHideChromeBubbles[] = "hide-chrome-bubbles";
|
||||||
|
|
||||||
} // namespace switches
|
} // namespace switches
|
||||||
} // namespace client
|
} // namespace client
|
||||||
|
@ -43,7 +43,6 @@ extern const char kNoActivate[];
|
|||||||
extern const char kEnableChromeRuntime[];
|
extern const char kEnableChromeRuntime[];
|
||||||
extern const char kShowChromeToolbar[];
|
extern const char kShowChromeToolbar[];
|
||||||
extern const char kInitialShowState[];
|
extern const char kInitialShowState[];
|
||||||
extern const char kHideChromeStatusBubble[];
|
|
||||||
extern const char kUseDefaultPopup[];
|
extern const char kUseDefaultPopup[];
|
||||||
extern const char kUseClientDialogs[];
|
extern const char kUseClientDialogs[];
|
||||||
extern const char kUseTestHttpServer[];
|
extern const char kUseTestHttpServer[];
|
||||||
@ -51,6 +50,7 @@ extern const char kShowWindowButtons[];
|
|||||||
extern const char kUseWindowModalDialog[];
|
extern const char kUseWindowModalDialog[];
|
||||||
extern const char kUseBottomControls[];
|
extern const char kUseBottomControls[];
|
||||||
extern const char kHidePipFrame[];
|
extern const char kHidePipFrame[];
|
||||||
|
extern const char kHideChromeBubbles[];
|
||||||
|
|
||||||
} // namespace switches
|
} // namespace switches
|
||||||
} // namespace client
|
} // namespace client
|
||||||
|
Reference in New Issue
Block a user