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

Side by Side Diff: content/test/accessibility_browser_test_utils.cc

Issue 268543008: Cross-process iframe accessibility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile error Created 6 years, 3 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
« no previous file with comments | « content/test/accessibility_browser_test_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/test/accessibility_browser_test_utils.h" 5 #include "content/test/accessibility_browser_test_utils.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "content/browser/frame_host/render_frame_host_impl.h" 11 #include "content/browser/frame_host/render_frame_host_impl.h"
12 #include "content/browser/renderer_host/render_widget_host_view_base.h" 12 #include "content/browser/renderer_host/render_widget_host_view_base.h"
13 #include "content/browser/web_contents/web_contents_impl.h" 13 #include "content/browser/web_contents/web_contents_impl.h"
14 #include "content/common/view_message_enums.h" 14 #include "content/common/view_message_enums.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "content/public/common/url_constants.h" 16 #include "content/public/common/url_constants.h"
17 #include "content/public/test/test_utils.h" 17 #include "content/public/test/test_utils.h"
18 #include "content/shell/browser/shell.h" 18 #include "content/shell/browser/shell.h"
19 #include "ui/accessibility/ax_node.h" 19 #include "ui/accessibility/ax_node.h"
20 20
21 namespace content { 21 namespace content {
22 22
23 AccessibilityNotificationWaiter::AccessibilityNotificationWaiter(Shell* shell) 23 AccessibilityNotificationWaiter::AccessibilityNotificationWaiter(Shell* shell)
24 : shell_(shell), 24 : event_to_wait_for_(ui::AX_EVENT_NONE),
25 event_to_wait_for_(ui::AX_EVENT_NONE),
26 loop_runner_(new MessageLoopRunner()), 25 loop_runner_(new MessageLoopRunner()),
27 weak_factory_(this), 26 weak_factory_(this),
28 event_target_id_(0) { 27 event_target_id_(0) {
29 WebContents* web_contents = shell_->web_contents(); 28 WebContents* web_contents = shell->web_contents();
30 frame_host_ = static_cast<RenderFrameHostImpl*>( 29 frame_host_ = static_cast<RenderFrameHostImpl*>(
31 web_contents->GetMainFrame()); 30 web_contents->GetMainFrame());
32 frame_host_->SetAccessibilityCallbackForTesting( 31 frame_host_->SetAccessibilityCallbackForTesting(
33 base::Bind(&AccessibilityNotificationWaiter::OnAccessibilityEvent, 32 base::Bind(&AccessibilityNotificationWaiter::OnAccessibilityEvent,
34 weak_factory_.GetWeakPtr())); 33 weak_factory_.GetWeakPtr()));
35 } 34 }
36 35
37 AccessibilityNotificationWaiter::AccessibilityNotificationWaiter( 36 AccessibilityNotificationWaiter::AccessibilityNotificationWaiter(
38 Shell* shell, 37 Shell* shell,
39 AccessibilityMode accessibility_mode, 38 AccessibilityMode accessibility_mode,
40 ui::AXEvent event_type) 39 ui::AXEvent event_type)
41 : shell_(shell), 40 : event_to_wait_for_(event_type),
42 event_to_wait_for_(event_type),
43 loop_runner_(new MessageLoopRunner()), 41 loop_runner_(new MessageLoopRunner()),
44 weak_factory_(this), 42 weak_factory_(this),
45 event_target_id_(0) { 43 event_target_id_(0) {
46 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( 44 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
47 shell_->web_contents()); 45 shell->web_contents());
48 frame_host_ = static_cast<RenderFrameHostImpl*>( 46 frame_host_ = static_cast<RenderFrameHostImpl*>(
49 web_contents->GetMainFrame()); 47 web_contents->GetMainFrame());
50 frame_host_->SetAccessibilityCallbackForTesting( 48 frame_host_->SetAccessibilityCallbackForTesting(
51 base::Bind(&AccessibilityNotificationWaiter::OnAccessibilityEvent, 49 base::Bind(&AccessibilityNotificationWaiter::OnAccessibilityEvent,
52 weak_factory_.GetWeakPtr())); 50 weak_factory_.GetWeakPtr()));
53 web_contents->AddAccessibilityMode(accessibility_mode); 51 web_contents->AddAccessibilityMode(accessibility_mode);
54 } 52 }
55 53
54 AccessibilityNotificationWaiter::AccessibilityNotificationWaiter(
55 RenderFrameHostImpl* frame_host,
56 ui::AXEvent event_type)
57 : frame_host_(frame_host),
58 event_to_wait_for_(event_type),
59 loop_runner_(new MessageLoopRunner()),
60 weak_factory_(this),
61 event_target_id_(0) {
62 frame_host_->SetAccessibilityCallbackForTesting(
63 base::Bind(&AccessibilityNotificationWaiter::OnAccessibilityEvent,
64 weak_factory_.GetWeakPtr()));
65 }
66
56 AccessibilityNotificationWaiter::~AccessibilityNotificationWaiter() { 67 AccessibilityNotificationWaiter::~AccessibilityNotificationWaiter() {
57 } 68 }
58 69
59 void AccessibilityNotificationWaiter::WaitForNotification() { 70 void AccessibilityNotificationWaiter::WaitForNotification() {
60 loop_runner_->Run(); 71 loop_runner_->Run();
61 72
62 // Each loop runner can only be called once. Create a new one in case 73 // Each loop runner can only be called once. Create a new one in case
63 // the caller wants to call this again to wait for the next notification. 74 // the caller wants to call this again to wait for the next notification.
64 loop_runner_ = new MessageLoopRunner(); 75 loop_runner_ = new MessageLoopRunner();
65 } 76 }
(...skipping 19 matching lines...) Expand all
85 for (size_t i = 0; i < root.string_attributes.size(); ++i) { 96 for (size_t i = 0; i < root.string_attributes.size(); ++i) {
86 if (root.string_attributes[i].first != ui::AX_ATTR_DOC_URL) 97 if (root.string_attributes[i].first != ui::AX_ATTR_DOC_URL)
87 continue; 98 continue;
88 const std::string& doc_url = root.string_attributes[i].second; 99 const std::string& doc_url = root.string_attributes[i].second;
89 return doc_url == url::kAboutBlankURL; 100 return doc_url == url::kAboutBlankURL;
90 } 101 }
91 return false; 102 return false;
92 } 103 }
93 104
94 } // namespace content 105 } // namespace content
OLDNEW
« no previous file with comments | « content/test/accessibility_browser_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698