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 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 target_url_status_(TARGET_NONE), | 722 target_url_status_(TARGET_NONE), |
723 uses_temporary_zoom_level_(false), | 723 uses_temporary_zoom_level_(false), |
724 #if defined(OS_ANDROID) | 724 #if defined(OS_ANDROID) |
725 top_controls_constraints_(cc::BOTH), | 725 top_controls_constraints_(cc::BOTH), |
726 #endif | 726 #endif |
727 has_scrolled_focused_editable_node_into_rect_(false), | 727 has_scrolled_focused_editable_node_into_rect_(false), |
728 speech_recognition_dispatcher_(NULL), | 728 speech_recognition_dispatcher_(NULL), |
729 media_stream_dispatcher_(NULL), | 729 media_stream_dispatcher_(NULL), |
730 browser_plugin_manager_(NULL), | 730 browser_plugin_manager_(NULL), |
731 devtools_agent_(NULL), | 731 devtools_agent_(NULL), |
732 accessibility_mode_(AccessibilityModeOff), | |
733 renderer_accessibility_(NULL), | |
734 mouse_lock_dispatcher_(NULL), | 732 mouse_lock_dispatcher_(NULL), |
735 #if defined(OS_ANDROID) | 733 #if defined(OS_ANDROID) |
736 expected_content_intent_id_(0), | 734 expected_content_intent_id_(0), |
737 #endif | 735 #endif |
738 #if defined(OS_WIN) | 736 #if defined(OS_WIN) |
739 focused_plugin_id_(-1), | 737 focused_plugin_id_(-1), |
740 #endif | 738 #endif |
741 #if defined(ENABLE_PLUGINS) | 739 #if defined(ENABLE_PLUGINS) |
742 plugin_find_handler_(NULL), | 740 plugin_find_handler_(NULL), |
743 focused_pepper_plugin_(NULL), | 741 focused_pepper_plugin_(NULL), |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 // The next group of objects all implement RenderViewObserver, so are deleted | 860 // The next group of objects all implement RenderViewObserver, so are deleted |
863 // along with the RenderView automatically. | 861 // along with the RenderView automatically. |
864 devtools_agent_ = new DevToolsAgent(this); | 862 devtools_agent_ = new DevToolsAgent(this); |
865 if (RenderWidgetCompositor* rwc = compositor()) { | 863 if (RenderWidgetCompositor* rwc = compositor()) { |
866 webview()->devToolsAgent()->setLayerTreeId(rwc->GetLayerTreeId()); | 864 webview()->devToolsAgent()->setLayerTreeId(rwc->GetLayerTreeId()); |
867 } | 865 } |
868 mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this); | 866 mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this); |
869 | 867 |
870 history_controller_.reset(new HistoryController(this)); | 868 history_controller_.reset(new HistoryController(this)); |
871 | 869 |
872 // Create renderer_accessibility_ if needed. | |
873 OnSetAccessibilityMode(params->accessibility_mode); | |
874 | |
875 new IdleUserDetector(this); | 870 new IdleUserDetector(this); |
876 | 871 |
877 if (command_line.HasSwitch(switches::kDomAutomationController)) | 872 if (command_line.HasSwitch(switches::kDomAutomationController)) |
878 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; | 873 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; |
879 if (command_line.HasSwitch(switches::kStatsCollectionController)) | 874 if (command_line.HasSwitch(switches::kStatsCollectionController)) |
880 enabled_bindings_ |= BINDINGS_POLICY_STATS_COLLECTION; | 875 enabled_bindings_ |= BINDINGS_POLICY_STATS_COLLECTION; |
881 | 876 |
882 ProcessViewLayoutFlags(command_line); | 877 ProcessViewLayoutFlags(command_line); |
883 | 878 |
884 GetContentClient()->renderer()->RenderViewCreated(this); | 879 GetContentClient()->renderer()->RenderViewCreated(this); |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 int32 main_frame_routing_id, | 1205 int32 main_frame_routing_id, |
1211 int32 surface_id, | 1206 int32 surface_id, |
1212 int64 session_storage_namespace_id, | 1207 int64 session_storage_namespace_id, |
1213 const base::string16& frame_name, | 1208 const base::string16& frame_name, |
1214 bool is_renderer_created, | 1209 bool is_renderer_created, |
1215 bool swapped_out, | 1210 bool swapped_out, |
1216 int32 proxy_routing_id, | 1211 int32 proxy_routing_id, |
1217 bool hidden, | 1212 bool hidden, |
1218 bool never_visible, | 1213 bool never_visible, |
1219 int32 next_page_id, | 1214 int32 next_page_id, |
1220 const blink::WebScreenInfo& screen_info, | 1215 const blink::WebScreenInfo& screen_info) { |
1221 AccessibilityMode accessibility_mode) { | |
1222 DCHECK(routing_id != MSG_ROUTING_NONE); | 1216 DCHECK(routing_id != MSG_ROUTING_NONE); |
1223 RenderViewImplParams params(opener_id, | 1217 RenderViewImplParams params(opener_id, |
1224 window_was_created_with_opener, | 1218 window_was_created_with_opener, |
1225 renderer_prefs, | 1219 renderer_prefs, |
1226 webkit_prefs, | 1220 webkit_prefs, |
1227 routing_id, | 1221 routing_id, |
1228 main_frame_routing_id, | 1222 main_frame_routing_id, |
1229 surface_id, | 1223 surface_id, |
1230 session_storage_namespace_id, | 1224 session_storage_namespace_id, |
1231 frame_name, | 1225 frame_name, |
1232 is_renderer_created, | 1226 is_renderer_created, |
1233 swapped_out, | 1227 swapped_out, |
1234 proxy_routing_id, | 1228 proxy_routing_id, |
1235 hidden, | 1229 hidden, |
1236 never_visible, | 1230 never_visible, |
1237 next_page_id, | 1231 next_page_id, |
1238 screen_info, | 1232 screen_info); |
1239 accessibility_mode); | |
1240 RenderViewImpl* render_view = NULL; | 1233 RenderViewImpl* render_view = NULL; |
1241 if (g_create_render_view_impl) | 1234 if (g_create_render_view_impl) |
1242 render_view = g_create_render_view_impl(¶ms); | 1235 render_view = g_create_render_view_impl(¶ms); |
1243 else | 1236 else |
1244 render_view = new RenderViewImpl(¶ms); | 1237 render_view = new RenderViewImpl(¶ms); |
1245 | 1238 |
1246 render_view->Initialize(¶ms); | 1239 render_view->Initialize(¶ms); |
1247 return render_view; | 1240 return render_view; |
1248 } | 1241 } |
1249 | 1242 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, | 1410 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, |
1418 OnGetAllSavableResourceLinksForCurrentPage) | 1411 OnGetAllSavableResourceLinksForCurrentPage) |
1419 IPC_MESSAGE_HANDLER( | 1412 IPC_MESSAGE_HANDLER( |
1420 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, | 1413 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, |
1421 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) | 1414 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) |
1422 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) | 1415 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) |
1423 // TODO(viettrungluu): Move to a separate message filter. | 1416 // TODO(viettrungluu): Move to a separate message filter. |
1424 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, | 1417 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, |
1425 OnSetHistoryLengthAndPrune) | 1418 OnSetHistoryLengthAndPrune) |
1426 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) | 1419 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
1427 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityMode, OnSetAccessibilityMode) | |
1428 IPC_MESSAGE_HANDLER(ViewMsg_DisownOpener, OnDisownOpener) | 1420 IPC_MESSAGE_HANDLER(ViewMsg_DisownOpener, OnDisownOpener) |
1429 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, | 1421 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, |
1430 OnReleaseDisambiguationPopupBitmap) | 1422 OnReleaseDisambiguationPopupBitmap) |
1431 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, | 1423 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, |
1432 OnWindowSnapshotCompleted) | 1424 OnWindowSnapshotCompleted) |
1433 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) | 1425 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) |
1434 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) | 1426 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) |
1435 #if defined(OS_ANDROID) | 1427 #if defined(OS_ANDROID) |
1436 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, | 1428 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, |
1437 OnActivateNearestFindResult) | 1429 OnActivateNearestFindResult) |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1759 main_frame_routing_id, | 1751 main_frame_routing_id, |
1760 surface_id, | 1752 surface_id, |
1761 cloned_session_storage_namespace_id, | 1753 cloned_session_storage_namespace_id, |
1762 base::string16(), // WebCore will take care of setting the correct name. | 1754 base::string16(), // WebCore will take care of setting the correct name. |
1763 true, // is_renderer_created | 1755 true, // is_renderer_created |
1764 false, // swapped_out | 1756 false, // swapped_out |
1765 MSG_ROUTING_NONE, // proxy_routing_id | 1757 MSG_ROUTING_NONE, // proxy_routing_id |
1766 params.disposition == NEW_BACKGROUND_TAB, // hidden | 1758 params.disposition == NEW_BACKGROUND_TAB, // hidden |
1767 never_visible, | 1759 never_visible, |
1768 1, // next_page_id | 1760 1, // next_page_id |
1769 screen_info_, | 1761 screen_info_); |
1770 accessibility_mode_); | |
1771 view->opened_by_user_gesture_ = params.user_gesture; | 1762 view->opened_by_user_gesture_ = params.user_gesture; |
1772 | 1763 |
1773 // Record whether the creator frame is trying to suppress the opener field. | 1764 // Record whether the creator frame is trying to suppress the opener field. |
1774 view->opener_suppressed_ = params.opener_suppressed; | 1765 view->opener_suppressed_ = params.opener_suppressed; |
1775 | 1766 |
1776 return view->webview(); | 1767 return view->webview(); |
1777 } | 1768 } |
1778 | 1769 |
1779 WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) { | 1770 WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) { |
1780 RenderWidget* widget = | 1771 RenderWidget* widget = |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2044 void RenderViewImpl::focusPrevious() { | 2035 void RenderViewImpl::focusPrevious() { |
2045 Send(new ViewHostMsg_TakeFocus(routing_id_, true)); | 2036 Send(new ViewHostMsg_TakeFocus(routing_id_, true)); |
2046 } | 2037 } |
2047 | 2038 |
2048 void RenderViewImpl::focusedNodeChanged(const WebNode& node) { | 2039 void RenderViewImpl::focusedNodeChanged(const WebNode& node) { |
2049 has_scrolled_focused_editable_node_into_rect_ = false; | 2040 has_scrolled_focused_editable_node_into_rect_ = false; |
2050 | 2041 |
2051 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); | 2042 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); |
2052 | 2043 |
2053 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); | 2044 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); |
| 2045 |
| 2046 // TODO(dmazzoni): this should be part of RenderFrameObserver. |
| 2047 main_render_frame()->FocusedNodeChanged(node); |
2054 } | 2048 } |
2055 | 2049 |
2056 void RenderViewImpl::didUpdateLayout() { | 2050 void RenderViewImpl::didUpdateLayout() { |
2057 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout()); | 2051 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout()); |
2058 | 2052 |
2059 // We don't always want to set up a timer, only if we've been put in that | 2053 // We don't always want to set up a timer, only if we've been put in that |
2060 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| | 2054 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
2061 // message. | 2055 // message. |
2062 if (!send_preferred_size_changes_ || !webview()) | 2056 if (!send_preferred_size_changes_ || !webview()) |
2063 return; | 2057 return; |
(...skipping 12 matching lines...) Expand all Loading... |
2076 int RenderViewImpl::historyBackListCount() { | 2070 int RenderViewImpl::historyBackListCount() { |
2077 return history_list_offset_ < 0 ? 0 : history_list_offset_; | 2071 return history_list_offset_ < 0 ? 0 : history_list_offset_; |
2078 } | 2072 } |
2079 | 2073 |
2080 int RenderViewImpl::historyForwardListCount() { | 2074 int RenderViewImpl::historyForwardListCount() { |
2081 return history_list_length_ - historyBackListCount() - 1; | 2075 return history_list_length_ - historyBackListCount() - 1; |
2082 } | 2076 } |
2083 | 2077 |
2084 void RenderViewImpl::postAccessibilityEvent( | 2078 void RenderViewImpl::postAccessibilityEvent( |
2085 const WebAXObject& obj, blink::WebAXEvent event) { | 2079 const WebAXObject& obj, blink::WebAXEvent event) { |
2086 if (renderer_accessibility_) { | 2080 main_render_frame()->HandleWebAccessibilityEvent(obj, event); |
2087 renderer_accessibility_->HandleWebAccessibilityEvent(obj, event); | |
2088 } | |
2089 } | 2081 } |
2090 | 2082 |
2091 void RenderViewImpl::didUpdateInspectorSetting(const WebString& key, | 2083 void RenderViewImpl::didUpdateInspectorSetting(const WebString& key, |
2092 const WebString& value) { | 2084 const WebString& value) { |
2093 Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_, | 2085 Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_, |
2094 key.utf8(), | 2086 key.utf8(), |
2095 value.utf8())); | 2087 value.utf8())); |
2096 } | 2088 } |
2097 | 2089 |
2098 // blink::WebWidgetClient ---------------------------------------------------- | 2090 // blink::WebWidgetClient ---------------------------------------------------- |
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3424 webview()->clearFocusedElement(); | 3416 webview()->clearFocusedElement(); |
3425 } | 3417 } |
3426 | 3418 |
3427 void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) { | 3419 void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) { |
3428 if (webview()) | 3420 if (webview()) |
3429 webview()->setIsTransparent(!opaque); | 3421 webview()->setIsTransparent(!opaque); |
3430 if (compositor_) | 3422 if (compositor_) |
3431 compositor_->setHasTransparentBackground(!opaque); | 3423 compositor_->setHasTransparentBackground(!opaque); |
3432 } | 3424 } |
3433 | 3425 |
3434 void RenderViewImpl::OnSetAccessibilityMode(AccessibilityMode new_mode) { | |
3435 if (accessibility_mode_ == new_mode) | |
3436 return; | |
3437 accessibility_mode_ = new_mode; | |
3438 if (renderer_accessibility_) { | |
3439 delete renderer_accessibility_; | |
3440 renderer_accessibility_ = NULL; | |
3441 } | |
3442 if (accessibility_mode_ == AccessibilityModeOff) | |
3443 return; | |
3444 | |
3445 if (accessibility_mode_ & AccessibilityModeFlagFullTree) | |
3446 renderer_accessibility_ = new RendererAccessibilityComplete(this); | |
3447 #if !defined(OS_ANDROID) | |
3448 else | |
3449 renderer_accessibility_ = new RendererAccessibilityFocusOnly(this); | |
3450 #endif | |
3451 } | |
3452 | |
3453 void RenderViewImpl::OnSetActive(bool active) { | 3426 void RenderViewImpl::OnSetActive(bool active) { |
3454 if (webview()) | 3427 if (webview()) |
3455 webview()->setIsActive(active); | 3428 webview()->setIsActive(active); |
3456 | 3429 |
3457 #if defined(ENABLE_PLUGINS) && defined(OS_MACOSX) | 3430 #if defined(ENABLE_PLUGINS) && defined(OS_MACOSX) |
3458 std::set<WebPluginDelegateProxy*>::iterator plugin_it; | 3431 std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
3459 for (plugin_it = plugin_delegates_.begin(); | 3432 for (plugin_it = plugin_delegates_.begin(); |
3460 plugin_it != plugin_delegates_.end(); ++plugin_it) { | 3433 plugin_it != plugin_delegates_.end(); ++plugin_it) { |
3461 (*plugin_it)->SetWindowFocus(active); | 3434 (*plugin_it)->SetWindowFocus(active); |
3462 } | 3435 } |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4123 if (main_frame && main_frame->opener()) | 4096 if (main_frame && main_frame->opener()) |
4124 main_frame->setOpener(NULL); | 4097 main_frame->setOpener(NULL); |
4125 } | 4098 } |
4126 | 4099 |
4127 #if defined(OS_ANDROID) | 4100 #if defined(OS_ANDROID) |
4128 bool RenderViewImpl::didTapMultipleTargets( | 4101 bool RenderViewImpl::didTapMultipleTargets( |
4129 const blink::WebGestureEvent& event, | 4102 const blink::WebGestureEvent& event, |
4130 const WebVector<WebRect>& target_rects) { | 4103 const WebVector<WebRect>& target_rects) { |
4131 // Never show a disambiguation popup when accessibility is enabled, | 4104 // Never show a disambiguation popup when accessibility is enabled, |
4132 // as this interferes with "touch exploration". | 4105 // as this interferes with "touch exploration". |
4133 bool matchesAccessibilityModeComplete = | 4106 AccessibilityMode accessibility_mode = |
4134 (accessibility_mode_ & AccessibilityModeComplete) == | 4107 main_render_frame()->accessibility_mode(); |
4135 AccessibilityModeComplete; | 4108 bool matches_accessibility_mode_complete = |
4136 if (matchesAccessibilityModeComplete) | 4109 (accessibility_mode & AccessibilityModeComplete) == |
| 4110 AccessibilityModeComplete; |
| 4111 if (matches_accessibility_mode_complete) |
4137 return false; | 4112 return false; |
4138 | 4113 |
4139 gfx::Rect finger_rect( | 4114 gfx::Rect finger_rect( |
4140 event.x - event.data.tap.width / 2, event.y - event.data.tap.height / 2, | 4115 event.x - event.data.tap.width / 2, event.y - event.data.tap.height / 2, |
4141 event.data.tap.width, event.data.tap.height); | 4116 event.data.tap.width, event.data.tap.height); |
4142 gfx::Rect zoom_rect; | 4117 gfx::Rect zoom_rect; |
4143 float new_total_scale = | 4118 float new_total_scale = |
4144 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( | 4119 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( |
4145 finger_rect, target_rects, GetSize(), | 4120 finger_rect, target_rects, GetSize(), |
4146 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), | 4121 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4291 std::vector<gfx::Size> sizes; | 4266 std::vector<gfx::Size> sizes; |
4292 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4267 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4293 if (!url.isEmpty()) | 4268 if (!url.isEmpty()) |
4294 urls.push_back( | 4269 urls.push_back( |
4295 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4270 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4296 } | 4271 } |
4297 SendUpdateFaviconURL(urls); | 4272 SendUpdateFaviconURL(urls); |
4298 } | 4273 } |
4299 | 4274 |
4300 } // namespace content | 4275 } // namespace content |
OLD | NEW |