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

Side by Side Diff: android_webview/glue/java/src/com/android/webview/chromium/WebViewChromium.java

Issue 2182683003: aw: Move thread hop code to ProviderFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 com.android.webview.chromium; 5 package com.android.webview.chromium;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.annotation.TargetApi; 8 import android.annotation.TargetApi;
9 import android.content.Context; 9 import android.content.Context;
10 import android.content.Intent; 10 import android.content.Intent;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 import org.chromium.android_webview.ResourcesContextWrapperFactory; 57 import org.chromium.android_webview.ResourcesContextWrapperFactory;
58 import org.chromium.base.ThreadUtils; 58 import org.chromium.base.ThreadUtils;
59 import org.chromium.base.annotations.SuppressFBWarnings; 59 import org.chromium.base.annotations.SuppressFBWarnings;
60 import org.chromium.content.browser.SmartClipProvider; 60 import org.chromium.content.browser.SmartClipProvider;
61 import org.chromium.content_public.browser.NavigationHistory; 61 import org.chromium.content_public.browser.NavigationHistory;
62 62
63 import java.io.BufferedWriter; 63 import java.io.BufferedWriter;
64 import java.io.File; 64 import java.io.File;
65 import java.lang.reflect.Method; 65 import java.lang.reflect.Method;
66 import java.util.Map; 66 import java.util.Map;
67 import java.util.Queue;
68 import java.util.concurrent.Callable; 67 import java.util.concurrent.Callable;
69 import java.util.concurrent.ConcurrentLinkedQueue;
70 import java.util.concurrent.FutureTask;
71 import java.util.concurrent.TimeUnit;
72 68
73 /** 69 /**
74 * This class is the delegate to which WebViewProxy forwards all API calls. 70 * This class is the delegate to which WebViewProxy forwards all API calls.
75 * 71 *
76 * Most of the actual functionality is implemented by AwContents (or ContentView Core within 72 * Most of the actual functionality is implemented by AwContents (or ContentView Core within
77 * it). This class also contains WebView-specific APIs that require the creation of other 73 * it). This class also contains WebView-specific APIs that require the creation of other
78 * adapters (otherwise org.chromium.content would depend on the webview.chromium package) 74 * adapters (otherwise org.chromium.content would depend on the webview.chromium package)
79 * and a small set of no-op deprecated APIs. 75 * and a small set of no-op deprecated APIs.
80 */ 76 */
81 @SuppressWarnings("deprecation") 77 @SuppressWarnings("deprecation")
82 class WebViewChromium implements WebViewProvider, WebViewProvider.ScrollDelegate , 78 class WebViewChromium implements WebViewProvider, WebViewProvider.ScrollDelegate ,
83 WebViewProvider.ViewDelegate, SmartClipProvider { 79 WebViewProvider.ViewDelegate, SmartClipProvider {
84 private class WebViewChromiumRunQueue {
85 public WebViewChromiumRunQueue() {
86 mQueue = new ConcurrentLinkedQueue<Runnable>();
87 }
88
89 public void addTask(Runnable task) {
90 mQueue.add(task);
91 if (mFactory.hasStarted()) {
92 ThreadUtils.runOnUiThread(new Runnable() {
93 @Override
94 public void run() {
95 drainQueue();
96 }
97 });
98 }
99 }
100
101 public void drainQueue() {
102 if (mQueue == null || mQueue.isEmpty()) {
103 return;
104 }
105
106 Runnable task = mQueue.poll();
107 while (task != null) {
108 task.run();
109 task = mQueue.poll();
110 }
111 }
112
113 private Queue<Runnable> mQueue;
114 }
115
116 private WebViewChromiumRunQueue mRunQueue;
117 80
118 private static final String TAG = WebViewChromium.class.getSimpleName(); 81 private static final String TAG = WebViewChromium.class.getSimpleName();
119 82
120 // The WebView that this WebViewChromium is the provider for. 83 // The WebView that this WebViewChromium is the provider for.
121 WebView mWebView; 84 WebView mWebView;
122 // Lets us access protected View-derived methods on the WebView instance we' re backing. 85 // Lets us access protected View-derived methods on the WebView instance we' re backing.
123 WebView.PrivateAccess mWebViewPrivate; 86 WebView.PrivateAccess mWebViewPrivate;
124 // The client adapter class. 87 // The client adapter class.
125 private WebViewContentsClientAdapter mContentsClientAdapter; 88 private WebViewContentsClientAdapter mContentsClientAdapter;
126 // The wrapped Context. 89 // The wrapped Context.
(...skipping 20 matching lines...) Expand all
147 // This does not touch any global / non-threadsafe state, but note that 110 // This does not touch any global / non-threadsafe state, but note that
148 // init is ofter called right after and is NOT threadsafe. 111 // init is ofter called right after and is NOT threadsafe.
149 public WebViewChromium(WebViewChromiumFactoryProvider factory, WebView webVi ew, 112 public WebViewChromium(WebViewChromiumFactoryProvider factory, WebView webVi ew,
150 WebView.PrivateAccess webViewPrivate) { 113 WebView.PrivateAccess webViewPrivate) {
151 mWebView = webView; 114 mWebView = webView;
152 mWebViewPrivate = webViewPrivate; 115 mWebViewPrivate = webViewPrivate;
153 mHitTestResult = new WebView.HitTestResult(); 116 mHitTestResult = new WebView.HitTestResult();
154 mContext = ResourcesContextWrapperFactory.get(mWebView.getContext()); 117 mContext = ResourcesContextWrapperFactory.get(mWebView.getContext());
155 mAppTargetSdkVersion = mContext.getApplicationInfo().targetSdkVersion; 118 mAppTargetSdkVersion = mContext.getApplicationInfo().targetSdkVersion;
156 mFactory = factory; 119 mFactory = factory;
157 mRunQueue = new WebViewChromiumRunQueue();
158 factory.getWebViewDelegate().addWebViewAssetPath(mWebView.getContext()); 120 factory.getWebViewDelegate().addWebViewAssetPath(mWebView.getContext());
159 } 121 }
160 122
161 static void completeWindowCreation(WebView parent, WebView child) { 123 static void completeWindowCreation(WebView parent, WebView child) {
162 AwContents parentContents = ((WebViewChromium) parent.getWebViewProvider ()).mAwContents; 124 AwContents parentContents = ((WebViewChromium) parent.getWebViewProvider ()).mAwContents;
163 AwContents childContents = 125 AwContents childContents =
164 child == null ? null : ((WebViewChromium) child.getWebViewProvid er()).mAwContents; 126 child == null ? null : ((WebViewChromium) child.getWebViewProvid er()).mAwContents;
165 parentContents.supplyContentsForPopup(childContents); 127 parentContents.supplyContentsForPopup(childContents);
166 } 128 }
167 129
168 private <T> T runBlockingFuture(FutureTask<T> task) {
169 if (!mFactory.hasStarted()) throw new RuntimeException("Must be started before we block!");
170 if (ThreadUtils.runningOnUiThread()) {
171 throw new IllegalStateException("This method should only be called o ff the UI thread");
172 }
173 mRunQueue.addTask(task);
174 try {
175 return task.get(4, TimeUnit.SECONDS);
176 } catch (java.util.concurrent.TimeoutException e) {
177 throw new RuntimeException("Probable deadlock detected due to WebVie w API being called "
178 + "on incorrect thread while the UI thread is blocke d.", e);
179 } catch (Exception e) {
180 throw new RuntimeException(e);
181 }
182 }
183
184 // We have a 4 second timeout to try to detect deadlocks to detect and aid i n debuggin
185 // deadlocks.
186 // Do not call this method while on the UI thread!
187 private void runVoidTaskOnUiThreadBlocking(Runnable r) {
188 FutureTask<Void> task = new FutureTask<Void>(r, null);
189 runBlockingFuture(task);
190 }
191
192 private <T> T runOnUiThreadBlocking(Callable<T> c) {
193 return runBlockingFuture(new FutureTask<T>(c));
194 }
195
196 // WebViewProvider methods ------------------------------------------------- ------------------- 130 // WebViewProvider methods ------------------------------------------------- -------------------
197 131
198 @Override 132 @Override
199 // BUG=6790250 |javaScriptInterfaces| was only ever used by the obsolete Dum pRenderTree 133 // BUG=6790250 |javaScriptInterfaces| was only ever used by the obsolete Dum pRenderTree
200 // so is ignored. TODO: remove it from WebViewProvider. 134 // so is ignored. TODO: remove it from WebViewProvider.
201 @TargetApi(Build.VERSION_CODES.LOLLIPOP) 135 @TargetApi(Build.VERSION_CODES.LOLLIPOP)
202 public void init(final Map<String, Object> javaScriptInterfaces, 136 public void init(final Map<String, Object> javaScriptInterfaces,
203 final boolean privateBrowsing) { 137 final boolean privateBrowsing) {
204 if (privateBrowsing) { 138 if (privateBrowsing) {
205 mFactory.startYourEngines(true); 139 mFactory.startYourEngines(true);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 areLegacyQuirksEnabled, allowEmptyDocumentPersistence, 176 areLegacyQuirksEnabled, allowEmptyDocumentPersistence,
243 allowGeolocationOnInsecureOrigins)); 177 allowGeolocationOnInsecureOrigins));
244 178
245 if (mAppTargetSdkVersion < Build.VERSION_CODES.LOLLIPOP) { 179 if (mAppTargetSdkVersion < Build.VERSION_CODES.LOLLIPOP) {
246 // Prior to Lollipop we always allowed third party cookies and mixed content. 180 // Prior to Lollipop we always allowed third party cookies and mixed content.
247 mWebSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_AL LOW); 181 mWebSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_AL LOW);
248 mWebSettings.setAcceptThirdPartyCookies(true); 182 mWebSettings.setAcceptThirdPartyCookies(true);
249 mWebSettings.getAwSettings().setZeroLayoutHeightDisablesViewportQuir k(true); 183 mWebSettings.getAwSettings().setZeroLayoutHeightDisablesViewportQuir k(true);
250 } 184 }
251 185
252 mRunQueue.addTask(new Runnable() { 186 mFactory.addTask(new Runnable() {
253 @Override 187 @Override
254 public void run() { 188 public void run() {
255 initForReal(); 189 initForReal();
256 if (privateBrowsing) { 190 if (privateBrowsing) {
257 // Intentionally irreversibly disable the webview instance, so that private 191 // Intentionally irreversibly disable the webview instance, so that private
258 // user data cannot leak through misuse of a non-privateBrow ing WebView 192 // user data cannot leak through misuse of a non-privateBrow ing WebView
259 // instance. Can't just null out mAwContents as we never nul l-check it 193 // instance. Can't just null out mAwContents as we never nul l-check it
260 // before use. 194 // before use.
261 destroy(); 195 destroy();
262 } 196 }
(...skipping 18 matching lines...) Expand all
281 if (mAppTargetSdkVersion < Build.VERSION_CODES.LOLLIPOP) { 215 if (mAppTargetSdkVersion < Build.VERSION_CODES.LOLLIPOP) {
282 // Prior to Lollipop, JavaScript objects injected via addJavascriptI nterface 216 // Prior to Lollipop, JavaScript objects injected via addJavascriptI nterface
283 // were not inspectable. 217 // were not inspectable.
284 mAwContents.disableJavascriptInterfacesInspection(); 218 mAwContents.disableJavascriptInterfacesInspection();
285 } 219 }
286 220
287 // TODO: This assumes AwContents ignores second Paint param. 221 // TODO: This assumes AwContents ignores second Paint param.
288 mAwContents.setLayerType(mWebView.getLayerType(), null); 222 mAwContents.setLayerType(mWebView.getLayerType(), null);
289 } 223 }
290 224
291 void startYourEngine() {
292 mRunQueue.drainQueue();
293 }
294
295 private RuntimeException createThreadException() { 225 private RuntimeException createThreadException() {
296 return new IllegalStateException( 226 return new IllegalStateException(
297 "Calling View methods on another thread than the UI thread."); 227 "Calling View methods on another thread than the UI thread.");
298 } 228 }
299 229
300 private boolean checkNeedsPost() { 230 private boolean checkNeedsPost() {
301 boolean needsPost = !mFactory.hasStarted() || !ThreadUtils.runningOnUiTh read(); 231 boolean needsPost = !mFactory.hasStarted() || !ThreadUtils.runningOnUiTh read();
302 if (!needsPost && mAwContents == null) { 232 if (!needsPost && mAwContents == null) {
303 throw new IllegalStateException("AwContents must be created if we ar e not posting!"); 233 throw new IllegalStateException("AwContents must be created if we ar e not posting!");
304 } 234 }
(...skipping 10 matching lines...) Expand all
315 throw threadViolation; 245 throw threadViolation;
316 } 246 }
317 }); 247 });
318 throw createThreadException(); 248 throw createThreadException();
319 } 249 }
320 } 250 }
321 251
322 @Override 252 @Override
323 public void setHorizontalScrollbarOverlay(final boolean overlay) { 253 public void setHorizontalScrollbarOverlay(final boolean overlay) {
324 if (checkNeedsPost()) { 254 if (checkNeedsPost()) {
325 mRunQueue.addTask(new Runnable() { 255 mFactory.addTask(new Runnable() {
326 @Override 256 @Override
327 public void run() { 257 public void run() {
328 setHorizontalScrollbarOverlay(overlay); 258 setHorizontalScrollbarOverlay(overlay);
329 } 259 }
330 }); 260 });
331 return; 261 return;
332 } 262 }
333 mAwContents.setHorizontalScrollbarOverlay(overlay); 263 mAwContents.setHorizontalScrollbarOverlay(overlay);
334 } 264 }
335 265
336 @Override 266 @Override
337 public void setVerticalScrollbarOverlay(final boolean overlay) { 267 public void setVerticalScrollbarOverlay(final boolean overlay) {
338 if (checkNeedsPost()) { 268 if (checkNeedsPost()) {
339 mRunQueue.addTask(new Runnable() { 269 mFactory.addTask(new Runnable() {
340 @Override 270 @Override
341 public void run() { 271 public void run() {
342 setVerticalScrollbarOverlay(overlay); 272 setVerticalScrollbarOverlay(overlay);
343 } 273 }
344 }); 274 });
345 return; 275 return;
346 } 276 }
347 mAwContents.setVerticalScrollbarOverlay(overlay); 277 mAwContents.setVerticalScrollbarOverlay(overlay);
348 } 278 }
349 279
350 @Override 280 @Override
351 public boolean overlayHorizontalScrollbar() { 281 public boolean overlayHorizontalScrollbar() {
352 mFactory.startYourEngines(false); 282 mFactory.startYourEngines(false);
353 if (checkNeedsPost()) { 283 if (checkNeedsPost()) {
354 boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 284 boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
355 @Override 285 @Override
356 public Boolean call() { 286 public Boolean call() {
357 return overlayHorizontalScrollbar(); 287 return overlayHorizontalScrollbar();
358 } 288 }
359 }); 289 });
360 return ret; 290 return ret;
361 } 291 }
362 return mAwContents.overlayHorizontalScrollbar(); 292 return mAwContents.overlayHorizontalScrollbar();
363 } 293 }
364 294
365 @Override 295 @Override
366 public boolean overlayVerticalScrollbar() { 296 public boolean overlayVerticalScrollbar() {
367 mFactory.startYourEngines(false); 297 mFactory.startYourEngines(false);
368 if (checkNeedsPost()) { 298 if (checkNeedsPost()) {
369 boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 299 boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
370 @Override 300 @Override
371 public Boolean call() { 301 public Boolean call() {
372 return overlayVerticalScrollbar(); 302 return overlayVerticalScrollbar();
373 } 303 }
374 }); 304 });
375 return ret; 305 return ret;
376 } 306 }
377 return mAwContents.overlayVerticalScrollbar(); 307 return mAwContents.overlayVerticalScrollbar();
378 } 308 }
379 309
380 @Override 310 @Override
381 public int getVisibleTitleHeight() { 311 public int getVisibleTitleHeight() {
382 // This is deprecated in WebView and should always return 0. 312 // This is deprecated in WebView and should always return 0.
383 return 0; 313 return 0;
384 } 314 }
385 315
386 @Override 316 @Override
387 public SslCertificate getCertificate() { 317 public SslCertificate getCertificate() {
388 mFactory.startYourEngines(true); 318 mFactory.startYourEngines(true);
389 if (checkNeedsPost()) { 319 if (checkNeedsPost()) {
390 SslCertificate ret = runOnUiThreadBlocking(new Callable<SslCertifica te>() { 320 SslCertificate ret = mFactory.runOnUiThreadBlocking(new Callable<Ssl Certificate>() {
391 @Override 321 @Override
392 public SslCertificate call() { 322 public SslCertificate call() {
393 return getCertificate(); 323 return getCertificate();
394 } 324 }
395 }); 325 });
396 return ret; 326 return ret;
397 } 327 }
398 return mAwContents.getCertificate(); 328 return mAwContents.getCertificate();
399 } 329 }
400 330
401 @Override 331 @Override
402 public void setCertificate(SslCertificate certificate) { 332 public void setCertificate(SslCertificate certificate) {
403 // intentional no-op 333 // intentional no-op
404 } 334 }
405 335
406 @Override 336 @Override
407 public void savePassword(String host, String username, String password) { 337 public void savePassword(String host, String username, String password) {
408 // This is a deprecated API: intentional no-op. 338 // This is a deprecated API: intentional no-op.
409 } 339 }
410 340
411 @Override 341 @Override
412 public void setHttpAuthUsernamePassword( 342 public void setHttpAuthUsernamePassword(
413 final String host, final String realm, final String username, final String password) { 343 final String host, final String realm, final String username, final String password) {
414 if (checkNeedsPost()) { 344 if (checkNeedsPost()) {
415 mRunQueue.addTask(new Runnable() { 345 mFactory.addTask(new Runnable() {
416 @Override 346 @Override
417 public void run() { 347 public void run() {
418 setHttpAuthUsernamePassword(host, realm, username, password) ; 348 setHttpAuthUsernamePassword(host, realm, username, password) ;
419 } 349 }
420 }); 350 });
421 return; 351 return;
422 } 352 }
423 mAwContents.setHttpAuthUsernamePassword(host, realm, username, password) ; 353 mAwContents.setHttpAuthUsernamePassword(host, realm, username, password) ;
424 } 354 }
425 355
426 @Override 356 @Override
427 public String[] getHttpAuthUsernamePassword(final String host, final String realm) { 357 public String[] getHttpAuthUsernamePassword(final String host, final String realm) {
428 mFactory.startYourEngines(true); 358 mFactory.startYourEngines(true);
429 if (checkNeedsPost()) { 359 if (checkNeedsPost()) {
430 String[] ret = runOnUiThreadBlocking(new Callable<String[]>() { 360 String[] ret = mFactory.runOnUiThreadBlocking(new Callable<String[]> () {
431 @Override 361 @Override
432 public String[] call() { 362 public String[] call() {
433 return getHttpAuthUsernamePassword(host, realm); 363 return getHttpAuthUsernamePassword(host, realm);
434 } 364 }
435 }); 365 });
436 return ret; 366 return ret;
437 } 367 }
438 return mAwContents.getHttpAuthUsernamePassword(host, realm); 368 return mAwContents.getHttpAuthUsernamePassword(host, realm);
439 } 369 }
440 370
441 @Override 371 @Override
442 public void destroy() { 372 public void destroy() {
443 if (checkNeedsPost()) { 373 if (checkNeedsPost()) {
444 mRunQueue.addTask(new Runnable() { 374 mFactory.addTask(new Runnable() {
445 @Override 375 @Override
446 public void run() { 376 public void run() {
447 destroy(); 377 destroy();
448 } 378 }
449 }); 379 });
450 return; 380 return;
451 } 381 }
452 382
453 // Make sure that we do not trigger any callbacks after destruction 383 // Make sure that we do not trigger any callbacks after destruction
454 mContentsClientAdapter.setWebChromeClient(null); 384 mContentsClientAdapter.setWebChromeClient(null);
455 mContentsClientAdapter.setWebViewClient(null); 385 mContentsClientAdapter.setWebViewClient(null);
456 mContentsClientAdapter.setPictureListener(null); 386 mContentsClientAdapter.setPictureListener(null);
457 mContentsClientAdapter.setFindListener(null); 387 mContentsClientAdapter.setFindListener(null);
458 mContentsClientAdapter.setDownloadListener(null); 388 mContentsClientAdapter.setDownloadListener(null);
459 389
460 mAwContents.destroy(); 390 mAwContents.destroy();
461 } 391 }
462 392
463 @Override 393 @Override
464 public void setNetworkAvailable(final boolean networkUp) { 394 public void setNetworkAvailable(final boolean networkUp) {
465 // Note that this purely toggles the JS navigator.online property. 395 // Note that this purely toggles the JS navigator.online property.
466 // It does not in affect chromium or network stack state in any way. 396 // It does not in affect chromium or network stack state in any way.
467 if (checkNeedsPost()) { 397 if (checkNeedsPost()) {
468 mRunQueue.addTask(new Runnable() { 398 mFactory.addTask(new Runnable() {
469 @Override 399 @Override
470 public void run() { 400 public void run() {
471 setNetworkAvailable(networkUp); 401 setNetworkAvailable(networkUp);
472 } 402 }
473 }); 403 });
474 return; 404 return;
475 } 405 }
476 mAwContents.setNetworkAvailable(networkUp); 406 mAwContents.setNetworkAvailable(networkUp);
477 } 407 }
478 408
479 @Override 409 @Override
480 public WebBackForwardList saveState(final Bundle outState) { 410 public WebBackForwardList saveState(final Bundle outState) {
481 mFactory.startYourEngines(true); 411 mFactory.startYourEngines(true);
482 if (checkNeedsPost()) { 412 if (checkNeedsPost()) {
483 WebBackForwardList ret = runOnUiThreadBlocking(new Callable<WebBackF orwardList>() { 413 WebBackForwardList ret =
484 @Override 414 mFactory.runOnUiThreadBlocking(new Callable<WebBackForwardLi st>() {
485 public WebBackForwardList call() { 415 @Override
486 return saveState(outState); 416 public WebBackForwardList call() {
487 } 417 return saveState(outState);
488 }); 418 }
419 });
489 return ret; 420 return ret;
490 } 421 }
491 if (outState == null) return null; 422 if (outState == null) return null;
492 if (!mAwContents.saveState(outState)) return null; 423 if (!mAwContents.saveState(outState)) return null;
493 return copyBackForwardList(); 424 return copyBackForwardList();
494 } 425 }
495 426
496 @Override 427 @Override
497 public boolean savePicture(Bundle b, File dest) { 428 public boolean savePicture(Bundle b, File dest) {
498 // Intentional no-op: hidden method on WebView. 429 // Intentional no-op: hidden method on WebView.
499 return false; 430 return false;
500 } 431 }
501 432
502 @Override 433 @Override
503 public boolean restorePicture(Bundle b, File src) { 434 public boolean restorePicture(Bundle b, File src) {
504 // Intentional no-op: hidden method on WebView. 435 // Intentional no-op: hidden method on WebView.
505 return false; 436 return false;
506 } 437 }
507 438
508 @Override 439 @Override
509 public WebBackForwardList restoreState(final Bundle inState) { 440 public WebBackForwardList restoreState(final Bundle inState) {
510 mFactory.startYourEngines(true); 441 mFactory.startYourEngines(true);
511 if (checkNeedsPost()) { 442 if (checkNeedsPost()) {
512 WebBackForwardList ret = runOnUiThreadBlocking(new Callable<WebBackF orwardList>() { 443 WebBackForwardList ret =
513 @Override 444 mFactory.runOnUiThreadBlocking(new Callable<WebBackForwardLi st>() {
514 public WebBackForwardList call() { 445 @Override
515 return restoreState(inState); 446 public WebBackForwardList call() {
516 } 447 return restoreState(inState);
517 }); 448 }
449 });
518 return ret; 450 return ret;
519 } 451 }
520 if (inState == null) return null; 452 if (inState == null) return null;
521 if (!mAwContents.restoreState(inState)) return null; 453 if (!mAwContents.restoreState(inState)) return null;
522 return copyBackForwardList(); 454 return copyBackForwardList();
523 } 455 }
524 456
525 @Override 457 @Override
526 public void loadUrl(final String url, final Map<String, String> additionalHt tpHeaders) { 458 public void loadUrl(final String url, final Map<String, String> additionalHt tpHeaders) {
527 mFactory.startYourEngines(true); 459 mFactory.startYourEngines(true);
528 if (checkNeedsPost()) { 460 if (checkNeedsPost()) {
529 // Disallowed in WebView API for apps targetting a new SDK 461 // Disallowed in WebView API for apps targetting a new SDK
530 assert mAppTargetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR2; 462 assert mAppTargetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR2;
531 mRunQueue.addTask(new Runnable() { 463 mFactory.addTask(new Runnable() {
532 @Override 464 @Override
533 public void run() { 465 public void run() {
534 mAwContents.loadUrl(url, additionalHttpHeaders); 466 mAwContents.loadUrl(url, additionalHttpHeaders);
535 } 467 }
536 }); 468 });
537 return; 469 return;
538 } 470 }
539 mAwContents.loadUrl(url, additionalHttpHeaders); 471 mAwContents.loadUrl(url, additionalHttpHeaders);
540 } 472 }
541 473
542 @Override 474 @Override
543 public void loadUrl(final String url) { 475 public void loadUrl(final String url) {
544 mFactory.startYourEngines(true); 476 mFactory.startYourEngines(true);
545 if (checkNeedsPost()) { 477 if (checkNeedsPost()) {
546 // Disallowed in WebView API for apps targetting a new SDK 478 // Disallowed in WebView API for apps targetting a new SDK
547 assert mAppTargetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR2; 479 assert mAppTargetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR2;
548 mRunQueue.addTask(new Runnable() { 480 mFactory.addTask(new Runnable() {
549 @Override 481 @Override
550 public void run() { 482 public void run() {
551 mAwContents.loadUrl(url); 483 mAwContents.loadUrl(url);
552 } 484 }
553 }); 485 });
554 return; 486 return;
555 } 487 }
556 mAwContents.loadUrl(url); 488 mAwContents.loadUrl(url);
557 } 489 }
558 490
559 @Override 491 @Override
560 public void postUrl(final String url, final byte[] postData) { 492 public void postUrl(final String url, final byte[] postData) {
561 mFactory.startYourEngines(true); 493 mFactory.startYourEngines(true);
562 if (checkNeedsPost()) { 494 if (checkNeedsPost()) {
563 // Disallowed in WebView API for apps targetting a new SDK 495 // Disallowed in WebView API for apps targetting a new SDK
564 assert mAppTargetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR2; 496 assert mAppTargetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR2;
565 mRunQueue.addTask(new Runnable() { 497 mFactory.addTask(new Runnable() {
566 @Override 498 @Override
567 public void run() { 499 public void run() {
568 mAwContents.postUrl(url, postData); 500 mAwContents.postUrl(url, postData);
569 } 501 }
570 }); 502 });
571 return; 503 return;
572 } 504 }
573 mAwContents.postUrl(url, postData); 505 mAwContents.postUrl(url, postData);
574 } 506 }
575 507
576 @Override 508 @Override
577 public void loadData(final String data, final String mimeType, final String encoding) { 509 public void loadData(final String data, final String mimeType, final String encoding) {
578 mFactory.startYourEngines(true); 510 mFactory.startYourEngines(true);
579 if (checkNeedsPost()) { 511 if (checkNeedsPost()) {
580 // Disallowed in WebView API for apps targetting a new SDK 512 // Disallowed in WebView API for apps targetting a new SDK
581 assert mAppTargetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR2; 513 assert mAppTargetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR2;
582 mRunQueue.addTask(new Runnable() { 514 mFactory.addTask(new Runnable() {
583 @Override 515 @Override
584 public void run() { 516 public void run() {
585 mAwContents.loadData(data, mimeType, encoding); 517 mAwContents.loadData(data, mimeType, encoding);
586 } 518 }
587 }); 519 });
588 return; 520 return;
589 } 521 }
590 mAwContents.loadData(data, mimeType, encoding); 522 mAwContents.loadData(data, mimeType, encoding);
591 } 523 }
592 524
593 @Override 525 @Override
594 public void loadDataWithBaseURL(final String baseUrl, final String data, fin al String mimeType, 526 public void loadDataWithBaseURL(final String baseUrl, final String data, fin al String mimeType,
595 final String encoding, final String historyUrl) { 527 final String encoding, final String historyUrl) {
596 mFactory.startYourEngines(true); 528 mFactory.startYourEngines(true);
597 if (checkNeedsPost()) { 529 if (checkNeedsPost()) {
598 // Disallowed in WebView API for apps targetting a new SDK 530 // Disallowed in WebView API for apps targetting a new SDK
599 assert mAppTargetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR2; 531 assert mAppTargetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR2;
600 mRunQueue.addTask(new Runnable() { 532 mFactory.addTask(new Runnable() {
601 @Override 533 @Override
602 public void run() { 534 public void run() {
603 mAwContents.loadDataWithBaseURL(baseUrl, data, mimeType, enc oding, historyUrl); 535 mAwContents.loadDataWithBaseURL(baseUrl, data, mimeType, enc oding, historyUrl);
604 } 536 }
605 }); 537 });
606 return; 538 return;
607 } 539 }
608 mAwContents.loadDataWithBaseURL(baseUrl, data, mimeType, encoding, histo ryUrl); 540 mAwContents.loadDataWithBaseURL(baseUrl, data, mimeType, encoding, histo ryUrl);
609 } 541 }
610 542
611 public void evaluateJavaScript(String script, ValueCallback<String> resultCa llback) { 543 public void evaluateJavaScript(String script, ValueCallback<String> resultCa llback) {
612 checkThread(); 544 checkThread();
613 mAwContents.evaluateJavaScript(script, resultCallback); 545 mAwContents.evaluateJavaScript(script, resultCallback);
614 } 546 }
615 547
616 @Override 548 @Override
617 public void saveWebArchive(String filename) { 549 public void saveWebArchive(String filename) {
618 saveWebArchive(filename, false, null); 550 saveWebArchive(filename, false, null);
619 } 551 }
620 552
621 @Override 553 @Override
622 public void saveWebArchive(final String basename, final boolean autoname, 554 public void saveWebArchive(final String basename, final boolean autoname,
623 final ValueCallback<String> callback) { 555 final ValueCallback<String> callback) {
624 if (checkNeedsPost()) { 556 if (checkNeedsPost()) {
625 mRunQueue.addTask(new Runnable() { 557 mFactory.addTask(new Runnable() {
626 @Override 558 @Override
627 public void run() { 559 public void run() {
628 saveWebArchive(basename, autoname, callback); 560 saveWebArchive(basename, autoname, callback);
629 } 561 }
630 }); 562 });
631 return; 563 return;
632 } 564 }
633 mAwContents.saveWebArchive(basename, autoname, callback); 565 mAwContents.saveWebArchive(basename, autoname, callback);
634 } 566 }
635 567
636 @Override 568 @Override
637 public void stopLoading() { 569 public void stopLoading() {
638 if (checkNeedsPost()) { 570 if (checkNeedsPost()) {
639 mRunQueue.addTask(new Runnable() { 571 mFactory.addTask(new Runnable() {
640 @Override 572 @Override
641 public void run() { 573 public void run() {
642 stopLoading(); 574 stopLoading();
643 } 575 }
644 }); 576 });
645 return; 577 return;
646 } 578 }
647 579
648 mAwContents.stopLoading(); 580 mAwContents.stopLoading();
649 } 581 }
650 582
651 @Override 583 @Override
652 public void reload() { 584 public void reload() {
653 if (checkNeedsPost()) { 585 if (checkNeedsPost()) {
654 mRunQueue.addTask(new Runnable() { 586 mFactory.addTask(new Runnable() {
655 @Override 587 @Override
656 public void run() { 588 public void run() {
657 reload(); 589 reload();
658 } 590 }
659 }); 591 });
660 return; 592 return;
661 } 593 }
662 mAwContents.reload(); 594 mAwContents.reload();
663 } 595 }
664 596
665 @Override 597 @Override
666 public boolean canGoBack() { 598 public boolean canGoBack() {
667 mFactory.startYourEngines(true); 599 mFactory.startYourEngines(true);
668 if (checkNeedsPost()) { 600 if (checkNeedsPost()) {
669 Boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 601 Boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
670 @Override 602 @Override
671 public Boolean call() { 603 public Boolean call() {
672 return canGoBack(); 604 return canGoBack();
673 } 605 }
674 }); 606 });
675 return ret; 607 return ret;
676 } 608 }
677 return mAwContents.canGoBack(); 609 return mAwContents.canGoBack();
678 } 610 }
679 611
680 @Override 612 @Override
681 public void goBack() { 613 public void goBack() {
682 if (checkNeedsPost()) { 614 if (checkNeedsPost()) {
683 mRunQueue.addTask(new Runnable() { 615 mFactory.addTask(new Runnable() {
684 @Override 616 @Override
685 public void run() { 617 public void run() {
686 goBack(); 618 goBack();
687 } 619 }
688 }); 620 });
689 return; 621 return;
690 } 622 }
691 mAwContents.goBack(); 623 mAwContents.goBack();
692 } 624 }
693 625
694 @Override 626 @Override
695 public boolean canGoForward() { 627 public boolean canGoForward() {
696 mFactory.startYourEngines(true); 628 mFactory.startYourEngines(true);
697 if (checkNeedsPost()) { 629 if (checkNeedsPost()) {
698 Boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 630 Boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
699 @Override 631 @Override
700 public Boolean call() { 632 public Boolean call() {
701 return canGoForward(); 633 return canGoForward();
702 } 634 }
703 }); 635 });
704 return ret; 636 return ret;
705 } 637 }
706 return mAwContents.canGoForward(); 638 return mAwContents.canGoForward();
707 } 639 }
708 640
709 @Override 641 @Override
710 public void goForward() { 642 public void goForward() {
711 if (checkNeedsPost()) { 643 if (checkNeedsPost()) {
712 mRunQueue.addTask(new Runnable() { 644 mFactory.addTask(new Runnable() {
713 @Override 645 @Override
714 public void run() { 646 public void run() {
715 goForward(); 647 goForward();
716 } 648 }
717 }); 649 });
718 return; 650 return;
719 } 651 }
720 mAwContents.goForward(); 652 mAwContents.goForward();
721 } 653 }
722 654
723 @Override 655 @Override
724 public boolean canGoBackOrForward(final int steps) { 656 public boolean canGoBackOrForward(final int steps) {
725 mFactory.startYourEngines(true); 657 mFactory.startYourEngines(true);
726 if (checkNeedsPost()) { 658 if (checkNeedsPost()) {
727 Boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 659 Boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
728 @Override 660 @Override
729 public Boolean call() { 661 public Boolean call() {
730 return canGoBackOrForward(steps); 662 return canGoBackOrForward(steps);
731 } 663 }
732 }); 664 });
733 return ret; 665 return ret;
734 } 666 }
735 return mAwContents.canGoBackOrForward(steps); 667 return mAwContents.canGoBackOrForward(steps);
736 } 668 }
737 669
738 @Override 670 @Override
739 public void goBackOrForward(final int steps) { 671 public void goBackOrForward(final int steps) {
740 if (checkNeedsPost()) { 672 if (checkNeedsPost()) {
741 mRunQueue.addTask(new Runnable() { 673 mFactory.addTask(new Runnable() {
742 @Override 674 @Override
743 public void run() { 675 public void run() {
744 goBackOrForward(steps); 676 goBackOrForward(steps);
745 } 677 }
746 }); 678 });
747 return; 679 return;
748 } 680 }
749 mAwContents.goBackOrForward(steps); 681 mAwContents.goBackOrForward(steps);
750 } 682 }
751 683
752 @Override 684 @Override
753 public boolean isPrivateBrowsingEnabled() { 685 public boolean isPrivateBrowsingEnabled() {
754 // Not supported in this WebView implementation. 686 // Not supported in this WebView implementation.
755 return false; 687 return false;
756 } 688 }
757 689
758 @Override 690 @Override
759 public boolean pageUp(final boolean top) { 691 public boolean pageUp(final boolean top) {
760 mFactory.startYourEngines(true); 692 mFactory.startYourEngines(true);
761 if (checkNeedsPost()) { 693 if (checkNeedsPost()) {
762 Boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 694 Boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
763 @Override 695 @Override
764 public Boolean call() { 696 public Boolean call() {
765 return pageUp(top); 697 return pageUp(top);
766 } 698 }
767 }); 699 });
768 return ret; 700 return ret;
769 } 701 }
770 return mAwContents.pageUp(top); 702 return mAwContents.pageUp(top);
771 } 703 }
772 704
773 @Override 705 @Override
774 public boolean pageDown(final boolean bottom) { 706 public boolean pageDown(final boolean bottom) {
775 mFactory.startYourEngines(true); 707 mFactory.startYourEngines(true);
776 if (checkNeedsPost()) { 708 if (checkNeedsPost()) {
777 Boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 709 Boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
778 @Override 710 @Override
779 public Boolean call() { 711 public Boolean call() {
780 return pageDown(bottom); 712 return pageDown(bottom);
781 } 713 }
782 }); 714 });
783 return ret; 715 return ret;
784 } 716 }
785 return mAwContents.pageDown(bottom); 717 return mAwContents.pageDown(bottom);
786 } 718 }
787 719
788 @Override 720 @Override
789 public void insertVisualStateCallback( 721 public void insertVisualStateCallback(
790 final long requestId, final VisualStateCallback callback) { 722 final long requestId, final VisualStateCallback callback) {
791 if (checkNeedsPost()) { 723 if (checkNeedsPost()) {
792 mRunQueue.addTask(new Runnable() { 724 mFactory.addTask(new Runnable() {
793 @Override 725 @Override
794 public void run() { 726 public void run() {
795 insertVisualStateCallback(requestId, callback); 727 insertVisualStateCallback(requestId, callback);
796 } 728 }
797 }); 729 });
798 return; 730 return;
799 } 731 }
800 mAwContents.insertVisualStateCallback( 732 mAwContents.insertVisualStateCallback(
801 requestId, new AwContents.VisualStateCallback() { 733 requestId, new AwContents.VisualStateCallback() {
802 @Override 734 @Override
803 public void onComplete(long requestId) { 735 public void onComplete(long requestId) {
804 callback.onComplete(requestId); 736 callback.onComplete(requestId);
805 } 737 }
806 }); 738 });
807 } 739 }
808 740
809 @Override 741 @Override
810 public void clearView() { 742 public void clearView() {
811 if (checkNeedsPost()) { 743 if (checkNeedsPost()) {
812 mRunQueue.addTask(new Runnable() { 744 mFactory.addTask(new Runnable() {
813 @Override 745 @Override
814 public void run() { 746 public void run() {
815 clearView(); 747 clearView();
816 } 748 }
817 }); 749 });
818 return; 750 return;
819 } 751 }
820 mAwContents.clearView(); 752 mAwContents.clearView();
821 } 753 }
822 754
823 @Override 755 @Override
824 public Picture capturePicture() { 756 public Picture capturePicture() {
825 mFactory.startYourEngines(true); 757 mFactory.startYourEngines(true);
826 if (checkNeedsPost()) { 758 if (checkNeedsPost()) {
827 Picture ret = runOnUiThreadBlocking(new Callable<Picture>() { 759 Picture ret = mFactory.runOnUiThreadBlocking(new Callable<Picture>() {
828 @Override 760 @Override
829 public Picture call() { 761 public Picture call() {
830 return capturePicture(); 762 return capturePicture();
831 } 763 }
832 }); 764 });
833 return ret; 765 return ret;
834 } 766 }
835 return mAwContents.capturePicture(); 767 return mAwContents.capturePicture();
836 } 768 }
837 769
838 @Override 770 @Override
839 public float getScale() { 771 public float getScale() {
840 // No checkThread() as it is mostly thread safe (workaround for b/106529 91). 772 // No checkThread() as it is mostly thread safe (workaround for b/106529 91).
841 mFactory.startYourEngines(true); 773 mFactory.startYourEngines(true);
842 return mAwContents.getScale(); 774 return mAwContents.getScale();
843 } 775 }
844 776
845 @Override 777 @Override
846 public void setInitialScale(final int scaleInPercent) { 778 public void setInitialScale(final int scaleInPercent) {
847 // No checkThread() as it is thread safe 779 // No checkThread() as it is thread safe
848 mWebSettings.getAwSettings().setInitialPageScale(scaleInPercent); 780 mWebSettings.getAwSettings().setInitialPageScale(scaleInPercent);
849 } 781 }
850 782
851 @Override 783 @Override
852 public void invokeZoomPicker() { 784 public void invokeZoomPicker() {
853 if (checkNeedsPost()) { 785 if (checkNeedsPost()) {
854 mRunQueue.addTask(new Runnable() { 786 mFactory.addTask(new Runnable() {
855 @Override 787 @Override
856 public void run() { 788 public void run() {
857 invokeZoomPicker(); 789 invokeZoomPicker();
858 } 790 }
859 }); 791 });
860 return; 792 return;
861 } 793 }
862 mAwContents.invokeZoomPicker(); 794 mAwContents.invokeZoomPicker();
863 } 795 }
864 796
865 @Override 797 @Override
866 public WebView.HitTestResult getHitTestResult() { 798 public WebView.HitTestResult getHitTestResult() {
867 mFactory.startYourEngines(true); 799 mFactory.startYourEngines(true);
868 if (checkNeedsPost()) { 800 if (checkNeedsPost()) {
869 WebView.HitTestResult ret = 801 WebView.HitTestResult ret =
870 runOnUiThreadBlocking(new Callable<WebView.HitTestResult>() { 802 mFactory.runOnUiThreadBlocking(new Callable<WebView.HitTestR esult>() {
871 @Override 803 @Override
872 public WebView.HitTestResult call() { 804 public WebView.HitTestResult call() {
873 return getHitTestResult(); 805 return getHitTestResult();
874 } 806 }
875 }); 807 });
876 return ret; 808 return ret;
877 } 809 }
878 AwContents.HitTestData data = mAwContents.getLastHitTestResult(); 810 AwContents.HitTestData data = mAwContents.getLastHitTestResult();
879 mHitTestResult.setType(data.hitTestResultType); 811 mHitTestResult.setType(data.hitTestResultType);
880 mHitTestResult.setExtra(data.hitTestResultExtraData); 812 mHitTestResult.setExtra(data.hitTestResultExtraData);
881 return mHitTestResult; 813 return mHitTestResult;
882 } 814 }
883 815
884 @Override 816 @Override
885 public void requestFocusNodeHref(final Message hrefMsg) { 817 public void requestFocusNodeHref(final Message hrefMsg) {
886 if (checkNeedsPost()) { 818 if (checkNeedsPost()) {
887 mRunQueue.addTask(new Runnable() { 819 mFactory.addTask(new Runnable() {
888 @Override 820 @Override
889 public void run() { 821 public void run() {
890 requestFocusNodeHref(hrefMsg); 822 requestFocusNodeHref(hrefMsg);
891 } 823 }
892 }); 824 });
893 return; 825 return;
894 } 826 }
895 mAwContents.requestFocusNodeHref(hrefMsg); 827 mAwContents.requestFocusNodeHref(hrefMsg);
896 } 828 }
897 829
898 @Override 830 @Override
899 public void requestImageRef(final Message msg) { 831 public void requestImageRef(final Message msg) {
900 if (checkNeedsPost()) { 832 if (checkNeedsPost()) {
901 mRunQueue.addTask(new Runnable() { 833 mFactory.addTask(new Runnable() {
902 @Override 834 @Override
903 public void run() { 835 public void run() {
904 requestImageRef(msg); 836 requestImageRef(msg);
905 } 837 }
906 }); 838 });
907 return; 839 return;
908 } 840 }
909 mAwContents.requestImageRef(msg); 841 mAwContents.requestImageRef(msg);
910 } 842 }
911 843
912 @Override 844 @Override
913 public String getUrl() { 845 public String getUrl() {
914 mFactory.startYourEngines(true); 846 mFactory.startYourEngines(true);
915 if (checkNeedsPost()) { 847 if (checkNeedsPost()) {
916 String ret = runOnUiThreadBlocking(new Callable<String>() { 848 String ret = mFactory.runOnUiThreadBlocking(new Callable<String>() {
917 @Override 849 @Override
918 public String call() { 850 public String call() {
919 return getUrl(); 851 return getUrl();
920 } 852 }
921 }); 853 });
922 return ret; 854 return ret;
923 } 855 }
924 return mAwContents.getUrl(); 856 return mAwContents.getUrl();
925 } 857 }
926 858
927 @Override 859 @Override
928 public String getOriginalUrl() { 860 public String getOriginalUrl() {
929 mFactory.startYourEngines(true); 861 mFactory.startYourEngines(true);
930 if (checkNeedsPost()) { 862 if (checkNeedsPost()) {
931 String ret = runOnUiThreadBlocking(new Callable<String>() { 863 String ret = mFactory.runOnUiThreadBlocking(new Callable<String>() {
932 @Override 864 @Override
933 public String call() { 865 public String call() {
934 return getOriginalUrl(); 866 return getOriginalUrl();
935 } 867 }
936 }); 868 });
937 return ret; 869 return ret;
938 } 870 }
939 return mAwContents.getOriginalUrl(); 871 return mAwContents.getOriginalUrl();
940 } 872 }
941 873
942 @Override 874 @Override
943 public String getTitle() { 875 public String getTitle() {
944 mFactory.startYourEngines(true); 876 mFactory.startYourEngines(true);
945 if (checkNeedsPost()) { 877 if (checkNeedsPost()) {
946 String ret = runOnUiThreadBlocking(new Callable<String>() { 878 String ret = mFactory.runOnUiThreadBlocking(new Callable<String>() {
947 @Override 879 @Override
948 public String call() { 880 public String call() {
949 return getTitle(); 881 return getTitle();
950 } 882 }
951 }); 883 });
952 return ret; 884 return ret;
953 } 885 }
954 return mAwContents.getTitle(); 886 return mAwContents.getTitle();
955 } 887 }
956 888
957 @Override 889 @Override
958 public Bitmap getFavicon() { 890 public Bitmap getFavicon() {
959 mFactory.startYourEngines(true); 891 mFactory.startYourEngines(true);
960 if (checkNeedsPost()) { 892 if (checkNeedsPost()) {
961 Bitmap ret = runOnUiThreadBlocking(new Callable<Bitmap>() { 893 Bitmap ret = mFactory.runOnUiThreadBlocking(new Callable<Bitmap>() {
962 @Override 894 @Override
963 public Bitmap call() { 895 public Bitmap call() {
964 return getFavicon(); 896 return getFavicon();
965 } 897 }
966 }); 898 });
967 return ret; 899 return ret;
968 } 900 }
969 return mAwContents.getFavicon(); 901 return mAwContents.getFavicon();
970 } 902 }
971 903
(...skipping 20 matching lines...) Expand all
992 @Override 924 @Override
993 public int getContentWidth() { 925 public int getContentWidth() {
994 if (mAwContents == null) return 0; 926 if (mAwContents == null) return 0;
995 // No checkThread() as it is mostly thread safe (workaround for b/105948 69). 927 // No checkThread() as it is mostly thread safe (workaround for b/105948 69).
996 return mAwContents.getContentWidthCss(); 928 return mAwContents.getContentWidthCss();
997 } 929 }
998 930
999 @Override 931 @Override
1000 public void pauseTimers() { 932 public void pauseTimers() {
1001 if (checkNeedsPost()) { 933 if (checkNeedsPost()) {
1002 mRunQueue.addTask(new Runnable() { 934 mFactory.addTask(new Runnable() {
1003 @Override 935 @Override
1004 public void run() { 936 public void run() {
1005 pauseTimers(); 937 pauseTimers();
1006 } 938 }
1007 }); 939 });
1008 return; 940 return;
1009 } 941 }
1010 mAwContents.pauseTimers(); 942 mAwContents.pauseTimers();
1011 } 943 }
1012 944
1013 @Override 945 @Override
1014 public void resumeTimers() { 946 public void resumeTimers() {
1015 if (checkNeedsPost()) { 947 if (checkNeedsPost()) {
1016 mRunQueue.addTask(new Runnable() { 948 mFactory.addTask(new Runnable() {
1017 @Override 949 @Override
1018 public void run() { 950 public void run() {
1019 resumeTimers(); 951 resumeTimers();
1020 } 952 }
1021 }); 953 });
1022 return; 954 return;
1023 } 955 }
1024 mAwContents.resumeTimers(); 956 mAwContents.resumeTimers();
1025 } 957 }
1026 958
1027 @Override 959 @Override
1028 public void onPause() { 960 public void onPause() {
1029 if (checkNeedsPost()) { 961 if (checkNeedsPost()) {
1030 mRunQueue.addTask(new Runnable() { 962 mFactory.addTask(new Runnable() {
1031 @Override 963 @Override
1032 public void run() { 964 public void run() {
1033 onPause(); 965 onPause();
1034 } 966 }
1035 }); 967 });
1036 return; 968 return;
1037 } 969 }
1038 mAwContents.onPause(); 970 mAwContents.onPause();
1039 } 971 }
1040 972
1041 @Override 973 @Override
1042 public void onResume() { 974 public void onResume() {
1043 if (checkNeedsPost()) { 975 if (checkNeedsPost()) {
1044 mRunQueue.addTask(new Runnable() { 976 mFactory.addTask(new Runnable() {
1045 @Override 977 @Override
1046 public void run() { 978 public void run() {
1047 onResume(); 979 onResume();
1048 } 980 }
1049 }); 981 });
1050 return; 982 return;
1051 } 983 }
1052 mAwContents.onResume(); 984 mAwContents.onResume();
1053 } 985 }
1054 986
1055 @Override 987 @Override
1056 public boolean isPaused() { 988 public boolean isPaused() {
1057 mFactory.startYourEngines(true); 989 mFactory.startYourEngines(true);
1058 if (checkNeedsPost()) { 990 if (checkNeedsPost()) {
1059 Boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 991 Boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
1060 @Override 992 @Override
1061 public Boolean call() { 993 public Boolean call() {
1062 return isPaused(); 994 return isPaused();
1063 } 995 }
1064 }); 996 });
1065 return ret; 997 return ret;
1066 } 998 }
1067 return mAwContents.isPaused(); 999 return mAwContents.isPaused();
1068 } 1000 }
1069 1001
1070 @Override 1002 @Override
1071 public void freeMemory() { 1003 public void freeMemory() {
1072 // Intentional no-op. Memory is managed automatically by Chromium. 1004 // Intentional no-op. Memory is managed automatically by Chromium.
1073 } 1005 }
1074 1006
1075 @Override 1007 @Override
1076 public void clearCache(final boolean includeDiskFiles) { 1008 public void clearCache(final boolean includeDiskFiles) {
1077 if (checkNeedsPost()) { 1009 if (checkNeedsPost()) {
1078 mRunQueue.addTask(new Runnable() { 1010 mFactory.addTask(new Runnable() {
1079 @Override 1011 @Override
1080 public void run() { 1012 public void run() {
1081 clearCache(includeDiskFiles); 1013 clearCache(includeDiskFiles);
1082 } 1014 }
1083 }); 1015 });
1084 return; 1016 return;
1085 } 1017 }
1086 mAwContents.clearCache(includeDiskFiles); 1018 mAwContents.clearCache(includeDiskFiles);
1087 } 1019 }
1088 1020
1089 /** 1021 /**
1090 * This is a poorly named method, but we keep it for historical reasons. 1022 * This is a poorly named method, but we keep it for historical reasons.
1091 */ 1023 */
1092 @Override 1024 @Override
1093 public void clearFormData() { 1025 public void clearFormData() {
1094 if (checkNeedsPost()) { 1026 if (checkNeedsPost()) {
1095 mRunQueue.addTask(new Runnable() { 1027 mFactory.addTask(new Runnable() {
1096 @Override 1028 @Override
1097 public void run() { 1029 public void run() {
1098 clearFormData(); 1030 clearFormData();
1099 } 1031 }
1100 }); 1032 });
1101 return; 1033 return;
1102 } 1034 }
1103 mAwContents.hideAutofillPopup(); 1035 mAwContents.hideAutofillPopup();
1104 } 1036 }
1105 1037
1106 @Override 1038 @Override
1107 public void clearHistory() { 1039 public void clearHistory() {
1108 if (checkNeedsPost()) { 1040 if (checkNeedsPost()) {
1109 mRunQueue.addTask(new Runnable() { 1041 mFactory.addTask(new Runnable() {
1110 @Override 1042 @Override
1111 public void run() { 1043 public void run() {
1112 clearHistory(); 1044 clearHistory();
1113 } 1045 }
1114 }); 1046 });
1115 return; 1047 return;
1116 } 1048 }
1117 mAwContents.clearHistory(); 1049 mAwContents.clearHistory();
1118 } 1050 }
1119 1051
1120 @Override 1052 @Override
1121 public void clearSslPreferences() { 1053 public void clearSslPreferences() {
1122 if (checkNeedsPost()) { 1054 if (checkNeedsPost()) {
1123 mRunQueue.addTask(new Runnable() { 1055 mFactory.addTask(new Runnable() {
1124 @Override 1056 @Override
1125 public void run() { 1057 public void run() {
1126 clearSslPreferences(); 1058 clearSslPreferences();
1127 } 1059 }
1128 }); 1060 });
1129 return; 1061 return;
1130 } 1062 }
1131 mAwContents.clearSslPreferences(); 1063 mAwContents.clearSslPreferences();
1132 } 1064 }
1133 1065
1134 @Override 1066 @Override
1135 public WebBackForwardList copyBackForwardList() { 1067 public WebBackForwardList copyBackForwardList() {
1136 mFactory.startYourEngines(true); 1068 mFactory.startYourEngines(true);
1137 if (checkNeedsPost()) { 1069 if (checkNeedsPost()) {
1138 WebBackForwardList ret = runOnUiThreadBlocking(new Callable<WebBackF orwardList>() { 1070 WebBackForwardList ret =
1139 @Override 1071 mFactory.runOnUiThreadBlocking(new Callable<WebBackForwardLi st>() {
1140 public WebBackForwardList call() { 1072 @Override
1141 return copyBackForwardList(); 1073 public WebBackForwardList call() {
1142 } 1074 return copyBackForwardList();
1143 }); 1075 }
1076 });
1144 return ret; 1077 return ret;
1145 } 1078 }
1146 // mAwContents.getNavigationHistory() can be null here if mAwContents ha s been destroyed, 1079 // mAwContents.getNavigationHistory() can be null here if mAwContents ha s been destroyed,
1147 // and we do not handle passing null to the WebBackForwardListChromium c onstructor. 1080 // and we do not handle passing null to the WebBackForwardListChromium c onstructor.
1148 NavigationHistory navHistory = mAwContents.getNavigationHistory(); 1081 NavigationHistory navHistory = mAwContents.getNavigationHistory();
1149 if (navHistory == null) navHistory = new NavigationHistory(); 1082 if (navHistory == null) navHistory = new NavigationHistory();
1150 return new WebBackForwardListChromium(navHistory); 1083 return new WebBackForwardListChromium(navHistory);
1151 } 1084 }
1152 1085
1153 @Override 1086 @Override
1154 public void setFindListener(WebView.FindListener listener) { 1087 public void setFindListener(WebView.FindListener listener) {
1155 mContentsClientAdapter.setFindListener(listener); 1088 mContentsClientAdapter.setFindListener(listener);
1156 } 1089 }
1157 1090
1158 @Override 1091 @Override
1159 public void findNext(final boolean forwards) { 1092 public void findNext(final boolean forwards) {
1160 if (checkNeedsPost()) { 1093 if (checkNeedsPost()) {
1161 mRunQueue.addTask(new Runnable() { 1094 mFactory.addTask(new Runnable() {
1162 @Override 1095 @Override
1163 public void run() { 1096 public void run() {
1164 findNext(forwards); 1097 findNext(forwards);
1165 } 1098 }
1166 }); 1099 });
1167 return; 1100 return;
1168 } 1101 }
1169 mAwContents.findNext(forwards); 1102 mAwContents.findNext(forwards);
1170 } 1103 }
1171 1104
1172 @Override 1105 @Override
1173 public int findAll(final String searchString) { 1106 public int findAll(final String searchString) {
1174 findAllAsync(searchString); 1107 findAllAsync(searchString);
1175 return 0; 1108 return 0;
1176 } 1109 }
1177 1110
1178 @Override 1111 @Override
1179 public void findAllAsync(final String searchString) { 1112 public void findAllAsync(final String searchString) {
1180 if (checkNeedsPost()) { 1113 if (checkNeedsPost()) {
1181 mRunQueue.addTask(new Runnable() { 1114 mFactory.addTask(new Runnable() {
1182 @Override 1115 @Override
1183 public void run() { 1116 public void run() {
1184 findAllAsync(searchString); 1117 findAllAsync(searchString);
1185 } 1118 }
1186 }); 1119 });
1187 return; 1120 return;
1188 } 1121 }
1189 mAwContents.findAllAsync(searchString); 1122 mAwContents.findAllAsync(searchString);
1190 } 1123 }
1191 1124
(...skipping 23 matching lines...) Expand all
1215 findAction.setText(text); 1148 findAction.setText(text);
1216 findAction.findAll(); 1149 findAction.findAll();
1217 } 1150 }
1218 1151
1219 return true; 1152 return true;
1220 } 1153 }
1221 1154
1222 @Override 1155 @Override
1223 public void notifyFindDialogDismissed() { 1156 public void notifyFindDialogDismissed() {
1224 if (checkNeedsPost()) { 1157 if (checkNeedsPost()) {
1225 mRunQueue.addTask(new Runnable() { 1158 mFactory.addTask(new Runnable() {
1226 @Override 1159 @Override
1227 public void run() { 1160 public void run() {
1228 notifyFindDialogDismissed(); 1161 notifyFindDialogDismissed();
1229 } 1162 }
1230 }); 1163 });
1231 return; 1164 return;
1232 } 1165 }
1233 clearMatches(); 1166 clearMatches();
1234 } 1167 }
1235 1168
1236 @Override 1169 @Override
1237 public void clearMatches() { 1170 public void clearMatches() {
1238 if (checkNeedsPost()) { 1171 if (checkNeedsPost()) {
1239 mRunQueue.addTask(new Runnable() { 1172 mFactory.addTask(new Runnable() {
1240 @Override 1173 @Override
1241 public void run() { 1174 public void run() {
1242 clearMatches(); 1175 clearMatches();
1243 } 1176 }
1244 }); 1177 });
1245 return; 1178 return;
1246 } 1179 }
1247 mAwContents.clearMatches(); 1180 mAwContents.clearMatches();
1248 } 1181 }
1249 1182
1250 @Override 1183 @Override
1251 public void documentHasImages(final Message response) { 1184 public void documentHasImages(final Message response) {
1252 if (checkNeedsPost()) { 1185 if (checkNeedsPost()) {
1253 mRunQueue.addTask(new Runnable() { 1186 mFactory.addTask(new Runnable() {
1254 @Override 1187 @Override
1255 public void run() { 1188 public void run() {
1256 documentHasImages(response); 1189 documentHasImages(response);
1257 } 1190 }
1258 }); 1191 });
1259 return; 1192 return;
1260 } 1193 }
1261 mAwContents.documentHasImages(response); 1194 mAwContents.documentHasImages(response);
1262 } 1195 }
1263 1196
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 } 1244 }
1312 clientClass = clientClass.getSuperclass(); 1245 clientClass = clientClass.getSuperclass();
1313 } 1246 }
1314 return foundShowMethod && foundHideMethod; 1247 return foundShowMethod && foundHideMethod;
1315 } 1248 }
1316 1249
1317 @Override 1250 @Override
1318 @SuppressWarnings("deprecation") 1251 @SuppressWarnings("deprecation")
1319 public void setPictureListener(final WebView.PictureListener listener) { 1252 public void setPictureListener(final WebView.PictureListener listener) {
1320 if (checkNeedsPost()) { 1253 if (checkNeedsPost()) {
1321 mRunQueue.addTask(new Runnable() { 1254 mFactory.addTask(new Runnable() {
1322 @Override 1255 @Override
1323 public void run() { 1256 public void run() {
1324 setPictureListener(listener); 1257 setPictureListener(listener);
1325 } 1258 }
1326 }); 1259 });
1327 return; 1260 return;
1328 } 1261 }
1329 mContentsClientAdapter.setPictureListener(listener); 1262 mContentsClientAdapter.setPictureListener(listener);
1330 mAwContents.enableOnNewPicture( 1263 mAwContents.enableOnNewPicture(
1331 listener != null, mAppTargetSdkVersion >= Build.VERSION_CODES.JE LLY_BEAN_MR2); 1264 listener != null, mAppTargetSdkVersion >= Build.VERSION_CODES.JE LLY_BEAN_MR2);
1332 } 1265 }
1333 1266
1334 @Override 1267 @Override
1335 public void addJavascriptInterface(final Object obj, final String interfaceN ame) { 1268 public void addJavascriptInterface(final Object obj, final String interfaceN ame) {
1336 if (checkNeedsPost()) { 1269 if (checkNeedsPost()) {
1337 mRunQueue.addTask(new Runnable() { 1270 mFactory.addTask(new Runnable() {
1338 @Override 1271 @Override
1339 public void run() { 1272 public void run() {
1340 addJavascriptInterface(obj, interfaceName); 1273 addJavascriptInterface(obj, interfaceName);
1341 } 1274 }
1342 }); 1275 });
1343 return; 1276 return;
1344 } 1277 }
1345 mAwContents.addJavascriptInterface(obj, interfaceName); 1278 mAwContents.addJavascriptInterface(obj, interfaceName);
1346 } 1279 }
1347 1280
1348 @Override 1281 @Override
1349 public void removeJavascriptInterface(final String interfaceName) { 1282 public void removeJavascriptInterface(final String interfaceName) {
1350 if (checkNeedsPost()) { 1283 if (checkNeedsPost()) {
1351 mRunQueue.addTask(new Runnable() { 1284 mFactory.addTask(new Runnable() {
1352 @Override 1285 @Override
1353 public void run() { 1286 public void run() {
1354 removeJavascriptInterface(interfaceName); 1287 removeJavascriptInterface(interfaceName);
1355 } 1288 }
1356 }); 1289 });
1357 return; 1290 return;
1358 } 1291 }
1359 mAwContents.removeJavascriptInterface(interfaceName); 1292 mAwContents.removeJavascriptInterface(interfaceName);
1360 } 1293 }
1361 1294
1362 @Override 1295 @Override
1363 public WebMessagePort[] createWebMessageChannel() { 1296 public WebMessagePort[] createWebMessageChannel() {
1364 mFactory.startYourEngines(true); 1297 mFactory.startYourEngines(true);
1365 if (checkNeedsPost()) { 1298 if (checkNeedsPost()) {
1366 WebMessagePort[] ret = runOnUiThreadBlocking(new Callable<WebMessage Port[]>() { 1299 WebMessagePort[] ret = mFactory.runOnUiThreadBlocking(new Callable<W ebMessagePort[]>() {
1367 @Override 1300 @Override
1368 public WebMessagePort[] call() { 1301 public WebMessagePort[] call() {
1369 return createWebMessageChannel(); 1302 return createWebMessageChannel();
1370 } 1303 }
1371 }); 1304 });
1372 return ret; 1305 return ret;
1373 } 1306 }
1374 return WebMessagePortAdapter.fromAwMessagePorts(mAwContents.createMessag eChannel()); 1307 return WebMessagePortAdapter.fromAwMessagePorts(mAwContents.createMessag eChannel());
1375 } 1308 }
1376 1309
1377 @Override 1310 @Override
1378 @TargetApi(Build.VERSION_CODES.M) 1311 @TargetApi(Build.VERSION_CODES.M)
1379 public void postMessageToMainFrame(final WebMessage message, final Uri targe tOrigin) { 1312 public void postMessageToMainFrame(final WebMessage message, final Uri targe tOrigin) {
1380 if (checkNeedsPost()) { 1313 if (checkNeedsPost()) {
1381 mRunQueue.addTask(new Runnable() { 1314 mFactory.addTask(new Runnable() {
1382 @Override 1315 @Override
1383 public void run() { 1316 public void run() {
1384 postMessageToMainFrame(message, targetOrigin); 1317 postMessageToMainFrame(message, targetOrigin);
1385 } 1318 }
1386 }); 1319 });
1387 return; 1320 return;
1388 } 1321 }
1389 mAwContents.postMessageToFrame(null, message.getData(), targetOrigin.toS tring(), 1322 mAwContents.postMessageToFrame(null, message.getData(), targetOrigin.toS tring(),
1390 WebMessagePortAdapter.toAwMessagePorts(message.getPorts())); 1323 WebMessagePortAdapter.toAwMessagePorts(message.getPorts()));
1391 } 1324 }
1392 1325
1393 @Override 1326 @Override
1394 public WebSettings getSettings() { 1327 public WebSettings getSettings() {
1395 return mWebSettings; 1328 return mWebSettings;
1396 } 1329 }
1397 1330
1398 @Override 1331 @Override
1399 public void setMapTrackballToArrowKeys(boolean setMap) { 1332 public void setMapTrackballToArrowKeys(boolean setMap) {
1400 // This is a deprecated API: intentional no-op. 1333 // This is a deprecated API: intentional no-op.
1401 } 1334 }
1402 1335
1403 @Override 1336 @Override
1404 public void flingScroll(final int vx, final int vy) { 1337 public void flingScroll(final int vx, final int vy) {
1405 if (checkNeedsPost()) { 1338 if (checkNeedsPost()) {
1406 mRunQueue.addTask(new Runnable() { 1339 mFactory.addTask(new Runnable() {
1407 @Override 1340 @Override
1408 public void run() { 1341 public void run() {
1409 flingScroll(vx, vy); 1342 flingScroll(vx, vy);
1410 } 1343 }
1411 }); 1344 });
1412 return; 1345 return;
1413 } 1346 }
1414 mAwContents.flingScroll(vx, vy); 1347 mAwContents.flingScroll(vx, vy);
1415 } 1348 }
1416 1349
(...skipping 23 matching lines...) Expand all
1440 if (checkNeedsPost()) { 1373 if (checkNeedsPost()) {
1441 return false; 1374 return false;
1442 } 1375 }
1443 return mAwContents.canZoomOut(); 1376 return mAwContents.canZoomOut();
1444 } 1377 }
1445 1378
1446 @Override 1379 @Override
1447 public boolean zoomIn() { 1380 public boolean zoomIn() {
1448 mFactory.startYourEngines(true); 1381 mFactory.startYourEngines(true);
1449 if (checkNeedsPost()) { 1382 if (checkNeedsPost()) {
1450 boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 1383 boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
1451 @Override 1384 @Override
1452 public Boolean call() { 1385 public Boolean call() {
1453 return zoomIn(); 1386 return zoomIn();
1454 } 1387 }
1455 }); 1388 });
1456 return ret; 1389 return ret;
1457 } 1390 }
1458 return mAwContents.zoomIn(); 1391 return mAwContents.zoomIn();
1459 } 1392 }
1460 1393
1461 @Override 1394 @Override
1462 public boolean zoomOut() { 1395 public boolean zoomOut() {
1463 mFactory.startYourEngines(true); 1396 mFactory.startYourEngines(true);
1464 if (checkNeedsPost()) { 1397 if (checkNeedsPost()) {
1465 boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 1398 boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
1466 @Override 1399 @Override
1467 public Boolean call() { 1400 public Boolean call() {
1468 return zoomOut(); 1401 return zoomOut();
1469 } 1402 }
1470 }); 1403 });
1471 return ret; 1404 return ret;
1472 } 1405 }
1473 return mAwContents.zoomOut(); 1406 return mAwContents.zoomOut();
1474 } 1407 }
1475 1408
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 } 1443 }
1511 1444
1512 // WebViewProvider.ViewDelegate implementation ----------------------------- ------------------- 1445 // WebViewProvider.ViewDelegate implementation ----------------------------- -------------------
1513 1446
1514 // TODO: remove from WebViewProvider and use default implementation from 1447 // TODO: remove from WebViewProvider and use default implementation from
1515 // ViewGroup. 1448 // ViewGroup.
1516 @Override 1449 @Override
1517 public boolean shouldDelayChildPressedState() { 1450 public boolean shouldDelayChildPressedState() {
1518 mFactory.startYourEngines(false); 1451 mFactory.startYourEngines(false);
1519 if (checkNeedsPost()) { 1452 if (checkNeedsPost()) {
1520 boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 1453 boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
1521 @Override 1454 @Override
1522 public Boolean call() { 1455 public Boolean call() {
1523 return shouldDelayChildPressedState(); 1456 return shouldDelayChildPressedState();
1524 } 1457 }
1525 }); 1458 });
1526 return ret; 1459 return ret;
1527 } 1460 }
1528 return true; 1461 return true;
1529 } 1462 }
1530 1463
1531 @Override 1464 @Override
1532 public AccessibilityNodeProvider getAccessibilityNodeProvider() { 1465 public AccessibilityNodeProvider getAccessibilityNodeProvider() {
1533 mFactory.startYourEngines(false); 1466 mFactory.startYourEngines(false);
1534 if (checkNeedsPost()) { 1467 if (checkNeedsPost()) {
1535 AccessibilityNodeProvider ret = 1468 AccessibilityNodeProvider ret =
1536 runOnUiThreadBlocking(new Callable<AccessibilityNodeProvider >() { 1469 mFactory.runOnUiThreadBlocking(new Callable<AccessibilityNod eProvider>() {
1537 @Override 1470 @Override
1538 public AccessibilityNodeProvider call() { 1471 public AccessibilityNodeProvider call() {
1539 return getAccessibilityNodeProvider(); 1472 return getAccessibilityNodeProvider();
1540 } 1473 }
1541 }); 1474 });
1542 return ret; 1475 return ret;
1543 } 1476 }
1544 return mAwContents.getAccessibilityNodeProvider(); 1477 return mAwContents.getAccessibilityNodeProvider();
1545 } 1478 }
1546 1479
1547 @TargetApi(Build.VERSION_CODES.M) 1480 @TargetApi(Build.VERSION_CODES.M)
1548 @Override 1481 @Override
1549 public void onProvideVirtualStructure(final ViewStructure structure) { 1482 public void onProvideVirtualStructure(final ViewStructure structure) {
1550 mFactory.startYourEngines(false); 1483 mFactory.startYourEngines(false);
1551 if (checkNeedsPost()) { 1484 if (checkNeedsPost()) {
1552 runVoidTaskOnUiThreadBlocking(new Runnable() { 1485 mFactory.runVoidTaskOnUiThreadBlocking(new Runnable() {
1553 @Override 1486 @Override
1554 public void run() { 1487 public void run() {
1555 onProvideVirtualStructure(structure); 1488 onProvideVirtualStructure(structure);
1556 } 1489 }
1557 }); 1490 });
1558 return; 1491 return;
1559 } 1492 }
1560 mAwContents.onProvideVirtualStructure(structure); 1493 mAwContents.onProvideVirtualStructure(structure);
1561 } 1494 }
1562 1495
1563 @Override 1496 @Override
1564 public void onInitializeAccessibilityNodeInfo(final AccessibilityNodeInfo in fo) { 1497 public void onInitializeAccessibilityNodeInfo(final AccessibilityNodeInfo in fo) {
1565 mFactory.startYourEngines(false); 1498 mFactory.startYourEngines(false);
1566 if (checkNeedsPost()) { 1499 if (checkNeedsPost()) {
1567 runVoidTaskOnUiThreadBlocking(new Runnable() { 1500 mFactory.runVoidTaskOnUiThreadBlocking(new Runnable() {
1568 @Override 1501 @Override
1569 public void run() { 1502 public void run() {
1570 onInitializeAccessibilityNodeInfo(info); 1503 onInitializeAccessibilityNodeInfo(info);
1571 } 1504 }
1572 }); 1505 });
1573 return; 1506 return;
1574 } 1507 }
1575 mAwContents.onInitializeAccessibilityNodeInfo(info); 1508 mAwContents.onInitializeAccessibilityNodeInfo(info);
1576 } 1509 }
1577 1510
1578 @Override 1511 @Override
1579 public void onInitializeAccessibilityEvent(final AccessibilityEvent event) { 1512 public void onInitializeAccessibilityEvent(final AccessibilityEvent event) {
1580 mFactory.startYourEngines(false); 1513 mFactory.startYourEngines(false);
1581 if (checkNeedsPost()) { 1514 if (checkNeedsPost()) {
1582 runVoidTaskOnUiThreadBlocking(new Runnable() { 1515 mFactory.runVoidTaskOnUiThreadBlocking(new Runnable() {
1583 @Override 1516 @Override
1584 public void run() { 1517 public void run() {
1585 onInitializeAccessibilityEvent(event); 1518 onInitializeAccessibilityEvent(event);
1586 } 1519 }
1587 }); 1520 });
1588 return; 1521 return;
1589 } 1522 }
1590 mAwContents.onInitializeAccessibilityEvent(event); 1523 mAwContents.onInitializeAccessibilityEvent(event);
1591 } 1524 }
1592 1525
1593 @Override 1526 @Override
1594 public boolean performAccessibilityAction(final int action, final Bundle arg uments) { 1527 public boolean performAccessibilityAction(final int action, final Bundle arg uments) {
1595 mFactory.startYourEngines(false); 1528 mFactory.startYourEngines(false);
1596 if (checkNeedsPost()) { 1529 if (checkNeedsPost()) {
1597 boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 1530 boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
1598 @Override 1531 @Override
1599 public Boolean call() { 1532 public Boolean call() {
1600 return performAccessibilityAction(action, arguments); 1533 return performAccessibilityAction(action, arguments);
1601 } 1534 }
1602 }); 1535 });
1603 return ret; 1536 return ret;
1604 } 1537 }
1605 if (mAwContents.supportsAccessibilityAction(action)) { 1538 if (mAwContents.supportsAccessibilityAction(action)) {
1606 return mAwContents.performAccessibilityAction(action, arguments); 1539 return mAwContents.performAccessibilityAction(action, arguments);
1607 } 1540 }
1608 return mWebViewPrivate.super_performAccessibilityAction(action, argument s); 1541 return mWebViewPrivate.super_performAccessibilityAction(action, argument s);
1609 } 1542 }
1610 1543
1611 @Override 1544 @Override
1612 public void setOverScrollMode(final int mode) { 1545 public void setOverScrollMode(final int mode) {
1613 // This gets called from the android.view.View c'tor that WebView inheri ts from. This 1546 // This gets called from the android.view.View c'tor that WebView inheri ts from. This
1614 // causes the method to be called when mAwContents == null. 1547 // causes the method to be called when mAwContents == null.
1615 // It's safe to ignore these calls however since AwContents will read th e current value of 1548 // It's safe to ignore these calls however since AwContents will read th e current value of
1616 // this setting when it's created. 1549 // this setting when it's created.
1617 if (mAwContents == null) return; 1550 if (mAwContents == null) return;
1618 1551
1619 if (checkNeedsPost()) { 1552 if (checkNeedsPost()) {
1620 mRunQueue.addTask(new Runnable() { 1553 mFactory.addTask(new Runnable() {
1621 @Override 1554 @Override
1622 public void run() { 1555 public void run() {
1623 setOverScrollMode(mode); 1556 setOverScrollMode(mode);
1624 } 1557 }
1625 }); 1558 });
1626 return; 1559 return;
1627 } 1560 }
1628 mAwContents.setOverScrollMode(mode); 1561 mAwContents.setOverScrollMode(mode);
1629 } 1562 }
1630 1563
1631 @Override 1564 @Override
1632 public void setScrollBarStyle(final int style) { 1565 public void setScrollBarStyle(final int style) {
1633 if (checkNeedsPost()) { 1566 if (checkNeedsPost()) {
1634 mRunQueue.addTask(new Runnable() { 1567 mFactory.addTask(new Runnable() {
1635 @Override 1568 @Override
1636 public void run() { 1569 public void run() {
1637 setScrollBarStyle(style); 1570 setScrollBarStyle(style);
1638 } 1571 }
1639 }); 1572 });
1640 return; 1573 return;
1641 } 1574 }
1642 mAwContents.setScrollBarStyle(style); 1575 mAwContents.setScrollBarStyle(style);
1643 } 1576 }
1644 1577
1645 @Override 1578 @Override
1646 public void onDrawVerticalScrollBar(final Canvas canvas, final Drawable scro llBar, final int l, 1579 public void onDrawVerticalScrollBar(final Canvas canvas, final Drawable scro llBar, final int l,
1647 final int t, final int r, final int b) { 1580 final int t, final int r, final int b) {
1648 // WebViewClassic was overriding this method to handle rubberband over-s croll. Since 1581 // WebViewClassic was overriding this method to handle rubberband over-s croll. Since
1649 // WebViewChromium doesn't support that the vanilla implementation of th is method can be 1582 // WebViewChromium doesn't support that the vanilla implementation of th is method can be
1650 // used. 1583 // used.
1651 mWebViewPrivate.super_onDrawVerticalScrollBar(canvas, scrollBar, l, t, r , b); 1584 mWebViewPrivate.super_onDrawVerticalScrollBar(canvas, scrollBar, l, t, r , b);
1652 } 1585 }
1653 1586
1654 @Override 1587 @Override
1655 public void onOverScrolled(final int scrollX, final int scrollY, 1588 public void onOverScrolled(final int scrollX, final int scrollY,
1656 final boolean clampedX, final boolean clampedY) { 1589 final boolean clampedX, final boolean clampedY) {
1657 if (checkNeedsPost()) { 1590 if (checkNeedsPost()) {
1658 mRunQueue.addTask(new Runnable() { 1591 mFactory.addTask(new Runnable() {
1659 @Override 1592 @Override
1660 public void run() { 1593 public void run() {
1661 onOverScrolled(scrollX, scrollY, clampedX, clampedY); 1594 onOverScrolled(scrollX, scrollY, clampedX, clampedY);
1662 } 1595 }
1663 }); 1596 });
1664 return; 1597 return;
1665 } 1598 }
1666 mAwContents.onContainerViewOverScrolled(scrollX, scrollY, clampedX, clam pedY); 1599 mAwContents.onContainerViewOverScrolled(scrollX, scrollY, clampedX, clam pedY);
1667 } 1600 }
1668 1601
1669 @Override 1602 @Override
1670 public void onWindowVisibilityChanged(final int visibility) { 1603 public void onWindowVisibilityChanged(final int visibility) {
1671 if (checkNeedsPost()) { 1604 if (checkNeedsPost()) {
1672 mRunQueue.addTask(new Runnable() { 1605 mFactory.addTask(new Runnable() {
1673 @Override 1606 @Override
1674 public void run() { 1607 public void run() {
1675 onWindowVisibilityChanged(visibility); 1608 onWindowVisibilityChanged(visibility);
1676 } 1609 }
1677 }); 1610 });
1678 return; 1611 return;
1679 } 1612 }
1680 mAwContents.onWindowVisibilityChanged(visibility); 1613 mAwContents.onWindowVisibilityChanged(visibility);
1681 } 1614 }
1682 1615
1683 @Override 1616 @Override
1684 @SuppressLint("DrawAllocation") 1617 @SuppressLint("DrawAllocation")
1685 public void onDraw(final Canvas canvas) { 1618 public void onDraw(final Canvas canvas) {
1686 mFactory.startYourEngines(true); 1619 mFactory.startYourEngines(true);
1687 if (checkNeedsPost()) { 1620 if (checkNeedsPost()) {
1688 runVoidTaskOnUiThreadBlocking(new Runnable() { 1621 mFactory.runVoidTaskOnUiThreadBlocking(new Runnable() {
1689 @Override 1622 @Override
1690 public void run() { 1623 public void run() {
1691 onDraw(canvas); 1624 onDraw(canvas);
1692 } 1625 }
1693 }); 1626 });
1694 return; 1627 return;
1695 } 1628 }
1696 mAwContents.onDraw(canvas); 1629 mAwContents.onDraw(canvas);
1697 } 1630 }
1698 1631
1699 @Override 1632 @Override
1700 public void setLayoutParams(final ViewGroup.LayoutParams layoutParams) { 1633 public void setLayoutParams(final ViewGroup.LayoutParams layoutParams) {
1701 // This API is our strongest signal from the View system that this 1634 // This API is our strongest signal from the View system that this
1702 // WebView is going to be bound to a View hierarchy and so at this 1635 // WebView is going to be bound to a View hierarchy and so at this
1703 // point we must bind Chromium's UI thread to the current thread. 1636 // point we must bind Chromium's UI thread to the current thread.
1704 mFactory.startYourEngines(false); 1637 mFactory.startYourEngines(false);
1705 checkThread(); 1638 checkThread();
1706 mWebViewPrivate.super_setLayoutParams(layoutParams); 1639 mWebViewPrivate.super_setLayoutParams(layoutParams);
1707 if (checkNeedsPost()) { 1640 if (checkNeedsPost()) {
1708 runVoidTaskOnUiThreadBlocking(new Runnable() { 1641 mFactory.runVoidTaskOnUiThreadBlocking(new Runnable() {
1709 @Override 1642 @Override
1710 public void run() { 1643 public void run() {
1711 mAwContents.setLayoutParams(layoutParams); 1644 mAwContents.setLayoutParams(layoutParams);
1712 } 1645 }
1713 }); 1646 });
1714 return; 1647 return;
1715 } 1648 }
1716 mAwContents.setLayoutParams(layoutParams); 1649 mAwContents.setLayoutParams(layoutParams);
1717 } 1650 }
1718 1651
1719 // Overrides WebViewProvider.ViewDelegate.onActivityResult (not in system ap i jar yet). 1652 // Overrides WebViewProvider.ViewDelegate.onActivityResult (not in system ap i jar yet).
1720 // crbug.com/543272. 1653 // crbug.com/543272.
1721 public void onActivityResult(final int requestCode, final int resultCode, fi nal Intent data) { 1654 public void onActivityResult(final int requestCode, final int resultCode, fi nal Intent data) {
1722 if (checkNeedsPost()) { 1655 if (checkNeedsPost()) {
1723 mRunQueue.addTask(new Runnable() { 1656 mFactory.addTask(new Runnable() {
1724 @Override 1657 @Override
1725 public void run() { 1658 public void run() {
1726 onActivityResult(requestCode, resultCode, data); 1659 onActivityResult(requestCode, resultCode, data);
1727 } 1660 }
1728 }); 1661 });
1729 return; 1662 return;
1730 } 1663 }
1731 mAwContents.onActivityResult(requestCode, resultCode, data); 1664 mAwContents.onActivityResult(requestCode, resultCode, data);
1732 } 1665 }
1733 1666
1734 @Override 1667 @Override
1735 public boolean performLongClick() { 1668 public boolean performLongClick() {
1736 // Return false unless the WebView is attached to a View with a parent 1669 // Return false unless the WebView is attached to a View with a parent
1737 return mWebView.getParent() != null ? mWebViewPrivate.super_performLongC lick() : false; 1670 return mWebView.getParent() != null ? mWebViewPrivate.super_performLongC lick() : false;
1738 } 1671 }
1739 1672
1740 @Override 1673 @Override
1741 public void onConfigurationChanged(final Configuration newConfig) { 1674 public void onConfigurationChanged(final Configuration newConfig) {
1742 if (checkNeedsPost()) { 1675 if (checkNeedsPost()) {
1743 mRunQueue.addTask(new Runnable() { 1676 mFactory.addTask(new Runnable() {
1744 @Override 1677 @Override
1745 public void run() { 1678 public void run() {
1746 onConfigurationChanged(newConfig); 1679 onConfigurationChanged(newConfig);
1747 } 1680 }
1748 }); 1681 });
1749 return; 1682 return;
1750 } 1683 }
1751 mAwContents.onConfigurationChanged(newConfig); 1684 mAwContents.onConfigurationChanged(newConfig);
1752 } 1685 }
1753 1686
1754 //TODO(hush): add override after release. 1687 //TODO(hush): add override after release.
1755 //@Override 1688 //@Override
1756 public boolean onDragEvent(final DragEvent event) { 1689 public boolean onDragEvent(final DragEvent event) {
1757 mFactory.startYourEngines(false); 1690 mFactory.startYourEngines(false);
1758 if (checkNeedsPost()) { 1691 if (checkNeedsPost()) {
1759 boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 1692 boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
1760 @Override 1693 @Override
1761 public Boolean call() { 1694 public Boolean call() {
1762 return onDragEvent(event); 1695 return onDragEvent(event);
1763 } 1696 }
1764 }); 1697 });
1765 return ret; 1698 return ret;
1766 } 1699 }
1767 return mAwContents.onDragEvent(event); 1700 return mAwContents.onDragEvent(event);
1768 } 1701 }
1769 1702
1770 @Override 1703 @Override
1771 public InputConnection onCreateInputConnection(final EditorInfo outAttrs) { 1704 public InputConnection onCreateInputConnection(final EditorInfo outAttrs) {
1772 mFactory.startYourEngines(false); 1705 mFactory.startYourEngines(false);
1773 if (checkNeedsPost()) { 1706 if (checkNeedsPost()) {
1774 return null; 1707 return null;
1775 } 1708 }
1776 return mAwContents.onCreateInputConnection(outAttrs); 1709 return mAwContents.onCreateInputConnection(outAttrs);
1777 } 1710 }
1778 1711
1779 @Override 1712 @Override
1780 public boolean onKeyMultiple(final int keyCode, final int repeatCount, final KeyEvent event) { 1713 public boolean onKeyMultiple(final int keyCode, final int repeatCount, final KeyEvent event) {
1781 mFactory.startYourEngines(false); 1714 mFactory.startYourEngines(false);
1782 if (checkNeedsPost()) { 1715 if (checkNeedsPost()) {
1783 boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 1716 boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
1784 @Override 1717 @Override
1785 public Boolean call() { 1718 public Boolean call() {
1786 return onKeyMultiple(keyCode, repeatCount, event); 1719 return onKeyMultiple(keyCode, repeatCount, event);
1787 } 1720 }
1788 }); 1721 });
1789 return ret; 1722 return ret;
1790 } 1723 }
1791 return false; 1724 return false;
1792 } 1725 }
1793 1726
1794 @Override 1727 @Override
1795 public boolean onKeyDown(final int keyCode, final KeyEvent event) { 1728 public boolean onKeyDown(final int keyCode, final KeyEvent event) {
1796 mFactory.startYourEngines(false); 1729 mFactory.startYourEngines(false);
1797 if (checkNeedsPost()) { 1730 if (checkNeedsPost()) {
1798 boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 1731 boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
1799 @Override 1732 @Override
1800 public Boolean call() { 1733 public Boolean call() {
1801 return onKeyDown(keyCode, event); 1734 return onKeyDown(keyCode, event);
1802 } 1735 }
1803 }); 1736 });
1804 return ret; 1737 return ret;
1805 } 1738 }
1806 return false; 1739 return false;
1807 } 1740 }
1808 1741
1809 @Override 1742 @Override
1810 public boolean onKeyUp(final int keyCode, final KeyEvent event) { 1743 public boolean onKeyUp(final int keyCode, final KeyEvent event) {
1811 mFactory.startYourEngines(false); 1744 mFactory.startYourEngines(false);
1812 if (checkNeedsPost()) { 1745 if (checkNeedsPost()) {
1813 boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 1746 boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
1814 @Override 1747 @Override
1815 public Boolean call() { 1748 public Boolean call() {
1816 return onKeyUp(keyCode, event); 1749 return onKeyUp(keyCode, event);
1817 } 1750 }
1818 }); 1751 });
1819 return ret; 1752 return ret;
1820 } 1753 }
1821 return mAwContents.onKeyUp(keyCode, event); 1754 return mAwContents.onKeyUp(keyCode, event);
1822 } 1755 }
1823 1756
1824 @Override 1757 @Override
1825 public void onAttachedToWindow() { 1758 public void onAttachedToWindow() {
1826 // This API is our strongest signal from the View system that this 1759 // This API is our strongest signal from the View system that this
1827 // WebView is going to be bound to a View hierarchy and so at this 1760 // WebView is going to be bound to a View hierarchy and so at this
1828 // point we must bind Chromium's UI thread to the current thread. 1761 // point we must bind Chromium's UI thread to the current thread.
1829 mFactory.startYourEngines(false); 1762 mFactory.startYourEngines(false);
1830 checkThread(); 1763 checkThread();
1831 mAwContents.onAttachedToWindow(); 1764 mAwContents.onAttachedToWindow();
1832 } 1765 }
1833 1766
1834 @Override 1767 @Override
1835 public void onDetachedFromWindow() { 1768 public void onDetachedFromWindow() {
1836 if (checkNeedsPost()) { 1769 if (checkNeedsPost()) {
1837 mRunQueue.addTask(new Runnable() { 1770 mFactory.addTask(new Runnable() {
1838 @Override 1771 @Override
1839 public void run() { 1772 public void run() {
1840 onDetachedFromWindow(); 1773 onDetachedFromWindow();
1841 } 1774 }
1842 }); 1775 });
1843 return; 1776 return;
1844 } 1777 }
1845 1778
1846 mAwContents.onDetachedFromWindow(); 1779 mAwContents.onDetachedFromWindow();
1847 } 1780 }
1848 1781
1849 @Override 1782 @Override
1850 public void onVisibilityChanged(final View changedView, final int visibility ) { 1783 public void onVisibilityChanged(final View changedView, final int visibility ) {
1851 // The AwContents will find out the container view visibility before the first draw so we 1784 // The AwContents will find out the container view visibility before the first draw so we
1852 // can safely ignore onVisibilityChanged callbacks that happen before in it(). 1785 // can safely ignore onVisibilityChanged callbacks that happen before in it().
1853 if (mAwContents == null) return; 1786 if (mAwContents == null) return;
1854 1787
1855 if (checkNeedsPost()) { 1788 if (checkNeedsPost()) {
1856 mRunQueue.addTask(new Runnable() { 1789 mFactory.addTask(new Runnable() {
1857 @Override 1790 @Override
1858 public void run() { 1791 public void run() {
1859 onVisibilityChanged(changedView, visibility); 1792 onVisibilityChanged(changedView, visibility);
1860 } 1793 }
1861 }); 1794 });
1862 return; 1795 return;
1863 } 1796 }
1864 mAwContents.onVisibilityChanged(changedView, visibility); 1797 mAwContents.onVisibilityChanged(changedView, visibility);
1865 } 1798 }
1866 1799
1867 @Override 1800 @Override
1868 public void onWindowFocusChanged(final boolean hasWindowFocus) { 1801 public void onWindowFocusChanged(final boolean hasWindowFocus) {
1869 if (checkNeedsPost()) { 1802 if (checkNeedsPost()) {
1870 mRunQueue.addTask(new Runnable() { 1803 mFactory.addTask(new Runnable() {
1871 @Override 1804 @Override
1872 public void run() { 1805 public void run() {
1873 onWindowFocusChanged(hasWindowFocus); 1806 onWindowFocusChanged(hasWindowFocus);
1874 } 1807 }
1875 }); 1808 });
1876 return; 1809 return;
1877 } 1810 }
1878 mAwContents.onWindowFocusChanged(hasWindowFocus); 1811 mAwContents.onWindowFocusChanged(hasWindowFocus);
1879 } 1812 }
1880 1813
1881 @Override 1814 @Override
1882 public void onFocusChanged( 1815 public void onFocusChanged(
1883 final boolean focused, final int direction, final Rect previouslyFoc usedRect) { 1816 final boolean focused, final int direction, final Rect previouslyFoc usedRect) {
1884 if (checkNeedsPost()) { 1817 if (checkNeedsPost()) {
1885 mRunQueue.addTask(new Runnable() { 1818 mFactory.addTask(new Runnable() {
1886 @Override 1819 @Override
1887 public void run() { 1820 public void run() {
1888 onFocusChanged(focused, direction, previouslyFocusedRect); 1821 onFocusChanged(focused, direction, previouslyFocusedRect);
1889 } 1822 }
1890 }); 1823 });
1891 return; 1824 return;
1892 } 1825 }
1893 mAwContents.onFocusChanged(focused, direction, previouslyFocusedRect); 1826 mAwContents.onFocusChanged(focused, direction, previouslyFocusedRect);
1894 } 1827 }
1895 1828
1896 @Override 1829 @Override
1897 public boolean setFrame(final int left, final int top, final int right, fina l int bottom) { 1830 public boolean setFrame(final int left, final int top, final int right, fina l int bottom) {
1898 return mWebViewPrivate.super_setFrame(left, top, right, bottom); 1831 return mWebViewPrivate.super_setFrame(left, top, right, bottom);
1899 } 1832 }
1900 1833
1901 @Override 1834 @Override
1902 public void onSizeChanged(final int w, final int h, final int ow, final int oh) { 1835 public void onSizeChanged(final int w, final int h, final int ow, final int oh) {
1903 if (checkNeedsPost()) { 1836 if (checkNeedsPost()) {
1904 mRunQueue.addTask(new Runnable() { 1837 mFactory.addTask(new Runnable() {
1905 @Override 1838 @Override
1906 public void run() { 1839 public void run() {
1907 onSizeChanged(w, h, ow, oh); 1840 onSizeChanged(w, h, ow, oh);
1908 } 1841 }
1909 }); 1842 });
1910 return; 1843 return;
1911 } 1844 }
1912 mAwContents.onSizeChanged(w, h, ow, oh); 1845 mAwContents.onSizeChanged(w, h, ow, oh);
1913 } 1846 }
1914 1847
1915 @Override 1848 @Override
1916 public void onScrollChanged(final int l, final int t, final int oldl, final int oldt) { 1849 public void onScrollChanged(final int l, final int t, final int oldl, final int oldt) {
1917 if (checkNeedsPost()) { 1850 if (checkNeedsPost()) {
1918 mRunQueue.addTask(new Runnable() { 1851 mFactory.addTask(new Runnable() {
1919 @Override 1852 @Override
1920 public void run() { 1853 public void run() {
1921 onScrollChanged(l, t, oldl, oldt); 1854 onScrollChanged(l, t, oldl, oldt);
1922 } 1855 }
1923 }); 1856 });
1924 return; 1857 return;
1925 } 1858 }
1926 mAwContents.onContainerViewScrollChanged(l, t, oldl, oldt); 1859 mAwContents.onContainerViewScrollChanged(l, t, oldl, oldt);
1927 } 1860 }
1928 1861
1929 @Override 1862 @Override
1930 public boolean dispatchKeyEvent(final KeyEvent event) { 1863 public boolean dispatchKeyEvent(final KeyEvent event) {
1931 mFactory.startYourEngines(false); 1864 mFactory.startYourEngines(false);
1932 if (checkNeedsPost()) { 1865 if (checkNeedsPost()) {
1933 boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 1866 boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
1934 @Override 1867 @Override
1935 public Boolean call() { 1868 public Boolean call() {
1936 return dispatchKeyEvent(event); 1869 return dispatchKeyEvent(event);
1937 } 1870 }
1938 }); 1871 });
1939 return ret; 1872 return ret;
1940 } 1873 }
1941 return mAwContents.dispatchKeyEvent(event); 1874 return mAwContents.dispatchKeyEvent(event);
1942 } 1875 }
1943 1876
1944 @Override 1877 @Override
1945 public boolean onTouchEvent(final MotionEvent ev) { 1878 public boolean onTouchEvent(final MotionEvent ev) {
1946 mFactory.startYourEngines(false); 1879 mFactory.startYourEngines(false);
1947 if (checkNeedsPost()) { 1880 if (checkNeedsPost()) {
1948 boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 1881 boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
1949 @Override 1882 @Override
1950 public Boolean call() { 1883 public Boolean call() {
1951 return onTouchEvent(ev); 1884 return onTouchEvent(ev);
1952 } 1885 }
1953 }); 1886 });
1954 return ret; 1887 return ret;
1955 } 1888 }
1956 return mAwContents.onTouchEvent(ev); 1889 return mAwContents.onTouchEvent(ev);
1957 } 1890 }
1958 1891
1959 @Override 1892 @Override
1960 public boolean onHoverEvent(final MotionEvent event) { 1893 public boolean onHoverEvent(final MotionEvent event) {
1961 mFactory.startYourEngines(false); 1894 mFactory.startYourEngines(false);
1962 if (checkNeedsPost()) { 1895 if (checkNeedsPost()) {
1963 boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 1896 boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
1964 @Override 1897 @Override
1965 public Boolean call() { 1898 public Boolean call() {
1966 return onHoverEvent(event); 1899 return onHoverEvent(event);
1967 } 1900 }
1968 }); 1901 });
1969 return ret; 1902 return ret;
1970 } 1903 }
1971 return mAwContents.onHoverEvent(event); 1904 return mAwContents.onHoverEvent(event);
1972 } 1905 }
1973 1906
1974 @Override 1907 @Override
1975 public boolean onGenericMotionEvent(final MotionEvent event) { 1908 public boolean onGenericMotionEvent(final MotionEvent event) {
1976 mFactory.startYourEngines(false); 1909 mFactory.startYourEngines(false);
1977 if (checkNeedsPost()) { 1910 if (checkNeedsPost()) {
1978 boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 1911 boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
1979 @Override 1912 @Override
1980 public Boolean call() { 1913 public Boolean call() {
1981 return onGenericMotionEvent(event); 1914 return onGenericMotionEvent(event);
1982 } 1915 }
1983 }); 1916 });
1984 return ret; 1917 return ret;
1985 } 1918 }
1986 return mAwContents.onGenericMotionEvent(event); 1919 return mAwContents.onGenericMotionEvent(event);
1987 } 1920 }
1988 1921
1989 @Override 1922 @Override
1990 public boolean onTrackballEvent(MotionEvent ev) { 1923 public boolean onTrackballEvent(MotionEvent ev) {
1991 // Trackball event not handled, which eventually gets converted to DPAD keyevents 1924 // Trackball event not handled, which eventually gets converted to DPAD keyevents
1992 return false; 1925 return false;
1993 } 1926 }
1994 1927
1995 @Override 1928 @Override
1996 public boolean requestFocus(final int direction, final Rect previouslyFocuse dRect) { 1929 public boolean requestFocus(final int direction, final Rect previouslyFocuse dRect) {
1997 mFactory.startYourEngines(false); 1930 mFactory.startYourEngines(false);
1998 if (checkNeedsPost()) { 1931 if (checkNeedsPost()) {
1999 boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 1932 boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
2000 @Override 1933 @Override
2001 public Boolean call() { 1934 public Boolean call() {
2002 return requestFocus(direction, previouslyFocusedRect); 1935 return requestFocus(direction, previouslyFocusedRect);
2003 } 1936 }
2004 }); 1937 });
2005 return ret; 1938 return ret;
2006 } 1939 }
2007 mAwContents.requestFocus(); 1940 mAwContents.requestFocus();
2008 return mWebViewPrivate.super_requestFocus(direction, previouslyFocusedRe ct); 1941 return mWebViewPrivate.super_requestFocus(direction, previouslyFocusedRe ct);
2009 } 1942 }
2010 1943
2011 @Override 1944 @Override
2012 @SuppressLint("DrawAllocation") 1945 @SuppressLint("DrawAllocation")
2013 public void onMeasure(final int widthMeasureSpec, final int heightMeasureSpe c) { 1946 public void onMeasure(final int widthMeasureSpec, final int heightMeasureSpe c) {
2014 mFactory.startYourEngines(false); 1947 mFactory.startYourEngines(false);
2015 if (checkNeedsPost()) { 1948 if (checkNeedsPost()) {
2016 runVoidTaskOnUiThreadBlocking(new Runnable() { 1949 mFactory.runVoidTaskOnUiThreadBlocking(new Runnable() {
2017 @Override 1950 @Override
2018 public void run() { 1951 public void run() {
2019 onMeasure(widthMeasureSpec, heightMeasureSpec); 1952 onMeasure(widthMeasureSpec, heightMeasureSpec);
2020 } 1953 }
2021 }); 1954 });
2022 return; 1955 return;
2023 } 1956 }
2024 mAwContents.onMeasure(widthMeasureSpec, heightMeasureSpec); 1957 mAwContents.onMeasure(widthMeasureSpec, heightMeasureSpec);
2025 } 1958 }
2026 1959
2027 @Override 1960 @Override
2028 public boolean requestChildRectangleOnScreen( 1961 public boolean requestChildRectangleOnScreen(
2029 final View child, final Rect rect, final boolean immediate) { 1962 final View child, final Rect rect, final boolean immediate) {
2030 mFactory.startYourEngines(false); 1963 mFactory.startYourEngines(false);
2031 if (checkNeedsPost()) { 1964 if (checkNeedsPost()) {
2032 boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { 1965 boolean ret = mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
2033 @Override 1966 @Override
2034 public Boolean call() { 1967 public Boolean call() {
2035 return requestChildRectangleOnScreen(child, rect, immediate) ; 1968 return requestChildRectangleOnScreen(child, rect, immediate) ;
2036 } 1969 }
2037 }); 1970 });
2038 return ret; 1971 return ret;
2039 } 1972 }
2040 return mAwContents.requestChildRectangleOnScreen(child, rect, immediate) ; 1973 return mAwContents.requestChildRectangleOnScreen(child, rect, immediate) ;
2041 } 1974 }
2042 1975
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 public void onFinishTemporaryDetach() { 2030 public void onFinishTemporaryDetach() {
2098 mAwContents.onFinishTemporaryDetach(); 2031 mAwContents.onFinishTemporaryDetach();
2099 } 2032 }
2100 2033
2101 // WebViewProvider.ScrollDelegate implementation --------------------------- ------------------- 2034 // WebViewProvider.ScrollDelegate implementation --------------------------- -------------------
2102 2035
2103 @Override 2036 @Override
2104 public int computeHorizontalScrollRange() { 2037 public int computeHorizontalScrollRange() {
2105 mFactory.startYourEngines(false); 2038 mFactory.startYourEngines(false);
2106 if (checkNeedsPost()) { 2039 if (checkNeedsPost()) {
2107 int ret = runOnUiThreadBlocking(new Callable<Integer>() { 2040 int ret = mFactory.runOnUiThreadBlocking(new Callable<Integer>() {
2108 @Override 2041 @Override
2109 public Integer call() { 2042 public Integer call() {
2110 return computeHorizontalScrollRange(); 2043 return computeHorizontalScrollRange();
2111 } 2044 }
2112 }); 2045 });
2113 return ret; 2046 return ret;
2114 } 2047 }
2115 return mAwContents.computeHorizontalScrollRange(); 2048 return mAwContents.computeHorizontalScrollRange();
2116 } 2049 }
2117 2050
2118 @Override 2051 @Override
2119 public int computeHorizontalScrollOffset() { 2052 public int computeHorizontalScrollOffset() {
2120 mFactory.startYourEngines(false); 2053 mFactory.startYourEngines(false);
2121 if (checkNeedsPost()) { 2054 if (checkNeedsPost()) {
2122 int ret = runOnUiThreadBlocking(new Callable<Integer>() { 2055 int ret = mFactory.runOnUiThreadBlocking(new Callable<Integer>() {
2123 @Override 2056 @Override
2124 public Integer call() { 2057 public Integer call() {
2125 return computeHorizontalScrollOffset(); 2058 return computeHorizontalScrollOffset();
2126 } 2059 }
2127 }); 2060 });
2128 return ret; 2061 return ret;
2129 } 2062 }
2130 return mAwContents.computeHorizontalScrollOffset(); 2063 return mAwContents.computeHorizontalScrollOffset();
2131 } 2064 }
2132 2065
2133 @Override 2066 @Override
2134 public int computeVerticalScrollRange() { 2067 public int computeVerticalScrollRange() {
2135 mFactory.startYourEngines(false); 2068 mFactory.startYourEngines(false);
2136 if (checkNeedsPost()) { 2069 if (checkNeedsPost()) {
2137 int ret = runOnUiThreadBlocking(new Callable<Integer>() { 2070 int ret = mFactory.runOnUiThreadBlocking(new Callable<Integer>() {
2138 @Override 2071 @Override
2139 public Integer call() { 2072 public Integer call() {
2140 return computeVerticalScrollRange(); 2073 return computeVerticalScrollRange();
2141 } 2074 }
2142 }); 2075 });
2143 return ret; 2076 return ret;
2144 } 2077 }
2145 return mAwContents.computeVerticalScrollRange(); 2078 return mAwContents.computeVerticalScrollRange();
2146 } 2079 }
2147 2080
2148 @Override 2081 @Override
2149 public int computeVerticalScrollOffset() { 2082 public int computeVerticalScrollOffset() {
2150 mFactory.startYourEngines(false); 2083 mFactory.startYourEngines(false);
2151 if (checkNeedsPost()) { 2084 if (checkNeedsPost()) {
2152 int ret = runOnUiThreadBlocking(new Callable<Integer>() { 2085 int ret = mFactory.runOnUiThreadBlocking(new Callable<Integer>() {
2153 @Override 2086 @Override
2154 public Integer call() { 2087 public Integer call() {
2155 return computeVerticalScrollOffset(); 2088 return computeVerticalScrollOffset();
2156 } 2089 }
2157 }); 2090 });
2158 return ret; 2091 return ret;
2159 } 2092 }
2160 return mAwContents.computeVerticalScrollOffset(); 2093 return mAwContents.computeVerticalScrollOffset();
2161 } 2094 }
2162 2095
2163 @Override 2096 @Override
2164 public int computeVerticalScrollExtent() { 2097 public int computeVerticalScrollExtent() {
2165 mFactory.startYourEngines(false); 2098 mFactory.startYourEngines(false);
2166 if (checkNeedsPost()) { 2099 if (checkNeedsPost()) {
2167 int ret = runOnUiThreadBlocking(new Callable<Integer>() { 2100 int ret = mFactory.runOnUiThreadBlocking(new Callable<Integer>() {
2168 @Override 2101 @Override
2169 public Integer call() { 2102 public Integer call() {
2170 return computeVerticalScrollExtent(); 2103 return computeVerticalScrollExtent();
2171 } 2104 }
2172 }); 2105 });
2173 return ret; 2106 return ret;
2174 } 2107 }
2175 return mAwContents.computeVerticalScrollExtent(); 2108 return mAwContents.computeVerticalScrollExtent();
2176 } 2109 }
2177 2110
2178 @Override 2111 @Override
2179 public void computeScroll() { 2112 public void computeScroll() {
2180 mFactory.startYourEngines(false); 2113 mFactory.startYourEngines(false);
2181 if (checkNeedsPost()) { 2114 if (checkNeedsPost()) {
2182 runVoidTaskOnUiThreadBlocking(new Runnable() { 2115 mFactory.runVoidTaskOnUiThreadBlocking(new Runnable() {
2183 @Override 2116 @Override
2184 public void run() { 2117 public void run() {
2185 computeScroll(); 2118 computeScroll();
2186 } 2119 }
2187 }); 2120 });
2188 return; 2121 return;
2189 } 2122 }
2190 mAwContents.computeScroll(); 2123 mAwContents.computeScroll();
2191 } 2124 }
2192 2125
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2294 mAwContents.extractSmartClipData(x, y, width, height); 2227 mAwContents.extractSmartClipData(x, y, width, height);
2295 } 2228 }
2296 2229
2297 // Implements SmartClipProvider 2230 // Implements SmartClipProvider
2298 @Override 2231 @Override
2299 public void setSmartClipResultHandler(final Handler resultHandler) { 2232 public void setSmartClipResultHandler(final Handler resultHandler) {
2300 checkThread(); 2233 checkThread();
2301 mAwContents.setSmartClipResultHandler(resultHandler); 2234 mAwContents.setSmartClipResultHandler(resultHandler);
2302 } 2235 }
2303 } 2236 }
OLDNEW
« no previous file with comments | « no previous file | android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698