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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_ANDROID_H_
6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_ANDROID_H_
8 #include "base/android/scoped_java_ref.h"
9 #include "content/browser/accessibility/browser_accessibility_manager.h"
10 #include "content/browser/android/content_view_core_impl.h"
14 namespace aria_strings
{
15 extern const char kAriaLivePolite
[];
16 extern const char kAriaLiveAssertive
[];
19 class CONTENT_EXPORT BrowserAccessibilityManagerAndroid
20 : public BrowserAccessibilityManager
{
22 BrowserAccessibilityManagerAndroid(
23 base::android::ScopedJavaLocalRef
<jobject
> content_view_core
,
24 const ui::AXTreeUpdate
& initial_tree
,
25 BrowserAccessibilityDelegate
* delegate
,
26 BrowserAccessibilityFactory
* factory
= new BrowserAccessibilityFactory());
28 virtual ~BrowserAccessibilityManagerAndroid();
30 static ui::AXTreeUpdate
GetEmptyDocument();
32 void SetContentViewCore(
33 base::android::ScopedJavaLocalRef
<jobject
> content_view_core
);
35 // Implementation of BrowserAccessibilityManager.
36 virtual void NotifyAccessibilityEvent(
37 ui::AXEvent event_type
, BrowserAccessibility
* node
) OVERRIDE
;
39 // --------------------------------------------------------------------------
40 // Methods called from Java via JNI
41 // --------------------------------------------------------------------------
44 jint
GetRootId(JNIEnv
* env
, jobject obj
);
45 jboolean
IsNodeValid(JNIEnv
* env
, jobject obj
, jint id
);
46 void HitTest(JNIEnv
* env
, jobject obj
, jint x
, jint y
);
48 // Populate Java accessibility data structures with info about a node.
49 jboolean
PopulateAccessibilityNodeInfo(
50 JNIEnv
* env
, jobject obj
, jobject info
, jint id
);
51 jboolean
PopulateAccessibilityEvent(
52 JNIEnv
* env
, jobject obj
, jobject event
, jint id
, jint event_type
);
55 void Click(JNIEnv
* env
, jobject obj
, jint id
);
56 void Focus(JNIEnv
* env
, jobject obj
, jint id
);
57 void Blur(JNIEnv
* env
, jobject obj
);
58 void ScrollToMakeNodeVisible(JNIEnv
* env
, jobject obj
, int id
);
60 // Return the id of the next node in tree order in the direction given by
61 // |forwards|, starting with |start_id|, that matches |element_type|,
62 // where |element_type| is a special uppercase string from TalkBack or
63 // BrailleBack indicating general categories of web content like
64 // "SECTION" or "CONTROL". Return 0 if not found.
65 jint
FindElementType(JNIEnv
* env
, jobject obj
, jint start_id
,
66 jstring element_type
, jboolean forwards
);
69 // AXTreeDelegate overrides.
70 virtual void OnRootChanged(ui::AXNode
* new_root
) OVERRIDE
;
72 virtual bool UseRootScrollOffsetsWhenComputingBounds() OVERRIDE
;
75 // This gives BrowserAccessibilityManager::Create access to the class
77 friend class BrowserAccessibilityManager
;
79 // A weak reference to the Java BrowserAccessibilityManager object.
80 // This avoids adding another reference to BrowserAccessibilityManager and
81 // preventing garbage collection.
82 // Premature garbage collection is prevented by the long-lived reference in
84 JavaObjectWeakGlobalRef java_ref_
;
86 // Handle a hover event from the renderer process.
87 void HandleHoverEvent(BrowserAccessibility
* node
);
89 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManagerAndroid
);
92 bool RegisterBrowserAccessibilityManager(JNIEnv
* env
);
96 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_ANDROID_H_