Fix bing images crash

 Bug: 4517571
 Caused by receiving onPageFinished callbacks for in page navigation links
 (eg, url#something).
 Also, only post an UPDATE_BOOKMARK_THUMBNAIL message if one is not already
 pending for the tab.

Change-Id: Ia45ae93206507b93ad6fc841ad291b97bc947675
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 09c7cd1..f4563bd 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -819,13 +819,16 @@
         if (!tab.isPrivateBrowsingEnabled()
                 && !TextUtils.isEmpty(tab.getUrl())
                 && !tab.isSnapshot()) {
+            // Only update the bookmark screenshot if the user did not
+            // cancel the load early and there is not already
+            // a pending update for the tab.
             if (tab.inForeground() && !didUserStopLoading()
                     || !tab.inForeground()) {
-                // Only update the bookmark screenshot if the user did not
-                // cancel the load early.
-                mHandler.sendMessageDelayed(mHandler.obtainMessage(
-                        UPDATE_BOOKMARK_THUMBNAIL, 0, 0, tab),
-                        500);
+                if (!mHandler.hasMessages(UPDATE_BOOKMARK_THUMBNAIL, tab)) {
+                    mHandler.sendMessageDelayed(mHandler.obtainMessage(
+                            UPDATE_BOOKMARK_THUMBNAIL, 0, 0, tab),
+                            500);
+                }
             }
         }
         // pause the WebView timer and release the wake lock if it is finished