diff options
author | John Reck <jreck@google.com> | 2010-12-21 14:15:50 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2010-12-21 17:27:03 -0800 |
commit | 568467e18d8b4d8bb143b6d3abf41bd4f70349bf (patch) | |
tree | 0eb84c0e678a1a3f7c045623975080b4f939ca55 /src/com/android | |
parent | 991412749b1e0837ab602d77a2264a2186741a05 (diff) | |
download | packages_apps_Browser-568467e18d8b4d8bb143b6d3abf41bd4f70349bf.zip packages_apps_Browser-568467e18d8b4d8bb143b6d3abf41bd4f70349bf.tar.gz packages_apps_Browser-568467e18d8b4d8bb143b6d3abf41bd4f70349bf.tar.bz2 |
Fix favicon updating to handle redirects
Bug: 3300913
Change-Id: Ifac69b47b4a1fb0ca4563769f5c281e264f7f368
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/browser/Bookmarks.java | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/com/android/browser/Bookmarks.java b/src/com/android/browser/Bookmarks.java index fef634f..9a5b6f0 100644 --- a/src/com/android/browser/Bookmarks.java +++ b/src/com/android/browser/Bookmarks.java @@ -29,6 +29,7 @@ import android.preference.PreferenceManager; import android.provider.BrowserContract; import android.provider.BrowserContract.Combined; import android.provider.BrowserContract.Images; +import android.text.TextUtils; import android.util.Log; import android.webkit.WebIconDatabase; import android.widget.Toast; @@ -218,25 +219,25 @@ import java.io.ByteArrayOutputStream; new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... unused) { - Cursor cursor = queryCombinedForUrl(cr, originalUrl, url); - try { - if (cursor.moveToFirst()) { - final ByteArrayOutputStream os = new ByteArrayOutputStream(); - favicon.compress(Bitmap.CompressFormat.PNG, 100, os); - - ContentValues values = new ContentValues(); - values.put(Images.FAVICON, os.toByteArray()); - values.put(Images.URL, cursor.getString(0)); - - do { - cr.update(Images.CONTENT_URI, values, null, null); - } while (cursor.moveToNext()); - } - } finally { - if (cursor != null) cursor.close(); - } + final ByteArrayOutputStream os = new ByteArrayOutputStream(); + favicon.compress(Bitmap.CompressFormat.PNG, 100, os); + + // The Images update will insert if it doesn't exist + ContentValues values = new ContentValues(); + values.put(Images.FAVICON, os.toByteArray()); + updateImages(cr, originalUrl, values); + updateImages(cr, url, values); return null; } + + private void updateImages(final ContentResolver cr, + final String url, ContentValues values) { + String iurl = removeQuery(url); + if (!TextUtils.isEmpty(iurl)) { + values.put(Images.URL, iurl); + cr.update(BrowserContract.Images.CONTENT_URI, values, null, null); + } + } }.execute(); } } |