OLD | NEW |
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 Loading... |
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(¶ms); | 944 render_view = g_create_render_view_impl(¶ms); |
945 else | 945 else |
946 render_view = new RenderViewImpl(¶ms); | 946 render_view = new RenderViewImpl(¶ms); |
947 | 947 |
948 render_view->Initialize(¶ms); | 948 render_view->Initialize(¶ms); |
| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 OnScrollFocusedEditableNodeIntoRect) | 1075 OnScrollFocusedEditableNodeIntoRect) |
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_CopyImageAt, OnCopyImageAt) | 1080 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) |
1077 IPC_MESSAGE_HANDLER(ViewMsg_SaveImageAt, OnSaveImageAt) | 1081 IPC_MESSAGE_HANDLER(ViewMsg_SaveImageAt, OnSaveImageAt) |
1078 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) | 1082 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) |
1079 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) | 1083 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) |
1080 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) | 1084 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
1081 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) | |
1082 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, | 1085 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, |
1083 OnSetZoomLevelForLoadingURL) | 1086 OnSetZoomLevelForLoadingURL) |
1084 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) | 1087 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) |
1085 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, | 1088 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, |
1086 OnResetPageEncodingToDefault) | 1089 OnResetPageEncodingToDefault) |
1087 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) | 1090 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) |
1088 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) | 1091 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) |
1089 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) | 1092 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) |
1090 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) | 1093 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) |
1091 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) | 1094 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) |
(...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2671 zoom_level = static_cast<int>(old_zoom_level + zoom); | 2674 zoom_level = static_cast<int>(old_zoom_level + zoom); |
2672 } else { | 2675 } else { |
2673 // We're going towards 100%, so first go to the next whole number. | 2676 // We're going towards 100%, so first go to the next whole number. |
2674 zoom_level = static_cast<int>(old_zoom_level); | 2677 zoom_level = static_cast<int>(old_zoom_level); |
2675 } | 2678 } |
2676 } | 2679 } |
2677 webview()->setZoomLevel(zoom_level); | 2680 webview()->setZoomLevel(zoom_level); |
2678 zoomLevelChanged(); | 2681 zoomLevelChanged(); |
2679 } | 2682 } |
2680 | 2683 |
2681 void RenderViewImpl::OnSetZoomLevel(double zoom_level) { | |
2682 webview()->hidePopups(); | |
2683 webview()->setZoomLevel(zoom_level); | |
2684 zoomLevelChanged(); | |
2685 } | |
2686 | |
2687 void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url, | 2684 void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url, |
2688 double zoom_level) { | 2685 double zoom_level) { |
2689 #if !defined(OS_ANDROID) | 2686 #if !defined(OS_ANDROID) |
2690 // On Android, page zoom isn't used, and in case of WebView, text zoom is used | 2687 // On Android, page zoom isn't used, and in case of WebView, text zoom is used |
2691 // for legacy WebView text scaling emulation. Thus, the code that resets | 2688 // for legacy WebView text scaling emulation. Thus, the code that resets |
2692 // the zoom level from this map will be effectively resetting text zoom level. | 2689 // the zoom level from this map will be effectively resetting text zoom level. |
2693 host_zoom_levels_[url] = zoom_level; | 2690 host_zoom_levels_[url] = zoom_level; |
2694 #endif | 2691 #endif |
2695 } | 2692 } |
2696 | 2693 |
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3664 } | 3661 } |
3665 | 3662 |
3666 blink::WebSpeechRecognizer* RenderViewImpl::speechRecognizer() { | 3663 blink::WebSpeechRecognizer* RenderViewImpl::speechRecognizer() { |
3667 if (!speech_recognition_dispatcher_) | 3664 if (!speech_recognition_dispatcher_) |
3668 speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this); | 3665 speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this); |
3669 return speech_recognition_dispatcher_; | 3666 return speech_recognition_dispatcher_; |
3670 } | 3667 } |
3671 | 3668 |
3672 void RenderViewImpl::zoomLimitsChanged(double minimum_level, | 3669 void RenderViewImpl::zoomLimitsChanged(double minimum_level, |
3673 double maximum_level) { | 3670 double maximum_level) { |
3674 // For now, don't remember plugin zoom values. We don't want to mix them with | |
3675 // normal web content (i.e. a fixed layout plugin would usually want them | |
3676 // different). | |
3677 bool remember = !webview()->mainFrame()->document().isPluginDocument(); | |
3678 | |
3679 int minimum_percent = static_cast<int>( | 3671 int minimum_percent = static_cast<int>( |
3680 ZoomLevelToZoomFactor(minimum_level) * 100); | 3672 ZoomLevelToZoomFactor(minimum_level) * 100); |
3681 int maximum_percent = static_cast<int>( | 3673 int maximum_percent = static_cast<int>( |
3682 ZoomLevelToZoomFactor(maximum_level) * 100); | 3674 ZoomLevelToZoomFactor(maximum_level) * 100); |
3683 | 3675 |
3684 Send(new ViewHostMsg_UpdateZoomLimits( | 3676 Send(new ViewHostMsg_UpdateZoomLimits( |
3685 routing_id_, minimum_percent, maximum_percent, remember)); | 3677 routing_id_, minimum_percent, maximum_percent)); |
3686 } | 3678 } |
3687 | 3679 |
3688 void RenderViewImpl::zoomLevelChanged() { | 3680 void RenderViewImpl::zoomLevelChanged() { |
3689 bool remember = !webview()->mainFrame()->document().isPluginDocument(); | |
3690 double zoom_level = webview()->zoomLevel(); | 3681 double zoom_level = webview()->zoomLevel(); |
3691 | 3682 |
3692 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ZoomLevelChanged()); | 3683 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ZoomLevelChanged()); |
3693 | 3684 |
3694 // Do not send empty URLs to the browser when we are just setting the default | 3685 // Do not send empty URLs to the browser when we are just setting the default |
3695 // zoom level (from RendererPreferences) before the first navigation. | 3686 // zoom level (from RendererPreferences) before the first navigation. |
3696 if (!webview()->mainFrame()->document().url().isEmpty()) { | 3687 if (!webview()->mainFrame()->document().url().isEmpty()) { |
3697 // Tell the browser which url got zoomed so it can update the menu and the | 3688 // Tell the browser which url got zoomed so it can update the menu and the |
3698 // saved values if necessary | 3689 // saved values if necessary |
3699 Send(new ViewHostMsg_DidZoomURL( | 3690 Send(new ViewHostMsg_DidZoomURL( |
3700 routing_id_, zoom_level, remember, | 3691 routing_id_, zoom_level, |
3701 GURL(webview()->mainFrame()->document().url()))); | 3692 GURL(webview()->mainFrame()->document().url()))); |
3702 } | 3693 } |
3703 } | 3694 } |
3704 | 3695 |
3705 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { | 3696 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { |
3706 return ZoomLevelToZoomFactor(zoom_level); | 3697 return ZoomLevelToZoomFactor(zoom_level); |
3707 } | 3698 } |
3708 | 3699 |
3709 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const { | 3700 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const { |
3710 return ZoomFactorToZoomLevel(factor); | 3701 return ZoomFactorToZoomLevel(factor); |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4079 std::vector<gfx::Size> sizes; | 4070 std::vector<gfx::Size> sizes; |
4080 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4071 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4081 if (!url.isEmpty()) | 4072 if (!url.isEmpty()) |
4082 urls.push_back( | 4073 urls.push_back( |
4083 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4074 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4084 } | 4075 } |
4085 SendUpdateFaviconURL(urls); | 4076 SendUpdateFaviconURL(urls); |
4086 } | 4077 } |
4087 | 4078 |
4088 } // namespace content | 4079 } // namespace content |
OLD | NEW |