| 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; |
| 11 import android.content.Intent; | 11 import android.content.Intent; |
| 12 import android.content.SharedPreferences; | 12 import android.content.SharedPreferences; |
| 13 import android.content.pm.PackageInfo; | 13 import android.content.pm.PackageInfo; |
| 14 import android.content.pm.PackageManager; | 14 import android.content.pm.PackageManager; |
| 15 import android.net.Uri; | 15 import android.net.Uri; |
| 16 import android.os.Build; | 16 import android.os.Build; |
| 17 import android.os.Looper; | 17 import android.os.Looper; |
| 18 import android.os.Process; | 18 import android.os.Process; |
| 19 import android.os.StrictMode; | 19 import android.os.StrictMode; |
| 20 import android.os.SystemClock; |
| 20 import android.os.UserManager; | 21 import android.os.UserManager; |
| 21 import android.provider.Settings; | 22 import android.provider.Settings; |
| 22 import android.util.Log; | 23 import android.util.Log; |
| 23 import android.view.ViewGroup; | 24 import android.view.ViewGroup; |
| 24 import android.webkit.CookieManager; | 25 import android.webkit.CookieManager; |
| 25 import android.webkit.GeolocationPermissions; | 26 import android.webkit.GeolocationPermissions; |
| 26 import android.webkit.ServiceWorkerController; | 27 import android.webkit.ServiceWorkerController; |
| 27 import android.webkit.TokenBindingService; | 28 import android.webkit.TokenBindingService; |
| 28 import android.webkit.ValueCallback; | 29 import android.webkit.ValueCallback; |
| 29 import android.webkit.WebStorage; | 30 import android.webkit.WebStorage; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 ContextUtils.getApplicationContext().getContentResolver(), | 234 ContextUtils.getApplicationContext().getContentResolver(), |
| 234 Settings.Global.WEBVIEW_MULTIPROCESS, 0) == 1; | 235 Settings.Global.WEBVIEW_MULTIPROCESS, 0) == 1; |
| 235 } | 236 } |
| 236 if (multiProcess) { | 237 if (multiProcess) { |
| 237 CommandLine cl = CommandLine.getInstance(); | 238 CommandLine cl = CommandLine.getInstance(); |
| 238 cl.appendSwitch("webview-sandboxed-renderer"); | 239 cl.appendSwitch("webview-sandboxed-renderer"); |
| 239 } | 240 } |
| 240 | 241 |
| 241 ThreadUtils.setWillOverrideUiThread(); | 242 ThreadUtils.setWillOverrideUiThread(); |
| 242 // Load chromium library. | 243 // Load chromium library. |
| 244 long before = SystemClock.elapsedRealtime(); |
| 243 AwBrowserProcess.loadLibrary(); | 245 AwBrowserProcess.loadLibrary(); |
| 246 long after = SystemClock.elapsedRealtime(); |
| 247 Log.i("foobar", "loadLibrary time " + (after - before)); |
| 244 | 248 |
| 245 final PackageInfo packageInfo = WebViewFactory.getLoadedPackageInfo(); | 249 final PackageInfo packageInfo = WebViewFactory.getLoadedPackageInfo(); |
| 246 | 250 |
| 247 // Load glue-layer support library. | 251 // Load glue-layer support library. |
| 248 System.loadLibrary("webviewchromium_plat_support"); | 252 System.loadLibrary("webviewchromium_plat_support"); |
| 249 | 253 |
| 250 // Use shared preference to check for package downgrade. | 254 // Use shared preference to check for package downgrade. |
| 251 // Since N, getSharedPreferences creates the preference dir if it doesn'
t exist, | 255 // Since N, getSharedPreferences creates the preference dir if it doesn'
t exist, |
| 252 // causing a disk write. | 256 // causing a disk write. |
| 253 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); | 257 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 assert Thread.holdsLock(mLock) && ThreadUtils.runningOnUiThread(); | 396 assert Thread.holdsLock(mLock) && ThreadUtils.runningOnUiThread(); |
| 393 | 397 |
| 394 // The post-condition of this method is everything is ready, so notify n
ow to cover all | 398 // The post-condition of this method is everything is ready, so notify n
ow to cover all |
| 395 // return paths. (Other threads will not wake-up until we release |mLock
|, whatever). | 399 // return paths. (Other threads will not wake-up until we release |mLock
|, whatever). |
| 396 mLock.notifyAll(); | 400 mLock.notifyAll(); |
| 397 | 401 |
| 398 if (mStarted) { | 402 if (mStarted) { |
| 399 return; | 403 return; |
| 400 } | 404 } |
| 401 | 405 |
| 406 long before = SystemClock.elapsedRealtime(); |
| 407 |
| 402 try { | 408 try { |
| 403 LibraryLoader.get(LibraryProcessType.PROCESS_WEBVIEW).ensureInitiali
zed(); | 409 LibraryLoader.get(LibraryProcessType.PROCESS_WEBVIEW).ensureInitiali
zed(); |
| 404 } catch (ProcessInitException e) { | 410 } catch (ProcessInitException e) { |
| 405 throw new RuntimeException("Error initializing WebView library", e); | 411 throw new RuntimeException("Error initializing WebView library", e); |
| 406 } | 412 } |
| 407 | 413 |
| 408 PathService.override(PathService.DIR_MODULE, "/system/lib/"); | 414 PathService.override(PathService.DIR_MODULE, "/system/lib/"); |
| 409 PathService.override(DIR_RESOURCE_PAKS_ANDROID, "/system/framework/webvi
ew/paks"); | 415 PathService.override(DIR_RESOURCE_PAKS_ANDROID, "/system/framework/webvi
ew/paks"); |
| 410 | 416 |
| 411 // Make sure that ResourceProvider is initialized before starting the br
owser process. | 417 // Make sure that ResourceProvider is initialized before starting the br
owser process. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 AwBrowserContext awBrowserContext = getBrowserContextOnUiThread(); | 451 AwBrowserContext awBrowserContext = getBrowserContextOnUiThread(); |
| 446 mGeolocationPermissions = new GeolocationPermissionsAdapter( | 452 mGeolocationPermissions = new GeolocationPermissionsAdapter( |
| 447 this, awBrowserContext.getGeolocationPermissions()); | 453 this, awBrowserContext.getGeolocationPermissions()); |
| 448 mWebStorage = new WebStorageAdapter(this, AwQuotaManagerBridge.getInstan
ce()); | 454 mWebStorage = new WebStorageAdapter(this, AwQuotaManagerBridge.getInstan
ce()); |
| 449 if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) { | 455 if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) { |
| 450 mServiceWorkerController = new ServiceWorkerControllerAdapter( | 456 mServiceWorkerController = new ServiceWorkerControllerAdapter( |
| 451 awBrowserContext.getServiceWorkerController()); | 457 awBrowserContext.getServiceWorkerController()); |
| 452 } | 458 } |
| 453 | 459 |
| 454 mRunQueue.drainQueue(); | 460 mRunQueue.drainQueue(); |
| 461 |
| 462 long after = SystemClock.elapsedRealtime(); |
| 463 Log.i("foobar", "startChromiumLocked time " + (after - before)); |
| 455 } | 464 } |
| 456 | 465 |
| 457 boolean hasStarted() { | 466 boolean hasStarted() { |
| 458 return mStarted; | 467 return mStarted; |
| 459 } | 468 } |
| 460 | 469 |
| 461 void startYourEngines(boolean onMainThread) { | 470 void startYourEngines(boolean onMainThread) { |
| 462 synchronized (mLock) { | 471 synchronized (mLock) { |
| 463 ensureChromiumStartedLocked(onMainThread); | 472 ensureChromiumStartedLocked(onMainThread); |
| 464 } | 473 } |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 // The method to support unreleased Android. | 718 // The method to support unreleased Android. |
| 710 WebViewContentsClientAdapter createWebViewContentsClientAdapter(WebView webV
iew, | 719 WebViewContentsClientAdapter createWebViewContentsClientAdapter(WebView webV
iew, |
| 711 Context context) { | 720 Context context) { |
| 712 return new WebViewContentsClientAdapter(webView, context, mWebViewDelega
te); | 721 return new WebViewContentsClientAdapter(webView, context, mWebViewDelega
te); |
| 713 } | 722 } |
| 714 | 723 |
| 715 AutofillProvider createAutofillProvider(Context context, ViewGroup container
View) { | 724 AutofillProvider createAutofillProvider(Context context, ViewGroup container
View) { |
| 716 return null; | 725 return null; |
| 717 } | 726 } |
| 718 } | 727 } |
| OLD | NEW |