From df1c654aba5a23d37fef47e5376694b8c55b9e30 Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Mon, 17 Nov 2014 20:34:32 +0000 Subject: Fix WebView targetSDK checks. The 4.4W SDK bump between K and L means that apps running on L that are compiled with targetSDK 20 are picking up some features only intended to be enabled on L devices, due to erroneous target SDK checks that didn't take 4.4W into account. Bug: 18385629 Change-Id: Ia7996e948f9902c535e9f7fa7dea5b05db0a1aa0 (cherry picked from commit 12399ba4bb12154b7897cf88bee04aca0adeb770) --- .../java/com/android/webview/chromium/WebViewChromium.java | 8 ++++---- .../webview/chromium/WebViewContentsClientAdapter.java | 13 +++++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'chromium') diff --git a/chromium/java/com/android/webview/chromium/WebViewChromium.java b/chromium/java/com/android/webview/chromium/WebViewChromium.java index 6cf4238..49c37c7 100644 --- a/chromium/java/com/android/webview/chromium/WebViewChromium.java +++ b/chromium/java/com/android/webview/chromium/WebViewChromium.java @@ -250,9 +250,9 @@ class WebViewChromium implements WebViewProvider, mWebView.getContext(), isAccessFromFileURLsGrantedByDefault, areLegacyQuirksEnabled)); - if (mAppTargetSdkVersion <= Build.VERSION_CODES.KITKAT) { + if (mAppTargetSdkVersion < Build.VERSION_CODES.LOLLIPOP) { + // Prior to Lollipop we always allowed third party cookies and mixed content. mWebSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); - // On KK and older versions we always allowed third party cookies. mWebSettings.setAcceptThirdPartyCookies(true); mWebSettings.getAwSettings().setZeroLayoutHeightDisablesViewportQuirk(true); } @@ -321,8 +321,8 @@ class WebViewChromium implements WebViewProvider, AwContentsStatics.setRecordFullDocument(sRecordWholeDocumentEnabledByApi || mAppTargetSdkVersion < Build.VERSION_CODES.LOLLIPOP); - if (mAppTargetSdkVersion <= Build.VERSION_CODES.KITKAT) { - // On KK and older versions, JavaScript objects injected via addJavascriptInterface + if (mAppTargetSdkVersion < Build.VERSION_CODES.LOLLIPOP) { + // Prior to Lollipop, JavaScript objects injected via addJavascriptInterface // were not inspectable. mAwContents.disableJavascriptInterfacesInspection(); } diff --git a/chromium/java/com/android/webview/chromium/WebViewContentsClientAdapter.java b/chromium/java/com/android/webview/chromium/WebViewContentsClientAdapter.java index 6b4b894..f3351c5 100644 --- a/chromium/java/com/android/webview/chromium/WebViewContentsClientAdapter.java +++ b/chromium/java/com/android/webview/chromium/WebViewContentsClientAdapter.java @@ -911,14 +911,23 @@ public class WebViewContentsClientAdapter extends AwContentsClient { uploadFileCallback.onReceiveValue(s); } }; + + // Invoke the new callback introduced in Lollipop. If the app handles + // it, we're done here. if (mWebChromeClient.onShowFileChooser(mWebView, callbackAdapter, adapter)) { return; } - if (mWebView.getContext().getApplicationInfo().targetSdkVersion > - Build.VERSION_CODES.KITKAT) { + + // If the app did not handle it and we are running on Lollipop or newer, then + // abort. + if (mWebView.getContext().getApplicationInfo().targetSdkVersion >= + Build.VERSION_CODES.LOLLIPOP) { uploadFileCallback.onReceiveValue(null); return; } + + // Otherwise, for older apps, attempt to invoke the legacy (hidden) API for + // backwards compatibility. ValueCallback innerCallback = new ValueCallback() { private boolean mCompleted; @Override -- cgit v1.2.3