Merge "Fix WebStorageSizeManagerUnitTest NPE"
diff --git a/res/menu/browser.xml b/res/menu/browser.xml
index 7d288c1..2b651c3 100644
--- a/res/menu/browser.xml
+++ b/res/menu/browser.xml
@@ -50,21 +50,30 @@
             android:icon="@drawable/ic_bookmarks_history_holo_dark"
             android:alphabeticShortcut="b"
             android:visible="@bool/menu_show_bookmarks" />
-        <item
-            android:id="@+id/share_page_menu_id"
-            android:title="@string/share_page"
-            android:icon="@drawable/ic_share_holo_dark"
-            android:alphabeticShortcut="s" />
-        <item
-            android:id="@+id/find_menu_id"
-            android:title="@*android:string/find_on_page"/>
-        <item
-            android:id="@+id/ua_desktop_menu_id"
-            android:checkable="true"
-            android:title="@string/ua_switcher_desktop" />
-        <item
-            android:id="@+id/save_snapshot_menu_id"
-            android:title="@string/menu_save_snapshot" />
+        <group
+            android:id="@+id/LIVE_MENU">
+            <item
+                android:id="@+id/share_page_menu_id"
+                android:title="@string/share_page"
+                android:icon="@drawable/ic_share_holo_dark"
+                android:alphabeticShortcut="s" />
+            <item
+                android:id="@+id/find_menu_id"
+                android:title="@*android:string/find_on_page"/>
+            <item
+                android:id="@+id/ua_desktop_menu_id"
+                android:checkable="true"
+                android:title="@string/ua_switcher_desktop" />
+            <item
+                android:id="@+id/save_snapshot_menu_id"
+                android:title="@string/menu_save_snapshot" />
+        </group>
+        <group
+            android:id="@+id/SNAPSHOT_MENU">
+            <item
+                android:id="@+id/snapshot_go_live"
+                android:title="@string/snapshot_go_live" />
+        </group>
         <item
             android:id="@+id/page_info_menu_id"
             android:title="@string/page_info" />
diff --git a/res/menu/snapshot_go_live.xml b/res/menu/snapshot_go_live.xml
deleted file mode 100644
index aa6b38e..0000000
--- a/res/menu/snapshot_go_live.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
-    <item
-        android:id="@+id/snapshot_go_live"
-        android:title="@string/snapshot_go_live" />
-</menu>
-
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9bf1dcb..307459c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -656,7 +656,7 @@
     <string name="pref_data_preload_value_never" translatable="false">NEVER</string>
     <string name="pref_data_preload_value_wifi_only" translatable="false">WIFI_ONLY</string>
     <string name="pref_data_preload_value_always" translatable="false">ALWAYS</string>
-    <string name="pref_data_preload_default_value" translatable="false">@string/pref_data_preload_value_always</string>
+    <string name="pref_data_preload_default_value" translatable="false">@string/pref_data_preload_value_wifi_only</string>
     <string-array name="pref_data_preload_values" translatable="false">
         <item><xliff:g>@string/pref_data_preload_value_never</xliff:g></item>
         <item><xliff:g>@string/pref_data_preload_value_wifi_only</xliff:g></item>
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java
index 6b8daec..cfaa18a 100644
--- a/src/com/android/browser/BrowserSettings.java
+++ b/src/com/android/browser/BrowserSettings.java
@@ -25,6 +25,7 @@
 import android.os.Message;
 import android.preference.PreferenceManager;
 import android.provider.Browser;
+import android.util.DisplayMetrics;
 import android.webkit.CookieManager;
 import android.webkit.GeolocationPermissions;
 import android.webkit.WebIconDatabase;
@@ -104,6 +105,7 @@
     private WeakHashMap<WebSettings, String> mCustomUserAgents;
     private static boolean sInitialized = false;
     private boolean mNeedsSharedSync = true;
+    private float mFontSizeMult = 1.0f;
 
     // Cached values
     private int mPageCacheCapacity = 1;
@@ -158,6 +160,8 @@
 
         @Override
         public void run() {
+            DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
+            mFontSizeMult = metrics.scaledDensity / metrics.density;
             // the cost of one cached page is ~3M (measured using nytimes.com). For
             // low end devices, we only cache one page. For high end devices, we try
             // to cache more pages, currently choose 5.
@@ -522,9 +526,9 @@
         return rawValue;
     }
 
-    public static int getAdjustedTextZoom(int rawValue) {
+    public int getAdjustedTextZoom(int rawValue) {
         rawValue = (rawValue - TEXT_ZOOM_START_VAL) * TEXT_ZOOM_STEP;
-        return rawValue + 100;
+        return (int) ((rawValue + 100) * mFontSizeMult);
     }
 
     static int getRawTextZoom(int percent) {
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 4809f13..0a54a89 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -18,7 +18,6 @@
 
 import android.app.Activity;
 import android.app.DownloadManager;
-import android.app.PendingIntent;
 import android.app.SearchManager;
 import android.content.ClipboardManager;
 import android.content.ContentProvider;
@@ -93,7 +92,6 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.regex.Pattern;
 
 /**
  * Controller for browser
@@ -769,7 +767,6 @@
     public void stopLoading() {
         mLoadStopped = true;
         Tab tab = mTabControl.getCurrentTab();
-        tab.clearPageLoadCompleteListener();
         WebView w = getCurrentTopWebView();
         w.stopLoading();
         mUi.onPageStopped(tab);
@@ -1248,10 +1245,6 @@
         }
         MenuInflater inflater = mActivity.getMenuInflater();
         inflater.inflate(R.menu.browser, menu);
-        updateInLoadMenuItems(menu);
-        // hold on to the menu reference here; it is used by the page callbacks
-        // to update the menu based on loading state
-        mCachedMenu = menu;
         return true;
     }
 
@@ -1435,6 +1428,10 @@
     }
 
     boolean onPrepareOptionsMenu(Menu menu) {
+        updateInLoadMenuItems(menu);
+        // hold on to the menu reference here; it is used by the page callbacks
+        // to update the menu based on loading state
+        mCachedMenu = menu;
         // Note: setVisible will decide whether an item is visible; while
         // setEnabled() will decide whether an item is enabled, which also means
         // whether the matching shortcut key will function.
@@ -1465,11 +1462,13 @@
         boolean canGoForward = false;
         boolean isHome = false;
         boolean isDesktopUa = false;
+        boolean isLive = false;
         if (tab != null) {
             canGoBack = tab.canGoBack();
             canGoForward = tab.canGoForward();
             isHome = mSettings.getHomePage().equals(tab.getUrl());
             isDesktopUa = mSettings.hasDesktopUseragent(tab.getWebView());
+            isLive = !tab.isSnapshot();
         }
         final MenuItem back = menu.findItem(R.id.back_menu_id);
         back.setEnabled(canGoBack);
@@ -1486,6 +1485,7 @@
             dest.setTitle(source.getTitle());
             dest.setIcon(source.getIcon());
         }
+        menu.setGroupVisible(R.id.NAV_MENU, isLive);
 
         // decide whether to show the share link option
         PackageManager pm = mActivity.getPackageManager();
@@ -1506,6 +1506,8 @@
         counter.setEnabled(showDebugSettings);
         final MenuItem uaSwitcher = menu.findItem(R.id.ua_desktop_menu_id);
         uaSwitcher.setChecked(isDesktopUa);
+        menu.setGroupVisible(R.id.LIVE_MENU, isLive);
+        menu.setGroupVisible(R.id.SNAPSHOT_MENU, !isLive);
 
         mUi.updateMenuState(tab, menu);
     }
@@ -1623,6 +1625,10 @@
                 mPageDialogsHandler.showPageInfo(mTabControl.getCurrentTab(), false, null);
                 break;
 
+            case R.id.snapshot_go_live:
+                goLive();
+                return true;
+
             case R.id.classic_history_menu_id:
                 bookmarksOrHistoryPicker(true);
                 break;
@@ -1690,6 +1696,11 @@
         return true;
     }
 
+    private void goLive() {
+        Tab t = getCurrentTab();
+        t.loadUrl(t.getUrl(), null);
+    }
+
     public boolean onContextItemSelected(MenuItem item) {
         // Let the History and Bookmark fragments handle menus they created.
         if (item.getGroupId() == R.id.CONTEXT_MENU) {
@@ -2167,8 +2178,7 @@
         final PreloadedTabControl tabControl = urlData.getPreloadedTab();
         final String sbQuery = urlData.getSearchBoxQueryToSubmit();
         if (sbQuery != null) {
-            if (!tabControl.searchBoxSubmit(sbQuery, urlData.mUrl, urlData.mHeaders,
-                    urlData.getOnLoadCompletePendingIntent())) {
+            if (!tabControl.searchBoxSubmit(sbQuery, urlData.mUrl, urlData.mHeaders)) {
                 // Could not submit query. Fallback to regular tab creation
                 tabControl.destroy();
                 return null;
@@ -2186,18 +2196,6 @@
         mTabControl.addPreloadedTab(t);
         addTab(t);
         setActiveTab(t);
-        if (sbQuery == null) {
-            // if the searchbox query is set, the load complete notification is handled within
-            // the preloaded tab controller.
-            if (t.inPageLoad()) {
-                requestLoadCompleteNotification(urlData.mOnLoadCompletePendingIntent, t,
-                        urlData.mUrl, true, true);
-            } else {
-                // the page is already fully loaded
-                IntentHandler.sendPageLoadCompletePendingIntent(mActivity,
-                        urlData.mOnLoadCompletePendingIntent, true, true);
-            }
-        }
         return t;
     }
 
@@ -2391,26 +2389,10 @@
                 // this isn't called for preloaded tabs
             } else {
                 loadUrl(t, data.mUrl, data.mHeaders);
-                requestLoadCompleteNotification(data.mOnLoadCompletePendingIntent, t, data.mUrl,
-                        null, null);
             }
         }
     }
 
-    private void requestLoadCompleteNotification(final PendingIntent loadCompletePendingIntent,
-            Tab t, String forUrl, final Boolean preloaded, final Boolean preloadSuccess) {
-        if (loadCompletePendingIntent != null) {
-            Pattern urlMatch = Pattern.compile(Pattern.quote(forUrl));
-            t.setOnPageLoadCompleteListener(urlMatch, new Tab.OnPageLoadCompleteListener() {
-                @Override
-                public void onPageLoadComplete() {
-                    IntentHandler.sendPageLoadCompletePendingIntent(mActivity,
-                            loadCompletePendingIntent, preloaded, preloadSuccess);
-                }
-            });
-        }
-    }
-
     @Override
     public void onUserCanceledSsl(Tab tab) {
         // TODO: Figure out the "right" behavior
diff --git a/src/com/android/browser/IntentHandler.java b/src/com/android/browser/IntentHandler.java
index 178ba62..cc6b57c 100644
--- a/src/com/android/browser/IntentHandler.java
+++ b/src/com/android/browser/IntentHandler.java
@@ -18,8 +18,6 @@
 package com.android.browser;
 
 import android.app.Activity;
-import android.app.PendingIntent;
-import android.app.PendingIntent.CanceledException;
 import android.app.SearchManager;
 import android.content.ContentResolver;
 import android.content.Context;
@@ -32,7 +30,6 @@
 import android.provider.MediaStore;
 import android.speech.RecognizerResultsIntent;
 import android.text.TextUtils;
-import android.util.Log;
 import android.util.Patterns;
 
 import com.android.browser.search.SearchEngine;
@@ -53,22 +50,6 @@
     // "source" parameter for Google search from unknown source
     final static String GOOGLE_SEARCH_SOURCE_UNKNOWN = "unknown";
 
-    // Pending intent extra attached to browser intents that is broadcast when the page load
-    // completes.
-    // TODO move to android.provider.Browser & make public?
-    private static final String EXTRA_LOAD_COMPLETE_PENDINGINTENT = "load_complete_intent";
-    // extra attached to intent received via EXTRA_LOAD_COMPLETE_PENDINGINTENT indicating the
-    // time at which the load completed.
-    public static final String EXTRA_LOAD_COMPLETION_TIME = "completets";
-    // extra attached to intent received via EXTRA_LOAD_COMPLETE_PENDINGINTENT indicating if
-    // preloading was attempted.
-    public static final String EXTRA_PREFETCH_ATTEMPTED = "prefattempt";
-    // extra attached to intent received via EXTRA_LOAD_COMPLETE_PENDINGINTENT indicating if
-    // preloading succeeded.
-    public static final String EXTRA_PREFETCH_SUCCESS = "prefsuccess";
-
-
-
     /* package */ static final UrlData EMPTY_URL_DATA = new UrlData(null);
 
     private Activity mActivity;
@@ -243,39 +224,11 @@
         }
     }
 
-    /**
-     * Send a pending intent received in a page view intent. This should be called when the page
-     * has finished loading.
-     *
-     * @param prefetchAttempted Indicates if prefetching was attempted, {@code null} if prefetching
-     *      was not requested or is disabled.
-     * @param prefetchSucceeded Indicates if prefetching succeeded, {@code null} if prefetching
-     *      was not requested or is disabled.
-     */
-    public static void sendPageLoadCompletePendingIntent(Context context, PendingIntent pi,
-            Boolean prefetchAttempted, Boolean prefetchSucceeded) {
-        if (pi == null) return;
-        Intent fillIn = new Intent();
-        fillIn.putExtra(EXTRA_LOAD_COMPLETION_TIME, System.currentTimeMillis());
-        if (prefetchAttempted != null) {
-            fillIn.putExtra(EXTRA_PREFETCH_ATTEMPTED, prefetchAttempted.booleanValue());
-        }
-        if (prefetchSucceeded != null) {
-            fillIn.putExtra(EXTRA_PREFETCH_SUCCESS, prefetchSucceeded.booleanValue());
-        }
-        try {
-            pi.send(context, Activity.RESULT_OK, fillIn);
-        } catch (CanceledException e) {
-            // ignore
-        }
-    }
-
     protected static UrlData getUrlDataFromIntent(Intent intent) {
         String url = "";
         Map<String, String> headers = null;
         PreloadedTabControl preloaded = null;
         String preloadedSearchBoxQuery = null;
-        PendingIntent loadCompletePendingIntent = null;
         if (intent != null
                 && (intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
             final String action = intent.getAction();
@@ -300,10 +253,6 @@
                             PreloadRequestReceiver.EXTRA_SEARCHBOX_SETQUERY);
                     preloaded = Preloader.getInstance().getPreloadedTab(id);
                 }
-                if (intent.hasExtra(EXTRA_LOAD_COMPLETE_PENDINGINTENT)) {
-                    loadCompletePendingIntent =
-                        intent.getParcelableExtra(EXTRA_LOAD_COMPLETE_PENDINGINTENT);
-                }
             } else if (Intent.ACTION_SEARCH.equals(action)
                     || MediaStore.INTENT_ACTION_MEDIA_SEARCH.equals(action)
                     || Intent.ACTION_WEB_SEARCH.equals(action)) {
@@ -328,8 +277,7 @@
                 }
             }
         }
-        return new UrlData(url, headers, intent, preloaded, preloadedSearchBoxQuery,
-                loadCompletePendingIntent);
+        return new UrlData(url, headers, intent, preloaded, preloadedSearchBoxQuery);
     }
 
     /**
@@ -414,7 +362,6 @@
         final Intent mVoiceIntent;
         final PreloadedTabControl mPreloadedTab;
         final String mSearchBoxQueryToSubmit;
-        final PendingIntent mOnLoadCompletePendingIntent;
 
         UrlData(String url) {
             this.mUrl = url;
@@ -422,16 +369,14 @@
             this.mVoiceIntent = null;
             this.mPreloadedTab = null;
             this.mSearchBoxQueryToSubmit = null;
-            this.mOnLoadCompletePendingIntent = null;
         }
 
         UrlData(String url, Map<String, String> headers, Intent intent) {
-            this(url, headers, intent, null, null, null);
+            this(url, headers, intent, null, null);
         }
 
         UrlData(String url, Map<String, String> headers, Intent intent,
-                PreloadedTabControl preloaded, String searchBoxQueryToSubmit,
-                PendingIntent onLoadCompletePendingIntent) {
+                PreloadedTabControl preloaded, String searchBoxQueryToSubmit) {
             this.mUrl = url;
             this.mHeaders = headers;
             if (RecognizerResultsIntent.ACTION_VOICE_SEARCH_RESULTS
@@ -442,7 +387,6 @@
             }
             this.mPreloadedTab = preloaded;
             this.mSearchBoxQueryToSubmit = searchBoxQueryToSubmit;
-            this.mOnLoadCompletePendingIntent = onLoadCompletePendingIntent;
         }
 
         boolean isEmpty() {
@@ -460,10 +404,6 @@
         String getSearchBoxQueryToSubmit() {
             return mSearchBoxQueryToSubmit;
         }
-
-        PendingIntent getOnLoadCompletePendingIntent() {
-            return mOnLoadCompletePendingIntent;
-        }
     }
 
 }
diff --git a/src/com/android/browser/NavigationBarPhone.java b/src/com/android/browser/NavigationBarPhone.java
index 7e8695b..a1e778d 100644
--- a/src/com/android/browser/NavigationBarPhone.java
+++ b/src/com/android/browser/NavigationBarPhone.java
@@ -15,6 +15,7 @@
  */
 package com.android.browser;
 
+import android.app.Activity;
 import android.content.Context;
 import android.content.res.Resources;
 import android.graphics.drawable.Drawable;
@@ -174,14 +175,21 @@
     }
 
     void showMenu(View anchor) {
-        mOverflowMenuShowing = true;
-        mPopupMenu = new PopupMenu(mContext, anchor);
+        Activity activity = mUiController.getActivity();
+        if (mPopupMenu == null) {
+            mPopupMenu = new PopupMenu(mContext, anchor);
+            mPopupMenu.setOnMenuItemClickListener(this);
+            mPopupMenu.setOnDismissListener(this);
+            if (!activity.onCreateOptionsMenu(mPopupMenu.getMenu())) {
+                mPopupMenu = null;
+                return;
+            }
+        }
         Menu menu = mPopupMenu.getMenu();
-        mPopupMenu.getMenuInflater().inflate(R.menu.browser, menu);
-        mUiController.updateMenuState(mBaseUi.getActiveTab(), menu);
-        mPopupMenu.setOnMenuItemClickListener(this);
-        mPopupMenu.setOnDismissListener(this);
-        mPopupMenu.show();
+        if (activity.onPrepareOptionsMenu(menu)) {
+            mOverflowMenuShowing = true;
+            mPopupMenu.show();
+        }
     }
 
     @Override
@@ -193,7 +201,6 @@
 
     private void onMenuHidden() {
         mOverflowMenuShowing = false;
-        mPopupMenu = null;
         mBaseUi.showTitleBarForDuration();
     }
 
diff --git a/src/com/android/browser/PhoneUi.java b/src/com/android/browser/PhoneUi.java
index f5a76b9..606a47d 100644
--- a/src/com/android/browser/PhoneUi.java
+++ b/src/com/android/browser/PhoneUi.java
@@ -162,7 +162,6 @@
 
     @Override
     public void updateMenuState(Tab tab, Menu menu) {
-        menu.setGroupVisible(R.id.NAV_MENU, (mNavScreen == null));
         MenuItem bm = menu.findItem(R.id.bookmarks_menu_id);
         if (bm != null) {
             bm.setVisible(mNavScreen == null);
@@ -173,7 +172,13 @@
         }
         MenuItem abm = menu.findItem(R.id.add_bookmark_menu_id);
         if (abm != null) {
-            abm.setVisible((tab != null) && !tab.isSnapshot());
+            abm.setVisible((tab != null) && !tab.isSnapshot() && mNavScreen == null);
+        }
+        if (mNavScreen != null) {
+            menu.setGroupVisible(R.id.LIVE_MENU, false);
+            menu.setGroupVisible(R.id.SNAPSHOT_MENU, false);
+            menu.findItem(R.id.page_info_menu_id).setVisible(false);
+            menu.setGroupVisible(R.id.NAV_MENU, false);
         }
     }
 
diff --git a/src/com/android/browser/PreloadedTabControl.java b/src/com/android/browser/PreloadedTabControl.java
index b0eff63..4ffe6b4 100644
--- a/src/com/android/browser/PreloadedTabControl.java
+++ b/src/com/android/browser/PreloadedTabControl.java
@@ -15,7 +15,6 @@
  */
 package com.android.browser;
 
-import android.app.PendingIntent;
 import android.net.Uri;
 import android.text.TextUtils;
 import android.util.Log;
@@ -40,7 +39,7 @@
         mTab = t;
     }
 
-    private boolean maybeSetQuery(final String query, SearchBox sb) {
+    private void maybeSetQuery(final String query, SearchBox sb) {
         if (!TextUtils.equals(mLastQuery, query)) {
             if (sb != null) {
                 if (LOGD_ENABLED) Log.d(LOGTAG, "Changing searchbox query to " + query);
@@ -56,27 +55,25 @@
                         }
                     }
                 });
-                return true;
             } else {
                 if (LOGD_ENABLED) Log.d(LOGTAG, "Cannot set query: no searchbox interface");
             }
         }
-        return false;
     }
 
     public void setQuery(String query) {
         maybeSetQuery(query, mTab.getWebView().getSearchBox());
     }
 
-    public boolean searchBoxSubmit(final String query, final String fallbackUrl,
-            final Map<String, String> fallbackHeaders, final PendingIntent onLoadCompleteIntent) {
+    public boolean searchBoxSubmit(final String query,
+            final String fallbackUrl, final Map<String, String> fallbackHeaders) {
         final SearchBox sb = mTab.getWebView().getSearchBox();
         if (sb == null) {
             // no searchbox, cannot submit. Fallback to regular tab creation
             if (LOGD_ENABLED) Log.d(LOGTAG, "No searchbox, cannot submit query");
             return false;
         }
-        final boolean newQuery = maybeSetQuery(query, sb);
+        maybeSetQuery(query, sb);
         if (LOGD_ENABLED) Log.d(LOGTAG, "Submitting query " + query);
         final String currentUrl = mTab.getUrl();
         sb.onsubmit(new SearchBox.SearchBoxListener() {
@@ -87,14 +84,9 @@
                 if (!called) {
                     if (LOGD_ENABLED) Log.d(LOGTAG, "Query not submitted; falling back");
                     loadUrl(fallbackUrl, fallbackHeaders);
-
                     // make sure that the failed, preloaded URL is cleared from the back stack
                     mTab.clearBackStackWhenItemAdded(Pattern.compile(
                             "^" + Pattern.quote(fallbackUrl) + "$"));
-                    // When setting the search box query, preloadAttempted=true implies that the
-                    // the query was prefetched using the searchbox API. This is the case if we
-                    // the query is not new.
-                    registerLoadCompleteListener(!newQuery, false, onLoadCompleteIntent);
                 } else {
                     // ignore the next fragment change, to avoid leaving a blank page in the browser
                     // after the query has been submitted.
@@ -108,27 +100,11 @@
                                     Pattern.quote(currentWithoutFragment) +
                                     "(\\#.*)?" +
                                     "$"));
-                    registerLoadCompleteListener(!newQuery, true, onLoadCompleteIntent);
                 }
             }});
         return true;
     }
 
-    private void registerLoadCompleteListener(
-            final boolean queryPreloaded,
-            final boolean preloadSucceeded,
-            final PendingIntent pendingIntent) {
-        if (pendingIntent == null) {
-            return;
-        }
-        mTab.setOnPageLoadCompleteListener(null, new Tab.OnPageLoadCompleteListener(){
-            @Override
-            public void onPageLoadComplete() {
-                IntentHandler.sendPageLoadCompletePendingIntent(mTab.mContext, pendingIntent,
-                        queryPreloaded, preloadSucceeded);
-            }});
-    }
-
     public void searchBoxCancel() {
         SearchBox sb = mTab.getWebView().getSearchBox();
         if (sb != null) {
diff --git a/src/com/android/browser/SnapshotBar.java b/src/com/android/browser/SnapshotBar.java
index 039afcf..2fb90d2 100644
--- a/src/com/android/browser/SnapshotBar.java
+++ b/src/com/android/browser/SnapshotBar.java
@@ -21,7 +21,6 @@
 import android.os.Message;
 import android.text.TextUtils;
 import android.util.AttributeSet;
-import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.View.OnClickListener;
@@ -29,21 +28,18 @@
 import android.view.ViewPropertyAnimator;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
-import android.widget.PopupMenu;
 import android.widget.PopupMenu.OnMenuItemClickListener;
 import android.widget.TextView;
 
 import java.text.DateFormat;
 import java.util.Date;
 
-public class SnapshotBar extends LinearLayout implements OnClickListener,
-        OnMenuItemClickListener {
+public class SnapshotBar extends LinearLayout implements OnClickListener {
 
     private static final int MSG_SHOW_TITLE = 1;
     private static final long DURATION_SHOW_DATE = BaseUi.HIDE_TITLEBAR_DELAY;
 
     private ImageView mFavicon;
-    private View mGoLive;
     private TextView mDate;
     private TextView mTitle;
     private View mBookmarks;
@@ -86,10 +82,7 @@
     @Override
     protected void onFinishInflate() {
         super.onFinishInflate();
-        mGoLive = mFavicon = (ImageView) findViewById(R.id.favicon);
-        if (mGoLive == null) {
-            mGoLive = findViewById(R.id.date_icon);
-        }
+        mFavicon = (ImageView) findViewById(R.id.favicon);
         mDate = (TextView) findViewById(R.id.date);
         mTitle = (TextView) findViewById(R.id.title);
         mBookmarks = findViewById(R.id.all_btn);
@@ -113,7 +106,6 @@
             mToggleContainer.setOnClickListener(this);
             resetAnimation();
         }
-        mGoLive.setOnClickListener(this);
     }
 
     @Override
@@ -173,12 +165,6 @@
     public void onClick(View v) {
         if (mBookmarks == v) {
             mTitleBar.getUiController().bookmarksOrHistoryPicker(false);
-        } else if (mGoLive == v) {
-            PopupMenu popup = new PopupMenu(mContext, mGoLive);
-            Menu menu = popup.getMenu();
-            popup.getMenuInflater().inflate(R.menu.snapshot_go_live, menu);
-            popup.setOnMenuItemClickListener(this);
-            popup.show();
         } else if (mTabSwitcher == v) {
             ((PhoneUi) mTitleBar.getUi()).toggleNavScreen();
         } else if (mOverflowMenu == v) {
@@ -195,21 +181,6 @@
         }
     }
 
-    @Override
-    public boolean onMenuItemClick(MenuItem item) {
-        switch (item.getItemId()) {
-        case R.id.snapshot_go_live:
-            goLive();
-            return true;
-        }
-        return false;
-    }
-
-    private void goLive() {
-        Tab t = mTitleBar.getUi().getActiveTab();
-        t.loadUrl(t.getUrl(), null);
-    }
-
     public void onTabDataChanged(Tab tab) {
         if (!tab.isSnapshot()) return;
         SnapshotTab snapshot = (SnapshotTab) tab;
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index 8dcc54b..8c9dc02 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -66,6 +66,8 @@
 import android.webkit.WebView.PictureListener;
 import android.webkit.WebViewClient;
 import android.widget.CheckBox;
+import android.widget.LinearLayout;
+import android.widget.TextView;
 import android.widget.Toast;
 
 import com.android.browser.TabControl.OnThumbnailUpdatedListener;
@@ -172,13 +174,10 @@
     private Handler mHandler;
 
     /**
-     * See {@link #clearBackStackWhenItemAdded(Pattern)}.
+     * See {@link #clearBackStackWhenItemAdded(String)}.
      */
     private Pattern mClearHistoryUrlPattern;
 
-    private OnPageLoadCompleteListener mOnPageLoadCompleteListener;
-    private Pattern mOnPageLoadCompleteUrlMatch;
-
     private static synchronized Bitmap getDefaultFavicon(Context context) {
         if (sDefaultFavicon == null) {
             sDefaultFavicon = BitmapFactory.decodeResource(
@@ -533,26 +532,6 @@
         }
     }
 
-    public interface OnPageLoadCompleteListener {
-        void onPageLoadComplete();
-    }
-
-    /**
-     * Requests a notification when the next page load completes. This is a one shot notification,
-     * the listener will be discarded after the first callback, or if the page load is cancelled.
-     * @param listener
-     */
-    public void setOnPageLoadCompleteListener(Pattern urlMatch,
-            OnPageLoadCompleteListener listener) {
-        mOnPageLoadCompleteListener = listener;
-        mOnPageLoadCompleteUrlMatch = urlMatch;
-    }
-
-    public void clearPageLoadCompleteListener() {
-        mOnPageLoadCompleteListener = null;
-        mOnPageLoadCompleteUrlMatch = null;
-    }
-
     // -------------------------------------------------------------------------
     // WebViewClient implementation for the main WebView
     // -------------------------------------------------------------------------
@@ -616,13 +595,6 @@
 
         @Override
         public void onPageFinished(WebView view, String url) {
-            if (mOnPageLoadCompleteListener != null) {
-                if (mOnPageLoadCompleteUrlMatch == null
-                        || mOnPageLoadCompleteUrlMatch.matcher(url).matches())
-                mOnPageLoadCompleteListener.onPageLoadComplete();
-                mOnPageLoadCompleteListener = null;
-                mOnPageLoadCompleteUrlMatch = null;
-            }
             if (!mInPageLoad) {
                 // In page navigation links (www.something.com#footer) will
                 // trigger an onPageFinished which we don't care about.
@@ -2070,7 +2042,6 @@
             mCurrentState = new PageState(mContext, false, url, null);
             mWebViewController.onPageStarted(this, mMainView, null);
             mMainView.loadUrl(url, headers);
-            clearPageLoadCompleteListener();
         }
     }
 
@@ -2122,14 +2093,12 @@
 
     public void goBack() {
         if (mMainView != null) {
-            clearPageLoadCompleteListener();
             mMainView.goBack();
         }
     }
 
     public void goForward() {
         if (mMainView != null) {
-            clearPageLoadCompleteListener();
             mMainView.goForward();
         }
     }
diff --git a/src/com/android/browser/UiController.java b/src/com/android/browser/UiController.java
index 0da523a..97e99a9 100644
--- a/src/com/android/browser/UiController.java
+++ b/src/com/android/browser/UiController.java
@@ -16,6 +16,7 @@
 
 package com.android.browser;
 
+import android.app.Activity;
 import android.content.Intent;
 import android.view.Menu;
 import android.view.MenuItem;
@@ -100,4 +101,6 @@
 
     void setBlockEvents(boolean block);
 
+    Activity getActivity();
+
 }
diff --git a/src/com/android/browser/UrlBarAutoShowManager.java b/src/com/android/browser/UrlBarAutoShowManager.java
index b491e0b..f1bbe7f 100644
--- a/src/com/android/browser/UrlBarAutoShowManager.java
+++ b/src/com/android/browser/UrlBarAutoShowManager.java
@@ -103,7 +103,7 @@
         case MotionEvent.ACTION_DOWN:
             if (!mIsTracking && event.getPointerCount() == 1) {
                 long sinceLastScroll =
-                        System.currentTimeMillis() - mLastScrollTime;
+                        SystemClock.uptimeMillis() - mLastScrollTime;
                 if (sinceLastScroll < IGNORE_INTERVAL) {
                     break;
                 }
diff --git a/src/com/android/browser/preferences/AccessibilityPreferencesFragment.java b/src/com/android/browser/preferences/AccessibilityPreferencesFragment.java
index 312a61e..6adfd23 100644
--- a/src/com/android/browser/preferences/AccessibilityPreferencesFragment.java
+++ b/src/com/android/browser/preferences/AccessibilityPreferencesFragment.java
@@ -76,7 +76,8 @@
                     .getAdjustedMinimumFontSize((Integer) objValue));
         }
         if (PreferenceKeys.PREF_TEXT_ZOOM.equals(pref.getKey())) {
-            updateTextZoomSummary(pref, BrowserSettings
+            BrowserSettings settings = BrowserSettings.getInstance();
+            updateTextZoomSummary(pref, settings
                     .getAdjustedTextZoom((Integer) objValue));
         }
         if (PreferenceKeys.PREF_INVERTED_CONTRAST.equals(pref.getKey())) {