Only update the bookmark screenshot if the page completed loading fully (i.e. do not save a screenshot if the user canceled loading.

Bug: 2148161
Change-Id: Ia226959cd18848d0eb2e302a9ef894c5c142d37d
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index 91d4fd1..fd06d90 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -2276,6 +2276,7 @@
     }
 
     /* package */ void stopLoading() {
+        mDidStopLoad = true;
         resetTitleAndRevertLockIcon();
         WebView w = getTopWindow();
         w.stopLoading();
@@ -2557,6 +2558,7 @@
             CookieSyncManager.getInstance().resetSync();
 
             mInLoad = true;
+            mDidStopLoad = false;
             showFakeTitleBar();
             updateInLoadMenuItems();
             if (!mIsNetworkUp) {
@@ -2572,7 +2574,12 @@
             // Reset the title and icon in case we stopped a provisional
             // load.
             resetTitleAndIcon(view);
-            updateScreenshot(view);
+
+            if (!mDidStopLoad) {
+                // Only update the bookmark screenshot if the user did not
+                // cancel the load early.
+                updateScreenshot(view);
+            }
 
             // Update the lock icon image only once we are done loading
             updateLockIconToLatest();
@@ -4394,6 +4401,7 @@
 
     private boolean mInLoad;
     private boolean mIsNetworkUp;
+    private boolean mDidStopLoad;
 
     private boolean mPageStarted;
     private boolean mActivityInPause = true;