summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/Tab.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/browser/Tab.java')
-rw-r--r--src/com/android/browser/Tab.java82
1 files changed, 77 insertions, 5 deletions
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index 78bf70e..a3e4a59 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -46,16 +46,19 @@ import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewStub;
-import android.webkit.BrowserDownloadListener;
+import android.webkit.ClientCertRequest;
import android.webkit.ConsoleMessage;
+import android.webkit.CookieManager;
import android.webkit.GeolocationPermissions;
+import android.webkit.GeolocationPermissions.Callback;
import android.webkit.HttpAuthHandler;
+import android.webkit.PermissionRequest;
import android.webkit.SslErrorHandler;
import android.webkit.URLUtil;
import android.webkit.ValueCallback;
import android.webkit.WebBackForwardList;
-import android.webkit.WebBackForwardListClient;
import android.webkit.WebChromeClient;
+import android.webkit.WebChromeClient.FileChooserParams;
import android.webkit.WebHistoryItem;
import android.webkit.WebResourceResponse;
import android.webkit.WebStorage;
@@ -75,6 +78,7 @@ import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;
+import java.security.Principal;
import java.util.LinkedList;
import java.util.Map;
import java.util.UUID;
@@ -133,6 +137,8 @@ class Tab implements PictureListener {
// The Geolocation permissions prompt
private GeolocationPermissionsPrompt mGeolocationPermissionsPrompt;
+ // The permissions prompt
+ private PermissionsPrompt mPermissionsPrompt;
// Main WebView wrapper
private View mContainer;
// Main WebView
@@ -560,6 +566,29 @@ class Tab implements PictureListener {
}
}
+ /**
+ * Displays client certificate request to the user.
+ */
+ @Override
+ public void onReceivedClientCertRequest(final WebView view,
+ final ClientCertRequest request) {
+ if (!mInForeground) {
+ request.ignore();
+ return;
+ }
+ KeyChain.choosePrivateKeyAlias(
+ mWebViewController.getActivity(), new KeyChainAliasCallback() {
+ @Override public void alias(String alias) {
+ if (alias == null) {
+ request.cancel();
+ return;
+ }
+ new KeyChainLookup(mContext, request, alias).execute();
+ }
+ }, request.getKeyTypes(), request.getPrincipals(), request.getHost(),
+ request.getPort(), null);
+ }
+
/**
* Handles an HTTP authentication request.
*
@@ -886,6 +915,19 @@ class Tab implements PictureListener {
}
}
+ @Override
+ public void onPermissionRequest(PermissionRequest request) {
+ if (!mInForeground) return;
+ getPermissionsPrompt().show(request);
+ }
+
+ @Override
+ public void onPermissionRequestCanceled(PermissionRequest request) {
+ if (mInForeground && mPermissionsPrompt != null) {
+ mPermissionsPrompt.hide();
+ }
+ }
+
/* Adds a JavaScript error message to the system log and if the JS
* console is enabled in the about:debug options, to that console
* also.
@@ -959,11 +1001,13 @@ class Tab implements PictureListener {
}
@Override
- public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
+ public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> callback,
+ FileChooserParams params) {
if (mInForeground) {
- mWebViewController.openFileChooser(uploadMsg, acceptType, capture);
+ mWebViewController.showFileChooser(callback, params);
+ return true;
} else {
- uploadMsg.onReceiveValue(null);
+ return false;
}
}
@@ -1014,6 +1058,10 @@ class Tab implements PictureListener {
mClient.onReceivedSslError(view, handler, error);
}
@Override
+ public void onReceivedClientCertRequest(WebView view, ClientCertRequest request) {
+ mClient.onReceivedClientCertRequest(view, request);
+ }
+ @Override
public void onReceivedHttpAuthRequest(WebView view,
HttpAuthHandler handler, String host, String realm) {
mClient.onReceivedHttpAuthRequest(view, handler, host, realm);
@@ -1202,6 +1250,10 @@ class Tab implements PictureListener {
mGeolocationPermissionsPrompt.hide();
}
+ if (mPermissionsPrompt != null) {
+ mPermissionsPrompt.hide();
+ }
+
mWebViewController.onSetWebView(this, w);
if (mMainView != null) {
@@ -1509,6 +1561,18 @@ class Tab implements PictureListener {
}
/**
+ * @return The permissions prompt for this tab.
+ */
+ PermissionsPrompt getPermissionsPrompt() {
+ if (mPermissionsPrompt == null) {
+ ViewStub stub = (ViewStub) mContainer
+ .findViewById(R.id.permissions_prompt);
+ mPermissionsPrompt = (PermissionsPrompt) stub.inflate();
+ }
+ return mPermissionsPrompt;
+ }
+
+ /**
* @return The application id string
*/
String getAppId() {
@@ -1911,4 +1975,12 @@ class Tab implements PictureListener {
setSecurityState(SecurityState.SECURITY_STATE_MIXED);
}
}
+
+ public void setAcceptThirdPartyCookies(boolean accept) {
+ CookieManager cookieManager = CookieManager.getInstance();
+ if (mMainView != null)
+ cookieManager.setAcceptThirdPartyCookies(mMainView, accept);
+ if (mSubView != null)
+ cookieManager.setAcceptThirdPartyCookies(mSubView, accept);
+ }
}