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 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 frames_in_progress_(0), | 719 frames_in_progress_(0), |
720 target_url_status_(TARGET_NONE), | 720 target_url_status_(TARGET_NONE), |
721 uses_temporary_zoom_level_(false), | 721 uses_temporary_zoom_level_(false), |
722 #if defined(OS_ANDROID) | 722 #if defined(OS_ANDROID) |
723 top_controls_constraints_(cc::BOTH), | 723 top_controls_constraints_(cc::BOTH), |
724 #endif | 724 #endif |
725 has_scrolled_focused_editable_node_into_rect_(false), | 725 has_scrolled_focused_editable_node_into_rect_(false), |
726 speech_recognition_dispatcher_(NULL), | 726 speech_recognition_dispatcher_(NULL), |
727 browser_plugin_manager_(NULL), | 727 browser_plugin_manager_(NULL), |
728 devtools_agent_(NULL), | 728 devtools_agent_(NULL), |
729 accessibility_mode_(AccessibilityModeOff), | |
730 renderer_accessibility_(NULL), | |
731 mouse_lock_dispatcher_(NULL), | 729 mouse_lock_dispatcher_(NULL), |
732 #if defined(OS_ANDROID) | 730 #if defined(OS_ANDROID) |
733 expected_content_intent_id_(0), | 731 expected_content_intent_id_(0), |
734 #endif | 732 #endif |
735 #if defined(OS_WIN) | 733 #if defined(OS_WIN) |
736 focused_plugin_id_(-1), | 734 focused_plugin_id_(-1), |
737 #endif | 735 #endif |
738 #if defined(ENABLE_PLUGINS) | 736 #if defined(ENABLE_PLUGINS) |
739 plugin_find_handler_(NULL), | 737 plugin_find_handler_(NULL), |
740 focused_pepper_plugin_(NULL), | 738 focused_pepper_plugin_(NULL), |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 // The next group of objects all implement RenderViewObserver, so are deleted | 851 // The next group of objects all implement RenderViewObserver, so are deleted |
854 // along with the RenderView automatically. | 852 // along with the RenderView automatically. |
855 devtools_agent_ = new DevToolsAgent(this); | 853 devtools_agent_ = new DevToolsAgent(this); |
856 if (RenderWidgetCompositor* rwc = compositor()) { | 854 if (RenderWidgetCompositor* rwc = compositor()) { |
857 webview()->devToolsAgent()->setLayerTreeId(rwc->GetLayerTreeId()); | 855 webview()->devToolsAgent()->setLayerTreeId(rwc->GetLayerTreeId()); |
858 } | 856 } |
859 mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this); | 857 mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this); |
860 | 858 |
861 history_controller_.reset(new HistoryController(this)); | 859 history_controller_.reset(new HistoryController(this)); |
862 | 860 |
863 // Create renderer_accessibility_ if needed. | |
864 OnSetAccessibilityMode(params->accessibility_mode); | |
865 | |
866 new IdleUserDetector(this); | 861 new IdleUserDetector(this); |
867 | 862 |
868 if (command_line.HasSwitch(switches::kDomAutomationController)) | 863 if (command_line.HasSwitch(switches::kDomAutomationController)) |
869 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; | 864 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; |
870 if (command_line.HasSwitch(switches::kStatsCollectionController)) | 865 if (command_line.HasSwitch(switches::kStatsCollectionController)) |
871 enabled_bindings_ |= BINDINGS_POLICY_STATS_COLLECTION; | 866 enabled_bindings_ |= BINDINGS_POLICY_STATS_COLLECTION; |
872 | 867 |
873 ProcessViewLayoutFlags(command_line); | 868 ProcessViewLayoutFlags(command_line); |
874 | 869 |
875 GetContentClient()->renderer()->RenderViewCreated(this); | 870 GetContentClient()->renderer()->RenderViewCreated(this); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 int32 main_frame_routing_id, | 1189 int32 main_frame_routing_id, |
1195 int32 surface_id, | 1190 int32 surface_id, |
1196 int64 session_storage_namespace_id, | 1191 int64 session_storage_namespace_id, |
1197 const base::string16& frame_name, | 1192 const base::string16& frame_name, |
1198 bool is_renderer_created, | 1193 bool is_renderer_created, |
1199 bool swapped_out, | 1194 bool swapped_out, |
1200 int32 proxy_routing_id, | 1195 int32 proxy_routing_id, |
1201 bool hidden, | 1196 bool hidden, |
1202 bool never_visible, | 1197 bool never_visible, |
1203 int32 next_page_id, | 1198 int32 next_page_id, |
1204 const blink::WebScreenInfo& screen_info, | 1199 const blink::WebScreenInfo& screen_info) { |
1205 AccessibilityMode accessibility_mode) { | |
1206 DCHECK(routing_id != MSG_ROUTING_NONE); | 1200 DCHECK(routing_id != MSG_ROUTING_NONE); |
1207 RenderViewImplParams params(opener_id, | 1201 RenderViewImplParams params(opener_id, |
1208 window_was_created_with_opener, | 1202 window_was_created_with_opener, |
1209 renderer_prefs, | 1203 renderer_prefs, |
1210 webkit_prefs, | 1204 webkit_prefs, |
1211 routing_id, | 1205 routing_id, |
1212 main_frame_routing_id, | 1206 main_frame_routing_id, |
1213 surface_id, | 1207 surface_id, |
1214 session_storage_namespace_id, | 1208 session_storage_namespace_id, |
1215 frame_name, | 1209 frame_name, |
1216 is_renderer_created, | 1210 is_renderer_created, |
1217 swapped_out, | 1211 swapped_out, |
1218 proxy_routing_id, | 1212 proxy_routing_id, |
1219 hidden, | 1213 hidden, |
1220 never_visible, | 1214 never_visible, |
1221 next_page_id, | 1215 next_page_id, |
1222 screen_info, | 1216 screen_info); |
1223 accessibility_mode); | |
1224 RenderViewImpl* render_view = NULL; | 1217 RenderViewImpl* render_view = NULL; |
1225 if (g_create_render_view_impl) | 1218 if (g_create_render_view_impl) |
1226 render_view = g_create_render_view_impl(¶ms); | 1219 render_view = g_create_render_view_impl(¶ms); |
1227 else | 1220 else |
1228 render_view = new RenderViewImpl(¶ms); | 1221 render_view = new RenderViewImpl(¶ms); |
1229 | 1222 |
1230 render_view->Initialize(¶ms); | 1223 render_view->Initialize(¶ms); |
1231 return render_view; | 1224 return render_view; |
1232 } | 1225 } |
1233 | 1226 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, | 1394 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, |
1402 OnGetAllSavableResourceLinksForCurrentPage) | 1395 OnGetAllSavableResourceLinksForCurrentPage) |
1403 IPC_MESSAGE_HANDLER( | 1396 IPC_MESSAGE_HANDLER( |
1404 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, | 1397 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, |
1405 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) | 1398 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) |
1406 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) | 1399 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) |
1407 // TODO(viettrungluu): Move to a separate message filter. | 1400 // TODO(viettrungluu): Move to a separate message filter. |
1408 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, | 1401 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, |
1409 OnSetHistoryLengthAndPrune) | 1402 OnSetHistoryLengthAndPrune) |
1410 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) | 1403 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
1411 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityMode, OnSetAccessibilityMode) | |
1412 IPC_MESSAGE_HANDLER(ViewMsg_DisownOpener, OnDisownOpener) | 1404 IPC_MESSAGE_HANDLER(ViewMsg_DisownOpener, OnDisownOpener) |
1413 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, | 1405 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, |
1414 OnReleaseDisambiguationPopupBitmap) | 1406 OnReleaseDisambiguationPopupBitmap) |
1415 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, | 1407 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, |
1416 OnWindowSnapshotCompleted) | 1408 OnWindowSnapshotCompleted) |
1417 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) | 1409 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) |
1418 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) | 1410 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) |
1419 #if defined(OS_ANDROID) | 1411 #if defined(OS_ANDROID) |
1420 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, | 1412 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, |
1421 OnActivateNearestFindResult) | 1413 OnActivateNearestFindResult) |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1743 main_frame_routing_id, | 1735 main_frame_routing_id, |
1744 surface_id, | 1736 surface_id, |
1745 cloned_session_storage_namespace_id, | 1737 cloned_session_storage_namespace_id, |
1746 base::string16(), // WebCore will take care of setting the correct name. | 1738 base::string16(), // WebCore will take care of setting the correct name. |
1747 true, // is_renderer_created | 1739 true, // is_renderer_created |
1748 false, // swapped_out | 1740 false, // swapped_out |
1749 MSG_ROUTING_NONE, // proxy_routing_id | 1741 MSG_ROUTING_NONE, // proxy_routing_id |
1750 params.disposition == NEW_BACKGROUND_TAB, // hidden | 1742 params.disposition == NEW_BACKGROUND_TAB, // hidden |
1751 never_visible, | 1743 never_visible, |
1752 1, // next_page_id | 1744 1, // next_page_id |
1753 screen_info_, | 1745 screen_info_); |
1754 accessibility_mode_); | |
1755 view->opened_by_user_gesture_ = params.user_gesture; | 1746 view->opened_by_user_gesture_ = params.user_gesture; |
1756 | 1747 |
1757 // Record whether the creator frame is trying to suppress the opener field. | 1748 // Record whether the creator frame is trying to suppress the opener field. |
1758 view->opener_suppressed_ = params.opener_suppressed; | 1749 view->opener_suppressed_ = params.opener_suppressed; |
1759 | 1750 |
1760 return view->webview(); | 1751 return view->webview(); |
1761 } | 1752 } |
1762 | 1753 |
1763 WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) { | 1754 WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) { |
1764 RenderWidget* widget = | 1755 RenderWidget* widget = |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2028 void RenderViewImpl::focusPrevious() { | 2019 void RenderViewImpl::focusPrevious() { |
2029 Send(new ViewHostMsg_TakeFocus(routing_id_, true)); | 2020 Send(new ViewHostMsg_TakeFocus(routing_id_, true)); |
2030 } | 2021 } |
2031 | 2022 |
2032 void RenderViewImpl::focusedNodeChanged(const WebNode& node) { | 2023 void RenderViewImpl::focusedNodeChanged(const WebNode& node) { |
2033 has_scrolled_focused_editable_node_into_rect_ = false; | 2024 has_scrolled_focused_editable_node_into_rect_ = false; |
2034 | 2025 |
2035 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); | 2026 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); |
2036 | 2027 |
2037 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); | 2028 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); |
| 2029 |
| 2030 // TODO(dmazzoni): this should be part of RenderFrameObserver. |
| 2031 main_render_frame()->FocusedNodeChanged(node); |
2038 } | 2032 } |
2039 | 2033 |
2040 void RenderViewImpl::didUpdateLayout() { | 2034 void RenderViewImpl::didUpdateLayout() { |
2041 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout()); | 2035 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout()); |
2042 | 2036 |
2043 // We don't always want to set up a timer, only if we've been put in that | 2037 // We don't always want to set up a timer, only if we've been put in that |
2044 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| | 2038 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
2045 // message. | 2039 // message. |
2046 if (!send_preferred_size_changes_ || !webview()) | 2040 if (!send_preferred_size_changes_ || !webview()) |
2047 return; | 2041 return; |
(...skipping 12 matching lines...) Expand all Loading... |
2060 int RenderViewImpl::historyBackListCount() { | 2054 int RenderViewImpl::historyBackListCount() { |
2061 return history_list_offset_ < 0 ? 0 : history_list_offset_; | 2055 return history_list_offset_ < 0 ? 0 : history_list_offset_; |
2062 } | 2056 } |
2063 | 2057 |
2064 int RenderViewImpl::historyForwardListCount() { | 2058 int RenderViewImpl::historyForwardListCount() { |
2065 return history_list_length_ - historyBackListCount() - 1; | 2059 return history_list_length_ - historyBackListCount() - 1; |
2066 } | 2060 } |
2067 | 2061 |
2068 void RenderViewImpl::postAccessibilityEvent( | 2062 void RenderViewImpl::postAccessibilityEvent( |
2069 const WebAXObject& obj, blink::WebAXEvent event) { | 2063 const WebAXObject& obj, blink::WebAXEvent event) { |
2070 if (renderer_accessibility_) { | 2064 main_render_frame()->HandleWebAccessibilityEvent(obj, event); |
2071 renderer_accessibility_->HandleWebAccessibilityEvent(obj, event); | |
2072 } | |
2073 } | 2065 } |
2074 | 2066 |
2075 void RenderViewImpl::didUpdateInspectorSetting(const WebString& key, | 2067 void RenderViewImpl::didUpdateInspectorSetting(const WebString& key, |
2076 const WebString& value) { | 2068 const WebString& value) { |
2077 Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_, | 2069 Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_, |
2078 key.utf8(), | 2070 key.utf8(), |
2079 value.utf8())); | 2071 value.utf8())); |
2080 } | 2072 } |
2081 | 2073 |
2082 // blink::WebWidgetClient ---------------------------------------------------- | 2074 // blink::WebWidgetClient ---------------------------------------------------- |
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3418 webview()->clearFocusedElement(); | 3410 webview()->clearFocusedElement(); |
3419 } | 3411 } |
3420 | 3412 |
3421 void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) { | 3413 void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) { |
3422 if (webview()) | 3414 if (webview()) |
3423 webview()->setIsTransparent(!opaque); | 3415 webview()->setIsTransparent(!opaque); |
3424 if (compositor_) | 3416 if (compositor_) |
3425 compositor_->setHasTransparentBackground(!opaque); | 3417 compositor_->setHasTransparentBackground(!opaque); |
3426 } | 3418 } |
3427 | 3419 |
3428 void RenderViewImpl::OnSetAccessibilityMode(AccessibilityMode new_mode) { | |
3429 if (accessibility_mode_ == new_mode) | |
3430 return; | |
3431 accessibility_mode_ = new_mode; | |
3432 if (renderer_accessibility_) { | |
3433 delete renderer_accessibility_; | |
3434 renderer_accessibility_ = NULL; | |
3435 } | |
3436 if (accessibility_mode_ == AccessibilityModeOff) | |
3437 return; | |
3438 | |
3439 if (accessibility_mode_ & AccessibilityModeFlagFullTree) | |
3440 renderer_accessibility_ = new RendererAccessibilityComplete(this); | |
3441 #if !defined(OS_ANDROID) | |
3442 else | |
3443 renderer_accessibility_ = new RendererAccessibilityFocusOnly(this); | |
3444 #endif | |
3445 } | |
3446 | |
3447 void RenderViewImpl::OnSetActive(bool active) { | 3420 void RenderViewImpl::OnSetActive(bool active) { |
3448 if (webview()) | 3421 if (webview()) |
3449 webview()->setIsActive(active); | 3422 webview()->setIsActive(active); |
3450 | 3423 |
3451 #if defined(ENABLE_PLUGINS) && defined(OS_MACOSX) | 3424 #if defined(ENABLE_PLUGINS) && defined(OS_MACOSX) |
3452 std::set<WebPluginDelegateProxy*>::iterator plugin_it; | 3425 std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
3453 for (plugin_it = plugin_delegates_.begin(); | 3426 for (plugin_it = plugin_delegates_.begin(); |
3454 plugin_it != plugin_delegates_.end(); ++plugin_it) { | 3427 plugin_it != plugin_delegates_.end(); ++plugin_it) { |
3455 (*plugin_it)->SetWindowFocus(active); | 3428 (*plugin_it)->SetWindowFocus(active); |
3456 } | 3429 } |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4133 if (main_frame && main_frame->opener()) | 4106 if (main_frame && main_frame->opener()) |
4134 main_frame->setOpener(NULL); | 4107 main_frame->setOpener(NULL); |
4135 } | 4108 } |
4136 | 4109 |
4137 #if defined(OS_ANDROID) | 4110 #if defined(OS_ANDROID) |
4138 bool RenderViewImpl::didTapMultipleTargets( | 4111 bool RenderViewImpl::didTapMultipleTargets( |
4139 const blink::WebGestureEvent& event, | 4112 const blink::WebGestureEvent& event, |
4140 const WebVector<WebRect>& target_rects) { | 4113 const WebVector<WebRect>& target_rects) { |
4141 // Never show a disambiguation popup when accessibility is enabled, | 4114 // Never show a disambiguation popup when accessibility is enabled, |
4142 // as this interferes with "touch exploration". | 4115 // as this interferes with "touch exploration". |
4143 bool matchesAccessibilityModeComplete = | 4116 AccessibilityMode accessibility_mode = |
4144 (accessibility_mode_ & AccessibilityModeComplete) == | 4117 main_render_frame()->accessibility_mode(); |
4145 AccessibilityModeComplete; | 4118 bool matches_accessibility_mode_complete = |
4146 if (matchesAccessibilityModeComplete) | 4119 (accessibility_mode & AccessibilityModeComplete) == |
| 4120 AccessibilityModeComplete; |
| 4121 if (matches_accessibility_mode_complete) |
4147 return false; | 4122 return false; |
4148 | 4123 |
4149 gfx::Rect finger_rect( | 4124 gfx::Rect finger_rect( |
4150 event.x - event.data.tap.width / 2, event.y - event.data.tap.height / 2, | 4125 event.x - event.data.tap.width / 2, event.y - event.data.tap.height / 2, |
4151 event.data.tap.width, event.data.tap.height); | 4126 event.data.tap.width, event.data.tap.height); |
4152 gfx::Rect zoom_rect; | 4127 gfx::Rect zoom_rect; |
4153 float new_total_scale = | 4128 float new_total_scale = |
4154 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( | 4129 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( |
4155 finger_rect, target_rects, GetSize(), | 4130 finger_rect, target_rects, GetSize(), |
4156 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), | 4131 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4301 std::vector<gfx::Size> sizes; | 4276 std::vector<gfx::Size> sizes; |
4302 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4277 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4303 if (!url.isEmpty()) | 4278 if (!url.isEmpty()) |
4304 urls.push_back( | 4279 urls.push_back( |
4305 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4280 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4306 } | 4281 } |
4307 SendUpdateFaviconURL(urls); | 4282 SendUpdateFaviconURL(urls); |
4308 } | 4283 } |
4309 | 4284 |
4310 } // namespace content | 4285 } // namespace content |
OLD | NEW |