Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4709)

Unified Diff: chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc

Issue 598163003: <webview>: Zooming the embedder should zoom the guest by the same level. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed spacing Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc
diff --git a/chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc b/chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc
index d07ebfc9eefb6ba02c36c0edcf3ac918bef27624..1a6b9f70253321a5ea1b3cb54fc3247c896f0af8 100644
--- a/chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc
+++ b/chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc
@@ -123,6 +123,20 @@ void ChromeWebViewGuestDelegate::OnEmbedderDestroyed() {
web_view_guest()->view_instance_id()));
}
+void ChromeWebViewGuestDelegate::OnDidAttachToEmbedder() {
+ // TODO(fsamuel): This code should be implemented in GuestViewBase once the
+ // ZoomController moves to the extensions module.
+ ZoomController* zoom_controller = ZoomController::FromWebContents(
+ web_view_guest()->embedder_web_contents());
+ if (!zoom_controller)
+ return;
+ // Listen to the embedder's zoom changes.
+ zoom_controller->AddObserver(this);
+ // Set the guest's initial zoom level to be equal to the embedder's.
+ ZoomController::FromWebContents(guest_web_contents())->
+ SetZoomLevel(zoom_controller->GetZoomLevel());
+}
+
void ChromeWebViewGuestDelegate::OnDidCommitProvisionalLoadForFrame(
bool is_main_frame) {
// Update the current zoom factor for the new page.
@@ -238,3 +252,9 @@ void ChromeWebViewGuestDelegate::OnAccessibilityStatusChanged(
}
}
#endif
+
+void ChromeWebViewGuestDelegate::OnZoomChanged(
+ const ZoomController::ZoomChangedEventData& data) {
+ ZoomController::FromWebContents(guest_web_contents())->
+ SetZoomLevel(data.new_zoom_level);
+}

Powered by Google App Engine
This is Rietveld 408576698