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