Add incognito and snapshot icons to tab switcher

 Bug: 5162768

Change-Id: Ie0e1af52d26d236f666c26e2aaccaf4f9f28eb95
diff --git a/src/com/android/browser/NavTabView.java b/src/com/android/browser/NavTabView.java
index 07ac164..4eec702 100644
--- a/src/com/android/browser/NavTabView.java
+++ b/src/com/android/browser/NavTabView.java
@@ -90,6 +90,22 @@
             }
             mTitle.setText(txt);
         }
+        if (mTab.isSnapshot()) {
+            setTitleIcon(R.drawable.ic_history_holo_dark);
+        } else if (mTab.isPrivateBrowsingEnabled()) {
+            setTitleIcon(R.drawable.ic_incognito_holo_dark);
+        } else {
+            setTitleIcon(0);
+        }
+    }
+
+    private void setTitleIcon(int id) {
+        if (id == 0) {
+            mTitle.setPadding(mTitle.getCompoundDrawablePadding(), 0, 0, 0);
+        } else {
+            mTitle.setPadding(0, 0, 0, 0);
+        }
+        mTitle.setCompoundDrawablesWithIntrinsicBounds(id, 0, 0, 0);
     }
 
     protected boolean isHighlighted() {
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index c6808e0..abc2467 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -191,10 +191,12 @@
         String mTitle;
         LockIcon mLockIcon;
         Bitmap mFavicon;
-        Boolean mIsBookmarkedSite = false;
+        boolean mIsBookmarkedSite = false;
+        boolean mIncognito = false;
 
         PageState(Context c, boolean incognito) {
-            if (incognito) {
+            mIncognito = incognito;
+            if (mIncognito) {
                 mOriginalUrl = mUrl = "browser:incognito";
                 mTitle = c.getString(R.string.new_incognito_tab);
             } else {
@@ -206,6 +208,7 @@
         }
 
         PageState(Context c, boolean incognito, String url, Bitmap favicon) {
+            mIncognito = incognito;
             mOriginalUrl = mUrl = url;
             mTitle = null;
             if (URLUtil.isHttpsUrl(url)) {
@@ -913,6 +916,7 @@
             // but before a provisional load occurred
             mCurrentState.mLockIcon = LockIcon.LOCK_ICON_UNSECURE;
         }
+        mCurrentState.mIncognito = view.isPrivateBrowsingEnabled();
     }
 
     // Called by DeviceAccountLogin when the Tab needs to have the auto-login UI
@@ -1746,11 +1750,7 @@
      * @return True if private browsing is enabled.
      */
     boolean isPrivateBrowsingEnabled() {
-        WebView webView = getWebView();
-        if (webView == null) {
-            return false;
-        }
-        return webView.isPrivateBrowsingEnabled();
+        return mCurrentState.mIncognito;
     }
 
     /**