merge in ics-release history after reset to master
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index bce3257..0ae2fda 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -49,7 +49,7 @@
 import android.widget.LinearLayout;
 import android.widget.Toast;
 
-import com.android.browser.Tab.LockIcon;
+import com.android.browser.Tab.SecurityState;
 import com.android.internal.view.menu.MenuBuilder;
 
 import java.util.List;
@@ -81,8 +81,8 @@
     protected Tab mActiveTab;
     private InputMethodManager mInputManager;
 
-    private Drawable mSecLockIcon;
-    private Drawable mMixLockIcon;
+    private Drawable mLockIconSecure;
+    private Drawable mLockIconMixed;
     protected Drawable mGenericFavicon;
 
     protected FrameLayout mContentView;
@@ -115,8 +115,8 @@
         Resources res = mActivity.getResources();
         mInputManager = (InputMethodManager)
                 browser.getSystemService(Activity.INPUT_METHOD_SERVICE);
-        mSecLockIcon = res.getDrawable(R.drawable.ic_secure_holo_dark);
-        mMixLockIcon = res.getDrawable(R.drawable.ic_secure_partial_holo_dark);
+        mLockIconSecure = res.getDrawable(R.drawable.ic_secure_holo_dark);
+        mLockIconMixed = res.getDrawable(R.drawable.ic_secure_partial_holo_dark);
 
         FrameLayout frameLayout = (FrameLayout) mActivity.getWindow()
                 .getDecorView().findViewById(android.R.id.content);
@@ -590,19 +590,19 @@
      */
     protected void updateLockIconToLatest(Tab t) {
         if (t != null && t.inForeground()) {
-            updateLockIconImage(t.getLockIconType());
+            updateLockIconImage(t.getSecurityState());
         }
     }
 
     /**
      * Updates the lock-icon image in the title-bar.
      */
-    private void updateLockIconImage(LockIcon lockIconType) {
+    private void updateLockIconImage(SecurityState securityState) {
         Drawable d = null;
-        if (lockIconType == LockIcon.LOCK_ICON_SECURE) {
-            d = mSecLockIcon;
-        } else if (lockIconType == LockIcon.LOCK_ICON_MIXED) {
-            d = mMixLockIcon;
+        if (securityState == SecurityState.SECURITY_STATE_SECURE) {
+            d = mLockIconSecure;
+        } else if (securityState == SecurityState.SECURITY_STATE_MIXED) {
+            d = mLockIconMixed;
         }
         mNavigationBar.setLock(d);
     }
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 78d0077..602df06 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -880,7 +880,7 @@
     }
 
     @Override
-    public void onUpdatedLockIcon(Tab tab) {
+    public void onUpdatedSecurityState(Tab tab) {
         mUi.onTabDataChanged(tab);
     }
 
diff --git a/src/com/android/browser/PageDialogsHandler.java b/src/com/android/browser/PageDialogsHandler.java
index 14373cb..0c24958 100644
--- a/src/com/android/browser/PageDialogsHandler.java
+++ b/src/com/android/browser/PageDialogsHandler.java
@@ -98,7 +98,7 @@
         mHttpAuthenticationDialog.setCancelListener(new HttpAuthenticationDialog.CancelListener() {
             public void onCancel() {
                 handler.cancel();
-                mController.onUpdatedLockIcon(tab);
+                mController.onUpdatedSecurityState(tab);
                 mHttpAuthenticationDialog = null;
             }
         });
@@ -319,13 +319,13 @@
         if (error.hasError(SslError.SSL_IDMISMATCH)) {
             addError(factory, placeholder, R.string.ssl_mismatch);
         }
-        if (error.hasError(SslError.SSL_EXPIRED) || true) {
+        if (error.hasError(SslError.SSL_EXPIRED)) {
             addError(factory, placeholder, R.string.ssl_expired);
         }
         if (error.hasError(SslError.SSL_NOTYETVALID)) {
             addError(factory, placeholder, R.string.ssl_not_yet_valid);
         }
-        if (error.hasError(SslError.SSL_DATE_INVALID) || true) {
+        if (error.hasError(SslError.SSL_DATE_INVALID)) {
             addError(factory, placeholder, R.string.ssl_date_invalid);
         }
         if (error.hasError(SslError.SSL_INVALID)) {
diff --git a/src/com/android/browser/PreloadController.java b/src/com/android/browser/PreloadController.java
index dec22ff..5de5be0 100644
--- a/src/com/android/browser/PreloadController.java
+++ b/src/com/android/browser/PreloadController.java
@@ -209,8 +209,8 @@
     }
 
     @Override
-    public void onUpdatedLockIcon(Tab tab) {
-        if (LOGD_ENABLED) Log.d(LOGTAG, "onUpdatedLockIcon()");
+    public void onUpdatedSecurityState(Tab tab) {
+        if (LOGD_ENABLED) Log.d(LOGTAG, "onUpdatedSecurityState()");
     }
 
     @Override
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index 96920a4..ae52943 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -112,10 +112,17 @@
         sAlphaPaint.setColor(Color.TRANSPARENT);
     }
 
-    public enum LockIcon {
-        LOCK_ICON_UNSECURE,
-        LOCK_ICON_SECURE,
-        LOCK_ICON_MIXED,
+    public enum SecurityState {
+        // The page does not use SSL.
+        SECURITY_STATE_NOT_SECURE,
+        // The page uses SSL, the certificate is good and all elements are secure.
+        SECURITY_STATE_SECURE,
+        // The page uses SSL and the certificate is good, but some elements are insecure.
+        SECURITY_STATE_MIXED,
+        // TODO: Add SECURITY_STATE_BAD_CERTIFICATE
+        // See http://b/5403366
+        // The page uses SSL but there is a problem with the certificate.
+        //SECURITY_STATE_BAD_CERTIFICATE,
     }
 
     Context mContext;
@@ -198,7 +205,7 @@
         String mUrl;
         String mOriginalUrl;
         String mTitle;
-        LockIcon mLockIcon;
+        SecurityState mSecurityState;
         Bitmap mFavicon;
         boolean mIsBookmarkedSite = false;
         boolean mIncognito = false;
@@ -213,7 +220,7 @@
                 mTitle = c.getString(R.string.new_tab);
             }
             mFavicon = null;
-            mLockIcon = LockIcon.LOCK_ICON_UNSECURE;
+            mSecurityState = SecurityState.SECURITY_STATE_NOT_SECURE;
         }
 
         PageState(Context c, boolean incognito, String url, Bitmap favicon) {
@@ -221,9 +228,9 @@
             mOriginalUrl = mUrl = url;
             mTitle = null;
             if (URLUtil.isHttpsUrl(url)) {
-                mLockIcon = LockIcon.LOCK_ICON_SECURE;
+                mSecurityState = SecurityState.SECURITY_STATE_SECURE;
             } else {
-                mLockIcon = LockIcon.LOCK_ICON_UNSECURE;
+                mSecurityState = SecurityState.SECURITY_STATE_NOT_SECURE;
             }
             mFavicon = favicon;
         }
@@ -640,21 +647,22 @@
         }
 
         /**
-         * Updates the lock icon. This method is called when we discover another
-         * resource to be loaded for this page (for example, javascript). While
-         * we update the icon type, we do not update the lock icon itself until
-         * we are done loading, it is slightly more secure this way.
+         * Updates the security state. This method is called when we discover
+         * another resource to be loaded for this page (for example,
+         * javascript). While we update the security state, we do not update
+         * the lock icon until we are done loading, as it is slightly more
+         * secure this way.
          */
         @Override
         public void onLoadResource(WebView view, String url) {
             if (url != null && url.length() > 0) {
                 // It is only if the page claims to be secure that we may have
-                // to update the lock:
-                if (mCurrentState.mLockIcon == LockIcon.LOCK_ICON_SECURE) {
-                    // If NOT a 'safe' url, change the lock to mixed content!
+                // to update the security state:
+                if (mCurrentState.mSecurityState == SecurityState.SECURITY_STATE_SECURE) {
+                    // If NOT a 'safe' url, change the state to mixed content!
                     if (!(URLUtil.isHttpsUrl(url) || URLUtil.isDataUrl(url)
                             || URLUtil.isAboutUrl(url))) {
-                        mCurrentState.mLockIcon = LockIcon.LOCK_ICON_MIXED;
+                        mCurrentState.mSecurityState = SecurityState.SECURITY_STATE_MIXED;
                     }
                 }
             }
@@ -755,7 +763,7 @@
                 final SslErrorHandler handler, final SslError error) {
             if (!mInForeground) {
                 handler.cancel();
-                setLockIconType(LockIcon.LOCK_ICON_UNSECURE);
+                setSecurityState(SecurityState.SECURITY_STATE_NOT_SECURE);
                 return;
             }
             if (mSettings.showSecurityWarnings()) {
@@ -793,7 +801,7 @@
                             @Override
                             public void onCancel(DialogInterface dialog) {
                                 handler.cancel();
-                                setLockIconType(LockIcon.LOCK_ICON_UNSECURE);
+                                setSecurityState(SecurityState.SECURITY_STATE_NOT_SECURE);
                                 mWebViewController.onUserCanceledSsl(Tab.this);
                             }
                         })
@@ -900,7 +908,7 @@
         if (!URLUtil.isHttpsUrl(mCurrentState.mUrl)) {
             // In case we stop when loading an HTTPS page from an HTTP page
             // but before a provisional load occurred
-            mCurrentState.mLockIcon = LockIcon.LOCK_ICON_UNSECURE;
+            mCurrentState.mSecurityState = SecurityState.SECURITY_STATE_NOT_SECURE;
         }
         mCurrentState.mIncognito = view.isPrivateBrowsingEnabled();
     }
@@ -1881,16 +1889,16 @@
         return mErrorConsole;
     }
 
-    private void setLockIconType(LockIcon icon) {
-        mCurrentState.mLockIcon = icon;
-        mWebViewController.onUpdatedLockIcon(this);
+    private void setSecurityState(SecurityState securityState) {
+        mCurrentState.mSecurityState = securityState;
+        mWebViewController.onUpdatedSecurityState(this);
     }
 
     /**
-     * @return The tab's lock icon type.
+     * @return The tab's security state.
      */
-    LockIcon getLockIconType() {
-        return mCurrentState.mLockIcon;
+    SecurityState getSecurityState() {
+        return mCurrentState.mSecurityState;
     }
 
     int getLoadProgress() {
diff --git a/src/com/android/browser/WebViewController.java b/src/com/android/browser/WebViewController.java
index f4ff764..20027e0 100644
--- a/src/com/android/browser/WebViewController.java
+++ b/src/com/android/browser/WebViewController.java
@@ -95,7 +95,7 @@
 
     boolean shouldShowErrorConsole();
 
-    void onUpdatedLockIcon(Tab tab);
+    void onUpdatedSecurityState(Tab tab);
 
     void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType);
 
diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java
index 7e4ac0d..8181efb 100644
--- a/src/com/android/browser/provider/BrowserProvider2.java
+++ b/src/com/android/browser/provider/BrowserProvider2.java
@@ -122,12 +122,25 @@
     private static final String[] SUGGEST_PROJECTION = new String[] {
             Bookmarks._ID,
             Bookmarks.URL,
-            Bookmarks.TITLE};
+            Bookmarks.TITLE,
+            "0"};
 
     private static final String SUGGEST_SELECTION =
             "url LIKE ? OR url LIKE ? OR url LIKE ? OR url LIKE ?"
             + " OR title LIKE ?";
 
+    private static final String[] HISTORY_SUGGEST_PROJECTION = new String[] {
+            History._ID,
+            History.URL,
+            History.TITLE,
+            History.DATE_LAST_VISITED};
+
+    private static final String HISTORY_SUGGEST_SELECTION =
+            History.DATE_LAST_VISITED + " != 0";
+
+    private static final String HISTORY_SUGGEST_ORDER_BY =
+            History.DATE_LAST_VISITED + " DESC";
+
     private static final String IMAGE_PRUNE =
             "url_key NOT IN (SELECT url FROM bookmarks " +
             "WHERE url IS NOT NULL AND deleted == 0) AND url_key NOT IN " +
@@ -1093,8 +1106,13 @@
     }
 
     private Cursor doSuggestQuery(String selection, String[] selectionArgs, String limit) {
-        if (selectionArgs[0] == null) {
-            return null;
+        Cursor c;
+        int iconId;
+        if (TextUtils.isEmpty(selectionArgs[0])) {
+            c = mOpenHelper.getReadableDatabase().query(TABLE_HISTORY,
+                    HISTORY_SUGGEST_PROJECTION, HISTORY_SUGGEST_SELECTION, null, null, null,
+                    HISTORY_SUGGEST_ORDER_BY, null);
+            iconId = R.drawable.ic_history_holo_dark;
         } else {
             String like = selectionArgs[0] + "%";
             if (selectionArgs[0].startsWith("http")
@@ -1110,15 +1128,16 @@
                 selectionArgs[4] = like;
                 selection = SUGGEST_SELECTION;
             }
+            selection = DatabaseUtils.concatenateWhere(selection,
+                    Bookmarks.IS_DELETED + "=0 AND " + Bookmarks.IS_FOLDER + "=0");
+
+            c = mOpenHelper.getReadableDatabase().query(TABLE_BOOKMARKS,
+                    SUGGEST_PROJECTION, selection, selectionArgs, null, null,
+                    DEFAULT_BOOKMARKS_SORT_ORDER, null);
+            iconId = R.drawable.ic_bookmark_off_holo_dark;
         }
-        selection = DatabaseUtils.concatenateWhere(selection,
-                Bookmarks.IS_DELETED + "=0 AND " + Bookmarks.IS_FOLDER + "=0");
 
-        Cursor c = mOpenHelper.getReadableDatabase().query(TABLE_BOOKMARKS,
-                SUGGEST_PROJECTION, selection, selectionArgs, null, null,
-                DEFAULT_BOOKMARKS_SORT_ORDER, null);
-
-        return new SuggestionsCursor(c);
+        return new SuggestionsCursor(c, iconId);
     }
 
     private String[] createCombinedQuery(
@@ -2016,6 +2035,7 @@
         private static final int ID_INDEX = 0;
         private static final int URL_INDEX = 1;
         private static final int TITLE_INDEX = 2;
+        private static final int LAST_ACCESS_TIME_INDEX = 3;
         // shared suggestion array index, make sure to match COLUMNS
         private static final int SUGGEST_COLUMN_INTENT_ACTION_ID = 1;
         private static final int SUGGEST_COLUMN_INTENT_DATA_ID = 2;
@@ -2023,6 +2043,7 @@
         private static final int SUGGEST_COLUMN_TEXT_2_TEXT_ID = 4;
         private static final int SUGGEST_COLUMN_TEXT_2_URL_ID = 5;
         private static final int SUGGEST_COLUMN_ICON_1_ID = 6;
+        private static final int SUGGEST_COLUMN_LAST_ACCESS_HINT_ID = 7;
 
         // shared suggestion columns
         private static final String[] COLUMNS = new String[] {
@@ -2032,12 +2053,15 @@
                 SearchManager.SUGGEST_COLUMN_TEXT_1,
                 SearchManager.SUGGEST_COLUMN_TEXT_2,
                 SearchManager.SUGGEST_COLUMN_TEXT_2_URL,
-                SearchManager.SUGGEST_COLUMN_ICON_1};
+                SearchManager.SUGGEST_COLUMN_ICON_1,
+                SearchManager.SUGGEST_COLUMN_LAST_ACCESS_HINT};
 
-        private Cursor mSource;
+        private final Cursor mSource;
+        private final String mIconId;
 
-        public SuggestionsCursor(Cursor cursor) {
+        public SuggestionsCursor(Cursor cursor, int iconId) {
             mSource = cursor;
+            mIconId = Integer.toString(iconId);
         }
 
         @Override
@@ -2060,7 +2084,9 @@
             case SUGGEST_COLUMN_TEXT_1_ID:
                 return mSource.getString(TITLE_INDEX);
             case SUGGEST_COLUMN_ICON_1_ID:
-                return Integer.toString(R.drawable.ic_bookmark_off_holo_dark);
+                return mIconId;
+            case SUGGEST_COLUMN_LAST_ACCESS_HINT_ID:
+                return mSource.getString(LAST_ACCESS_TIME_INDEX);
             }
             return null;
         }
@@ -2090,6 +2116,8 @@
             switch (column) {
             case ID_INDEX:
                 return mSource.getLong(ID_INDEX);
+            case SUGGEST_COLUMN_LAST_ACCESS_HINT_ID:
+                return mSource.getLong(LAST_ACCESS_TIME_INDEX);
             }
             throw new UnsupportedOperationException();
         }