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 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 OnScrollFocusedEditableNodeIntoRect) | 1065 OnScrollFocusedEditableNodeIntoRect) |
1066 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, | 1066 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, |
1067 OnSetEditCommandsForNextKeyEvent) | 1067 OnSetEditCommandsForNextKeyEvent) |
1068 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate) | 1068 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate) |
1069 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) | 1069 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) |
1070 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) | 1070 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) |
1071 IPC_MESSAGE_HANDLER(ViewMsg_SaveImageAt, OnSaveImageAt) | 1071 IPC_MESSAGE_HANDLER(ViewMsg_SaveImageAt, OnSaveImageAt) |
1072 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) | 1072 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) |
1073 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) | 1073 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) |
1074 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) | 1074 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
1075 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) | |
1076 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, | 1075 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, |
1077 OnSetZoomLevelForLoadingURL) | 1076 OnSetZoomLevelForLoadingURL) |
1078 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) | 1077 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) |
1079 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, | 1078 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, |
1080 OnResetPageEncodingToDefault) | 1079 OnResetPageEncodingToDefault) |
1081 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) | 1080 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) |
1082 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) | 1081 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) |
1083 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) | 1082 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) |
1084 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) | 1083 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) |
1085 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) | 1084 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) |
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2645 zoom_level = static_cast<int>(old_zoom_level + zoom); | 2644 zoom_level = static_cast<int>(old_zoom_level + zoom); |
2646 } else { | 2645 } else { |
2647 // We're going towards 100%, so first go to the next whole number. | 2646 // We're going towards 100%, so first go to the next whole number. |
2648 zoom_level = static_cast<int>(old_zoom_level); | 2647 zoom_level = static_cast<int>(old_zoom_level); |
2649 } | 2648 } |
2650 } | 2649 } |
2651 webview()->setZoomLevel(zoom_level); | 2650 webview()->setZoomLevel(zoom_level); |
2652 zoomLevelChanged(); | 2651 zoomLevelChanged(); |
2653 } | 2652 } |
2654 | 2653 |
2655 void RenderViewImpl::OnSetZoomLevel(double zoom_level) { | |
2656 webview()->hidePopups(); | |
2657 webview()->setZoomLevel(zoom_level); | |
2658 zoomLevelChanged(); | |
2659 } | |
2660 | |
2661 void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url, | 2654 void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url, |
2662 double zoom_level) { | 2655 double zoom_level) { |
2663 #if !defined(OS_ANDROID) | 2656 #if !defined(OS_ANDROID) |
2664 // On Android, page zoom isn't used, and in case of WebView, text zoom is used | 2657 // On Android, page zoom isn't used, and in case of WebView, text zoom is used |
2665 // for legacy WebView text scaling emulation. Thus, the code that resets | 2658 // for legacy WebView text scaling emulation. Thus, the code that resets |
2666 // the zoom level from this map will be effectively resetting text zoom level. | 2659 // the zoom level from this map will be effectively resetting text zoom level. |
2667 host_zoom_levels_[url] = zoom_level; | 2660 host_zoom_levels_[url] = zoom_level; |
2668 #endif | 2661 #endif |
2669 } | 2662 } |
2670 | 2663 |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3650 } | 3643 } |
3651 | 3644 |
3652 blink::WebSpeechRecognizer* RenderViewImpl::speechRecognizer() { | 3645 blink::WebSpeechRecognizer* RenderViewImpl::speechRecognizer() { |
3653 if (!speech_recognition_dispatcher_) | 3646 if (!speech_recognition_dispatcher_) |
3654 speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this); | 3647 speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this); |
3655 return speech_recognition_dispatcher_; | 3648 return speech_recognition_dispatcher_; |
3656 } | 3649 } |
3657 | 3650 |
3658 void RenderViewImpl::zoomLimitsChanged(double minimum_level, | 3651 void RenderViewImpl::zoomLimitsChanged(double minimum_level, |
3659 double maximum_level) { | 3652 double maximum_level) { |
3660 // For now, don't remember plugin zoom values. We don't want to mix them with | |
3661 // normal web content (i.e. a fixed layout plugin would usually want them | |
3662 // different). | |
3663 bool remember = !webview()->mainFrame()->document().isPluginDocument(); | |
3664 | |
3665 int minimum_percent = static_cast<int>( | 3653 int minimum_percent = static_cast<int>( |
3666 ZoomLevelToZoomFactor(minimum_level) * 100); | 3654 ZoomLevelToZoomFactor(minimum_level) * 100); |
3667 int maximum_percent = static_cast<int>( | 3655 int maximum_percent = static_cast<int>( |
3668 ZoomLevelToZoomFactor(maximum_level) * 100); | 3656 ZoomLevelToZoomFactor(maximum_level) * 100); |
3669 | 3657 |
3670 Send(new ViewHostMsg_UpdateZoomLimits( | 3658 Send(new ViewHostMsg_UpdateZoomLimits( |
3671 routing_id_, minimum_percent, maximum_percent, remember)); | 3659 routing_id_, minimum_percent, maximum_percent)); |
3672 } | 3660 } |
3673 | 3661 |
3674 void RenderViewImpl::zoomLevelChanged() { | 3662 void RenderViewImpl::zoomLevelChanged() { |
3675 bool remember = !webview()->mainFrame()->document().isPluginDocument(); | |
3676 double zoom_level = webview()->zoomLevel(); | 3663 double zoom_level = webview()->zoomLevel(); |
3677 | 3664 |
3678 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ZoomLevelChanged()); | 3665 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ZoomLevelChanged()); |
3679 | 3666 |
3680 // Do not send empty URLs to the browser when we are just setting the default | 3667 // Do not send empty URLs to the browser when we are just setting the default |
3681 // zoom level (from RendererPreferences) before the first navigation. | 3668 // zoom level (from RendererPreferences) before the first navigation. |
3682 if (!webview()->mainFrame()->document().url().isEmpty()) { | 3669 if (!webview()->mainFrame()->document().url().isEmpty()) { |
3683 // Tell the browser which url got zoomed so it can update the menu and the | 3670 // Tell the browser which url got zoomed so it can update the menu and the |
3684 // saved values if necessary | 3671 // saved values if necessary |
3685 Send(new ViewHostMsg_DidZoomURL( | 3672 Send(new ViewHostMsg_DidZoomURL( |
3686 routing_id_, zoom_level, remember, | 3673 routing_id_, zoom_level, |
3687 GURL(webview()->mainFrame()->document().url()))); | 3674 GURL(webview()->mainFrame()->document().url()))); |
3688 } | 3675 } |
3689 } | 3676 } |
3690 | 3677 |
3691 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { | 3678 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { |
3692 return ZoomLevelToZoomFactor(zoom_level); | 3679 return ZoomLevelToZoomFactor(zoom_level); |
3693 } | 3680 } |
3694 | 3681 |
3695 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const { | 3682 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const { |
3696 return ZoomFactorToZoomLevel(factor); | 3683 return ZoomFactorToZoomLevel(factor); |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4065 std::vector<gfx::Size> sizes; | 4052 std::vector<gfx::Size> sizes; |
4066 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4053 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4067 if (!url.isEmpty()) | 4054 if (!url.isEmpty()) |
4068 urls.push_back( | 4055 urls.push_back( |
4069 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4056 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4070 } | 4057 } |
4071 SendUpdateFaviconURL(urls); | 4058 SendUpdateFaviconURL(urls); |
4072 } | 4059 } |
4073 | 4060 |
4074 } // namespace content | 4061 } // namespace content |
OLD | NEW |