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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 #include "content/public/common/ssl_status.h" | 60 #include "content/public/common/ssl_status.h" |
61 #include "content/public/common/three_d_api_types.h" | 61 #include "content/public/common/three_d_api_types.h" |
62 #include "content/public/common/url_constants.h" | 62 #include "content/public/common/url_constants.h" |
63 #include "content/public/common/url_utils.h" | 63 #include "content/public/common/url_utils.h" |
64 #include "content/public/renderer/content_renderer_client.h" | 64 #include "content/public/renderer/content_renderer_client.h" |
65 #include "content/public/renderer/document_state.h" | 65 #include "content/public/renderer/document_state.h" |
66 #include "content/public/renderer/navigation_state.h" | 66 #include "content/public/renderer/navigation_state.h" |
67 #include "content/public/renderer/render_view_observer.h" | 67 #include "content/public/renderer/render_view_observer.h" |
68 #include "content/public/renderer/render_view_visitor.h" | 68 #include "content/public/renderer/render_view_visitor.h" |
69 #include "content/public/renderer/web_preferences.h" | 69 #include "content/public/renderer/web_preferences.h" |
70 #include "content/renderer/accessibility/renderer_accessibility.h" | |
71 #include "content/renderer/accessibility/renderer_accessibility_complete.h" | |
72 #include "content/renderer/accessibility/renderer_accessibility_focus_only.h" | |
73 #include "content/renderer/browser_plugin/browser_plugin.h" | 70 #include "content/renderer/browser_plugin/browser_plugin.h" |
74 #include "content/renderer/browser_plugin/browser_plugin_manager.h" | 71 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
75 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" | 72 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" |
76 #include "content/renderer/devtools/devtools_agent.h" | 73 #include "content/renderer/devtools/devtools_agent.h" |
77 #include "content/renderer/disambiguation_popup_helper.h" | 74 #include "content/renderer/disambiguation_popup_helper.h" |
78 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" | 75 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
79 #include "content/renderer/drop_data_builder.h" | 76 #include "content/renderer/drop_data_builder.h" |
80 #include "content/renderer/external_popup_menu.h" | 77 #include "content/renderer/external_popup_menu.h" |
81 #include "content/renderer/geolocation_dispatcher.h" | 78 #include "content/renderer/geolocation_dispatcher.h" |
82 #include "content/renderer/gpu/render_widget_compositor.h" | 79 #include "content/renderer/gpu/render_widget_compositor.h" |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 cached_is_main_frame_pinned_to_left_(false), | 646 cached_is_main_frame_pinned_to_left_(false), |
650 cached_is_main_frame_pinned_to_right_(false), | 647 cached_is_main_frame_pinned_to_right_(false), |
651 has_scrolled_focused_editable_node_into_rect_(false), | 648 has_scrolled_focused_editable_node_into_rect_(false), |
652 push_messaging_dispatcher_(NULL), | 649 push_messaging_dispatcher_(NULL), |
653 geolocation_dispatcher_(NULL), | 650 geolocation_dispatcher_(NULL), |
654 speech_recognition_dispatcher_(NULL), | 651 speech_recognition_dispatcher_(NULL), |
655 media_stream_dispatcher_(NULL), | 652 media_stream_dispatcher_(NULL), |
656 browser_plugin_manager_(NULL), | 653 browser_plugin_manager_(NULL), |
657 midi_dispatcher_(NULL), | 654 midi_dispatcher_(NULL), |
658 devtools_agent_(NULL), | 655 devtools_agent_(NULL), |
659 accessibility_mode_(AccessibilityModeOff), | |
660 renderer_accessibility_(NULL), | |
661 mouse_lock_dispatcher_(NULL), | 656 mouse_lock_dispatcher_(NULL), |
662 #if defined(OS_ANDROID) | 657 #if defined(OS_ANDROID) |
663 expected_content_intent_id_(0), | 658 expected_content_intent_id_(0), |
664 media_player_manager_(NULL), | 659 media_player_manager_(NULL), |
665 #endif | 660 #endif |
666 #if defined(OS_WIN) | 661 #if defined(OS_WIN) |
667 focused_plugin_id_(-1), | 662 focused_plugin_id_(-1), |
668 #endif | 663 #endif |
669 #if defined(ENABLE_PLUGINS) | 664 #if defined(ENABLE_PLUGINS) |
670 plugin_find_handler_(NULL), | 665 plugin_find_handler_(NULL), |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 // The next group of objects all implement RenderViewObserver, so are deleted | 783 // The next group of objects all implement RenderViewObserver, so are deleted |
789 // along with the RenderView automatically. | 784 // along with the RenderView automatically. |
790 devtools_agent_ = new DevToolsAgent(this); | 785 devtools_agent_ = new DevToolsAgent(this); |
791 if (RenderWidgetCompositor* rwc = compositor()) { | 786 if (RenderWidgetCompositor* rwc = compositor()) { |
792 webview()->devToolsAgent()->setLayerTreeId(rwc->GetLayerTreeId()); | 787 webview()->devToolsAgent()->setLayerTreeId(rwc->GetLayerTreeId()); |
793 } | 788 } |
794 mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this); | 789 mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this); |
795 | 790 |
796 history_controller_.reset(new HistoryController(this)); | 791 history_controller_.reset(new HistoryController(this)); |
797 | 792 |
798 // Create renderer_accessibility_ if needed. | |
799 OnSetAccessibilityMode(params->accessibility_mode); | |
800 | |
801 new IdleUserDetector(this); | 793 new IdleUserDetector(this); |
802 | 794 |
803 if (command_line.HasSwitch(switches::kDomAutomationController)) | 795 if (command_line.HasSwitch(switches::kDomAutomationController)) |
804 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; | 796 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; |
805 if (command_line.HasSwitch(switches::kStatsCollectionController)) | 797 if (command_line.HasSwitch(switches::kStatsCollectionController)) |
806 enabled_bindings_ |= BINDINGS_POLICY_STATS_COLLECTION; | 798 enabled_bindings_ |= BINDINGS_POLICY_STATS_COLLECTION; |
807 | 799 |
808 ProcessViewLayoutFlags(command_line); | 800 ProcessViewLayoutFlags(command_line); |
809 | 801 |
810 GetContentClient()->renderer()->RenderViewCreated(this); | 802 GetContentClient()->renderer()->RenderViewCreated(this); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 int32 routing_id, | 896 int32 routing_id, |
905 int32 main_frame_routing_id, | 897 int32 main_frame_routing_id, |
906 int32 surface_id, | 898 int32 surface_id, |
907 int64 session_storage_namespace_id, | 899 int64 session_storage_namespace_id, |
908 const base::string16& frame_name, | 900 const base::string16& frame_name, |
909 bool is_renderer_created, | 901 bool is_renderer_created, |
910 bool swapped_out, | 902 bool swapped_out, |
911 bool hidden, | 903 bool hidden, |
912 bool never_visible, | 904 bool never_visible, |
913 int32 next_page_id, | 905 int32 next_page_id, |
914 const blink::WebScreenInfo& screen_info, | 906 const blink::WebScreenInfo& screen_info) { |
915 AccessibilityMode accessibility_mode) { | |
916 DCHECK(routing_id != MSG_ROUTING_NONE); | 907 DCHECK(routing_id != MSG_ROUTING_NONE); |
917 RenderViewImplParams params(opener_id, | 908 RenderViewImplParams params(opener_id, |
918 window_was_created_with_opener, | 909 window_was_created_with_opener, |
919 renderer_prefs, | 910 renderer_prefs, |
920 webkit_prefs, | 911 webkit_prefs, |
921 routing_id, | 912 routing_id, |
922 main_frame_routing_id, | 913 main_frame_routing_id, |
923 surface_id, | 914 surface_id, |
924 session_storage_namespace_id, | 915 session_storage_namespace_id, |
925 frame_name, | 916 frame_name, |
926 is_renderer_created, | 917 is_renderer_created, |
927 swapped_out, | 918 swapped_out, |
928 hidden, | 919 hidden, |
929 never_visible, | 920 never_visible, |
930 next_page_id, | 921 next_page_id, |
931 screen_info, | 922 screen_info); |
932 accessibility_mode); | |
933 RenderViewImpl* render_view = NULL; | 923 RenderViewImpl* render_view = NULL; |
934 if (g_create_render_view_impl) | 924 if (g_create_render_view_impl) |
935 render_view = g_create_render_view_impl(¶ms); | 925 render_view = g_create_render_view_impl(¶ms); |
936 else | 926 else |
937 render_view = new RenderViewImpl(¶ms); | 927 render_view = new RenderViewImpl(¶ms); |
938 | 928 |
939 render_view->Initialize(¶ms); | 929 render_view->Initialize(¶ms); |
940 return render_view; | 930 return render_view; |
941 } | 931 } |
942 | 932 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, | 1103 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, |
1114 OnGetAllSavableResourceLinksForCurrentPage) | 1104 OnGetAllSavableResourceLinksForCurrentPage) |
1115 IPC_MESSAGE_HANDLER( | 1105 IPC_MESSAGE_HANDLER( |
1116 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, | 1106 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, |
1117 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) | 1107 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) |
1118 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) | 1108 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) |
1119 // TODO(viettrungluu): Move to a separate message filter. | 1109 // TODO(viettrungluu): Move to a separate message filter. |
1120 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, | 1110 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, |
1121 OnSetHistoryLengthAndPrune) | 1111 OnSetHistoryLengthAndPrune) |
1122 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) | 1112 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
1123 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityMode, OnSetAccessibilityMode) | |
1124 IPC_MESSAGE_HANDLER(ViewMsg_DisownOpener, OnDisownOpener) | 1113 IPC_MESSAGE_HANDLER(ViewMsg_DisownOpener, OnDisownOpener) |
1125 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, | 1114 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, |
1126 OnReleaseDisambiguationPopupBitmap) | 1115 OnReleaseDisambiguationPopupBitmap) |
1127 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, | 1116 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, |
1128 OnWindowSnapshotCompleted) | 1117 OnWindowSnapshotCompleted) |
1129 #if defined(OS_ANDROID) | 1118 #if defined(OS_ANDROID) |
1130 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, | 1119 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, |
1131 OnActivateNearestFindResult) | 1120 OnActivateNearestFindResult) |
1132 IPC_MESSAGE_HANDLER(ViewMsg_FindMatchRects, OnFindMatchRects) | 1121 IPC_MESSAGE_HANDLER(ViewMsg_FindMatchRects, OnFindMatchRects) |
1133 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) | 1122 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1483 routing_id, | 1472 routing_id, |
1484 main_frame_routing_id, | 1473 main_frame_routing_id, |
1485 surface_id, | 1474 surface_id, |
1486 cloned_session_storage_namespace_id, | 1475 cloned_session_storage_namespace_id, |
1487 base::string16(), // WebCore will take care of setting the correct name. | 1476 base::string16(), // WebCore will take care of setting the correct name. |
1488 true, // is_renderer_created | 1477 true, // is_renderer_created |
1489 false, // swapped_out | 1478 false, // swapped_out |
1490 params.disposition == NEW_BACKGROUND_TAB, // hidden | 1479 params.disposition == NEW_BACKGROUND_TAB, // hidden |
1491 never_visible, | 1480 never_visible, |
1492 1, // next_page_id | 1481 1, // next_page_id |
1493 screen_info_, | 1482 screen_info_); |
1494 accessibility_mode_); | |
1495 view->opened_by_user_gesture_ = params.user_gesture; | 1483 view->opened_by_user_gesture_ = params.user_gesture; |
1496 | 1484 |
1497 // Record whether the creator frame is trying to suppress the opener field. | 1485 // Record whether the creator frame is trying to suppress the opener field. |
1498 view->opener_suppressed_ = params.opener_suppressed; | 1486 view->opener_suppressed_ = params.opener_suppressed; |
1499 | 1487 |
1500 return view->webview(); | 1488 return view->webview(); |
1501 } | 1489 } |
1502 | 1490 |
1503 WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) { | 1491 WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) { |
1504 RenderWidget* widget = | 1492 RenderWidget* widget = |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1828 int RenderViewImpl::historyBackListCount() { | 1816 int RenderViewImpl::historyBackListCount() { |
1829 return history_list_offset_ < 0 ? 0 : history_list_offset_; | 1817 return history_list_offset_ < 0 ? 0 : history_list_offset_; |
1830 } | 1818 } |
1831 | 1819 |
1832 int RenderViewImpl::historyForwardListCount() { | 1820 int RenderViewImpl::historyForwardListCount() { |
1833 return history_list_length_ - historyBackListCount() - 1; | 1821 return history_list_length_ - historyBackListCount() - 1; |
1834 } | 1822 } |
1835 | 1823 |
1836 void RenderViewImpl::postAccessibilityEvent( | 1824 void RenderViewImpl::postAccessibilityEvent( |
1837 const WebAXObject& obj, blink::WebAXEvent event) { | 1825 const WebAXObject& obj, blink::WebAXEvent event) { |
1838 if (renderer_accessibility_) { | 1826 main_render_frame()->HandleWebAccessibilityEvent(obj, event); |
1839 renderer_accessibility_->HandleWebAccessibilityEvent(obj, event); | |
1840 } | |
1841 } | 1827 } |
1842 | 1828 |
1843 void RenderViewImpl::didUpdateInspectorSetting(const WebString& key, | 1829 void RenderViewImpl::didUpdateInspectorSetting(const WebString& key, |
1844 const WebString& value) { | 1830 const WebString& value) { |
1845 Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_, | 1831 Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_, |
1846 key.utf8(), | 1832 key.utf8(), |
1847 value.utf8())); | 1833 value.utf8())); |
1848 } | 1834 } |
1849 | 1835 |
1850 // blink::WebWidgetClient ---------------------------------------------------- | 1836 // blink::WebWidgetClient ---------------------------------------------------- |
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3228 | 3214 |
3229 void RenderViewImpl::OnSetBackground(const SkBitmap& background) { | 3215 void RenderViewImpl::OnSetBackground(const SkBitmap& background) { |
3230 if (webview()) | 3216 if (webview()) |
3231 webview()->setIsTransparent(!background.empty()); | 3217 webview()->setIsTransparent(!background.empty()); |
3232 if (compositor_) | 3218 if (compositor_) |
3233 compositor_->setHasTransparentBackground(!background.empty()); | 3219 compositor_->setHasTransparentBackground(!background.empty()); |
3234 | 3220 |
3235 SetBackground(background); | 3221 SetBackground(background); |
3236 } | 3222 } |
3237 | 3223 |
3238 void RenderViewImpl::OnSetAccessibilityMode(AccessibilityMode new_mode) { | |
3239 if (accessibility_mode_ == new_mode) | |
3240 return; | |
3241 accessibility_mode_ = new_mode; | |
3242 if (renderer_accessibility_) { | |
3243 delete renderer_accessibility_; | |
3244 renderer_accessibility_ = NULL; | |
3245 } | |
3246 if (accessibility_mode_ == AccessibilityModeOff) | |
3247 return; | |
3248 | |
3249 if (accessibility_mode_ & AccessibilityModeFlagFullTree) | |
3250 renderer_accessibility_ = new RendererAccessibilityComplete(this); | |
3251 #if !defined(OS_ANDROID) | |
3252 else | |
3253 renderer_accessibility_ = new RendererAccessibilityFocusOnly(this); | |
3254 #endif | |
3255 } | |
3256 | |
3257 void RenderViewImpl::OnSetActive(bool active) { | 3224 void RenderViewImpl::OnSetActive(bool active) { |
3258 if (webview()) | 3225 if (webview()) |
3259 webview()->setIsActive(active); | 3226 webview()->setIsActive(active); |
3260 | 3227 |
3261 #if defined(ENABLE_PLUGINS) && defined(OS_MACOSX) | 3228 #if defined(ENABLE_PLUGINS) && defined(OS_MACOSX) |
3262 std::set<WebPluginDelegateProxy*>::iterator plugin_it; | 3229 std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
3263 for (plugin_it = plugin_delegates_.begin(); | 3230 for (plugin_it = plugin_delegates_.begin(); |
3264 plugin_it != plugin_delegates_.end(); ++plugin_it) { | 3231 plugin_it != plugin_delegates_.end(); ++plugin_it) { |
3265 (*plugin_it)->SetWindowFocus(active); | 3232 (*plugin_it)->SetWindowFocus(active); |
3266 } | 3233 } |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3934 if (main_frame && main_frame->opener()) | 3901 if (main_frame && main_frame->opener()) |
3935 main_frame->setOpener(NULL); | 3902 main_frame->setOpener(NULL); |
3936 } | 3903 } |
3937 | 3904 |
3938 #if defined(OS_ANDROID) | 3905 #if defined(OS_ANDROID) |
3939 bool RenderViewImpl::didTapMultipleTargets( | 3906 bool RenderViewImpl::didTapMultipleTargets( |
3940 const blink::WebGestureEvent& event, | 3907 const blink::WebGestureEvent& event, |
3941 const WebVector<WebRect>& target_rects) { | 3908 const WebVector<WebRect>& target_rects) { |
3942 // Never show a disambiguation popup when accessibility is enabled, | 3909 // Never show a disambiguation popup when accessibility is enabled, |
3943 // as this interferes with "touch exploration". | 3910 // as this interferes with "touch exploration". |
3944 bool matchesAccessibilityModeComplete = | 3911 AccessibilityMode accessibility_mode = |
3945 (accessibility_mode_ & AccessibilityModeComplete) == | 3912 main_render_frame()->accessibility_mode(); |
3946 AccessibilityModeComplete; | 3913 bool matches_accessibility_mode_complete = |
3947 if (matchesAccessibilityModeComplete) | 3914 (accessibility_mode & AccessibilityModeComplete) == |
| 3915 AccessibilityModeComplete; |
| 3916 if (matches_accessibility_mode_complete) |
3948 return false; | 3917 return false; |
3949 | 3918 |
3950 gfx::Rect finger_rect( | 3919 gfx::Rect finger_rect( |
3951 event.x - event.data.tap.width / 2, event.y - event.data.tap.height / 2, | 3920 event.x - event.data.tap.width / 2, event.y - event.data.tap.height / 2, |
3952 event.data.tap.width, event.data.tap.height); | 3921 event.data.tap.width, event.data.tap.height); |
3953 gfx::Rect zoom_rect; | 3922 gfx::Rect zoom_rect; |
3954 float new_total_scale = | 3923 float new_total_scale = |
3955 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( | 3924 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( |
3956 finger_rect, target_rects, GetSize(), | 3925 finger_rect, target_rects, GetSize(), |
3957 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), | 3926 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4097 std::vector<gfx::Size> sizes; | 4066 std::vector<gfx::Size> sizes; |
4098 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4067 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4099 if (!url.isEmpty()) | 4068 if (!url.isEmpty()) |
4100 urls.push_back( | 4069 urls.push_back( |
4101 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4070 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4102 } | 4071 } |
4103 SendUpdateFaviconURL(urls); | 4072 SendUpdateFaviconURL(urls); |
4104 } | 4073 } |
4105 | 4074 |
4106 } // namespace content | 4075 } // namespace content |
OLD | NEW |