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

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

Issue 23503028: Merge 220541 "Defer enabling native accessibility until it's used." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1599/src/
Patch Set: Created 7 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
===================================================================
--- content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java (revision 220949)
+++ content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java (working copy)
@@ -403,6 +403,12 @@
// The AccessibilityInjector that handles loading Accessibility scripts into the web page.
private AccessibilityInjector mAccessibilityInjector;
+ // Whether native accessibility, i.e. without any script injection, is allowed.
+ private boolean mNativeAccessibilityAllowed;
+
+ // Whether native accessibility, i.e. without any script injection, has been enabled.
+ private boolean mNativeAccessibilityEnabled;
+
// Handles native accessibility, i.e. without any script injection.
private BrowserAccessibilityManager mBrowserAccessibilityManager;
@@ -2769,14 +2775,23 @@
* If native accessibility (not script injection) is enabled, and if this is
* running on JellyBean or later, returns an AccessibilityNodeProvider that
* implements native accessibility for this view. Returns null otherwise.
+ * Lazily initializes native accessibility here if it's allowed.
* @return The AccessibilityNodeProvider, if available, or null otherwise.
*/
public AccessibilityNodeProvider getAccessibilityNodeProvider() {
if (mBrowserAccessibilityManager != null) {
return mBrowserAccessibilityManager.getAccessibilityNodeProvider();
- } else {
- return null;
}
+
+ if (mNativeAccessibilityAllowed &&
+ !mNativeAccessibilityEnabled &&
+ mNativeContentViewCore != 0 &&
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+ mNativeAccessibilityEnabled = true;
+ nativeSetAccessibilityEnabled(mNativeContentViewCore, true);
+ }
+
+ return null;
}
/**
@@ -2863,29 +2878,20 @@
* Turns browser accessibility on or off.
* If |state| is |false|, this turns off both native and injected accessibility.
* Otherwise, if accessibility script injection is enabled, this will enable the injected
- * accessibility scripts, and if it is disabled this will enable the native accessibility.
+ * accessibility scripts. Native accessibility is enabled on demand.
*/
public void setAccessibilityState(boolean state) {
- boolean injectedAccessibility = false;
- boolean nativeAccessibility = false;
- if (state) {
- if (isDeviceAccessibilityScriptInjectionEnabled()) {
- injectedAccessibility = true;
- } else {
- nativeAccessibility = true;
- }
+ if (!state) {
+ setInjectedAccessibility(false);
+ return;
}
- setInjectedAccessibility(injectedAccessibility);
- setNativeAccessibilityState(nativeAccessibility);
- }
- /**
- * Enable or disable native accessibility features.
- */
- public void setNativeAccessibilityState(boolean enabled) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
- nativeSetAccessibilityEnabled(mNativeContentViewCore, enabled);
+ if (isDeviceAccessibilityScriptInjectionEnabled()) {
+ setInjectedAccessibility(true);
+ return;
}
+
+ mNativeAccessibilityAllowed = true;
}
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698