Re-login after a week.

Refactor GoogleAccountLogin to handle the progress dialog.  Store the last login
time and login after a week to refresh cookies.

Bug: 3367395
Change-Id: I62a277610af5b642f51cc775f17806c558812d4a
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 472201b..a2ddc8c 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -2093,8 +2093,8 @@
     // This method does a ton of stuff. It will attempt to create a new tab
     // if we haven't reached MAX_TABS. Otherwise it uses the current tab. If
     // url isn't null, it will load the given url.
-    public Tab openTabAndShow(Tab parent, UrlData urlData, boolean closeOnExit,
-            String appId) {
+    public Tab openTabAndShow(Tab parent, final UrlData urlData,
+            boolean closeOnExit, String appId) {
         final Tab currentTab = mTabControl.getCurrentTab();
         if (mTabControl.canCreateNewTab()) {
             final Tab tab = mTabControl.createNewTab(closeOnExit, appId,
@@ -2105,9 +2105,17 @@
             // animation behavior.
             addTab(tab);
             setActiveTab(tab);
-            if (!urlData.isEmpty()) {
-                loadUrlDataIn(tab, urlData);
-            }
+
+            // Callback to load the url data.
+            final Runnable load = new Runnable() {
+                @Override public void run() {
+                    if (!urlData.isEmpty()) {
+                        loadUrlDataIn(tab, urlData);
+                    }
+                }
+            };
+
+            GoogleAccountLogin.startLoginIfNeeded(mActivity, mSettings, load);
             return tab;
         } else {
             // Get rid of the subwindow if it exists