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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/accessibility/AccessibilityInjector.java

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 side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/accessibility/AccessibilityInjector.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/accessibility/AccessibilityInjector.java b/content/public/android/java/src/org/chromium/content/browser/accessibility/AccessibilityInjector.java
index c0dcf03a5f4ff6347092cab417bb8579f631248c..c2e933fbfbd25cb5dfc7f27400f0e26799aa9274 100644
--- a/content/public/android/java/src/org/chromium/content/browser/accessibility/AccessibilityInjector.java
+++ b/content/public/android/java/src/org/chromium/content/browser/accessibility/AccessibilityInjector.java
@@ -130,27 +130,22 @@ public class AccessibilityInjector extends WebContentsObserverAndroid {
if (!accessibilityIsAvailable()) return;
int axsParameterValue = getAxsUrlParameterValue();
- 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) {
+ if (axsParameterValue != ACCESSIBILITY_SCRIPT_INJECTION_UNDEFINED) {
+ return;
+ }
+
+ try {
+ String js = getScreenReaderInjectingJs();
+ if (mContentViewCore.onDeviceAccessibilityScriptInjectionEnabled() &&
+ js != null && mContentViewCore.isAlive()) {
+ addOrRemoveAccessibilityApisIfNecessary();
+ mContentViewCore.evaluateJavaScript(js, null);
+ mInjectedScriptEnabled = true;
+ mScriptInjected = true;
}
+ } catch (NoSuchFieldException ex) {
+ } catch (IllegalArgumentException ex) {
+ } catch (IllegalAccessException ex) {
bulach 2013/06/19 10:26:53 as above, probably best catching these at onDevice
dmazzoni 2013/06/19 19:54:41 Done.
}
}
@@ -198,10 +193,11 @@ 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.
+ * we output that is occurring. If the script has not yet been injected, injects it.
* @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;

Powered by Google App Engine
This is Rietveld 408576698