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

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

Issue 23750002: Defer enabling native accessibility until it's used. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix wrap 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.content.ContentResolver; 8 import android.content.ContentResolver;
9 import android.content.Context; 9 import android.content.Context;
10 import android.content.pm.ActivityInfo; 10 import android.content.pm.ActivityInfo;
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 private boolean mSelectionEditable; 396 private boolean mSelectionEditable;
397 private ActionMode mActionMode; 397 private ActionMode mActionMode;
398 private boolean mUnselectAllOnActionModeDismiss; 398 private boolean mUnselectAllOnActionModeDismiss;
399 399
400 // Delegate that will handle GET downloads, and be notified of completion of POST downloads. 400 // Delegate that will handle GET downloads, and be notified of completion of POST downloads.
401 private ContentViewDownloadDelegate mDownloadDelegate; 401 private ContentViewDownloadDelegate mDownloadDelegate;
402 402
403 // The AccessibilityInjector that handles loading Accessibility scripts into the web page. 403 // The AccessibilityInjector that handles loading Accessibility scripts into the web page.
404 private AccessibilityInjector mAccessibilityInjector; 404 private AccessibilityInjector mAccessibilityInjector;
405 405
406 // Whether native accessibility, i.e. without any script injection, is allow ed.
407 private boolean mNativeAccessibilityAllowed;
408
409 // Whether native accessibility, i.e. without any script injection, has been enabled.
410 private boolean mNativeAccessibilityEnabled;
411
406 // Handles native accessibility, i.e. without any script injection. 412 // Handles native accessibility, i.e. without any script injection.
407 private BrowserAccessibilityManager mBrowserAccessibilityManager; 413 private BrowserAccessibilityManager mBrowserAccessibilityManager;
408 414
409 // System accessibility service. 415 // System accessibility service.
410 private final AccessibilityManager mAccessibilityManager; 416 private final AccessibilityManager mAccessibilityManager;
411 417
412 // Allows us to dynamically respond when the accessibility script injection flag changes. 418 // Allows us to dynamically respond when the accessibility script injection flag changes.
413 private ContentObserver mAccessibilityScriptInjectionObserver; 419 private ContentObserver mAccessibilityScriptInjectionObserver;
414 420
415 // Temporary notification to tell onSizeChanged to focus a form element, 421 // Temporary notification to tell onSizeChanged to focus a form element,
(...skipping 2346 matching lines...) Expand 10 before | Expand all | Expand 10 after
2762 * @return This view's BrowserAccessibilityManager. 2768 * @return This view's BrowserAccessibilityManager.
2763 */ 2769 */
2764 public BrowserAccessibilityManager getBrowserAccessibilityManager() { 2770 public BrowserAccessibilityManager getBrowserAccessibilityManager() {
2765 return mBrowserAccessibilityManager; 2771 return mBrowserAccessibilityManager;
2766 } 2772 }
2767 2773
2768 /** 2774 /**
2769 * If native accessibility (not script injection) is enabled, and if this is 2775 * If native accessibility (not script injection) is enabled, and if this is
2770 * running on JellyBean or later, returns an AccessibilityNodeProvider that 2776 * running on JellyBean or later, returns an AccessibilityNodeProvider that
2771 * implements native accessibility for this view. Returns null otherwise. 2777 * implements native accessibility for this view. Returns null otherwise.
2778 * Lazily initializes native accessibility here if it's allowed.
2772 * @return The AccessibilityNodeProvider, if available, or null otherwise. 2779 * @return The AccessibilityNodeProvider, if available, or null otherwise.
2773 */ 2780 */
2774 public AccessibilityNodeProvider getAccessibilityNodeProvider() { 2781 public AccessibilityNodeProvider getAccessibilityNodeProvider() {
2775 if (mBrowserAccessibilityManager != null) { 2782 if (mBrowserAccessibilityManager != null) {
2776 return mBrowserAccessibilityManager.getAccessibilityNodeProvider(); 2783 return mBrowserAccessibilityManager.getAccessibilityNodeProvider();
2777 } else {
2778 return null;
2779 } 2784 }
2785
2786 if (mNativeAccessibilityAllowed &&
2787 !mNativeAccessibilityEnabled &&
2788 mNativeContentViewCore != 0 &&
2789 Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
2790 mNativeAccessibilityEnabled = true;
2791 nativeSetAccessibilityEnabled(mNativeContentViewCore, true);
2792 }
2793
2794 return null;
2780 } 2795 }
2781 2796
2782 /** 2797 /**
2783 * @see View#onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo) 2798 * @see View#onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo)
2784 */ 2799 */
2785 public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { 2800 public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
2786 // Note: this is only used by the script-injecting accessibility code. 2801 // Note: this is only used by the script-injecting accessibility code.
2787 mAccessibilityInjector.onInitializeAccessibilityNodeInfo(info); 2802 mAccessibilityInjector.onInitializeAccessibilityNodeInfo(info);
2788 } 2803 }
2789 2804
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2856 * Returns whether or not accessibility injection is being used. 2871 * Returns whether or not accessibility injection is being used.
2857 */ 2872 */
2858 public boolean isInjectingAccessibilityScript() { 2873 public boolean isInjectingAccessibilityScript() {
2859 return mAccessibilityInjector.accessibilityIsAvailable(); 2874 return mAccessibilityInjector.accessibilityIsAvailable();
2860 } 2875 }
2861 2876
2862 /** 2877 /**
2863 * Turns browser accessibility on or off. 2878 * Turns browser accessibility on or off.
2864 * If |state| is |false|, this turns off both native and injected accessibil ity. 2879 * If |state| is |false|, this turns off both native and injected accessibil ity.
2865 * Otherwise, if accessibility script injection is enabled, this will enable the injected 2880 * Otherwise, if accessibility script injection is enabled, this will enable the injected
2866 * accessibility scripts, and if it is disabled this will enable the native accessibility. 2881 * accessibility scripts. Native accessibility is enabled on demand.
2867 */ 2882 */
2868 public void setAccessibilityState(boolean state) { 2883 public void setAccessibilityState(boolean state) {
2869 boolean injectedAccessibility = false; 2884 if (!state) {
2870 boolean nativeAccessibility = false; 2885 setInjectedAccessibility(false);
2871 if (state) { 2886 return;
2872 if (isDeviceAccessibilityScriptInjectionEnabled()) {
2873 injectedAccessibility = true;
2874 } else {
2875 nativeAccessibility = true;
2876 }
2877 } 2887 }
2878 setInjectedAccessibility(injectedAccessibility); 2888
2879 setNativeAccessibilityState(nativeAccessibility); 2889 if (isDeviceAccessibilityScriptInjectionEnabled()) {
2890 setInjectedAccessibility(true);
2891 return;
2892 }
2893
2894 mNativeAccessibilityAllowed = true;
2880 } 2895 }
2881 2896
2882 /** 2897 /**
2883 * Enable or disable native accessibility features.
2884 */
2885 public void setNativeAccessibilityState(boolean enabled) {
2886 if (mNativeContentViewCore == 0) return;
2887 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
2888 nativeSetAccessibilityEnabled(mNativeContentViewCore, enabled);
2889 }
2890 }
2891
2892 /**
2893 * Enable or disable injected accessibility features 2898 * Enable or disable injected accessibility features
2894 */ 2899 */
2895 public void setInjectedAccessibility(boolean enabled) { 2900 public void setInjectedAccessibility(boolean enabled) {
2896 mAccessibilityInjector.addOrRemoveAccessibilityApisIfNecessary(); 2901 mAccessibilityInjector.addOrRemoveAccessibilityApisIfNecessary();
2897 mAccessibilityInjector.setScriptEnabled(enabled); 2902 mAccessibilityInjector.setScriptEnabled(enabled);
2898 } 2903 }
2899 2904
2900 /** 2905 /**
2901 * Stop any TTS notifications that are currently going on. 2906 * Stop any TTS notifications that are currently going on.
2902 */ 2907 */
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
3190 3195
3191 private native void nativeAttachExternalVideoSurface( 3196 private native void nativeAttachExternalVideoSurface(
3192 int nativeContentViewCoreImpl, int playerId, Surface surface); 3197 int nativeContentViewCoreImpl, int playerId, Surface surface);
3193 3198
3194 private native void nativeDetachExternalVideoSurface( 3199 private native void nativeDetachExternalVideoSurface(
3195 int nativeContentViewCoreImpl, int playerId); 3200 int nativeContentViewCoreImpl, int playerId);
3196 3201
3197 private native void nativeSetAccessibilityEnabled( 3202 private native void nativeSetAccessibilityEnabled(
3198 int nativeContentViewCoreImpl, boolean enabled); 3203 int nativeContentViewCoreImpl, boolean enabled);
3199 } 3204 }
OLDNEW
« 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