OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 && !mNativeAccessibilityEnabled && | |
2787 mNativeContentViewCore != 0 && Build.VERSION.SDK_INT >= Build.VERSIO N_CODES.JELLY_BEAN) { | |
David Trainor- moved to gerrit
2013/08/29 18:22:07
line too long
| |
2788 mNativeAccessibilityEnabled = true; | |
2789 nativeSetAccessibilityEnabled(mNativeContentViewCore, true); | |
2790 } | |
2791 | |
2792 return null; | |
2780 } | 2793 } |
2781 | 2794 |
2782 /** | 2795 /** |
2783 * @see View#onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo) | 2796 * @see View#onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo) |
2784 */ | 2797 */ |
2785 public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { | 2798 public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { |
2786 // Note: this is only used by the script-injecting accessibility code. | 2799 // Note: this is only used by the script-injecting accessibility code. |
2787 mAccessibilityInjector.onInitializeAccessibilityNodeInfo(info); | 2800 mAccessibilityInjector.onInitializeAccessibilityNodeInfo(info); |
2788 } | 2801 } |
2789 | 2802 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2856 * Returns whether or not accessibility injection is being used. | 2869 * Returns whether or not accessibility injection is being used. |
2857 */ | 2870 */ |
2858 public boolean isInjectingAccessibilityScript() { | 2871 public boolean isInjectingAccessibilityScript() { |
2859 return mAccessibilityInjector.accessibilityIsAvailable(); | 2872 return mAccessibilityInjector.accessibilityIsAvailable(); |
2860 } | 2873 } |
2861 | 2874 |
2862 /** | 2875 /** |
2863 * Turns browser accessibility on or off. | 2876 * Turns browser accessibility on or off. |
2864 * If |state| is |false|, this turns off both native and injected accessibil ity. | 2877 * 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 | 2878 * 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. | 2879 * accessibility scripts. Native accessibility is enabled on demand. |
2867 */ | 2880 */ |
2868 public void setAccessibilityState(boolean state) { | 2881 public void setAccessibilityState(boolean state) { |
2869 boolean injectedAccessibility = false; | 2882 if (!state) { |
2870 boolean nativeAccessibility = false; | 2883 setInjectedAccessibility(false); |
2871 if (state) { | 2884 return; |
2872 if (isDeviceAccessibilityScriptInjectionEnabled()) { | |
2873 injectedAccessibility = true; | |
2874 } else { | |
2875 nativeAccessibility = true; | |
2876 } | |
2877 } | 2885 } |
2878 setInjectedAccessibility(injectedAccessibility); | 2886 |
2879 setNativeAccessibilityState(nativeAccessibility); | 2887 if (isDeviceAccessibilityScriptInjectionEnabled()) { |
2888 setInjectedAccessibility(true); | |
2889 return; | |
2890 } | |
2891 | |
2892 mNativeAccessibilityAllowed = true; | |
2880 } | 2893 } |
2881 | 2894 |
2882 /** | 2895 /** |
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 | 2896 * Enable or disable injected accessibility features |
2894 */ | 2897 */ |
2895 public void setInjectedAccessibility(boolean enabled) { | 2898 public void setInjectedAccessibility(boolean enabled) { |
2896 mAccessibilityInjector.addOrRemoveAccessibilityApisIfNecessary(); | 2899 mAccessibilityInjector.addOrRemoveAccessibilityApisIfNecessary(); |
2897 mAccessibilityInjector.setScriptEnabled(enabled); | 2900 mAccessibilityInjector.setScriptEnabled(enabled); |
2898 } | 2901 } |
2899 | 2902 |
2900 /** | 2903 /** |
2901 * Stop any TTS notifications that are currently going on. | 2904 * Stop any TTS notifications that are currently going on. |
2902 */ | 2905 */ |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3190 | 3193 |
3191 private native void nativeAttachExternalVideoSurface( | 3194 private native void nativeAttachExternalVideoSurface( |
3192 int nativeContentViewCoreImpl, int playerId, Surface surface); | 3195 int nativeContentViewCoreImpl, int playerId, Surface surface); |
3193 | 3196 |
3194 private native void nativeDetachExternalVideoSurface( | 3197 private native void nativeDetachExternalVideoSurface( |
3195 int nativeContentViewCoreImpl, int playerId); | 3198 int nativeContentViewCoreImpl, int playerId); |
3196 | 3199 |
3197 private native void nativeSetAccessibilityEnabled( | 3200 private native void nativeSetAccessibilityEnabled( |
3198 int nativeContentViewCoreImpl, boolean enabled); | 3201 int nativeContentViewCoreImpl, boolean enabled); |
3199 } | 3202 } |
OLD | NEW |