summaryrefslogtreecommitdiff
path: root/src/com/android/browser/Controller.java
diff options
context:
space:
mode:
authorPatrick Scott <phanna@android.com>2011-02-04 09:27:26 -0500
committerPatrick Scott <phanna@android.com>2011-02-04 13:22:01 -0500
commit7d50a9364107c21e3358e1dbc51a06359a5287fb (patch)
tree77912ffefe7bfd6fbcccf956adfba8e39fe592ff /src/com/android/browser/Controller.java
parent18793490c4a4fe1a9979218c7b3f2c88bc04e128 (diff)
Clear session cookies before attempting pre-login.
If ClientLogin issues session cookies, we do not want to clear them immediately after getting them from login. If we are not going to restore tabs, go ahead and clear the cookies before attempting pre-login. Keep track of the tab to restore so that we don't need to figure it out again. Requires a change in frameworks/base that exposes the CookieManager api. If we receive a 403 from IssueTokenAuth, inval the auth tokens and try again. Bug: 3421214 Change-Id: I5dd4cc0eba365a20a731ac43dd2571ef6274eaa9
Diffstat (limited to 'src/com/android/browser/Controller.java')
-rw-r--r--src/com/android/browser/Controller.java31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 07e1ef97..74a66b16 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -251,7 +251,7 @@ public class Controller
retainIconsOnStartup();
}
- void start(Bundle icicle, Intent intent) {
+ void start(final Bundle icicle, final Intent intent) {
// Unless the last browser usage was within 24 hours, destroy any
// remaining incognito tabs.
@@ -261,17 +261,32 @@ public class Controller
Calendar yesterday = Calendar.getInstance();
yesterday.add(Calendar.DATE, -1);
- boolean restoreIncognitoTabs = !(lastActiveDate == null
+ final boolean restoreIncognitoTabs = !(lastActiveDate == null
|| lastActiveDate.before(yesterday)
|| lastActiveDate.after(today));
- if (!mTabControl.restoreState(icicle, restoreIncognitoTabs,
- mUi.needsRestoreAllTabs())) {
- // there is no quit on Android. But if we can't restore the state,
- // we can treat it as a new Browser, remove the old session cookies.
- // This is done async in the CookieManager.
+ // Find out if we will restore any state and remember the tab.
+ final int currentTab =
+ mTabControl.canRestoreState(icicle, restoreIncognitoTabs);
+
+ if (currentTab == -1) {
+ // Not able to restore so we go ahead and clear session cookies. We
+ // must do this before trying to login the user as we don't want to
+ // clear any session cookies set during login.
CookieManager.getInstance().removeSessionCookie();
+ }
+
+ GoogleAccountLogin.startLoginIfNeeded(mActivity, mSettings,
+ new Runnable() {
+ @Override public void run() {
+ start(icicle, intent, currentTab, restoreIncognitoTabs);
+ }
+ });
+ }
+ private void start(Bundle icicle, Intent intent, int currentTab,
+ boolean restoreIncognitoTabs) {
+ if (currentTab == -1) {
final Bundle extra = intent.getExtras();
// Create an initial tab.
// If the intent is ACTION_VIEW and data is not null, the Browser is
@@ -303,6 +318,8 @@ public class Controller
loadUrlDataIn(t, urlData);
}
} else {
+ mTabControl.restoreState(icicle, currentTab, restoreIncognitoTabs,
+ mUi.needsRestoreAllTabs());
mUi.updateTabs(mTabControl.getTabs());
// TabControl.restoreState() will create a new tab even if
// restoring the state fails.