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"
23 class WebTestDelegate;
25 class AccessibilityController :
26 public base::SupportsWeakPtr<AccessibilityController> {
28 AccessibilityController();
29 ~AccessibilityController();
32 void Install(blink::WebFrame* frame);
33 void SetFocusedElement(const blink::WebAXObject&);
34 bool ShouldLogAccessibilityEvents();
35 void NotificationReceived(const blink::WebAXObject& target,
36 const std::string& notification_name);
38 void SetDelegate(WebTestDelegate* delegate);
39 void SetWebView(blink::WebView* web_view);
42 friend class AccessibilityControllerBindings;
44 // Bound methods and properties
45 void LogAccessibilityEvents();
46 void SetNotificationListener(v8::Handle<v8::Function> callback);
47 void UnsetNotificationListener();
48 v8::Handle<v8::Object> FocusedElement();
49 v8::Handle<v8::Object> RootElement();
50 v8::Handle<v8::Object> AccessibleElementById(const std::string& id);
52 v8::Handle<v8::Object> FindAccessibleElementByIdRecursive(
53 const blink::WebAXObject&, const blink::WebString& id);
55 // If true, will log all accessibility notifications.
56 bool log_accessibility_events_;
58 blink::WebAXObject focused_element_;
59 blink::WebAXObject root_element_;
61 WebAXObjectProxyList elements_;
63 v8::Persistent<v8::Function> notification_callback_;
65 WebTestDelegate* delegate_;
66 blink::WebView* web_view_;
68 base::WeakPtrFactory<AccessibilityController> weak_factory_;
70 DISALLOW_COPY_AND_ASSIGN(AccessibilityController);
73 } // namespace content
75 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_ACCESSIBILITY_CONTROLLER_H_