@Override public void cleanup() { clearFormData(); clearHistory(); clearMatches(); clearSslPreferences(); clearCache(true); // We don't care about the callback - we just want to make sure cookies are gone CookieManager.getInstance().removeAllCookies(null); WebStorage.getInstance().deleteAllData(); final WebViewDatabase webViewDatabase = WebViewDatabase.getInstance(getContext()); // It isn't entirely clear how this differs from WebView.clearFormData() webViewDatabase.clearFormData(); webViewDatabase.clearHttpAuthUsernamePassword(); deleteContentFromKnownLocations(getContext()); }
/** * Handle database quota exceeded notification. * * @param url * @param databaseIdentifier * @param currentQuota * @param estimatedSize * @param totalUsedQuota * @param quotaUpdater */ @Override public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize, long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) { LOG.d(LOG_TAG, "onExceededDatabaseQuota estimatedSize: %d currentQuota: %d totalUsedQuota: %d", estimatedSize, currentQuota, totalUsedQuota); if (estimatedSize < MAX_QUOTA) { //increase for 1Mb long newQuota = estimatedSize; LOG.d(LOG_TAG, "calling quotaUpdater.updateQuota newQuota: %d", newQuota); quotaUpdater.updateQuota(newQuota); } else { // Set the quota to whatever it is and force an error // TODO: get docs on how to handle this properly quotaUpdater.updateQuota(currentQuota); } }
/** * Handle database quota exceeded notification. * * @param url * @param databaseIdentifier * @param currentQuota * @param estimatedSize * @param totalUsedQuota * @param quotaUpdater */ @Override public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize, long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) { LOG.d(TAG, "onExceededDatabaseQuota estimatedSize: %d currentQuota: %d totalUsedQuota: %d", estimatedSize, currentQuota, totalUsedQuota); if (estimatedSize < MAX_QUOTA) { //increase for 1Mb long newQuota = estimatedSize; LOG.d(TAG, "calling quotaUpdater.updateQuota newQuota: %d", newQuota); quotaUpdater.updateQuota(newQuota); } else { // Set the quota to whatever it is and force an error // TODO: get docs on how to handle this properly quotaUpdater.updateQuota(currentQuota); } }
/** 当超出数据库限额时的处理 */ @Override public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize, long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) { XLog.d(CLASS_NAME, "onExceededDatabaseQuota estimatedSize: %d currentQuota: %d totalUsedQuota: %d", estimatedSize, currentQuota, totalUsedQuota); if (estimatedSize < MAX_QUOTA) { // increase for 1Mb long newQuota = estimatedSize; XLog.d(CLASS_NAME, "calling quotaUpdater.updateQuota newQuota: %d", newQuota); quotaUpdater.updateQuota(newQuota); } else { // TODO: get docs on how to handle this properly quotaUpdater.updateQuota(currentQuota); } }
/** * Handle database quota exceeded notification. */ @Override public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize, long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) { LOG.d(LOG_TAG, "onExceededDatabaseQuota estimatedSize: %d currentQuota: %d totalUsedQuota: %d", estimatedSize, currentQuota, totalUsedQuota); quotaUpdater.updateQuota(MAX_QUOTA); }
@Deprecated public void onExceededDatabaseQuota(String url, String databaseIdentifier, long quota, long estimatedDatabaseSize, long totalQuota, WebStorage.QuotaUpdater quotaUpdater) { // This default implementation passes the current quota back to WebCore. // WebCore will interpret this that new quota was declined. //注掉 // quotaUpdater.updateQuota(quota); if (this.mRealWebChromeClient != null){ this.mRealWebChromeClient.onExceededDatabaseQuota(url, databaseIdentifier, quota, estimatedDatabaseSize, totalQuota, quotaUpdater); return; } super.onExceededDatabaseQuota(url,databaseIdentifier,quota,estimatedDatabaseSize,totalQuota,quotaUpdater); }
@Deprecated public void onReachedMaxAppCacheSize(long requiredStorage, long quota, WebStorage.QuotaUpdater quotaUpdater) { if (this.mRealWebChromeClient != null){ this.mRealWebChromeClient.onReachedMaxAppCacheSize(requiredStorage, quota, quotaUpdater); return; } super.onReachedMaxAppCacheSize(requiredStorage,quota,quotaUpdater); }
@Override public void onExceededDatabaseQuota(String url, String databaseIdentifier, long quota, long estimatedDatabaseSize, long totalQuota, WebStorage.QuotaUpdater quotaUpdater) { if (AgentWebUtils.isOverriedMethod(mWebChromeClient, "onExceededDatabaseQuota", ChromePath + ".onExceededDatabaseQuota", String.class, String.class, long.class, long.class, long.class, WebStorage.QuotaUpdater.class)) { super.onExceededDatabaseQuota(url, databaseIdentifier, quota, estimatedDatabaseSize, totalQuota, quotaUpdater); return; } quotaUpdater.updateQuota(totalQuota * 2); }
@Override public void onReachedMaxAppCacheSize(long requiredStorage, long quota, WebStorage.QuotaUpdater quotaUpdater) { if (AgentWebUtils.isOverriedMethod(mWebChromeClient, "onReachedMaxAppCacheSize", ChromePath + ".onReachedMaxAppCacheSize", long.class, long.class, WebStorage.QuotaUpdater.class)) { super.onReachedMaxAppCacheSize(requiredStorage, quota, quotaUpdater); return; } quotaUpdater.updateQuota(requiredStorage * 2); }
@SuppressLint("NewApi") @SuppressWarnings("deprecation") public void clearCookies() { // TODO Break out web storage deletion into its own option/action // TODO clear web storage for all sites that are visited in Incognito mode WebStorage storage = WebStorage.getInstance(); storage.deleteAllData(); CookieManager c = CookieManager.getInstance(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { c.removeAllCookies(null); } else { CookieSyncManager.createInstance(this); c.removeAllCookie(); } }
/** * Handle database quota exceeded notification. */ @Override public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize, long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) { LOG.d(TAG, "onExceededDatabaseQuota estimatedSize: %d currentQuota: %d totalUsedQuota: %d", estimatedSize, currentQuota, totalUsedQuota); quotaUpdater.updateQuota(MAX_QUOTA); }
@Override public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize, long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) { Log.d(TAG, "onExceededDatabaseQuota() called with: url = [" + url + "], " + "databaseIdentifier = [" + databaseIdentifier + "], currentQuota = [" + currentQuota + "], estimatedSize = [" + estimatedSize + "], " + "totalUsedQuota = [" + totalUsedQuota + "], quotaUpdater = [" + quotaUpdater + "]"); quotaUpdater.updateQuota(5 * 1024 * 1024); }
@Override public void onExceededDatabaseQuota(String url, String databaseIdentifier, long quota, long estimatedDatabaseSize, long totalQuota, WebStorage.QuotaUpdater quotaUpdater) { if (originalWebChromeClient != null) { originalWebChromeClient.onExceededDatabaseQuota(url, databaseIdentifier, quota, estimatedDatabaseSize, totalQuota, quotaUpdater); } else { super.onExceededDatabaseQuota(url, databaseIdentifier, quota, estimatedDatabaseSize, totalQuota, quotaUpdater); } }
@Override public void onReachedMaxAppCacheSize(long requiredStorage, long quota, WebStorage.QuotaUpdater quotaUpdater) { if (originalWebChromeClient != null) { originalWebChromeClient.onReachedMaxAppCacheSize(requiredStorage, quota, quotaUpdater); } else { super.onReachedMaxAppCacheSize(requiredStorage, quota, quotaUpdater); } }
/** * A cleanup that should occur when a new browser session starts. This might be able to be merged with * {@link #performCleanup(Context)}, but I didn't want to do it now to avoid unforeseen side effects. We can do this * when we rethink our erase strategy: #1472. * * This function must be called before WebView.loadUrl to avoid erasing current session data. */ public static void performNewBrowserSessionCleanup() { // If the app is closed in certain ways, WebView.cleanup will not get called and we don't clear cookies. CookieManager.getInstance().removeAllCookies(null); // We run this on the main thread to guarantee it occurs before loadUrl so we don't erase current session data. final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); // When left open on erase, some pages, like the google search results, will asynchronously write LocalStorage // files to disk after we erase them. To work-around this, we delete this data again when starting a new browser session. WebStorage.getInstance().deleteAllData(); StrictMode.setThreadPolicy(oldPolicy); }