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/public/test/browser_test_utils.h" | 5 #include "content/public/test/browser_test_utils.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <tuple> | 8 #include <tuple> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "content/browser/frame_host/frame_tree_node.h" | 33 #include "content/browser/frame_host/frame_tree_node.h" |
34 #include "content/browser/frame_host/render_frame_host_impl.h" | 34 #include "content/browser/frame_host/render_frame_host_impl.h" |
35 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 35 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
36 #include "content/browser/renderer_host/render_widget_host_impl.h" | 36 #include "content/browser/renderer_host/render_widget_host_impl.h" |
37 #include "content/browser/web_contents/web_contents_impl.h" | 37 #include "content/browser/web_contents/web_contents_impl.h" |
38 #include "content/browser/web_contents/web_contents_view.h" | 38 #include "content/browser/web_contents/web_contents_view.h" |
39 #include "content/common/input/synthetic_web_input_event_builders.h" | 39 #include "content/common/input/synthetic_web_input_event_builders.h" |
40 #include "content/common/input_messages.h" | 40 #include "content/common/input_messages.h" |
41 #include "content/common/view_messages.h" | 41 #include "content/common/view_messages.h" |
42 #include "content/public/browser/browser_context.h" | 42 #include "content/public/browser/browser_context.h" |
| 43 #include "content/public/browser/browser_plugin_guest_manager.h" |
43 #include "content/public/browser/histogram_fetcher.h" | 44 #include "content/public/browser/histogram_fetcher.h" |
44 #include "content/public/browser/navigation_entry.h" | 45 #include "content/public/browser/navigation_entry.h" |
45 #include "content/public/browser/notification_service.h" | 46 #include "content/public/browser/notification_service.h" |
46 #include "content/public/browser/notification_types.h" | 47 #include "content/public/browser/notification_types.h" |
47 #include "content/public/browser/render_frame_host.h" | 48 #include "content/public/browser/render_frame_host.h" |
48 #include "content/public/browser/render_process_host.h" | 49 #include "content/public/browser/render_process_host.h" |
49 #include "content/public/browser/render_view_host.h" | 50 #include "content/public/browser/render_view_host.h" |
50 #include "content/public/browser/storage_partition.h" | 51 #include "content/public/browser/storage_partition.h" |
51 #include "content/public/browser/web_contents.h" | 52 #include "content/public/browser/web_contents.h" |
52 #include "content/public/test/test_navigation_observer.h" | 53 #include "content/public/test/test_navigation_observer.h" |
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 const std::string& name) { | 971 const std::string& name) { |
971 if (node->GetStringAttribute(ui::AX_ATTR_NAME) == name) | 972 if (node->GetStringAttribute(ui::AX_ATTR_NAME) == name) |
972 return true; | 973 return true; |
973 for (unsigned i = 0; i < node->PlatformChildCount(); i++) { | 974 for (unsigned i = 0; i < node->PlatformChildCount(); i++) { |
974 if (AccessibilityTreeContainsNodeWithName(node->PlatformGetChild(i), name)) | 975 if (AccessibilityTreeContainsNodeWithName(node->PlatformGetChild(i), name)) |
975 return true; | 976 return true; |
976 } | 977 } |
977 return false; | 978 return false; |
978 } | 979 } |
979 | 980 |
| 981 bool ListenToGuestWebContents( |
| 982 AccessibilityNotificationWaiter* accessibility_waiter, |
| 983 WebContents* web_contents) { |
| 984 accessibility_waiter->ListenToAdditionalFrame( |
| 985 static_cast<RenderFrameHostImpl*>(web_contents->GetMainFrame())); |
| 986 return true; |
| 987 } |
| 988 |
980 void WaitForAccessibilityTreeToContainNodeWithName(WebContents* web_contents, | 989 void WaitForAccessibilityTreeToContainNodeWithName(WebContents* web_contents, |
981 const std::string& name) { | 990 const std::string& name) { |
982 WebContentsImpl* web_contents_impl = static_cast<WebContentsImpl*>( | 991 WebContentsImpl* web_contents_impl = static_cast<WebContentsImpl*>( |
983 web_contents); | 992 web_contents); |
984 RenderFrameHostImpl* main_frame = static_cast<RenderFrameHostImpl*>( | 993 RenderFrameHostImpl* main_frame = static_cast<RenderFrameHostImpl*>( |
985 web_contents_impl->GetMainFrame()); | 994 web_contents_impl->GetMainFrame()); |
986 BrowserAccessibilityManager* main_frame_manager = | 995 BrowserAccessibilityManager* main_frame_manager = |
987 main_frame->browser_accessibility_manager(); | 996 main_frame->browser_accessibility_manager(); |
988 FrameTree* frame_tree = web_contents_impl->GetFrameTree(); | 997 FrameTree* frame_tree = web_contents_impl->GetFrameTree(); |
989 while (!AccessibilityTreeContainsNodeWithName( | 998 while (!main_frame_manager || !AccessibilityTreeContainsNodeWithName( |
990 main_frame_manager->GetRoot(), name)) { | 999 main_frame_manager->GetRoot(), name)) { |
991 AccessibilityNotificationWaiter accessibility_waiter(main_frame, | 1000 AccessibilityNotificationWaiter accessibility_waiter(main_frame, |
992 ui::AX_EVENT_NONE); | 1001 ui::AX_EVENT_NONE); |
993 for (FrameTreeNode* node : frame_tree->Nodes()) | 1002 for (FrameTreeNode* node : frame_tree->Nodes()) { |
994 accessibility_waiter.ListenToAdditionalFrame( | 1003 accessibility_waiter.ListenToAdditionalFrame( |
995 node->current_frame_host()); | 1004 node->current_frame_host()); |
| 1005 } |
| 1006 |
| 1007 content::BrowserPluginGuestManager* guest_manager = |
| 1008 web_contents_impl->GetBrowserContext()->GetGuestManager(); |
| 1009 if (guest_manager) { |
| 1010 guest_manager->ForEachGuest(web_contents_impl, |
| 1011 base::Bind(&ListenToGuestWebContents, |
| 1012 &accessibility_waiter)); |
| 1013 } |
996 | 1014 |
997 accessibility_waiter.WaitForNotification(); | 1015 accessibility_waiter.WaitForNotification(); |
| 1016 main_frame_manager = main_frame->browser_accessibility_manager(); |
998 } | 1017 } |
999 } | 1018 } |
1000 | 1019 |
1001 ui::AXTreeUpdate GetAccessibilityTreeSnapshot(WebContents* web_contents) { | 1020 ui::AXTreeUpdate GetAccessibilityTreeSnapshot(WebContents* web_contents) { |
1002 WebContentsImpl* web_contents_impl = | 1021 WebContentsImpl* web_contents_impl = |
1003 static_cast<WebContentsImpl*>(web_contents); | 1022 static_cast<WebContentsImpl*>(web_contents); |
1004 BrowserAccessibilityManager* manager = | 1023 BrowserAccessibilityManager* manager = |
1005 web_contents_impl->GetRootBrowserAccessibilityManager(); | 1024 web_contents_impl->GetRootBrowserAccessibilityManager(); |
1006 if (!manager) | 1025 if (!manager) |
1007 return ui::AXTreeUpdate(); | 1026 return ui::AXTreeUpdate(); |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1406 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1425 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1407 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN) | 1426 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN) |
1408 return ack_result_; | 1427 return ack_result_; |
1409 base::RunLoop run_loop; | 1428 base::RunLoop run_loop; |
1410 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); | 1429 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); |
1411 run_loop.Run(); | 1430 run_loop.Run(); |
1412 return ack_result_; | 1431 return ack_result_; |
1413 } | 1432 } |
1414 | 1433 |
1415 } // namespace content | 1434 } // namespace content |
OLD | NEW |