73 lines
3.2 KiB
Diff
73 lines
3.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: John Kleinschmidt <kleinschmidtorama@gmail.com>
|
|
Date: Mon, 23 Sep 2019 17:07:53 -0400
|
|
Subject: add zoom limit setters to webcontents
|
|
|
|
Allows minimum_zoom_percent_ and maximum_zoom_percent_ to be set on WebContents.
|
|
This is needed by Electron to allow apps to limit how much an app can zoom in
|
|
or out.
|
|
|
|
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
|
|
index 8586f71224f1cae6a5e9b4005a6acfef9ff64d4d..4d4dce8124312d46f90db8d2fc59bd0b7acd498d 100644
|
|
--- a/content/browser/web_contents/web_contents_impl.cc
|
|
+++ b/content/browser/web_contents/web_contents_impl.cc
|
|
@@ -4142,10 +4142,18 @@ bool WebContentsImpl::GetClosedByUserGesture() {
|
|
return closed_by_user_gesture_;
|
|
}
|
|
|
|
+void WebContentsImpl::SetMinimumZoomPercent(int zoom_percent) {
|
|
+ minimum_zoom_percent_ = zoom_percent;
|
|
+}
|
|
+
|
|
int WebContentsImpl::GetMinimumZoomPercent() {
|
|
return minimum_zoom_percent_;
|
|
}
|
|
|
|
+void WebContentsImpl::SetMaximumZoomPercent(int zoom_percent) {
|
|
+ maximum_zoom_percent_ = zoom_percent;
|
|
+}
|
|
+
|
|
int WebContentsImpl::GetMaximumZoomPercent() {
|
|
return maximum_zoom_percent_;
|
|
}
|
|
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
|
|
index 72f7570ed92886e97629116fec98c1c4dcf95f52..e876929be3df7ba7251886a56acf9b84bbe62e32 100644
|
|
--- a/content/browser/web_contents/web_contents_impl.h
|
|
+++ b/content/browser/web_contents/web_contents_impl.h
|
|
@@ -450,7 +450,9 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
|
|
void SystemDragEnded(RenderWidgetHost* source_rwh) override;
|
|
void SetClosedByUserGesture(bool value) override;
|
|
bool GetClosedByUserGesture() override;
|
|
+ void SetMinimumZoomPercent(int zoom_percent) override;
|
|
int GetMinimumZoomPercent() override;
|
|
+ void SetMaximumZoomPercent(int zoom_percent) override;
|
|
int GetMaximumZoomPercent() override;
|
|
void SetPageScale(float page_scale_factor) override;
|
|
gfx::Size GetPreferredSize() override;
|
|
@@ -1714,8 +1716,8 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
|
|
bool closed_by_user_gesture_;
|
|
|
|
// Minimum/maximum zoom percent.
|
|
- const int minimum_zoom_percent_;
|
|
- const int maximum_zoom_percent_;
|
|
+ int minimum_zoom_percent_;
|
|
+ int maximum_zoom_percent_;
|
|
|
|
// Used to correctly handle integer zooming through a smooth scroll device.
|
|
float zoom_scroll_remainder_;
|
|
diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h
|
|
index 94a5b87ca72998729f1fca14f247914bb81d60d1..3af575d51d0a36f9586a3cfc00575e83e70a46b9 100644
|
|
--- a/content/public/browser/web_contents.h
|
|
+++ b/content/public/browser/web_contents.h
|
|
@@ -808,8 +808,10 @@ class WebContents : public PageNavigator,
|
|
virtual void SetClosedByUserGesture(bool value) = 0;
|
|
virtual bool GetClosedByUserGesture() = 0;
|
|
|
|
- // Gets the minimum/maximum zoom percent.
|
|
+ // Gets/sets the minimum/maximum zoom percent.
|
|
+ virtual void SetMinimumZoomPercent(int zoom_percent) = 0;
|
|
virtual int GetMinimumZoomPercent() = 0;
|
|
+ virtual void SetMaximumZoomPercent(int zoom_percent) = 0;
|
|
virtual int GetMaximumZoomPercent() = 0;
|
|
|
|
// Set the renderer's page scale to the given factor.
|