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

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 287093002: Remove ViewMsg_SetZoomLevel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 next_page_id, 930 next_page_id,
931 screen_info, 931 screen_info,
932 accessibility_mode); 932 accessibility_mode);
933 RenderViewImpl* render_view = NULL; 933 RenderViewImpl* render_view = NULL;
934 if (g_create_render_view_impl) 934 if (g_create_render_view_impl)
935 render_view = g_create_render_view_impl(&params); 935 render_view = g_create_render_view_impl(&params);
936 else 936 else
937 render_view = new RenderViewImpl(&params); 937 render_view = new RenderViewImpl(&params);
938 938
939 render_view->Initialize(&params); 939 render_view->Initialize(&params);
940 bool uses_temporary_zoom_settings =
941 render_view->webview()->mainFrame()->document().isPluginDocument();
Fady Samuel 2014/05/15 23:26:53 This check is probably too early to know what we a
wjmaclean 2014/05/16 01:57:08 Actually, for a mainFrame document, I think this s
Fady Samuel 2014/05/16 19:20:07 Yes, it can, at least for a <webview>. We keep aro
wjmaclean 2014/05/16 19:32:49 Will investigate that.
wjmaclean 2014/05/21 20:59:13 The way the temporary zoom settings are currently
942 render_view->Send(new ViewHostMsg_DidCreateDocument(
943 render_view->GetRoutingID(), uses_temporary_zoom_settings));
940 return render_view; 944 return render_view;
941 } 945 }
942 946
943 // static 947 // static
944 void RenderViewImpl::InstallCreateHook( 948 void RenderViewImpl::InstallCreateHook(
945 RenderViewImpl* (*create_render_view_impl)(RenderViewImplParams*)) { 949 RenderViewImpl* (*create_render_view_impl)(RenderViewImplParams*)) {
946 CHECK(!g_create_render_view_impl); 950 CHECK(!g_create_render_view_impl);
947 g_create_render_view_impl = create_render_view_impl; 951 g_create_render_view_impl = create_render_view_impl;
948 } 952 }
949 953
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, 1068 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent,
1065 OnSetEditCommandsForNextKeyEvent) 1069 OnSetEditCommandsForNextKeyEvent)
1066 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate) 1070 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate)
1067 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) 1071 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop)
1068 IPC_MESSAGE_HANDLER(ViewMsg_SetName, OnSetName) 1072 IPC_MESSAGE_HANDLER(ViewMsg_SetName, OnSetName)
1069 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) 1073 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt)
1070 IPC_MESSAGE_HANDLER(ViewMsg_SaveImageAt, OnSaveImageAt) 1074 IPC_MESSAGE_HANDLER(ViewMsg_SaveImageAt, OnSaveImageAt)
1071 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) 1075 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind)
1072 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) 1076 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding)
1073 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) 1077 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
1074 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel)
1075 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, 1078 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL,
1076 OnSetZoomLevelForLoadingURL) 1079 OnSetZoomLevelForLoadingURL)
1077 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) 1080 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding)
1078 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, 1081 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault,
1079 OnResetPageEncodingToDefault) 1082 OnResetPageEncodingToDefault)
1080 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) 1083 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent)
1081 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) 1084 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter)
1082 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) 1085 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver)
1083 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) 1086 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave)
1084 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) 1087 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop)
(...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after
2685 zoom_level = static_cast<int>(old_zoom_level + zoom); 2688 zoom_level = static_cast<int>(old_zoom_level + zoom);
2686 } else { 2689 } else {
2687 // We're going towards 100%, so first go to the next whole number. 2690 // We're going towards 100%, so first go to the next whole number.
2688 zoom_level = static_cast<int>(old_zoom_level); 2691 zoom_level = static_cast<int>(old_zoom_level);
2689 } 2692 }
2690 } 2693 }
2691 webview()->setZoomLevel(zoom_level); 2694 webview()->setZoomLevel(zoom_level);
2692 zoomLevelChanged(); 2695 zoomLevelChanged();
2693 } 2696 }
2694 2697
2695 void RenderViewImpl::OnSetZoomLevel(double zoom_level) {
2696 webview()->hidePopups();
2697 webview()->setZoomLevel(zoom_level);
2698 zoomLevelChanged();
2699 }
2700
2701 void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url, 2698 void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url,
2702 double zoom_level) { 2699 double zoom_level) {
2703 #if !defined(OS_ANDROID) 2700 #if !defined(OS_ANDROID)
2704 // On Android, page zoom isn't used, and in case of WebView, text zoom is used 2701 // On Android, page zoom isn't used, and in case of WebView, text zoom is used
2705 // for legacy WebView text scaling emulation. Thus, the code that resets 2702 // for legacy WebView text scaling emulation. Thus, the code that resets
2706 // the zoom level from this map will be effectively resetting text zoom level. 2703 // the zoom level from this map will be effectively resetting text zoom level.
2707 host_zoom_levels_[url] = zoom_level; 2704 host_zoom_levels_[url] = zoom_level;
2708 #endif 2705 #endif
2709 } 2706 }
2710 2707
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after
3678 } 3675 }
3679 3676
3680 blink::WebSpeechRecognizer* RenderViewImpl::speechRecognizer() { 3677 blink::WebSpeechRecognizer* RenderViewImpl::speechRecognizer() {
3681 if (!speech_recognition_dispatcher_) 3678 if (!speech_recognition_dispatcher_)
3682 speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this); 3679 speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this);
3683 return speech_recognition_dispatcher_; 3680 return speech_recognition_dispatcher_;
3684 } 3681 }
3685 3682
3686 void RenderViewImpl::zoomLimitsChanged(double minimum_level, 3683 void RenderViewImpl::zoomLimitsChanged(double minimum_level,
3687 double maximum_level) { 3684 double maximum_level) {
3688 // For now, don't remember plugin zoom values. We don't want to mix them with
3689 // normal web content (i.e. a fixed layout plugin would usually want them
3690 // different).
3691 bool remember = !webview()->mainFrame()->document().isPluginDocument();
3692
3693 int minimum_percent = static_cast<int>( 3685 int minimum_percent = static_cast<int>(
3694 ZoomLevelToZoomFactor(minimum_level) * 100); 3686 ZoomLevelToZoomFactor(minimum_level) * 100);
3695 int maximum_percent = static_cast<int>( 3687 int maximum_percent = static_cast<int>(
3696 ZoomLevelToZoomFactor(maximum_level) * 100); 3688 ZoomLevelToZoomFactor(maximum_level) * 100);
3697 3689
3698 Send(new ViewHostMsg_UpdateZoomLimits( 3690 Send(new ViewHostMsg_UpdateZoomLimits(
3699 routing_id_, minimum_percent, maximum_percent, remember)); 3691 routing_id_, minimum_percent, maximum_percent));
3700 } 3692 }
3701 3693
3702 void RenderViewImpl::zoomLevelChanged() { 3694 void RenderViewImpl::zoomLevelChanged() {
3703 bool remember = !webview()->mainFrame()->document().isPluginDocument();
3704 double zoom_level = webview()->zoomLevel(); 3695 double zoom_level = webview()->zoomLevel();
3705 3696
3706 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ZoomLevelChanged()); 3697 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ZoomLevelChanged());
3707 3698
3708 // Do not send empty URLs to the browser when we are just setting the default 3699 // Do not send empty URLs to the browser when we are just setting the default
3709 // zoom level (from RendererPreferences) before the first navigation. 3700 // zoom level (from RendererPreferences) before the first navigation.
3710 if (!webview()->mainFrame()->document().url().isEmpty()) { 3701 if (!webview()->mainFrame()->document().url().isEmpty()) {
3711 // Tell the browser which url got zoomed so it can update the menu and the 3702 // Tell the browser which url got zoomed so it can update the menu and the
3712 // saved values if necessary 3703 // saved values if necessary
3713 Send(new ViewHostMsg_DidZoomURL( 3704 Send(new ViewHostMsg_DidZoomURL(
3714 routing_id_, zoom_level, remember, 3705 routing_id_, zoom_level,
3715 GURL(webview()->mainFrame()->document().url()))); 3706 GURL(webview()->mainFrame()->document().url())));
3716 } 3707 }
3717 } 3708 }
3718 3709
3719 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { 3710 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const {
3720 return ZoomLevelToZoomFactor(zoom_level); 3711 return ZoomLevelToZoomFactor(zoom_level);
3721 } 3712 }
3722 3713
3723 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const { 3714 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const {
3724 return ZoomFactorToZoomLevel(factor); 3715 return ZoomFactorToZoomLevel(factor);
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
4063 std::vector<gfx::Size> sizes; 4054 std::vector<gfx::Size> sizes;
4064 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); 4055 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
4065 if (!url.isEmpty()) 4056 if (!url.isEmpty())
4066 urls.push_back( 4057 urls.push_back(
4067 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); 4058 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes));
4068 } 4059 }
4069 SendUpdateFaviconURL(urls); 4060 SendUpdateFaviconURL(urls);
4070 } 4061 }
4071 4062
4072 } // namespace content 4063 } // namespace content
OLDNEW
« content/browser/web_contents/web_contents_impl.cc ('K') | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698