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

Side by Side Diff: content/browser/accessibility/browser_accessibility_android.cc

Issue 15741009: Native Android accessibility. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split RendererAccessibilityFocusOnly fix into separate changelist Created 7 years, 6 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
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/browser/accessibility/browser_accessibility_android.h" 5 #include "content/browser/accessibility/browser_accessibility_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_registrar.h" 8 #include "base/android/jni_registrar.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "content/browser/accessibility/browser_accessibility_manager_android.h" 12 #include "content/browser/accessibility/browser_accessibility_manager_android.h"
13 #include "content/common/accessibility_messages.h" 13 #include "content/common/accessibility_messages.h"
14 #include "content/common/accessibility_node_data.h" 14 #include "content/common/accessibility_node_data.h"
15 15 #include "jni/BrowserAccessibility_jni.h"
16 using base::android::ScopedJavaLocalRef;
17 16
18 namespace content { 17 namespace content {
19 18
20 // static 19 // static
21 BrowserAccessibility* BrowserAccessibility::Create() { 20 BrowserAccessibility* BrowserAccessibility::Create() {
22 return new BrowserAccessibilityAndroid(); 21 return new BrowserAccessibilityAndroid();
23 } 22 }
24 23
25 BrowserAccessibilityAndroid::BrowserAccessibilityAndroid() { 24 BrowserAccessibilityAndroid::BrowserAccessibilityAndroid() {
26 first_time_ = true; 25 first_time_ = true;
(...skipping 21 matching lines...) Expand all
48 47
49 ScopedJavaLocalRef<jstring> 48 ScopedJavaLocalRef<jstring>
50 BrowserAccessibilityAndroid::GetNameJNI(JNIEnv* env, jobject obj) const { 49 BrowserAccessibilityAndroid::GetNameJNI(JNIEnv* env, jobject obj) const {
51 return base::android::ConvertUTF16ToJavaString(env, ComputeName()); 50 return base::android::ConvertUTF16ToJavaString(env, ComputeName());
52 } 51 }
53 52
54 ScopedJavaLocalRef<jobject> 53 ScopedJavaLocalRef<jobject>
55 BrowserAccessibilityAndroid::GetAbsoluteRectJNI( 54 BrowserAccessibilityAndroid::GetAbsoluteRectJNI(
56 JNIEnv* env, jobject obj) const { 55 JNIEnv* env, jobject obj) const {
57 gfx::Rect rect = GetLocalBoundsRect(); 56 gfx::Rect rect = GetLocalBoundsRect();
58 57 return Java_BrowserAccessibility_createRect(
59 // TODO(aboxhall): replace with non-stub implementation 58 env,
60 return ScopedJavaLocalRef<jobject>(env, NULL); 59 static_cast<int>(rect.x()),
60 static_cast<int>(rect.y()),
61 static_cast<int>(rect.right()),
62 static_cast<int>(rect.bottom()));
61 } 63 }
62 64
63 ScopedJavaLocalRef<jobject> 65 ScopedJavaLocalRef<jobject>
64 BrowserAccessibilityAndroid::GetRectInParentJNI( 66 BrowserAccessibilityAndroid::GetRectInParentJNI(
65 JNIEnv* env, jobject obj) const { 67 JNIEnv* env, jobject obj) const {
66 gfx::Rect rect = GetLocalBoundsRect(); 68 gfx::Rect rect = GetLocalBoundsRect();
67 if (parent()) { 69 if (parent()) {
68 gfx::Rect parent_rect = parent()->GetLocalBoundsRect(); 70 gfx::Rect parent_rect = parent()->GetLocalBoundsRect();
69 rect.Offset(-parent_rect.OffsetFromOrigin()); 71 rect.Offset(-parent_rect.OffsetFromOrigin());
70 } 72 }
71 73
72 // TODO(aboxhall): replace with non-stub implementation 74 return Java_BrowserAccessibility_createRect(
73 return ScopedJavaLocalRef<jobject>(env, NULL); 75 env,
76 static_cast<int>(rect.x()),
77 static_cast<int>(rect.y()),
78 static_cast<int>(rect.right()),
79 static_cast<int>(rect.bottom()));
74 } 80 }
75 81
76 jboolean 82 jboolean
77 BrowserAccessibilityAndroid::IsFocusableJNI(JNIEnv* env, jobject obj) const { 83 BrowserAccessibilityAndroid::IsFocusableJNI(JNIEnv* env, jobject obj) const {
78 return static_cast<jboolean>(IsFocusable()); 84 return static_cast<jboolean>(IsFocusable());
79 } 85 }
80 86
81 jboolean 87 jboolean
82 BrowserAccessibilityAndroid::IsEditableTextJNI(JNIEnv* env, jobject obj) const { 88 BrowserAccessibilityAndroid::IsEditableTextJNI(JNIEnv* env, jobject obj) const {
83 return IsEditableText(); 89 return IsEditableText();
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 if (cached_text_ != text) { 526 if (cached_text_ != text) {
521 if (!text.empty()) { 527 if (!text.empty()) {
522 manager_->NotifyAccessibilityEvent(AccessibilityNotificationObjectShow, 528 manager_->NotifyAccessibilityEvent(AccessibilityNotificationObjectShow,
523 this); 529 this);
524 } 530 }
525 cached_text_ = text; 531 cached_text_ = text;
526 } 532 }
527 } 533 }
528 534
529 bool RegisterBrowserAccessibility(JNIEnv* env) { 535 bool RegisterBrowserAccessibility(JNIEnv* env) {
530 // TODO(aboxhall): replace with non-stub implementation 536 return RegisterNativesImpl(env);
531 return false;
532 } 537 }
533 538
534 } // namespace content 539 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698