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

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

Issue 572013002: Removing ContentViewCore dependencies from direct WebContents functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased the patch and addressed review comments. Created 6 years, 2 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
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.accessibility; 5 package org.chromium.content.browser.accessibility;
6 6
7 import android.accessibilityservice.AccessibilityServiceInfo; 7 import android.accessibilityservice.AccessibilityServiceInfo;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.pm.PackageManager; 9 import android.content.pm.PackageManager;
10 import android.os.Build; 10 import android.os.Build;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 int axsParameterValue = getAxsUrlParameterValue(); 132 int axsParameterValue = getAxsUrlParameterValue();
133 if (axsParameterValue != ACCESSIBILITY_SCRIPT_INJECTION_UNDEFINED) { 133 if (axsParameterValue != ACCESSIBILITY_SCRIPT_INJECTION_UNDEFINED) {
134 return; 134 return;
135 } 135 }
136 136
137 String js = getScreenReaderInjectingJs(); 137 String js = getScreenReaderInjectingJs();
138 if (mContentViewCore.isDeviceAccessibilityScriptInjectionEnabled() && 138 if (mContentViewCore.isDeviceAccessibilityScriptInjectionEnabled() &&
139 js != null && mContentViewCore.isAlive()) { 139 js != null && mContentViewCore.isAlive()) {
140 addOrRemoveAccessibilityApisIfNecessary(); 140 addOrRemoveAccessibilityApisIfNecessary();
141 mContentViewCore.evaluateJavaScript(js, null); 141 mContentViewCore.getWebContents().evaluateJavaScript(js, null);
142 mInjectedScriptEnabled = true; 142 mInjectedScriptEnabled = true;
143 mScriptInjected = true; 143 mScriptInjected = true;
144 } 144 }
145 } 145 }
146 146
147 /** 147 /**
148 * Handles adding or removing accessibility related Java objects ({@link Tex tToSpeech} and 148 * Handles adding or removing accessibility related Java objects ({@link Tex tToSpeech} and
149 * {@link Vibrator}) interfaces from Javascript. This method should be call ed at a time when it 149 * {@link Vibrator}) interfaces from Javascript. This method should be call ed at a time when it
150 * is safe to add or remove these interfaces, specifically when the {@link C ontentViewCore} is 150 * is safe to add or remove these interfaces, specifically when the {@link C ontentViewCore} is
151 * first initialized or right before the {@link ContentViewCore} is about to navigate to a URL 151 * first initialized or right before the {@link ContentViewCore} is about to navigate to a URL
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 * @param enabled Whether or not to enable the script. 192 * @param enabled Whether or not to enable the script.
193 */ 193 */
194 public void setScriptEnabled(boolean enabled) { 194 public void setScriptEnabled(boolean enabled) {
195 if (enabled && !mScriptInjected) injectAccessibilityScriptIntoPage(); 195 if (enabled && !mScriptInjected) injectAccessibilityScriptIntoPage();
196 if (!accessibilityIsAvailable() || mInjectedScriptEnabled == enabled) re turn; 196 if (!accessibilityIsAvailable() || mInjectedScriptEnabled == enabled) re turn;
197 197
198 mInjectedScriptEnabled = enabled; 198 mInjectedScriptEnabled = enabled;
199 if (mContentViewCore.isAlive()) { 199 if (mContentViewCore.isAlive()) {
200 String js = String.format(TOGGLE_CHROME_VOX_JAVASCRIPT, Boolean.toSt ring( 200 String js = String.format(TOGGLE_CHROME_VOX_JAVASCRIPT, Boolean.toSt ring(
201 mInjectedScriptEnabled)); 201 mInjectedScriptEnabled));
202 mContentViewCore.evaluateJavaScript(js, null); 202 mContentViewCore.getWebContents().evaluateJavaScript(js, null);
203 203
204 if (!mInjectedScriptEnabled) { 204 if (!mInjectedScriptEnabled) {
205 // Stop any TTS/Vibration right now. 205 // Stop any TTS/Vibration right now.
206 onPageLostFocus(); 206 onPageLostFocus();
207 } 207 }
208 } 208 }
209 } 209 }
210 210
211 /** 211 /**
212 * Notifies this handler that a page load has started, which means we should mark the 212 * Notifies this handler that a page load has started, which means we should mark the
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 } 462 }
463 } 463 }
464 464
465 @SuppressWarnings("unused") 465 @SuppressWarnings("unused")
466 protected void shutdownInternal() { 466 protected void shutdownInternal() {
467 mTextToSpeech.shutdown(); 467 mTextToSpeech.shutdown();
468 mSelfBrailleClient.shutdown(); 468 mSelfBrailleClient.shutdown();
469 } 469 }
470 } 470 }
471 } 471 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698