Merge commit '7bf3f38c493642b181f0c7ddf30b8214e50fea3b' into fix_am

Fixed conflicts:
	src/com/android/browser/AddBookmarkPage.java
	src/com/android/browser/DownloadTouchIcon.java

Change-Id: I06cc43e41d1a01ef68aaad5dec3923f07d165329
diff --git a/src/com/android/browser/AddBookmarkPage.java b/src/com/android/browser/AddBookmarkPage.java
index c8251f9..593c247 100644
--- a/src/com/android/browser/AddBookmarkPage.java
+++ b/src/com/android/browser/AddBookmarkPage.java
@@ -474,7 +474,9 @@
     private class SaveBookmarkRunnable implements Runnable {
         // FIXME: This should be an async task.
         private Message mMessage;
-        public SaveBookmarkRunnable(Message msg) {
+        private Context mContext;
+        public SaveBookmarkRunnable(Context ctx, Message msg) {
+            mContext = ctx;
             mMessage = msg;
         }
         public void run() {
@@ -494,7 +496,7 @@
                 Bookmarks.addBookmark(AddBookmarkPage.this, false, url,
                         title, thumbnail, true, mCurrentFolder);
                 if (touchIconUrl != null) {
-                    new DownloadTouchIcon(AddBookmarkPage.this, cr, url).execute(mTouchIconUrl);
+                    new DownloadTouchIcon(mContext, cr, url).execute(mTouchIconUrl);
                 }
                 mMessage.arg1 = 1;
             } catch (IllegalStateException e) {
@@ -600,7 +602,7 @@
             Message msg = Message.obtain(mHandler, SAVE_BOOKMARK);
             msg.setData(bundle);
             // Start a new thread so as to not slow down the UI
-            Thread t = new Thread(new SaveBookmarkRunnable(msg));
+            Thread t = new Thread(new SaveBookmarkRunnable(getApplicationContext(), msg));
             t.start();
             setResult(RESULT_OK);
             LogTag.logBookmarkAdded(url, "bookmarkview");
diff --git a/src/com/android/browser/DownloadTouchIcon.java b/src/com/android/browser/DownloadTouchIcon.java
index 7bb93dc..992284f 100644
--- a/src/com/android/browser/DownloadTouchIcon.java
+++ b/src/com/android/browser/DownloadTouchIcon.java
@@ -23,10 +23,9 @@
 import org.apache.http.client.params.HttpClientParams;
 import org.apache.http.conn.params.ConnRouteParams;
 
-import android.app.Activity;
 import android.content.ContentResolver;
-import android.content.ContentUris;
 import android.content.ContentValues;
+import android.content.Context;
 import android.database.Cursor;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
@@ -35,7 +34,6 @@
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.os.Message;
-import android.provider.BrowserContract;
 import android.provider.BrowserContract.Images;
 import android.webkit.WebView;
 
@@ -51,7 +49,7 @@
     private final String mUserAgent; // Sites may serve a different icon to different UAs
     private Message mMessage;
 
-    private final Activity mActivity;
+    private final Context mContext;
     /* package */ Tab mTab;
 
     /**
@@ -59,9 +57,9 @@
      * the originalUrl so we take account of redirects. Used when the user
      * bookmarks a page from outside the bookmarks activity.
      */
-    public DownloadTouchIcon(Tab tab, BrowserActivity activity, ContentResolver cr, WebView view) {
+    public DownloadTouchIcon(Tab tab, Context ctx, ContentResolver cr, WebView view) {
         mTab = tab;
-        mActivity = activity;
+        mContext = ctx;
         mContentResolver = cr;
         // Store these in case they change.
         mOriginalUrl = view.getOriginalUrl();
@@ -76,9 +74,9 @@
      * TODO: Would be nice to set the user agent here so that there is no
      * potential for the three different ctors here to return different icons.
      */
-    public DownloadTouchIcon(AddBookmarkPage activity, ContentResolver cr, String url) {
+    public DownloadTouchIcon(Context ctx, ContentResolver cr, String url) {
         mTab = null;
-        mActivity = activity;
+        mContext = ctx;
         mContentResolver = cr;
         mOriginalUrl = null;
         mUrl = url;
@@ -90,9 +88,9 @@
      * the passed Message's data bundle with the key "touchIcon" and then send
      * the message.
      */
-    public DownloadTouchIcon(BrowserActivity activity, Message msg, String userAgent) {
+    public DownloadTouchIcon(Context context, Message msg, String userAgent) {
         mMessage = msg;
-        mActivity = activity;
+        mContext = context;
         mContentResolver = null;
         mOriginalUrl = null;
         mUrl = null;
@@ -112,7 +110,7 @@
 
         if (inDatabase || mMessage != null) {
             AndroidHttpClient client = AndroidHttpClient.newInstance(mUserAgent);
-            HttpHost httpHost = Proxy.getPreferredHttpHost(mActivity, url);
+            HttpHost httpHost = Proxy.getPreferredHttpHost(mContext, url);
             if (httpHost != null) {
                 ConnRouteParams.setDefaultProxy(client.getParams(), httpHost);
             }