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; |