| 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 // For now, don't remember plugin zoom values. We don't want to mix them with |
| 950 // normal web content (i.e. a fixed layout plugin would usually want them |
| 951 // different). |
| 952 bool uses_temporary_zoom_level = |
| 953 render_view->webview()->mainFrame()->document().isPluginDocument(); |
| 954 render_view->Send(new ViewHostMsg_DidCreateDocument( |
| 955 render_view->GetRoutingID(), uses_temporary_zoom_level)); |
| 949 return render_view; | 956 return render_view; |
| 950 } | 957 } |
| 951 | 958 |
| 952 // static | 959 // static |
| 953 void RenderViewImpl::InstallCreateHook( | 960 void RenderViewImpl::InstallCreateHook( |
| 954 RenderViewImpl* (*create_render_view_impl)(RenderViewImplParams*)) { | 961 RenderViewImpl* (*create_render_view_impl)(RenderViewImplParams*)) { |
| 955 CHECK(!g_create_render_view_impl); | 962 CHECK(!g_create_render_view_impl); |
| 956 g_create_render_view_impl = create_render_view_impl; | 963 g_create_render_view_impl = create_render_view_impl; |
| 957 } | 964 } |
| 958 | 965 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 OnScrollFocusedEditableNodeIntoRect) | 1078 OnScrollFocusedEditableNodeIntoRect) |
| 1072 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, | 1079 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, |
| 1073 OnSetEditCommandsForNextKeyEvent) | 1080 OnSetEditCommandsForNextKeyEvent) |
| 1074 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate) | 1081 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate) |
| 1075 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) | 1082 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) |
| 1076 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) | 1083 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) |
| 1077 IPC_MESSAGE_HANDLER(ViewMsg_SaveImageAt, OnSaveImageAt) | 1084 IPC_MESSAGE_HANDLER(ViewMsg_SaveImageAt, OnSaveImageAt) |
| 1078 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) | 1085 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) |
| 1079 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) | 1086 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) |
| 1080 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) | 1087 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
| 1081 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) | |
| 1082 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, | 1088 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, |
| 1083 OnSetZoomLevelForLoadingURL) | 1089 OnSetZoomLevelForLoadingURL) |
| 1084 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) | 1090 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) |
| 1085 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, | 1091 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, |
| 1086 OnResetPageEncodingToDefault) | 1092 OnResetPageEncodingToDefault) |
| 1087 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) | 1093 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) |
| 1088 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) | 1094 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) |
| 1089 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) | 1095 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) |
| 1090 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) | 1096 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) |
| 1091 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) | 1097 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); | 2677 zoom_level = static_cast<int>(old_zoom_level + zoom); |
| 2672 } else { | 2678 } else { |
| 2673 // We're going towards 100%, so first go to the next whole number. | 2679 // We're going towards 100%, so first go to the next whole number. |
| 2674 zoom_level = static_cast<int>(old_zoom_level); | 2680 zoom_level = static_cast<int>(old_zoom_level); |
| 2675 } | 2681 } |
| 2676 } | 2682 } |
| 2677 webview()->setZoomLevel(zoom_level); | 2683 webview()->setZoomLevel(zoom_level); |
| 2678 zoomLevelChanged(); | 2684 zoomLevelChanged(); |
| 2679 } | 2685 } |
| 2680 | 2686 |
| 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, | 2687 void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url, |
| 2688 double zoom_level) { | 2688 double zoom_level) { |
| 2689 #if !defined(OS_ANDROID) | 2689 #if !defined(OS_ANDROID) |
| 2690 // On Android, page zoom isn't used, and in case of WebView, text zoom is used | 2690 // 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 | 2691 // 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. | 2692 // the zoom level from this map will be effectively resetting text zoom level. |
| 2693 host_zoom_levels_[url] = zoom_level; | 2693 host_zoom_levels_[url] = zoom_level; |
| 2694 #endif | 2694 #endif |
| 2695 } | 2695 } |
| 2696 | 2696 |
| (...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3669 } | 3669 } |
| 3670 | 3670 |
| 3671 blink::WebSpeechRecognizer* RenderViewImpl::speechRecognizer() { | 3671 blink::WebSpeechRecognizer* RenderViewImpl::speechRecognizer() { |
| 3672 if (!speech_recognition_dispatcher_) | 3672 if (!speech_recognition_dispatcher_) |
| 3673 speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this); | 3673 speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this); |
| 3674 return speech_recognition_dispatcher_; | 3674 return speech_recognition_dispatcher_; |
| 3675 } | 3675 } |
| 3676 | 3676 |
| 3677 void RenderViewImpl::zoomLimitsChanged(double minimum_level, | 3677 void RenderViewImpl::zoomLimitsChanged(double minimum_level, |
| 3678 double maximum_level) { | 3678 double maximum_level) { |
| 3679 // For now, don't remember plugin zoom values. We don't want to mix them with | |
| 3680 // normal web content (i.e. a fixed layout plugin would usually want them | |
| 3681 // different). | |
| 3682 bool remember = !webview()->mainFrame()->document().isPluginDocument(); | |
| 3683 | |
| 3684 int minimum_percent = static_cast<int>( | 3679 int minimum_percent = static_cast<int>( |
| 3685 ZoomLevelToZoomFactor(minimum_level) * 100); | 3680 ZoomLevelToZoomFactor(minimum_level) * 100); |
| 3686 int maximum_percent = static_cast<int>( | 3681 int maximum_percent = static_cast<int>( |
| 3687 ZoomLevelToZoomFactor(maximum_level) * 100); | 3682 ZoomLevelToZoomFactor(maximum_level) * 100); |
| 3688 | 3683 |
| 3689 Send(new ViewHostMsg_UpdateZoomLimits( | 3684 Send(new ViewHostMsg_UpdateZoomLimits( |
| 3690 routing_id_, minimum_percent, maximum_percent, remember)); | 3685 routing_id_, minimum_percent, maximum_percent)); |
| 3691 } | 3686 } |
| 3692 | 3687 |
| 3693 void RenderViewImpl::zoomLevelChanged() { | 3688 void RenderViewImpl::zoomLevelChanged() { |
| 3694 bool remember = !webview()->mainFrame()->document().isPluginDocument(); | |
| 3695 double zoom_level = webview()->zoomLevel(); | 3689 double zoom_level = webview()->zoomLevel(); |
| 3696 | 3690 |
| 3697 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ZoomLevelChanged()); | 3691 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ZoomLevelChanged()); |
| 3698 | 3692 |
| 3699 // 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 |
| 3700 // zoom level (from RendererPreferences) before the first navigation. | 3694 // zoom level (from RendererPreferences) before the first navigation. |
| 3701 if (!webview()->mainFrame()->document().url().isEmpty()) { | 3695 if (!webview()->mainFrame()->document().url().isEmpty()) { |
| 3702 // 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 |
| 3703 // saved values if necessary | 3697 // saved values if necessary |
| 3704 Send(new ViewHostMsg_DidZoomURL( | 3698 Send(new ViewHostMsg_DidZoomURL( |
| 3705 routing_id_, zoom_level, remember, | 3699 routing_id_, zoom_level, |
| 3706 GURL(webview()->mainFrame()->document().url()))); | 3700 GURL(webview()->mainFrame()->document().url()))); |
| 3707 } | 3701 } |
| 3708 } | 3702 } |
| 3709 | 3703 |
| 3710 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { | 3704 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { |
| 3711 return ZoomLevelToZoomFactor(zoom_level); | 3705 return ZoomLevelToZoomFactor(zoom_level); |
| 3712 } | 3706 } |
| 3713 | 3707 |
| 3714 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const { | 3708 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const { |
| 3715 return ZoomFactorToZoomLevel(factor); | 3709 return ZoomFactorToZoomLevel(factor); |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4084 std::vector<gfx::Size> sizes; | 4078 std::vector<gfx::Size> sizes; |
| 4085 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4079 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
| 4086 if (!url.isEmpty()) | 4080 if (!url.isEmpty()) |
| 4087 urls.push_back( | 4081 urls.push_back( |
| 4088 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4082 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
| 4089 } | 4083 } |
| 4090 SendUpdateFaviconURL(urls); | 4084 SendUpdateFaviconURL(urls); |
| 4091 } | 4085 } |
| 4092 | 4086 |
| 4093 } // namespace content | 4087 } // namespace content |
| OLD | NEW |