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

Side by Side Diff: content/public/test/browser_test_utils.cc

Issue 2100753003: Enable PDF accessibility when RenderFrame's accessibility mode changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix win assertion Created 4 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
OLDNEW
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 16 matching lines...) Expand all
27 #include "content/browser/accessibility/browser_accessibility_manager.h" 27 #include "content/browser/accessibility/browser_accessibility_manager.h"
28 #include "content/browser/frame_host/frame_tree_node.h" 28 #include "content/browser/frame_host/frame_tree_node.h"
29 #include "content/browser/frame_host/render_frame_host_impl.h" 29 #include "content/browser/frame_host/render_frame_host_impl.h"
30 #include "content/browser/renderer_host/render_widget_host_impl.h" 30 #include "content/browser/renderer_host/render_widget_host_impl.h"
31 #include "content/browser/web_contents/web_contents_impl.h" 31 #include "content/browser/web_contents/web_contents_impl.h"
32 #include "content/browser/web_contents/web_contents_view.h" 32 #include "content/browser/web_contents/web_contents_view.h"
33 #include "content/common/input/synthetic_web_input_event_builders.h" 33 #include "content/common/input/synthetic_web_input_event_builders.h"
34 #include "content/common/input_messages.h" 34 #include "content/common/input_messages.h"
35 #include "content/common/view_messages.h" 35 #include "content/common/view_messages.h"
36 #include "content/public/browser/browser_context.h" 36 #include "content/public/browser/browser_context.h"
37 #include "content/public/browser/browser_plugin_guest_manager.h"
37 #include "content/public/browser/histogram_fetcher.h" 38 #include "content/public/browser/histogram_fetcher.h"
38 #include "content/public/browser/navigation_entry.h" 39 #include "content/public/browser/navigation_entry.h"
39 #include "content/public/browser/notification_service.h" 40 #include "content/public/browser/notification_service.h"
40 #include "content/public/browser/notification_types.h" 41 #include "content/public/browser/notification_types.h"
41 #include "content/public/browser/render_frame_host.h" 42 #include "content/public/browser/render_frame_host.h"
42 #include "content/public/browser/render_process_host.h" 43 #include "content/public/browser/render_process_host.h"
43 #include "content/public/browser/render_view_host.h" 44 #include "content/public/browser/render_view_host.h"
44 #include "content/public/browser/storage_partition.h" 45 #include "content/public/browser/storage_partition.h"
45 #include "content/public/browser/web_contents.h" 46 #include "content/public/browser/web_contents.h"
46 #include "content/public/test/test_navigation_observer.h" 47 #include "content/public/test/test_navigation_observer.h"
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 const std::string& name) { 966 const std::string& name) {
966 if (node->GetStringAttribute(ui::AX_ATTR_NAME) == name) 967 if (node->GetStringAttribute(ui::AX_ATTR_NAME) == name)
967 return true; 968 return true;
968 for (unsigned i = 0; i < node->PlatformChildCount(); i++) { 969 for (unsigned i = 0; i < node->PlatformChildCount(); i++) {
969 if (AccessibilityTreeContainsNodeWithName(node->PlatformGetChild(i), name)) 970 if (AccessibilityTreeContainsNodeWithName(node->PlatformGetChild(i), name))
970 return true; 971 return true;
971 } 972 }
972 return false; 973 return false;
973 } 974 }
974 975
976 bool ListenToGuestWebContents(
977 AccessibilityNotificationWaiter* accessibility_waiter,
978 WebContents* web_contents) {
979 accessibility_waiter->ListenToAdditionalFrame(
980 static_cast<RenderFrameHostImpl*>(web_contents->GetMainFrame()));
981 return true;
982 }
983
975 void WaitForAccessibilityTreeToContainNodeWithName(WebContents* web_contents, 984 void WaitForAccessibilityTreeToContainNodeWithName(WebContents* web_contents,
976 const std::string& name) { 985 const std::string& name) {
977 WebContentsImpl* web_contents_impl = static_cast<WebContentsImpl*>( 986 WebContentsImpl* web_contents_impl = static_cast<WebContentsImpl*>(
978 web_contents); 987 web_contents);
979 RenderFrameHostImpl* main_frame = static_cast<RenderFrameHostImpl*>( 988 RenderFrameHostImpl* main_frame = static_cast<RenderFrameHostImpl*>(
980 web_contents_impl->GetMainFrame()); 989 web_contents_impl->GetMainFrame());
981 BrowserAccessibilityManager* main_frame_manager = 990 BrowserAccessibilityManager* main_frame_manager =
982 main_frame->browser_accessibility_manager(); 991 main_frame->browser_accessibility_manager();
983 FrameTree* frame_tree = web_contents_impl->GetFrameTree(); 992 FrameTree* frame_tree = web_contents_impl->GetFrameTree();
984 while (!AccessibilityTreeContainsNodeWithName( 993 while (!main_frame_manager || !AccessibilityTreeContainsNodeWithName(
985 main_frame_manager->GetRoot(), name)) { 994 main_frame_manager->GetRoot(), name)) {
986 AccessibilityNotificationWaiter accessibility_waiter(main_frame, 995 AccessibilityNotificationWaiter accessibility_waiter(main_frame,
987 ui::AX_EVENT_NONE); 996 ui::AX_EVENT_NONE);
988 for (FrameTreeNode* node : frame_tree->Nodes()) 997 for (FrameTreeNode* node : frame_tree->Nodes()) {
989 accessibility_waiter.ListenToAdditionalFrame( 998 accessibility_waiter.ListenToAdditionalFrame(
990 node->current_frame_host()); 999 node->current_frame_host());
1000 }
1001
1002 content::BrowserPluginGuestManager* guest_manager =
1003 web_contents_impl->GetBrowserContext()->GetGuestManager();
1004 if (guest_manager) {
1005 guest_manager->ForEachGuest(web_contents_impl,
1006 base::Bind(&ListenToGuestWebContents,
1007 &accessibility_waiter));
1008 }
991 1009
992 accessibility_waiter.WaitForNotification(); 1010 accessibility_waiter.WaitForNotification();
1011 main_frame_manager = main_frame->browser_accessibility_manager();
993 } 1012 }
994 } 1013 }
995 1014
996 ui::AXTreeUpdate GetAccessibilityTreeSnapshot(WebContents* web_contents) { 1015 ui::AXTreeUpdate GetAccessibilityTreeSnapshot(WebContents* web_contents) {
997 WebContentsImpl* web_contents_impl = 1016 WebContentsImpl* web_contents_impl =
998 static_cast<WebContentsImpl*>(web_contents); 1017 static_cast<WebContentsImpl*>(web_contents);
999 BrowserAccessibilityManager* manager = 1018 BrowserAccessibilityManager* manager =
1000 web_contents_impl->GetRootBrowserAccessibilityManager(); 1019 web_contents_impl->GetRootBrowserAccessibilityManager();
1001 if (!manager) 1020 if (!manager)
1002 return ui::AXTreeUpdate(); 1021 return ui::AXTreeUpdate();
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1336 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1318 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN) 1337 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN)
1319 return ack_result_; 1338 return ack_result_;
1320 base::RunLoop run_loop; 1339 base::RunLoop run_loop;
1321 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); 1340 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure());
1322 run_loop.Run(); 1341 run_loop.Run();
1323 return ack_result_; 1342 return ack_result_;
1324 } 1343 }
1325 1344
1326 } // namespace content 1345 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698