| 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.UserManager; | 20 import android.os.UserManager; |
| 20 import android.provider.Settings; | 21 import android.provider.Settings; |
| 21 import android.util.Log; | 22 import android.util.Log; |
| 22 import android.webkit.CookieManager; | 23 import android.webkit.CookieManager; |
| 23 import android.webkit.GeolocationPermissions; | 24 import android.webkit.GeolocationPermissions; |
| 24 import android.webkit.ServiceWorkerController; | 25 import android.webkit.ServiceWorkerController; |
| 25 import android.webkit.TokenBindingService; | 26 import android.webkit.TokenBindingService; |
| 26 import android.webkit.ValueCallback; | 27 import android.webkit.ValueCallback; |
| 27 import android.webkit.WebStorage; | 28 import android.webkit.WebStorage; |
| 28 import android.webkit.WebView; | 29 import android.webkit.WebView; |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 ThreadUtils.setWillOverrideUiThread(); | 242 ThreadUtils.setWillOverrideUiThread(); |
| 242 // Load chromium library. | 243 // Load chromium library. |
| 243 AwBrowserProcess.loadLibrary(); | 244 AwBrowserProcess.loadLibrary(); |
| 244 | 245 |
| 245 final PackageInfo packageInfo = WebViewFactory.getLoadedPackageInfo(); | 246 final PackageInfo packageInfo = WebViewFactory.getLoadedPackageInfo(); |
| 246 | 247 |
| 247 // Load glue-layer support library. | 248 // Load glue-layer support library. |
| 248 System.loadLibrary("webviewchromium_plat_support"); | 249 System.loadLibrary("webviewchromium_plat_support"); |
| 249 | 250 |
| 250 // Use shared preference to check for package downgrade. | 251 // Use shared preference to check for package downgrade. |
| 251 mWebViewPrefs = ContextUtils.getApplicationContext().getSharedPreference
s( | 252 // Since N, getSharedPreferences creates the preference dir if it doesn'
t exist, |
| 252 CHROMIUM_PREFS_NAME, Context.MODE_PRIVATE); | 253 // causing a disk write. |
| 254 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); |
| 255 try { |
| 256 mWebViewPrefs = ContextUtils.getApplicationContext().getSharedPrefer
ences( |
| 257 CHROMIUM_PREFS_NAME, Context.MODE_PRIVATE); |
| 258 } finally { |
| 259 StrictMode.setThreadPolicy(oldPolicy); |
| 260 } |
| 253 int lastVersion = mWebViewPrefs.getInt(VERSION_CODE_PREF, 0); | 261 int lastVersion = mWebViewPrefs.getInt(VERSION_CODE_PREF, 0); |
| 254 int currentVersion = packageInfo.versionCode; | 262 int currentVersion = packageInfo.versionCode; |
| 255 if (!versionCodeGE(currentVersion, lastVersion)) { | 263 if (!versionCodeGE(currentVersion, lastVersion)) { |
| 256 // The WebView package has been downgraded since we last ran in this
application. | 264 // The WebView package has been downgraded since we last ran in this
application. |
| 257 // Delete the WebView data directory's contents. | 265 // Delete the WebView data directory's contents. |
| 258 String dataDir = PathUtils.getDataDirectory(); | 266 String dataDir = PathUtils.getDataDirectory(); |
| 259 Log.i(TAG, "WebView package downgraded from " + lastVersion + " to "
+ currentVersion | 267 Log.i(TAG, "WebView package downgraded from " + lastVersion + " to "
+ currentVersion |
| 260 + "; deleting contents of " + dataDir); | 268 + "; deleting contents of " + dataDir); |
| 261 deleteContents(new File(dataDir)); | 269 deleteContents(new File(dataDir)); |
| 262 } | 270 } |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 WebViewDelegate getWebViewDelegate() { | 702 WebViewDelegate getWebViewDelegate() { |
| 695 return mWebViewDelegate; | 703 return mWebViewDelegate; |
| 696 } | 704 } |
| 697 | 705 |
| 698 // The method to support unreleased Android. | 706 // The method to support unreleased Android. |
| 699 WebViewContentsClientAdapter createWebViewContentsClientAdapter(WebView webV
iew, | 707 WebViewContentsClientAdapter createWebViewContentsClientAdapter(WebView webV
iew, |
| 700 Context context) { | 708 Context context) { |
| 701 return new WebViewContentsClientAdapter(webView, context, mWebViewDelega
te); | 709 return new WebViewContentsClientAdapter(webView, context, mWebViewDelega
te); |
| 702 } | 710 } |
| 703 } | 711 } |
| OLD | NEW |