| 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..2a85b4fa6133edcc835ad36ec56a238b98bf3bc9 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,17 @@ 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;
|
| + }
|
| +
|
| + String js = getScreenReaderInjectingJs();
|
| + if (mContentViewCore.isDeviceAccessibilityScriptInjectionEnabled() &&
|
| + js != null && mContentViewCore.isAlive()) {
|
| + addOrRemoveAccessibilityApisIfNecessary();
|
| + mContentViewCore.evaluateJavaScript(js, null);
|
| + mInjectedScriptEnabled = true;
|
| + mScriptInjected = true;
|
| }
|
| }
|
|
|
| @@ -198,10 +188,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;
|
|
|