Merge change 4094

* changes:
  Consolidate bookmark add/delete code in the browser.
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index d7f3910..18fe793 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -2060,12 +2060,12 @@
     }
 
     // 500ms animation with 800ms delay
-    private static final int TAB_ANIMATION_DURATION = 500;
-    private static final int TAB_OVERVIEW_DELAY     = 800;
+    private static final int TAB_ANIMATION_DURATION = 200;
+    private static final int TAB_OVERVIEW_DELAY     = 500;
 
     // Called by TabControl when a tab is requesting focus
     /* package */ void showTab(TabControl.Tab t) {
-        showTab(t, null);
+        showTab(t, EMPTY_URL_DATA);
     }
 
     private void showTab(TabControl.Tab t, UrlData urlData) {
@@ -2518,7 +2518,7 @@
      * or an empty string if, for example, the URL in question is a
      * file:// URL with no hostname.
      */
-    private static String buildTitleUrl(String url) {
+    /* package */ static String buildTitleUrl(String url) {
         String titleUrl = null;
 
         if (url != null) {
@@ -2617,7 +2617,8 @@
         // Change to the parent tab
         final TabControl.Tab tab = mTabControl.getTab(indexToShow);
         if (tab != null) {
-            sendAnimateFromOverview(tab, false, null, null, delay, null);
+            sendAnimateFromOverview(tab, false, EMPTY_URL_DATA, null, delay,
+                    null);
         } else {
             // Increment this here so that no other animations can happen in
             // between the end of the tab picker transition and the beginning
@@ -3493,8 +3494,8 @@
                 // openTabAndShow will dispatch the message after creating the
                 // new WebView. This will prevent another request from coming
                 // in during the animation.
-                final TabControl.Tab newTab = openTabAndShow((String) null, msg, false,
-                        null);
+                final TabControl.Tab newTab =
+                        openTabAndShow(EMPTY_URL_DATA, msg, false, null);
                 if (newTab != parent) {
                     parent.addChildTab(newTab);
                 }
@@ -4518,7 +4519,7 @@
                 openTabAndShow(mSettings.getHomePage(), null, false, null);
             } else {
                 sendAnimateFromOverview(mTabControl.getTab(index),
-                        false, null, null, 0, null);
+                        false, EMPTY_URL_DATA, null, 0, null);
             }
         }
     }
diff --git a/src/com/android/browser/BrowserProvider.java b/src/com/android/browser/BrowserProvider.java
index 8ed889e..8743254 100644
--- a/src/com/android/browser/BrowserProvider.java
+++ b/src/com/android/browser/BrowserProvider.java
@@ -31,12 +31,15 @@
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
 import android.database.AbstractCursor;
+import android.database.ContentObserver;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
 import android.database.sqlite.SQLiteOpenHelper;
 import android.net.Uri;
+import android.os.Handler;
 import android.preference.PreferenceManager;
 import android.provider.Browser;
+import android.provider.Settings;
 import android.server.search.SearchableInfo;
 import android.text.TextUtils;
 import android.text.util.Regex;
@@ -267,9 +270,65 @@
                 ed.commit();
             }
         }
+        mShowWebSuggestionsSettingChangeObserver
+            = new ShowWebSuggestionsSettingChangeObserver();
+        context.getContentResolver().registerContentObserver(
+                Settings.System.getUriFor(
+                        Settings.System.SHOW_WEB_SUGGESTIONS),
+                true, mShowWebSuggestionsSettingChangeObserver);
+        updateShowWebSuggestions();
         return true;
     }
 
+    /**
+     * This Observer will ensure that if the user changes the system
+     * setting of whether to display web suggestions, we will
+     * change accordingly.
+     */
+    /* package */ class ShowWebSuggestionsSettingChangeObserver
+            extends ContentObserver {
+        public ShowWebSuggestionsSettingChangeObserver() {
+            super(new Handler());
+        }
+
+        @Override
+        public void onChange(boolean selfChange) {
+            updateShowWebSuggestions();
+        }
+    }
+
+    private ShowWebSuggestionsSettingChangeObserver
+            mShowWebSuggestionsSettingChangeObserver;
+
+    // If non-null, then the system is set to show web suggestions,
+    // and this is the SearchableInfo to use to get them.
+    private SearchableInfo mSearchableInfo;
+
+    /**
+     * Check the system settings to see whether web suggestions are
+     * allowed.  If so, store the SearchableInfo to grab suggestions
+     * while the user is typing.
+     */
+    private void updateShowWebSuggestions() {
+        mSearchableInfo = null;
+        Context context = getContext();
+        if (Settings.System.getInt(context.getContentResolver(),
+                Settings.System.SHOW_WEB_SUGGESTIONS,
+                1 /* default on */) == 1) {
+            Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
+            intent.addCategory(Intent.CATEGORY_DEFAULT);
+            ResolveInfo info = context.getPackageManager().resolveActivity(
+                    intent, PackageManager.MATCH_DEFAULT_ONLY);
+            if (info != null) {
+                ComponentName googleSearchComponent =
+                        new ComponentName(info.activityInfo.packageName,
+                                info.activityInfo.name);
+                mSearchableInfo = SearchManager.getSearchableInfo(
+                        googleSearchComponent, false);
+            }
+        }
+    }
+
     private void fixPicasaBookmark() {
         SQLiteDatabase db = mOpenHelper.getWritableDatabase();
         Cursor cursor = db.rawQuery("SELECT _id FROM bookmarks WHERE " +
@@ -603,21 +662,11 @@
             } else {
                 // get Google suggest if there is still space in the list
                 if (myArgs != null && myArgs.length > 1
+                        && mSearchableInfo != null
                         && c.getCount() < (MAX_SUGGESTION_SHORT_ENTRIES - 1)) {
-                    Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
-                    intent.addCategory(Intent.CATEGORY_DEFAULT);
-                    ResolveInfo info = getContext().getPackageManager().resolveActivity(
-                            intent, PackageManager.MATCH_DEFAULT_ONLY);
-                    if (info != null) {
-                        ComponentName googleSearchComponent =
-                                new ComponentName(info.activityInfo.packageName,
-                                        info.activityInfo.name);
-                        SearchableInfo si =
-                                SearchManager.getSearchableInfo(googleSearchComponent, false);
-                        Cursor sc = SearchManager.getSuggestions(
-                                getContext(), si, selectionArgs[0]);
-                        return new MySuggestionCursor(c, sc, selectionArgs[0]);
-                    }
+                    Cursor sc = SearchManager.getSuggestions(
+                            getContext(), mSearchableInfo, selectionArgs[0]);
+                    return new MySuggestionCursor(c, sc, selectionArgs[0]);
                 }
                 return new MySuggestionCursor(c, null, selectionArgs[0]);
             }
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java
index 34cab94..5276ef9 100644
--- a/src/com/android/browser/BrowserSettings.java
+++ b/src/com/android/browser/BrowserSettings.java
@@ -82,6 +82,7 @@
     // The Browser always enables Application Caches.
     private boolean appCacheEnabled = true;
     private String appCachePath;  // default value set in loadFromDb().
+    private boolean domStorageEnabled = true;
 
     private final static String TAG = "BrowserSettings";
 
@@ -204,6 +205,7 @@
 
             s.setDatabasePath(b.databasePath);
             s.setDatabaseEnabled(b.databaseEnabled);
+            s.setDomStorageEnabled(b.domStorageEnabled);
             s.setWebStorageDefaultQuota(b.webStorageDefaultQuota);
 
             // Turn on Application Caches.
@@ -259,7 +261,9 @@
         webStorageDefaultQuota = Long.parseLong(p.getString(PREF_DEFAULT_QUOTA,
                 String.valueOf(webStorageDefaultQuota)));
         appCacheEnabled = p.getBoolean("enable_appcache",
-            appCacheEnabled);
+                appCacheEnabled);
+        domStorageEnabled = p.getBoolean("enable_domstorage",
+                domStorageEnabled);
         appCachePath = p.getString("appcache_path", appCachePath);
         javaScriptCanOpenWindowsAutomatically = !p.getBoolean(
             "block_popup_windows",
diff --git a/src/com/android/browser/TitleBar.java b/src/com/android/browser/TitleBar.java
index f43058b..fdcab3c 100644
--- a/src/com/android/browser/TitleBar.java
+++ b/src/com/android/browser/TitleBar.java
@@ -137,7 +137,7 @@
         } else {
             mTitle.setText(title);
         }
-        mUrl.setText(url);
+        mUrl.setText(BrowserActivity.buildTitleUrl(url.toString()));
     }
 
     /* package */ void setToTabPicker() {