| OLD | NEW |
| 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.Manifest; | 7 import android.Manifest; |
| 8 import android.app.ActivityManager; | 8 import android.app.ActivityManager; |
| 9 import android.content.ComponentCallbacks2; | 9 import android.content.ComponentCallbacks2; |
| 10 import android.content.Context; | 10 import android.content.Context; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 import com.android.webview.chromium.WebViewDelegateFactory.WebViewDelegate; | 30 import com.android.webview.chromium.WebViewDelegateFactory.WebViewDelegate; |
| 31 | 31 |
| 32 import org.chromium.android_webview.AwBrowserContext; | 32 import org.chromium.android_webview.AwBrowserContext; |
| 33 import org.chromium.android_webview.AwBrowserProcess; | 33 import org.chromium.android_webview.AwBrowserProcess; |
| 34 import org.chromium.android_webview.AwContents; | 34 import org.chromium.android_webview.AwContents; |
| 35 import org.chromium.android_webview.AwContentsClient; | 35 import org.chromium.android_webview.AwContentsClient; |
| 36 import org.chromium.android_webview.AwContentsStatics; | 36 import org.chromium.android_webview.AwContentsStatics; |
| 37 import org.chromium.android_webview.AwCookieManager; | 37 import org.chromium.android_webview.AwCookieManager; |
| 38 import org.chromium.android_webview.AwDevToolsServer; | 38 import org.chromium.android_webview.AwDevToolsServer; |
| 39 import org.chromium.android_webview.AwGeolocationPermissions; | |
| 40 import org.chromium.android_webview.AwNetworkChangeNotifierRegistrationPolicy; | 39 import org.chromium.android_webview.AwNetworkChangeNotifierRegistrationPolicy; |
| 41 import org.chromium.android_webview.AwQuotaManagerBridge; | 40 import org.chromium.android_webview.AwQuotaManagerBridge; |
| 42 import org.chromium.android_webview.AwResource; | 41 import org.chromium.android_webview.AwResource; |
| 43 import org.chromium.android_webview.AwSettings; | 42 import org.chromium.android_webview.AwSettings; |
| 44 import org.chromium.android_webview.HttpAuthDatabase; | |
| 45 import org.chromium.android_webview.R; | 43 import org.chromium.android_webview.R; |
| 46 import org.chromium.android_webview.ResourcesContextWrapperFactory; | 44 import org.chromium.android_webview.ResourcesContextWrapperFactory; |
| 47 import org.chromium.base.BuildConfig; | |
| 48 import org.chromium.base.CommandLine; | 45 import org.chromium.base.CommandLine; |
| 49 import org.chromium.base.ContextUtils; | 46 import org.chromium.base.ContextUtils; |
| 50 import org.chromium.base.MemoryPressureListener; | 47 import org.chromium.base.MemoryPressureListener; |
| 51 import org.chromium.base.PathService; | 48 import org.chromium.base.PathService; |
| 52 import org.chromium.base.PathUtils; | 49 import org.chromium.base.PathUtils; |
| 53 import org.chromium.base.ThreadUtils; | 50 import org.chromium.base.ThreadUtils; |
| 54 import org.chromium.base.TraceEvent; | 51 import org.chromium.base.TraceEvent; |
| 55 import org.chromium.base.annotations.SuppressFBWarnings; | 52 import org.chromium.base.annotations.SuppressFBWarnings; |
| 56 import org.chromium.base.library_loader.LibraryLoader; | 53 import org.chromium.base.library_loader.LibraryLoader; |
| 57 import org.chromium.base.library_loader.LibraryProcessType; | 54 import org.chromium.base.library_loader.LibraryProcessType; |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 boolean hasStarted() { | 372 boolean hasStarted() { |
| 376 return mStarted; | 373 return mStarted; |
| 377 } | 374 } |
| 378 | 375 |
| 379 void startYourEngines(boolean onMainThread) { | 376 void startYourEngines(boolean onMainThread) { |
| 380 synchronized (mLock) { | 377 synchronized (mLock) { |
| 381 ensureChromiumStartedLocked(onMainThread); | 378 ensureChromiumStartedLocked(onMainThread); |
| 382 } | 379 } |
| 383 } | 380 } |
| 384 | 381 |
| 385 // Only on UI thread. | 382 AwBrowserContext getBrowserContext() { |
| 386 AwBrowserContext getBrowserContextOnUiThread() { | 383 synchronized (mLock) { |
| 384 return getBrowserContextLocked(); |
| 385 } |
| 386 } |
| 387 |
| 388 private AwBrowserContext getBrowserContextLocked() { |
| 389 assert Thread.holdsLock(mLock); |
| 387 assert mStarted; | 390 assert mStarted; |
| 388 if (BuildConfig.DCHECK_IS_ON && !ThreadUtils.runningOnUiThread()) { | |
| 389 throw new RuntimeException( | |
| 390 "getBrowserContextOnUiThread called on " + Thread.currentThr
ead()); | |
| 391 } | |
| 392 | |
| 393 if (mBrowserContext == null) { | 391 if (mBrowserContext == null) { |
| 394 mBrowserContext = | 392 mBrowserContext = |
| 395 new AwBrowserContext(mWebViewPrefs, ContextUtils.getApplicat
ionContext()); | 393 new AwBrowserContext(mWebViewPrefs, ContextUtils.getApplicat
ionContext()); |
| 396 } | 394 } |
| 397 return mBrowserContext; | 395 return mBrowserContext; |
| 398 } | 396 } |
| 399 | 397 |
| 400 private void setWebContentsDebuggingEnabled(boolean enable) { | 398 private void setWebContentsDebuggingEnabled(boolean enable) { |
| 401 if (Looper.myLooper() != ThreadUtils.getUiThreadLooper()) { | 399 if (Looper.myLooper() != ThreadUtils.getUiThreadLooper()) { |
| 402 throw new RuntimeException( | 400 throw new RuntimeException( |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 public WebViewProvider createWebView(WebView webView, WebView.PrivateAccess
privateAccess) { | 475 public WebViewProvider createWebView(WebView webView, WebView.PrivateAccess
privateAccess) { |
| 478 return new WebViewChromium(this, webView, privateAccess); | 476 return new WebViewChromium(this, webView, privateAccess); |
| 479 } | 477 } |
| 480 | 478 |
| 481 @Override | 479 @Override |
| 482 public GeolocationPermissions getGeolocationPermissions() { | 480 public GeolocationPermissions getGeolocationPermissions() { |
| 483 synchronized (mLock) { | 481 synchronized (mLock) { |
| 484 if (mGeolocationPermissions == null) { | 482 if (mGeolocationPermissions == null) { |
| 485 ensureChromiumStartedLocked(true); | 483 ensureChromiumStartedLocked(true); |
| 486 mGeolocationPermissions = new GeolocationPermissionsAdapter( | 484 mGeolocationPermissions = new GeolocationPermissionsAdapter( |
| 487 runOnUiThreadBlocking(new Callable<AwGeolocationPermissi
ons>() { | 485 getBrowserContextLocked().getGeolocationPermissions()); |
| 488 @Override | |
| 489 public AwGeolocationPermissions call() { | |
| 490 return getBrowserContextOnUiThread().getGeolocat
ionPermissions(); | |
| 491 } | |
| 492 })); | |
| 493 } | 486 } |
| 494 } | 487 } |
| 495 return mGeolocationPermissions; | 488 return mGeolocationPermissions; |
| 496 } | 489 } |
| 497 | 490 |
| 498 @Override | 491 @Override |
| 499 public CookieManager getCookieManager() { | 492 public CookieManager getCookieManager() { |
| 500 synchronized (mLock) { | 493 synchronized (mLock) { |
| 501 if (mCookieManager == null) { | 494 if (mCookieManager == null) { |
| 502 mCookieManager = new CookieManagerAdapter(new AwCookieManager())
; | 495 mCookieManager = new CookieManagerAdapter(new AwCookieManager())
; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 514 } | 507 } |
| 515 } | 508 } |
| 516 return mWebIconDatabase; | 509 return mWebIconDatabase; |
| 517 } | 510 } |
| 518 | 511 |
| 519 @Override | 512 @Override |
| 520 public WebStorage getWebStorage() { | 513 public WebStorage getWebStorage() { |
| 521 synchronized (mLock) { | 514 synchronized (mLock) { |
| 522 if (mWebStorage == null) { | 515 if (mWebStorage == null) { |
| 523 ensureChromiumStartedLocked(true); | 516 ensureChromiumStartedLocked(true); |
| 524 mWebStorage = new WebStorageAdapter( | 517 mWebStorage = new WebStorageAdapter(AwQuotaManagerBridge.getInst
ance()); |
| 525 runOnUiThreadBlocking(new Callable<AwQuotaManagerBridge>
() { | |
| 526 @Override | |
| 527 public AwQuotaManagerBridge call() { | |
| 528 return AwQuotaManagerBridge.getInstance(); | |
| 529 } | |
| 530 })); | |
| 531 } | 518 } |
| 532 } | 519 } |
| 533 return mWebStorage; | 520 return mWebStorage; |
| 534 } | 521 } |
| 535 | 522 |
| 536 @Override | 523 @Override |
| 537 public WebViewDatabase getWebViewDatabase(final Context context) { | 524 public WebViewDatabase getWebViewDatabase(Context context) { |
| 538 synchronized (mLock) { | 525 synchronized (mLock) { |
| 539 if (mWebViewDatabase == null) { | 526 if (mWebViewDatabase == null) { |
| 540 ensureChromiumStartedLocked(true); | 527 ensureChromiumStartedLocked(true); |
| 528 AwBrowserContext browserContext = getBrowserContextLocked(); |
| 541 mWebViewDatabase = new WebViewDatabaseAdapter( | 529 mWebViewDatabase = new WebViewDatabaseAdapter( |
| 542 runOnUiThreadBlocking(new Callable<HttpAuthDatabase>() { | 530 browserContext.getHttpAuthDatabase(context)); |
| 543 @Override | |
| 544 public HttpAuthDatabase call() { | |
| 545 return getBrowserContextOnUiThread().getHttpAuth
Database(context); | |
| 546 } | |
| 547 })); | |
| 548 } | 531 } |
| 549 } | 532 } |
| 550 return mWebViewDatabase; | 533 return mWebViewDatabase; |
| 551 } | 534 } |
| 552 | 535 |
| 553 WebViewDelegate getWebViewDelegate() { | 536 WebViewDelegate getWebViewDelegate() { |
| 554 return mWebViewDelegate; | 537 return mWebViewDelegate; |
| 555 } | 538 } |
| 556 } | 539 } |
| OLD | NEW |