Commit 0415561b authored by dmichael@chromium.org's avatar dmichael@chromium.org

Revert 207875 "Native Android accessibility."

Broke Android Tests:
http://build.chromium.org/p/chromium.linux/buildstatus?builder=Android%20Tests&number=5462
Some output:
W  102s Main  Failed obtaining tests from 014E378305008009 with exception: End Of File (EOF) in read_nonblocking(). Exception style platform.
<pexpect.spawn object at 0x28d5510>
version: 2.3 ($Revision: 399 $)
command: /b/build_internal/scripts/slave/android/adb
args: ['/b/build_internal/scripts/slave/android/adb', '-s', '014E378305008009', 'shell', 'cat', '/data/data/org.chromium.native_test/files/test.fifo']
searcher: searcher_re:
    0: re.compile("<<ScopedMainEntryLogger")
buffer (last 100 chars): 
before (last 100 chars): t/browser/accessibility/BrowserAccessibilityManager

> Native Android accessibility.
> 
> This is the final changelist that completes the initial implementation.
> When accessibility is on and script injection is turned off or
> unavailable, constructs a BrowserAccessibilityManager for the
> ContentViewCore that provides a native accessibility implementation.
> 
> BUG=242953
> R=benm@chromium.org, bulach@chromium.org, dtrainor@chromium.org
> 
> Review URL: https://codereview.chromium.org/15741009

TBR=dmazzoni@chromium.org

Review URL: https://codereview.chromium.org/17045010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207891 0039d316-1c4b-4281-b951-d872f2087c98
parent 4d77ecd0
......@@ -26,7 +26,6 @@ import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeProvider;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.webkit.GeolocationPermissions;
......@@ -1130,13 +1129,6 @@ public class AwContents {
return mContentViewCore.onGenericMotionEvent(event);
}
/**
* @see android.view.View#dispatchHoverEvent()
*/
public boolean dispatchHoverEvent(MotionEvent event) {
return mContentViewCore.dispatchHoverEvent(event);
}
/**
* @see android.view.View#onConfigurationChanged()
*/
......@@ -1302,13 +1294,6 @@ public class AwContents {
mContentViewCore.removeJavascriptInterface(interfaceName);
}
/**
* @see View#getAccessibilityNodeProvider()
*/
public AccessibilityNodeProvider getAccessibilityNodeProvider() {
return mContentViewCore.getAccessibilityNodeProvider();
}
/**
* @see android.webkit.WebView#onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo)
*/
......
......@@ -52,36 +52,54 @@ void AccessibilityTreeFormatter::AddProperties(
const BrowserAccessibility& node, DictionaryValue* dict) {
const BrowserAccessibilityAndroid* android_node =
static_cast<const BrowserAccessibilityAndroid*>(&node);
JNIEnv* env = base::android::AttachCurrentThread();
// Class name.
dict->SetString("class", android_node->GetClassName());
dict->SetString("class", base::android::ConvertJavaStringToUTF8(
android_node->GetClassNameJNI(env, NULL)));
// Bool attributes.
dict->SetBoolean("focusable", android_node->IsFocusable());
dict->SetBoolean("focused", android_node->IsFocused());
dict->SetBoolean("clickable", android_node->IsClickable());
dict->SetBoolean("editable_text", android_node->IsEditableText());
dict->SetBoolean("checkable", android_node->IsCheckable());
dict->SetBoolean("checked", android_node->IsChecked());
dict->SetBoolean("disabled", !android_node->IsEnabled());
dict->SetBoolean("scrollable", android_node->IsScrollable());
dict->SetBoolean("password", android_node->IsPassword());
dict->SetBoolean("selected", android_node->IsSelected());
dict->SetBoolean("invisible", !android_node->IsVisibleToUser());
dict->SetBoolean("focusable",
android_node->IsFocusableJNI(env, NULL));
dict->SetBoolean("focused",
android_node->IsFocusedJNI(env, NULL));
dict->SetBoolean("clickable",
android_node->GetClickableJNI(env, NULL));
dict->SetBoolean("editable_text",
android_node->IsEditableTextJNI(env, NULL));
dict->SetBoolean("checkable",
android_node->IsCheckableJNI(env, NULL));
dict->SetBoolean("checked",
android_node->IsCheckedJNI(env, NULL));
dict->SetBoolean("disabled",
!android_node->IsEnabledJNI(env, NULL));
dict->SetBoolean("scrollable",
android_node->IsScrollableJNI(env, NULL));
dict->SetBoolean("password",
android_node->IsPasswordJNI(env, NULL));
dict->SetBoolean("selected",
android_node->IsSelectedJNI(env, NULL));
dict->SetBoolean("invisible",
!android_node->IsVisibleJNI(env, NULL));
// String attributes.
dict->SetString("name", android_node->GetText());
dict->SetString("name", base::android::ConvertJavaStringToUTF8(
android_node->GetNameJNI(env, NULL)));
// Int attributes.
dict->SetInteger("item_index", android_node->GetItemIndex());
dict->SetInteger("item_count", android_node->GetItemCount());
dict->SetInteger("item_index",
android_node->GetItemIndexJNI(env, NULL));
dict->SetInteger("item_count",
android_node->GetItemCountJNI(env, NULL));
}
bool AccessibilityTreeFormatter::IncludeChildren(
const BrowserAccessibility& node) {
const BrowserAccessibilityAndroid* android_node =
static_cast<const BrowserAccessibilityAndroid*>(&node);
return !android_node->IsLeaf();
JNIEnv* env = base::android::AttachCurrentThread();
return 0 != android_node->GetChildCountJNI(env, NULL);
}
string16 AccessibilityTreeFormatter::ToString(const DictionaryValue& dict,
......
......@@ -16,48 +16,71 @@ class BrowserAccessibilityAndroid : public BrowserAccessibility {
virtual void PostInitialize() OVERRIDE;
virtual bool IsNative() const OVERRIDE;
bool IsLeaf() const;
bool IsCheckable() const;
bool IsChecked() const;
bool IsClickable() const;
bool IsEnabled() const;
bool IsFocusable() const;
bool IsFocused() const;
bool IsPassword() const;
bool IsScrollable() const;
bool IsSelected() const;
bool IsVisibleToUser() const;
const char* GetClassName() const;
string16 GetText() const;
int GetItemIndex() const;
int GetItemCount() const;
int GetScrollX() const;
int GetScrollY() const;
int GetMaxScrollX() const;
int GetMaxScrollY() const;
int GetTextChangeFromIndex() const;
int GetTextChangeAddedCount() const;
int GetTextChangeRemovedCount() const;
string16 GetTextChangeBeforeText() const;
int GetSelectionStart() const;
int GetSelectionEnd() const;
int GetEditableTextLength() const;
// --------------------------------------------------------------------------
// Methods called from Java via JNI
// --------------------------------------------------------------------------
// Actions
void FocusJNI(JNIEnv* env, jobject obj);
void ClickJNI(JNIEnv* env, jobject obj);
// Const accessors
jboolean GetClickableJNI(JNIEnv* env, jobject obj) const;
jboolean IsFocusedJNI(JNIEnv* env, jobject obj) const;
jboolean IsEditableTextJNI(JNIEnv* env, jobject obj) const;
base::android::ScopedJavaLocalRef<jstring> GetNameJNI(
JNIEnv* env, jobject obj) const;
base::android::ScopedJavaLocalRef<jobject> GetAbsoluteRectJNI(
JNIEnv* env, jobject obj) const;
base::android::ScopedJavaLocalRef<jobject> GetRectInParentJNI(
JNIEnv* env, jobject obj) const;
jboolean IsFocusableJNI(JNIEnv* env, jobject obj) const;
jint GetParentJNI(JNIEnv* env, jobject obj) const;
jint GetChildCountJNI(JNIEnv* env, jobject obj) const;
jint GetChildIdAtJNI(
JNIEnv* env, jobject obj, jint child_index) const;
jboolean IsCheckableJNI(JNIEnv* env, jobject obj) const;
jboolean IsCheckedJNI(JNIEnv* env, jobject obj) const;
base::android::ScopedJavaLocalRef<jstring> GetClassNameJNI(
JNIEnv* env, jobject obj) const;
jboolean IsEnabledJNI(JNIEnv* env, jobject obj) const;
jboolean IsPasswordJNI(JNIEnv* env, jobject obj) const;
jboolean IsScrollableJNI(JNIEnv* env, jobject obj) const;
jboolean IsSelectedJNI(JNIEnv* env, jobject obj) const;
jboolean IsVisibleJNI(JNIEnv* env, jobject obj) const;
jint GetItemIndexJNI(JNIEnv* env, jobject obj) const;
jint GetItemCountJNI(JNIEnv* env, jobject obj) const;
jint GetScrollXJNI(JNIEnv* env, jobject obj) const;
jint GetScrollYJNI(JNIEnv* env, jobject obj) const;
jint GetMaxScrollXJNI(JNIEnv* env, jobject obj) const;
jint GetMaxScrollYJNI(JNIEnv* env, jobject obj) const;
base::android::ScopedJavaLocalRef<jstring> GetAriaLiveJNI(
JNIEnv* env, jobject obj) const;
jint GetSelectionStartJNI(JNIEnv* env, jobject obj) const;
jint GetSelectionEndJNI(JNIEnv* env, jobject obj) const;
jint GetEditableTextLengthJNI(JNIEnv* env, jobject obj) const;
jint GetTextChangeFromIndexJNI(JNIEnv* env, jobject obj) const;
jint GetTextChangeAddedCountJNI(JNIEnv* env, jobject obj) const;
jint GetTextChangeRemovedCountJNI(JNIEnv* env, jobject obj) const;
base::android::ScopedJavaLocalRef<jstring> GetTextChangeBeforeTextJNI(
JNIEnv* env, jobject obj) const;
private:
// This gives BrowserAccessibility::Create access to the class constructor.
friend class BrowserAccessibility;
// Allow BrowserAccessibilityManagerAndroid to call these private methods.
friend class BrowserAccessibilityManagerAndroid;
BrowserAccessibilityAndroid();
string16 ComputeName() const;
string16 GetAriaLive() const;
bool IsFocusable() const;
bool HasFocusableChild() const;
bool HasOnlyStaticTextChildren() const;
bool IsIframe() const;
bool IsLeaf() const;
void NotifyLiveRegionUpdate(string16& aria_live);
......@@ -69,6 +92,8 @@ class BrowserAccessibilityAndroid : public BrowserAccessibility {
DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityAndroid);
};
bool RegisterBrowserAccessibility(JNIEnv* env);
} // namespace content
#endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_ANDROID_H_
......@@ -13,19 +13,12 @@
#include "base/values.h"
#include "content/browser/accessibility/browser_accessibility_android.h"
#include "content/common/accessibility_messages.h"
#include "jni/BrowserAccessibilityManager_jni.h"
using base::android::AttachCurrentThread;
using base::android::ScopedJavaLocalRef;
namespace {
// These are enums from android.view.accessibility.AccessibilityEvent in Java:
enum {
ANDROID_ACCESSIBILITY_EVENT_TYPE_VIEW_TEXT_CHANGED = 16,
ANDROID_ACCESSIBILITY_EVENT_TYPE_VIEW_TEXT_SELECTION_CHANGED = 8192
};
// Restricts |val| to the range [min, max].
int Clamp(int val, int min, int max) {
return std::min(std::max(val, min), max);
......@@ -58,19 +51,16 @@ BrowserAccessibilityManagerAndroid::BrowserAccessibilityManagerAndroid(
if (content_view_core.is_null())
return;
JNIEnv* env = AttachCurrentThread();
java_ref_ = JavaObjectWeakGlobalRef(
env, Java_BrowserAccessibilityManager_create(
env, reinterpret_cast<jint>(this), content_view_core.obj()).obj());
// TODO(aboxhall): set up Java references
}
BrowserAccessibilityManagerAndroid::~BrowserAccessibilityManagerAndroid() {
JNIEnv* env = AttachCurrentThread();
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
if (obj.is_null())
return;
Java_BrowserAccessibilityManager_onNativeObjectDestroyed(env, obj.obj());
// TODO(aboxhall): tear down Java references
}
// static
......@@ -85,62 +75,13 @@ AccessibilityNodeData BrowserAccessibilityManagerAndroid::GetEmptyDocument() {
void BrowserAccessibilityManagerAndroid::NotifyAccessibilityEvent(
int type,
BrowserAccessibility* node) {
JNIEnv* env = AttachCurrentThread();
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
if (obj.is_null())
return;
switch (type) {
case AccessibilityNotificationLoadComplete:
Java_BrowserAccessibilityManager_handlePageLoaded(
env, obj.obj(), focus_->renderer_id());
break;
case AccessibilityNotificationFocusChanged:
Java_BrowserAccessibilityManager_handleFocusChanged(
env, obj.obj(), node->renderer_id());
break;
case AccessibilityNotificationCheckStateChanged:
Java_BrowserAccessibilityManager_handleCheckStateChanged(
env, obj.obj(), node->renderer_id());
break;
case AccessibilityNotificationScrolledToAnchor:
Java_BrowserAccessibilityManager_handleScrolledToAnchor(
env, obj.obj(), node->renderer_id());
break;
case AccessibilityNotificationAlert:
// An alert is a special case of live region. Fall through to the
// next case to handle it.
case AccessibilityNotificationObjectShow: {
// This event is fired when an object appears in a live region.
// Speak its text.
BrowserAccessibilityAndroid* android_node =
static_cast<BrowserAccessibilityAndroid*>(node);
Java_BrowserAccessibilityManager_announceLiveRegionText(
env, obj.obj(),
base::android::ConvertUTF16ToJavaString(
env, android_node->GetText()).obj());
break;
}
case AccessibilityNotificationSelectedTextChanged:
Java_BrowserAccessibilityManager_handleTextSelectionChanged(
env, obj.obj(), node->renderer_id());
break;
case AccessibilityNotificationChildrenChanged:
case AccessibilityNotificationTextChanged:
case AccessibilityNotificationValueChanged:
if (node->IsEditableText()) {
Java_BrowserAccessibilityManager_handleEditableTextChanged(
env, obj.obj(), node->renderer_id());
} else {
Java_BrowserAccessibilityManager_handleContentChanged(
env, obj.obj(), node->renderer_id());
}
break;
default:
// There are some notifications that aren't meaningful on Android.
// It's okay to skip them.
break;
}
// TODO(aboxhall): call into appropriate Java method for each type of
// notification
}
jint BrowserAccessibilityManagerAndroid::GetRootId(JNIEnv* env, jobject obj) {
......@@ -168,128 +109,6 @@ jint BrowserAccessibilityManagerAndroid::HitTest(
return root_->renderer_id();
}
jboolean BrowserAccessibilityManagerAndroid::PopulateAccessibilityNodeInfo(
JNIEnv* env, jobject obj, jobject info, jint id) {
BrowserAccessibilityAndroid* node = static_cast<BrowserAccessibilityAndroid*>(
GetFromRendererID(id));
if (!node)
return false;
if (node->parent()) {
Java_BrowserAccessibilityManager_setAccessibilityNodeInfoParent(
env, obj, info, node->parent()->renderer_id());
}
if (!node->IsLeaf()) {
for (unsigned i = 0; i < node->child_count(); ++i) {
Java_BrowserAccessibilityManager_addAccessibilityNodeInfoChild(
env, obj, info, node->children()[i]->renderer_id());
}
}
Java_BrowserAccessibilityManager_setAccessibilityNodeInfoBooleanAttributes(
env, obj, info,
node->IsCheckable(),
node->IsChecked(),
node->IsClickable(),
node->IsEnabled(),
node->IsFocusable(),
node->IsFocused(),
node->IsPassword(),
node->IsScrollable(),
node->IsSelected(),
node->IsVisibleToUser());
Java_BrowserAccessibilityManager_setAccessibilityNodeInfoStringAttributes(
env, obj, info,
base::android::ConvertUTF8ToJavaString(env, node->GetClassName()).obj(),
base::android::ConvertUTF16ToJavaString(env, node->GetText()).obj());
gfx::Rect absolute_rect = node->GetLocalBoundsRect();
gfx::Rect parent_relative_rect = absolute_rect;
if (node->parent()) {
gfx::Rect parent_rect = node->parent()->GetLocalBoundsRect();
parent_relative_rect.Offset(-parent_rect.OffsetFromOrigin());
}
bool is_root = node->parent() == NULL;
Java_BrowserAccessibilityManager_setAccessibilityNodeInfoLocation(
env, obj, info,
absolute_rect.x(), absolute_rect.y(),
parent_relative_rect.x(), parent_relative_rect.y(),
absolute_rect.width(), absolute_rect.height(),
is_root);
return true;
}
jboolean BrowserAccessibilityManagerAndroid::PopulateAccessibilityEvent(
JNIEnv* env, jobject obj, jobject event, jint id, jint event_type) {
BrowserAccessibilityAndroid* node = static_cast<BrowserAccessibilityAndroid*>(
GetFromRendererID(id));
if (!node)
return false;
Java_BrowserAccessibilityManager_setAccessibilityEventBooleanAttributes(
env, obj, event,
node->IsChecked(),
node->IsEnabled(),
node->IsPassword(),
node->IsScrollable());
Java_BrowserAccessibilityManager_setAccessibilityEventClassName(
env, obj, event,
base::android::ConvertUTF8ToJavaString(env, node->GetClassName()).obj());
Java_BrowserAccessibilityManager_setAccessibilityEventListAttributes(
env, obj, event,
node->GetItemIndex(),
node->GetItemCount());
Java_BrowserAccessibilityManager_setAccessibilityEventScrollAttributes(
env, obj, event,
node->GetScrollX(),
node->GetScrollY(),
node->GetMaxScrollX(),
node->GetMaxScrollY());
switch (event_type) {
case ANDROID_ACCESSIBILITY_EVENT_TYPE_VIEW_TEXT_CHANGED:
Java_BrowserAccessibilityManager_setAccessibilityEventTextChangedAttrs(
env, obj, event,
node->GetTextChangeFromIndex(),
node->GetTextChangeAddedCount(),
node->GetTextChangeRemovedCount(),
base::android::ConvertUTF16ToJavaString(
env, node->GetTextChangeBeforeText()).obj(),
base::android::ConvertUTF16ToJavaString(env, node->GetText()).obj());
break;
case ANDROID_ACCESSIBILITY_EVENT_TYPE_VIEW_TEXT_SELECTION_CHANGED:
Java_BrowserAccessibilityManager_setAccessibilityEventSelectionAttrs(
env, obj, event,
node->GetSelectionStart(),
node->GetSelectionEnd(),
node->GetEditableTextLength(),
base::android::ConvertUTF16ToJavaString(env, node->GetText()).obj());
break;
default:
break;
}
return true;
}
void BrowserAccessibilityManagerAndroid::Click(
JNIEnv* env, jobject obj, jint id) {
BrowserAccessibility* node = GetFromRendererID(id);
if (node)
DoDefaultAction(*node);
}
void BrowserAccessibilityManagerAndroid::Focus(
JNIEnv* env, jobject obj, jint id) {
BrowserAccessibility* node = GetFromRendererID(id);
if (node)
SetFocus(node, true);
}
void BrowserAccessibilityManagerAndroid::Blur(JNIEnv* env, jobject obj) {
SetFocus(root_, true);
}
BrowserAccessibility* BrowserAccessibilityManagerAndroid::FuzzyHitTest(
int x, int y, BrowserAccessibility* start_node) {
BrowserAccessibility* nearest_node = NULL;
......@@ -316,7 +135,7 @@ void BrowserAccessibilityManagerAndroid::FuzzyHitTestImpl(
return;
}
if (!node->GetText().empty()) {
if (!node->ComputeName().empty()) {
if (distance < *nearest_distance) {
*nearest_candidate = node;
*nearest_distance = distance;
......@@ -343,13 +162,13 @@ int BrowserAccessibilityManagerAndroid::CalculateDistanceSquared(
return dx * dx + dy * dy;
}
void BrowserAccessibilityManagerAndroid::NotifyRootChanged() {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
if (obj.is_null())
return;
jint BrowserAccessibilityManagerAndroid::GetNativeNodeById(
JNIEnv* env, jobject obj, jint id) {
return reinterpret_cast<jint>(GetFromRendererID(id));
}
Java_BrowserAccessibilityManager_handleNavigate(env, obj.obj());
void BrowserAccessibilityManagerAndroid::NotifyRootChanged() {
// TODO(aboxhall): non-stub implementation
}
bool
......@@ -359,7 +178,8 @@ BrowserAccessibilityManagerAndroid::UseRootScrollOffsetsWhenComputingBounds() {
}
bool RegisterBrowserAccessibilityManager(JNIEnv* env) {
return RegisterNativesImpl(env);
// TODO(aboxhall): non-stub implementation
return false;
}
} // namespace content
......@@ -41,16 +41,9 @@ class CONTENT_EXPORT BrowserAccessibilityManagerAndroid
jint GetRootId(JNIEnv* env, jobject obj);
jint HitTest(JNIEnv* env, jobject obj, jint x, jint y);
// Populate Java accessibility data structures with info about a node.
jboolean PopulateAccessibilityNodeInfo(
JNIEnv* env, jobject obj, jobject info, jint id);
jboolean PopulateAccessibilityEvent(
JNIEnv* env, jobject obj, jobject event, jint id, jint event_type);
// Perform actions.
void Click(JNIEnv* env, jobject obj, jint id);
void Focus(JNIEnv* env, jobject obj, jint id);
void Blur(JNIEnv* env, jobject obj);
// Gets a temporary pointer to a specific node, only valid in this scope.
// May return 0 if that node id is no longer valid.
jint GetNativeNodeById(JNIEnv* env, jobject obj, jint id);
protected:
virtual void NotifyRootChanged() OVERRIDE;
......
......@@ -6,8 +6,6 @@
#include "base/android/jni_android.h"
#include "base/android/jni_registrar.h"
#include "content/browser/accessibility/browser_accessibility_android.h"
#include "content/browser/accessibility/browser_accessibility_manager_android.h"
#include "content/browser/android/android_browser_process.h"
#include "content/browser/android/child_process_launcher_android.h"
#include "content/browser/android/content_settings.h"
......@@ -36,8 +34,6 @@ base::android::RegistrationMethod kContentRegisteredMethods[] = {
{ "AndroidLocationApiAdapter",
content::AndroidLocationApiAdapter::RegisterGeolocationService },
{ "AndroidBrowserProcess", content::RegisterAndroidBrowserProcess },
{ "BrowserAccessibilityManager",
content::RegisterBrowserAccessibilityManager },
{ "ChildProcessLauncher", content::RegisterChildProcessLauncher },
{ "ContentSettings", content::ContentSettings::RegisterContentSettings },
{ "ContentViewRenderView",
......
......@@ -32,7 +32,6 @@
#include "content/browser/web_contents/web_contents_view_android.h"
#include "content/common/input_messages.h"
#include "content/common/view_messages.h"
#include "content/public/browser/browser_accessibility_state.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/favicon_status.h"
#include "content/public/browser/notification_details.h"
......@@ -1573,19 +1572,6 @@ void ContentViewCoreImpl::SetUseDesktopUserAgent(
}
}
void ContentViewCoreImpl::SetAccessibilityEnabled(JNIEnv* env, jobject obj,
bool enabled) {
RenderWidgetHostImpl* host_impl = RenderWidgetHostImpl::From(
GetRenderWidgetHostViewAndroid()->GetRenderWidgetHost());
if (enabled) {
BrowserAccessibilityState::GetInstance()->EnableAccessibility();
host_impl->SetAccessibilityMode(AccessibilityModeComplete);
} else {
BrowserAccessibilityState::GetInstance()->DisableAccessibility();
host_impl->SetAccessibilityMode(AccessibilityModeOff);
}
}
// This is called for each ContentView.
jint Init(JNIEnv* env, jobject obj,
jboolean hardware_accelerated,
......
......@@ -221,7 +221,6 @@ class ContentViewCoreImpl : public ContentViewCore,
jint player_id,
jobject jsurface);
void DetachExternalVideoSurface(JNIEnv* env, jobject obj, jint player_id);
void SetAccessibilityEnabled(JNIEnv* env, jobject obj, bool enabled);
// --------------------------------------------------------------------------
// Public methods that call to Java via JNI
......
......@@ -11,7 +11,6 @@
'public/android/java/src/org/chromium/content/app/ChildProcessService.java',
'public/android/java/src/org/chromium/content/app/ContentMain.java',
'public/android/java/src/org/chromium/content/app/LibraryLoader.java',
'public/android/java/src/org/chromium/content/browser/accessibility/BrowserAccessibilityManager.java',
'public/android/java/src/org/chromium/content/browser/AndroidBrowserProcess.java',
'public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java',
'public/android/java/src/org/chromium/content/browser/ContentSettings.java',
......
......@@ -17,7 +17,6 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeProvider;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.widget.FrameLayout;
......@@ -489,14 +488,6 @@ public class ContentView extends FrameLayout
return mContentViewCore.onGenericMotionEvent(event);
}
@Override
public boolean dispatchHoverEvent(MotionEvent event) {
if (mContentViewCore.dispatchHoverEvent(event)) {
return true;
}
return super.dispatchHoverEvent(event);
}
/**
* Sets the current amount to offset incoming touch events by. This is used to handle content
* moving and not lining up properly with the android input system.
......@@ -587,16 +578,6 @@ public class ContentView extends FrameLayout
return mContentViewCore.getContentViewGestureHandler().getSingleTapY();
}
@Override
public AccessibilityNodeProvider getAccessibilityNodeProvider() {
AccessibilityNodeProvider provider = mContentViewCore.getAccessibilityNodeProvider();
if (provider != null) {
return provider;
} else {
return super.getAccessibilityNodeProvider();
}
}
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
......
......@@ -130,17 +130,27 @@ public class AccessibilityInjector extends WebContentsObserverAndroid {
if (!accessibilityIsAvailable()) return;
int axsParameterValue = getAxsUrlParameterValue();
if (axsParameterValue != ACCESSIBILITY_SCRIPT_INJECTION_UNDEFINED) {
return;
}
String js = getScreenReaderInjectingJs();
if (mContentViewCore.isDeviceAccessibilityScriptInjectionEnabled() &&
js != null && mContentViewCore.isAlive()) {
addOrRemoveAccessibilityApisIfNecessary();
mContentViewCore.evaluateJavaScript(js, null);
mInjectedScriptEnabled = true;
mScriptInjected = true;
if (axsParameterValue == ACCESSIBILITY_SCRIPT_INJECTION_UNDEFINED) {
try {
Field field = Settings.Secure.class.getField("ACCESSIBILITY_SCRIPT_INJECTION");
field.setAccessible(true);
String ACCESSIBILITY_SCRIPT_INJECTION = (String) field.get(null);
boolean onDeviceScriptInjectionEnabled = (Settings.Secure.getInt(
mContentViewCore.getContext().getContentResolver(),
ACCESSIBILITY_SCRIPT_INJECTION, 0) == 1);
String js = getScreenReaderInjectingJs();
if (onDeviceScriptInjectionEnabled && js != null && mContentViewCore.isAlive()) {
addOrRemoveAccessibilityApisIfNecessary();
mContentViewCore.evaluateJavaScript(js, null);
mInjectedScriptEnabled = true;
mScriptInjected = true;
}
} catch (NoSuchFieldException ex) {
} catch (IllegalArgumentException ex) {
} catch (IllegalAccessException ex) {
}
}
}
......@@ -188,11 +198,10 @@ public class AccessibilityInjector extends WebContentsObserverAndroid {
/**
* Sets whether or not the script is enabled. If the script is disabled, we also stop any
* we output that is occurring. If the script has not yet been injected, injects it.
* we output that is occurring.
* @param enabled Whether or not to enable the script.
*/
public void setScriptEnabled(boolean enabled) {
if (enabled && !mScriptInjected) injectAccessibilityScriptIntoPage();
if (!accessibilityIsAvailable() || mInjectedScriptEnabled == enabled) return;
mInjectedScriptEnabled = enabled;
......
......@@ -7,6 +7,7 @@ package org.chromium.content.browser.accessibility;
import android.content.Context;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.View;
import android.view.accessibility.AccessibilityNodeInfo;
import org.chromium.content.browser.ContentViewCore;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment