Support precomposed app icons.

The precomposed icon overrides any other touch icon. We still need to do the
round rect clip because apparently apple still applies the rounded corners, just
not the glass effect. Inset the rectangle by 1 to fit the icons better.
diff --git a/src/com/android/browser/DownloadTouchIcon.java b/src/com/android/browser/DownloadTouchIcon.java
index 6662e09..07d2d3a 100644
--- a/src/com/android/browser/DownloadTouchIcon.java
+++ b/src/com/android/browser/DownloadTouchIcon.java
@@ -42,8 +42,11 @@
     private final String mOriginalUrl;
     private final String mUrl;
     private final String mUserAgent;
+    /* package */ BrowserActivity mActivity;
 
-    public DownloadTouchIcon(ContentResolver cr, Cursor c, WebView view) {
+    public DownloadTouchIcon(BrowserActivity activity, ContentResolver cr,
+            Cursor c, WebView view) {
+        mActivity = activity;
         mContentResolver = cr;
         mCursor = c;
         // Store these in case they change.
@@ -53,6 +56,7 @@
     }
 
     public DownloadTouchIcon(ContentResolver cr, Cursor c, String url) {
+        mActivity = null;
         mContentResolver = cr;
         mCursor = c;
         mOriginalUrl = null;
@@ -96,10 +100,24 @@
     }
 
     @Override
+    protected void onCancelled() {
+        if (mCursor != null) {
+            mCursor.close();
+        }
+    }
+
+    @Override
     public void onPostExecute(Bitmap icon) {
-        if (icon == null || mCursor == null) {
+        // Do this first in case the download failed.
+        if (mActivity != null) {
+            // Remove the touch icon loader from the BrowserActivity.
+            mActivity.mTouchIconLoader = null;
+        }
+
+        if (icon == null || mCursor == null || isCancelled()) {
             return;
         }
+
         final ByteArrayOutputStream os = new ByteArrayOutputStream();
         icon.compress(Bitmap.CompressFormat.PNG, 100, os);
         ContentValues values = new ContentValues();