Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1321)

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 407493002: Revert of Migrate accessibility from RenderView to RenderFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/frame_host/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/containers/hash_tables.h" 8 #include "base/containers/hash_tables.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/metrics/user_metrics_action.h" 10 #include "base/metrics/user_metrics_action.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "content/browser/accessibility/accessibility_mode_helper.h"
13 #include "content/browser/accessibility/browser_accessibility_manager.h"
14 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
15 #include "content/browser/child_process_security_policy_impl.h" 12 #include "content/browser/child_process_security_policy_impl.h"
16 #include "content/browser/frame_host/cross_process_frame_connector.h" 13 #include "content/browser/frame_host/cross_process_frame_connector.h"
17 #include "content/browser/frame_host/cross_site_transferring_request.h" 14 #include "content/browser/frame_host/cross_site_transferring_request.h"
18 #include "content/browser/frame_host/frame_tree.h" 15 #include "content/browser/frame_host/frame_tree.h"
19 #include "content/browser/frame_host/frame_tree_node.h" 16 #include "content/browser/frame_host/frame_tree_node.h"
20 #include "content/browser/frame_host/navigator.h" 17 #include "content/browser/frame_host/navigator.h"
21 #include "content/browser/frame_host/render_frame_host_delegate.h" 18 #include "content/browser/frame_host/render_frame_host_delegate.h"
22 #include "content/browser/frame_host/render_frame_proxy_host.h" 19 #include "content/browser/frame_host/render_frame_proxy_host.h"
23 #include "content/browser/renderer_host/input/input_router.h" 20 #include "content/browser/renderer_host/input/input_router.h"
24 #include "content/browser/renderer_host/input/timeout_monitor.h" 21 #include "content/browser/renderer_host/input/timeout_monitor.h"
25 #include "content/browser/renderer_host/render_process_host_impl.h" 22 #include "content/browser/renderer_host/render_process_host_impl.h"
26 #include "content/browser/renderer_host/render_view_host_impl.h" 23 #include "content/browser/renderer_host/render_view_host_impl.h"
27 #include "content/browser/renderer_host/render_widget_host_impl.h" 24 #include "content/browser/renderer_host/render_widget_host_impl.h"
28 #include "content/browser/renderer_host/render_widget_host_view_base.h"
29 #include "content/browser/transition_request_manager.h" 25 #include "content/browser/transition_request_manager.h"
30 #include "content/common/accessibility_messages.h"
31 #include "content/common/desktop_notification_messages.h" 26 #include "content/common/desktop_notification_messages.h"
32 #include "content/common/frame_messages.h" 27 #include "content/common/frame_messages.h"
33 #include "content/common/input_messages.h" 28 #include "content/common/input_messages.h"
34 #include "content/common/inter_process_time_ticks_converter.h" 29 #include "content/common/inter_process_time_ticks_converter.h"
35 #include "content/common/render_frame_setup.mojom.h" 30 #include "content/common/render_frame_setup.mojom.h"
36 #include "content/common/swapped_out_messages.h" 31 #include "content/common/swapped_out_messages.h"
37 #include "content/public/browser/ax_event_notification_details.h"
38 #include "content/public/browser/browser_accessibility_state.h"
39 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
40 #include "content/public/browser/content_browser_client.h" 33 #include "content/public/browser/content_browser_client.h"
41 #include "content/public/browser/desktop_notification_delegate.h" 34 #include "content/public/browser/desktop_notification_delegate.h"
42 #include "content/public/browser/render_process_host.h" 35 #include "content/public/browser/render_process_host.h"
43 #include "content/public/browser/render_widget_host_view.h" 36 #include "content/public/browser/render_widget_host_view.h"
44 #include "content/public/browser/user_metrics.h" 37 #include "content/public/browser/user_metrics.h"
45 #include "content/public/common/content_constants.h" 38 #include "content/public/common/content_constants.h"
46 #include "content/public/common/url_constants.h" 39 #include "content/public/common/url_constants.h"
47 #include "content/public/common/url_utils.h" 40 #include "content/public/common/url_utils.h"
48 #include "ui/accessibility/ax_tree.h"
49 #include "url/gurl.h" 41 #include "url/gurl.h"
50 42
51 using base::TimeDelta; 43 using base::TimeDelta;
52 44
53 namespace content { 45 namespace content {
54 46
55 namespace { 47 namespace {
56 48
57 // The (process id, routing id) pair that identifies one RenderFrame. 49 // The (process id, routing id) pair that identifies one RenderFrame.
58 typedef std::pair<int32, int32> RenderFrameHostID; 50 typedef std::pair<int32, int32> RenderFrameHostID;
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation, 339 IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation,
348 OnBeginNavigation) 340 OnBeginNavigation)
349 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission, 341 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission,
350 OnRequestDesktopNotificationPermission) 342 OnRequestDesktopNotificationPermission)
351 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show, 343 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show,
352 OnShowDesktopNotification) 344 OnShowDesktopNotification)
353 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel, 345 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel,
354 OnCancelDesktopNotification) 346 OnCancelDesktopNotification)
355 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse, 347 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse,
356 OnTextSurroundingSelectionResponse) 348 OnTextSurroundingSelectionResponse)
357 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents)
358 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges,
359 OnAccessibilityLocationChanges)
360 IPC_END_MESSAGE_MAP() 349 IPC_END_MESSAGE_MAP()
361 350
362 return handled; 351 return handled;
363 } 352 }
364 353
365 void RenderFrameHostImpl::AccessibilitySetFocus(int object_id) {
366 Send(new AccessibilityMsg_SetFocus(routing_id_, object_id));
367 }
368
369 void RenderFrameHostImpl::AccessibilityDoDefaultAction(int object_id) {
370 Send(new AccessibilityMsg_DoDefaultAction(routing_id_, object_id));
371 }
372
373 void RenderFrameHostImpl::AccessibilityShowMenu(
374 const gfx::Point& global_point) {
375 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
376 render_view_host_->GetView());
377 if (view)
378 view->AccessibilityShowMenu(global_point);
379 }
380
381 void RenderFrameHostImpl::AccessibilityScrollToMakeVisible(
382 int acc_obj_id, const gfx::Rect& subfocus) {
383 Send(new AccessibilityMsg_ScrollToMakeVisible(
384 routing_id_, acc_obj_id, subfocus));
385 }
386
387 void RenderFrameHostImpl::AccessibilityScrollToPoint(
388 int acc_obj_id, const gfx::Point& point) {
389 Send(new AccessibilityMsg_ScrollToPoint(
390 routing_id_, acc_obj_id, point));
391 }
392
393 void RenderFrameHostImpl::AccessibilitySetTextSelection(
394 int object_id, int start_offset, int end_offset) {
395 Send(new AccessibilityMsg_SetTextSelection(
396 routing_id_, object_id, start_offset, end_offset));
397 }
398
399 bool RenderFrameHostImpl::AccessibilityViewHasFocus() const {
400 RenderWidgetHostView* view = render_view_host_->GetView();
401 if (view)
402 return view->HasFocus();
403 return false;
404 }
405
406 gfx::Rect RenderFrameHostImpl::AccessibilityGetViewBounds() const {
407 RenderWidgetHostView* view = render_view_host_->GetView();
408 if (view)
409 return view->GetViewBounds();
410 return gfx::Rect();
411 }
412
413 gfx::Point RenderFrameHostImpl::AccessibilityOriginInScreen(
414 const gfx::Rect& bounds) const {
415 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
416 render_view_host_->GetView());
417 if (view)
418 return view->AccessibilityOriginInScreen(bounds);
419 return gfx::Point();
420 }
421
422 void RenderFrameHostImpl::AccessibilityHitTest(const gfx::Point& point) {
423 Send(new AccessibilityMsg_HitTest(routing_id_, point));
424 }
425
426 void RenderFrameHostImpl::AccessibilityFatalError() {
427 Send(new AccessibilityMsg_FatalError(routing_id_));
428 browser_accessibility_manager_.reset(NULL);
429 }
430
431 void RenderFrameHostImpl::Init() { 354 void RenderFrameHostImpl::Init() {
432 GetProcess()->ResumeRequestsForView(routing_id_); 355 GetProcess()->ResumeRequestsForView(routing_id_);
433 } 356 }
434 357
435 void RenderFrameHostImpl::OnAddMessageToConsole( 358 void RenderFrameHostImpl::OnAddMessageToConsole(
436 int32 level, 359 int32 level,
437 const base::string16& message, 360 const base::string16& message,
438 int32 line_no, 361 int32 line_no,
439 const base::string16& source_id) { 362 const base::string16& source_id) {
440 if (delegate_->AddMessageToConsole(level, message, line_no, source_id)) 363 if (delegate_->AddMessageToConsole(level, message, line_no, source_id))
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 WebTextDirectionToChromeTextDirection( 765 WebTextDirectionToChromeTextDirection(
843 title_direction)); 766 title_direction));
844 } 767 }
845 768
846 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) { 769 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) {
847 // This message is only sent for top-level frames. TODO(avi): when frame tree 770 // This message is only sent for top-level frames. TODO(avi): when frame tree
848 // mirroring works correctly, add a check here to enforce it. 771 // mirroring works correctly, add a check here to enforce it.
849 delegate_->UpdateEncoding(this, encoding_name); 772 delegate_->UpdateEncoding(this, encoding_name);
850 } 773 }
851 774
852
853 void RenderFrameHostImpl::OnBeginNavigation( 775 void RenderFrameHostImpl::OnBeginNavigation(
854 const FrameHostMsg_BeginNavigation_Params& params) { 776 const FrameHostMsg_BeginNavigation_Params& params) {
855 #if defined(USE_BROWSER_SIDE_NAVIGATION) 777 #if defined(USE_BROWSER_SIDE_NAVIGATION)
856 frame_tree_node()->render_manager()->OnBeginNavigation(params); 778 frame_tree_node()->render_manager()->OnBeginNavigation(params);
857 #endif 779 #endif
858 } 780 }
859 781
860 void RenderFrameHostImpl::OnAccessibilityEvents(
861 const std::vector<AccessibilityHostMsg_EventParams>& params) {
862 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
863 render_view_host_->GetView());
864
865
866 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode();
867 if ((accessibility_mode != AccessibilityModeOff) && view &&
868 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) {
869 if (accessibility_mode & AccessibilityModeFlagPlatform) {
870 GetOrCreateBrowserAccessibilityManager();
871 if (browser_accessibility_manager_)
872 browser_accessibility_manager_->OnAccessibilityEvents(params);
873 }
874
875 std::vector<AXEventNotificationDetails> details;
876 details.reserve(params.size());
877 for (size_t i = 0; i < params.size(); ++i) {
878 const AccessibilityHostMsg_EventParams& param = params[i];
879 AXEventNotificationDetails detail(param.update.node_id_to_clear,
880 param.update.nodes,
881 param.event_type,
882 param.id,
883 GetProcess()->GetID(),
884 routing_id_);
885 details.push_back(detail);
886 }
887
888 delegate_->AccessibilityEventReceived(details);
889 }
890
891 // Always send an ACK or the renderer can be in a bad state.
892 Send(new AccessibilityMsg_Events_ACK(routing_id_));
893
894 // The rest of this code is just for testing; bail out if we're not
895 // in that mode.
896 if (accessibility_testing_callback_.is_null())
897 return;
898
899 for (size_t i = 0; i < params.size(); i++) {
900 const AccessibilityHostMsg_EventParams& param = params[i];
901 if (static_cast<int>(param.event_type) < 0)
902 continue;
903 if (!ax_tree_for_testing_) {
904 ax_tree_for_testing_.reset(new ui::AXTree(param.update));
905 } else {
906 CHECK(ax_tree_for_testing_->Unserialize(param.update))
907 << ax_tree_for_testing_->error();
908 }
909 accessibility_testing_callback_.Run(param.event_type, param.id);
910 }
911 }
912
913 void RenderFrameHostImpl::OnAccessibilityLocationChanges(
914 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) {
915 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
916 render_view_host_->GetView());
917 if (view &&
918 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) {
919 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode();
920 if (accessibility_mode & AccessibilityModeFlagPlatform) {
921 if (!browser_accessibility_manager_) {
922 browser_accessibility_manager_.reset(
923 view->CreateBrowserAccessibilityManager(this));
924 }
925 if (browser_accessibility_manager_)
926 browser_accessibility_manager_->OnLocationChanges(params);
927 }
928 // TODO(aboxhall): send location change events to web contents observers too
929 }
930 }
931
932 void RenderFrameHostImpl::SetPendingShutdown(const base::Closure& on_swap_out) { 782 void RenderFrameHostImpl::SetPendingShutdown(const base::Closure& on_swap_out) {
933 render_view_host_->SetPendingShutdown(on_swap_out); 783 render_view_host_->SetPendingShutdown(on_swap_out);
934 } 784 }
935 785
936 bool RenderFrameHostImpl::CanCommitURL(const GURL& url) { 786 bool RenderFrameHostImpl::CanCommitURL(const GURL& url) {
937 // TODO(creis): We should also check for WebUI pages here. Also, when the 787 // TODO(creis): We should also check for WebUI pages here. Also, when the
938 // out-of-process iframes implementation is ready, we should check for 788 // out-of-process iframes implementation is ready, we should check for
939 // cross-site URLs that are not allowed to commit in this process. 789 // cross-site URLs that are not allowed to commit in this process.
940 790
941 // Give the client a chance to disallow URLs from committing. 791 // Give the client a chance to disallow URLs from committing.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 void RenderFrameHostImpl::NotificationClosed(int notification_id) { 939 void RenderFrameHostImpl::NotificationClosed(int notification_id) {
1090 cancel_notification_callbacks_.erase(notification_id); 940 cancel_notification_callbacks_.erase(notification_id);
1091 } 941 }
1092 942
1093 void RenderFrameHostImpl::DesktopNotificationPermissionRequestDone( 943 void RenderFrameHostImpl::DesktopNotificationPermissionRequestDone(
1094 int callback_context) { 944 int callback_context) {
1095 Send(new DesktopNotificationMsg_PermissionRequestDone( 945 Send(new DesktopNotificationMsg_PermissionRequestDone(
1096 routing_id_, callback_context)); 946 routing_id_, callback_context));
1097 } 947 }
1098 948
1099 void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) {
1100 Send(new FrameMsg_SetAccessibilityMode(routing_id_, mode));
1101 }
1102
1103 void RenderFrameHostImpl::SetAccessibilityCallbackForTesting(
1104 const base::Callback<void(ui::AXEvent, int)>& callback) {
1105 accessibility_testing_callback_ = callback;
1106 }
1107
1108 const ui::AXTree* RenderFrameHostImpl::GetAXTreeForTesting() {
1109 return ax_tree_for_testing_.get();
1110 }
1111
1112 BrowserAccessibilityManager*
1113 RenderFrameHostImpl::GetOrCreateBrowserAccessibilityManager() {
1114 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
1115 render_view_host_->GetView());
1116 if (view &&
1117 !browser_accessibility_manager_) {
1118 browser_accessibility_manager_.reset(
1119 view->CreateBrowserAccessibilityManager(this));
1120 }
1121 return browser_accessibility_manager_.get();
1122 }
1123
1124 #if defined(OS_WIN)
1125 void RenderFrameHostImpl::SetParentNativeViewAccessible(
1126 gfx::NativeViewAccessible accessible_parent) {
1127 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
1128 render_view_host_->GetView());
1129 if (view)
1130 view->SetParentNativeViewAccessible(accessible_parent);
1131 }
1132
1133 gfx::NativeViewAccessible
1134 RenderFrameHostImpl::GetParentNativeViewAccessible() const {
1135 return delegate_->GetParentNativeViewAccessible();
1136 }
1137 #endif // defined(OS_WIN)
1138
1139 void RenderFrameHostImpl::SetHasPendingTransitionRequest( 949 void RenderFrameHostImpl::SetHasPendingTransitionRequest(
1140 bool has_pending_request) { 950 bool has_pending_request) {
1141 BrowserThread::PostTask( 951 BrowserThread::PostTask(
1142 BrowserThread::IO, 952 BrowserThread::IO,
1143 FROM_HERE, 953 FROM_HERE,
1144 base::Bind( 954 base::Bind(
1145 &TransitionRequestManager::SetHasPendingTransitionRequest, 955 &TransitionRequestManager::SetHasPendingTransitionRequest,
1146 base::Unretained(TransitionRequestManager::GetInstance()), 956 base::Unretained(TransitionRequestManager::GetInstance()),
1147 GetProcess()->GetID(), 957 GetProcess()->GetID(),
1148 routing_id_, 958 routing_id_,
1149 has_pending_request)); 959 has_pending_request));
1150 } 960 }
1151 961
1152 } // namespace content 962 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/browser/renderer_host/legacy_render_widget_host_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698