Add new auto-login UI.
When the WebView notifies us of an auto-login request, check if the account is
valid. If so, use it to log into the account manager. If that fails or the
account is not valid, display the login UI.
Bug: 3367381
Change-Id: I5a164ef676921eec03a89860fa5be722d3d987d4
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index 70028ea..2d194f0 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -132,6 +132,8 @@
// Listener used to know when we move forward or back in the history list.
private final WebBackForwardListClient mWebBackForwardListClient;
private DataController mDataController;
+ // State of the auto-login request.
+ private DeviceAccountLogin mDeviceAccountLogin;
// AsyncTask for downloading touch icons
DownloadTouchIcon mTouchIconLoader;
@@ -527,6 +529,13 @@
}
}
+ // Cancel the auto-login process.
+ if (mDeviceAccountLogin != null) {
+ mDeviceAccountLogin.cancel();
+ mDeviceAccountLogin = null;
+ mWebViewController.hideAutoLogin(Tab.this);
+ }
+
// finally update the UI in the activity if it is in the foreground
mWebViewController.onPageStarted(Tab.this, view, favicon);
@@ -809,8 +818,27 @@
}
mWebViewController.onUnhandledKeyEvent(event);
}
+
+ @Override
+ public void onReceivedLoginRequest(WebView view, String realm,
+ String account, String args) {
+ new DeviceAccountLogin(mActivity, view, Tab.this, mWebViewController)
+ .handleLogin(realm, account, args);
+ }
+
};
+ // Called by DeviceAccountLogin when the Tab needs to have the auto-login UI
+ // displayed.
+ void setDeviceAccountLogin(DeviceAccountLogin login) {
+ mDeviceAccountLogin = login;
+ }
+
+ // Returns non-null if the title bar should display the auto-login UI.
+ DeviceAccountLogin getDeviceAccountLogin() {
+ return mDeviceAccountLogin;
+ }
+
// -------------------------------------------------------------------------
// WebChromeClient implementation for the main WebView
// -------------------------------------------------------------------------