1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_ACCESSIBILITY_CONTROLLER_H_
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_ACCESSIBILITY_CONTROLLER_H_
10 #include "base/memory/weak_ptr.h"
11 #include "content/shell/renderer/test_runner/web_ax_object_proxy.h"
12 #include "third_party/WebKit/public/web/WebAXObject.h"
13 #include "v8/include/v8.h"
21 namespace WebTestRunner
{
22 class WebTestDelegate
;
27 class AccessibilityController
:
28 public base::SupportsWeakPtr
<AccessibilityController
> {
30 AccessibilityController();
31 ~AccessibilityController();
34 void Install(blink::WebFrame
* frame
);
35 void SetFocusedElement(const blink::WebAXObject
&);
36 bool ShouldLogAccessibilityEvents();
37 void NotificationReceived(const blink::WebAXObject
& target
,
38 const std::string
& notification_name
);
40 void SetDelegate(WebTestRunner::WebTestDelegate
* delegate
);
41 void SetWebView(blink::WebView
* web_view
);
44 friend class AccessibilityControllerBindings
;
46 // Bound methods and properties
47 void LogAccessibilityEvents();
48 void SetNotificationListener(v8::Handle
<v8::Function
> callback
);
49 void UnsetNotificationListener();
50 v8::Handle
<v8::Object
> FocusedElement();
51 v8::Handle
<v8::Object
> RootElement();
52 v8::Handle
<v8::Object
> AccessibleElementById(const std::string
& id
);
54 v8::Handle
<v8::Object
> FindAccessibleElementByIdRecursive(
55 const blink::WebAXObject
&, const blink::WebString
& id
);
57 // If true, will log all accessibility notifications.
58 bool log_accessibility_events_
;
60 blink::WebAXObject focused_element_
;
61 blink::WebAXObject root_element_
;
63 WebAXObjectProxyList elements_
;
65 v8::Persistent
<v8::Function
> notification_callback_
;
67 WebTestRunner::WebTestDelegate
* delegate_
;
68 blink::WebView
* web_view_
;
70 base::WeakPtrFactory
<AccessibilityController
> weak_factory_
;
72 DISALLOW_COPY_AND_ASSIGN(AccessibilityController
);
75 } // namespace content
77 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_ACCESSIBILITY_CONTROLLER_H_