diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/webkit/AccessibilityInjector.java | 18 | ||||
-rw-r--r-- | core/java/android/webkit/WebSettingsClassic.java | 1 | ||||
-rw-r--r-- | core/java/android/webkit/WebViewClassic.java | 6 |
3 files changed, 25 insertions, 0 deletions
diff --git a/core/java/android/webkit/AccessibilityInjector.java b/core/java/android/webkit/AccessibilityInjector.java index 7dfb5bb..fd73fda 100644 --- a/core/java/android/webkit/AccessibilityInjector.java +++ b/core/java/android/webkit/AccessibilityInjector.java @@ -279,6 +279,7 @@ class AccessibilityInjector { } if (!shouldInjectJavaScript(url)) { + mAccessibilityScriptInjected = false; toggleFallbackAccessibilityInjector(true); return; } @@ -292,6 +293,23 @@ class AccessibilityInjector { } /** + * Adjusts the accessibility injection state to reflect changes in the + * JavaScript enabled state. + * + * @param enabled Whether JavaScript is enabled. + */ + public void updateJavaScriptEnabled(boolean enabled) { + if (enabled) { + addAccessibilityApisIfNecessary(); + } else { + removeAccessibilityApisIfNecessary(); + } + + // We have to reload the page after adding or removing APIs. + mWebView.reload(); + } + + /** * Toggles the non-JavaScript method for handling accessibility. * * @param enabled {@code true} to enable the non-JavaScript method, or diff --git a/core/java/android/webkit/WebSettingsClassic.java b/core/java/android/webkit/WebSettingsClassic.java index 66651f7..1be917e 100644 --- a/core/java/android/webkit/WebSettingsClassic.java +++ b/core/java/android/webkit/WebSettingsClassic.java @@ -1135,6 +1135,7 @@ public class WebSettingsClassic extends WebSettings { if (mJavaScriptEnabled != flag) { mJavaScriptEnabled = flag; postSync(); + mWebView.updateJavaScriptEnabled(flag); } } diff --git a/core/java/android/webkit/WebViewClassic.java b/core/java/android/webkit/WebViewClassic.java index 8d79492..a9efd7b 100644 --- a/core/java/android/webkit/WebViewClassic.java +++ b/core/java/android/webkit/WebViewClassic.java @@ -1626,6 +1626,12 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc mZoomManager.updateMultiTouchSupport(context); } + void updateJavaScriptEnabled(boolean enabled) { + if (isAccessibilityEnabled()) { + getAccessibilityInjector().updateJavaScriptEnabled(enabled); + } + } + private void init() { OnTrimMemoryListener.init(mContext); mWebView.setWillNotDraw(false); |