IndexedDBFactory now ForceCloses databases.
[chromium-blink-merge.git] / content / browser / accessibility / browser_accessibility_manager_android.h
blob921ca3a938c71f5d8f1bd184321a7cc3562011e9
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"
12 namespace content {
14 namespace aria_strings {
15 extern const char kAriaLivePolite[];
16 extern const char kAriaLiveAssertive[];
19 class CONTENT_EXPORT BrowserAccessibilityManagerAndroid
20 : public BrowserAccessibilityManager {
21 public:
22 BrowserAccessibilityManagerAndroid(
23 base::android::ScopedJavaLocalRef<jobject> content_view_core,
24 const ui::AXNodeData& src,
25 BrowserAccessibilityDelegate* delegate,
26 BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory());
28 virtual ~BrowserAccessibilityManagerAndroid();
30 static ui::AXNodeData 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 // --------------------------------------------------------------------------
43 // Tree methods.
44 jint GetRootId(JNIEnv* env, jobject obj);
45 jboolean IsNodeValid(JNIEnv* env, jobject obj, jint id);
46 jint 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);
54 // Perform actions.
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);
59 protected:
60 virtual void NotifyRootChanged() OVERRIDE;
62 virtual bool UseRootScrollOffsetsWhenComputingBounds() OVERRIDE;
64 private:
65 // This gives BrowserAccessibilityManager::Create access to the class
66 // constructor.
67 friend class BrowserAccessibilityManager;
69 // A weak reference to the Java BrowserAccessibilityManager object.
70 // This avoids adding another reference to BrowserAccessibilityManager and
71 // preventing garbage collection.
72 // Premature garbage collection is prevented by the long-lived reference in
73 // ContentViewCore.
74 JavaObjectWeakGlobalRef java_ref_;
76 // Searches through the children of start_node to find the nearest
77 // accessibility focus candidate for a touch which has not landed directly on
78 // an accessibility focus candidate.
79 BrowserAccessibility* FuzzyHitTest(
80 int x, int y, BrowserAccessibility* start_node);
82 static void FuzzyHitTestImpl(int x, int y, BrowserAccessibility* start_node,
83 BrowserAccessibility** nearest_candidate, int* min_distance);
85 // Calculates the distance from the point (x, y) to the nearest point on the
86 // edge of |node|.
87 static int CalculateDistanceSquared(int x, int y, BrowserAccessibility* node);
89 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManagerAndroid);
92 bool RegisterBrowserAccessibilityManager(JNIEnv* env);
96 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_ANDROID_H_