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

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: Update temporary zoom settings in OnDocumentAvailableInMainFrame 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 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 next_page_id, 939 next_page_id,
940 screen_info, 940 screen_info,
941 accessibility_mode); 941 accessibility_mode);
942 RenderViewImpl* render_view = NULL; 942 RenderViewImpl* render_view = NULL;
943 if (g_create_render_view_impl) 943 if (g_create_render_view_impl)
944 render_view = g_create_render_view_impl(&params); 944 render_view = g_create_render_view_impl(&params);
945 else 945 else
946 render_view = new RenderViewImpl(&params); 946 render_view = new RenderViewImpl(&params);
947 947
948 render_view->Initialize(&params); 948 render_view->Initialize(&params);
949 bool uses_temporary_zoom_settings =
950 render_view->webview()->mainFrame()->document().isPluginDocument();
951 render_view->Send(new ViewHostMsg_DidCreateDocument(
952 render_view->GetRoutingID(), uses_temporary_zoom_settings));
949 return render_view; 953 return render_view;
950 } 954 }
951 955
952 // static 956 // static
953 void RenderViewImpl::InstallCreateHook( 957 void RenderViewImpl::InstallCreateHook(
954 RenderViewImpl* (*create_render_view_impl)(RenderViewImplParams*)) { 958 RenderViewImpl* (*create_render_view_impl)(RenderViewImplParams*)) {
955 CHECK(!g_create_render_view_impl); 959 CHECK(!g_create_render_view_impl);
956 g_create_render_view_impl = create_render_view_impl; 960 g_create_render_view_impl = create_render_view_impl;
957 } 961 }
958 962
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, 1076 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent,
1073 OnSetEditCommandsForNextKeyEvent) 1077 OnSetEditCommandsForNextKeyEvent)
1074 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate) 1078 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate)
1075 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) 1079 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop)
1076 IPC_MESSAGE_HANDLER(ViewMsg_SetName, OnSetName) 1080 IPC_MESSAGE_HANDLER(ViewMsg_SetName, OnSetName)
1077 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) 1081 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt)
1078 IPC_MESSAGE_HANDLER(ViewMsg_SaveImageAt, OnSaveImageAt) 1082 IPC_MESSAGE_HANDLER(ViewMsg_SaveImageAt, OnSaveImageAt)
1079 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) 1083 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind)
1080 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) 1084 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding)
1081 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) 1085 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
1082 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel)
1083 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, 1086 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL,
1084 OnSetZoomLevelForLoadingURL) 1087 OnSetZoomLevelForLoadingURL)
1085 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) 1088 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding)
1086 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, 1089 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault,
1087 OnResetPageEncodingToDefault) 1090 OnResetPageEncodingToDefault)
1088 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) 1091 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent)
1089 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) 1092 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter)
1090 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) 1093 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver)
1091 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) 1094 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave)
1092 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) 1095 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop)
(...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after
2679 zoom_level = static_cast<int>(old_zoom_level + zoom); 2682 zoom_level = static_cast<int>(old_zoom_level + zoom);
2680 } else { 2683 } else {
2681 // We're going towards 100%, so first go to the next whole number. 2684 // We're going towards 100%, so first go to the next whole number.
2682 zoom_level = static_cast<int>(old_zoom_level); 2685 zoom_level = static_cast<int>(old_zoom_level);
2683 } 2686 }
2684 } 2687 }
2685 webview()->setZoomLevel(zoom_level); 2688 webview()->setZoomLevel(zoom_level);
2686 zoomLevelChanged(); 2689 zoomLevelChanged();
2687 } 2690 }
2688 2691
2689 void RenderViewImpl::OnSetZoomLevel(double zoom_level) {
2690 webview()->hidePopups();
2691 webview()->setZoomLevel(zoom_level);
2692 zoomLevelChanged();
2693 }
2694
2695 void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url, 2692 void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url,
2696 double zoom_level) { 2693 double zoom_level) {
2697 #if !defined(OS_ANDROID) 2694 #if !defined(OS_ANDROID)
2698 // On Android, page zoom isn't used, and in case of WebView, text zoom is used 2695 // On Android, page zoom isn't used, and in case of WebView, text zoom is used
2699 // for legacy WebView text scaling emulation. Thus, the code that resets 2696 // for legacy WebView text scaling emulation. Thus, the code that resets
2700 // the zoom level from this map will be effectively resetting text zoom level. 2697 // the zoom level from this map will be effectively resetting text zoom level.
2701 host_zoom_levels_[url] = zoom_level; 2698 host_zoom_levels_[url] = zoom_level;
2702 #endif 2699 #endif
2703 } 2700 }
2704 2701
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after
3672 } 3669 }
3673 3670
3674 blink::WebSpeechRecognizer* RenderViewImpl::speechRecognizer() { 3671 blink::WebSpeechRecognizer* RenderViewImpl::speechRecognizer() {
3675 if (!speech_recognition_dispatcher_) 3672 if (!speech_recognition_dispatcher_)
3676 speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this); 3673 speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this);
3677 return speech_recognition_dispatcher_; 3674 return speech_recognition_dispatcher_;
3678 } 3675 }
3679 3676
3680 void RenderViewImpl::zoomLimitsChanged(double minimum_level, 3677 void RenderViewImpl::zoomLimitsChanged(double minimum_level,
3681 double maximum_level) { 3678 double maximum_level) {
3682 // For now, don't remember plugin zoom values. We don't want to mix them with
3683 // normal web content (i.e. a fixed layout plugin would usually want them
3684 // different).
3685 bool remember = !webview()->mainFrame()->document().isPluginDocument();
3686
3687 int minimum_percent = static_cast<int>( 3679 int minimum_percent = static_cast<int>(
3688 ZoomLevelToZoomFactor(minimum_level) * 100); 3680 ZoomLevelToZoomFactor(minimum_level) * 100);
3689 int maximum_percent = static_cast<int>( 3681 int maximum_percent = static_cast<int>(
3690 ZoomLevelToZoomFactor(maximum_level) * 100); 3682 ZoomLevelToZoomFactor(maximum_level) * 100);
3691 3683
3692 Send(new ViewHostMsg_UpdateZoomLimits( 3684 Send(new ViewHostMsg_UpdateZoomLimits(
3693 routing_id_, minimum_percent, maximum_percent, remember)); 3685 routing_id_, minimum_percent, maximum_percent));
3694 } 3686 }
3695 3687
3696 void RenderViewImpl::zoomLevelChanged() { 3688 void RenderViewImpl::zoomLevelChanged() {
3697 bool remember = !webview()->mainFrame()->document().isPluginDocument();
3698 double zoom_level = webview()->zoomLevel(); 3689 double zoom_level = webview()->zoomLevel();
3699 3690
3700 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ZoomLevelChanged()); 3691 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ZoomLevelChanged());
3701 3692
3702 // Do not send empty URLs to the browser when we are just setting the default 3693 // Do not send empty URLs to the browser when we are just setting the default
3703 // zoom level (from RendererPreferences) before the first navigation. 3694 // zoom level (from RendererPreferences) before the first navigation.
3704 if (!webview()->mainFrame()->document().url().isEmpty()) { 3695 if (!webview()->mainFrame()->document().url().isEmpty()) {
3705 // Tell the browser which url got zoomed so it can update the menu and the 3696 // Tell the browser which url got zoomed so it can update the menu and the
3706 // saved values if necessary 3697 // saved values if necessary
3707 Send(new ViewHostMsg_DidZoomURL( 3698 Send(new ViewHostMsg_DidZoomURL(
3708 routing_id_, zoom_level, remember, 3699 routing_id_, zoom_level,
3709 GURL(webview()->mainFrame()->document().url()))); 3700 GURL(webview()->mainFrame()->document().url())));
3710 } 3701 }
3711 } 3702 }
3712 3703
3713 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { 3704 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const {
3714 return ZoomLevelToZoomFactor(zoom_level); 3705 return ZoomLevelToZoomFactor(zoom_level);
3715 } 3706 }
3716 3707
3717 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const { 3708 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const {
3718 return ZoomFactorToZoomLevel(factor); 3709 return ZoomFactorToZoomLevel(factor);
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
4087 std::vector<gfx::Size> sizes; 4078 std::vector<gfx::Size> sizes;
4088 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); 4079 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
4089 if (!url.isEmpty()) 4080 if (!url.isEmpty())
4090 urls.push_back( 4081 urls.push_back(
4091 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); 4082 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes));
4092 } 4083 }
4093 SendUpdateFaviconURL(urls); 4084 SendUpdateFaviconURL(urls);
4094 } 4085 }
4095 4086
4096 } // namespace content 4087 } // namespace content
OLDNEW
« content/public/browser/host_zoom_map.h ('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