diff options
author | John Reck <jreck@google.com> | 2011-07-25 13:55:44 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2011-07-26 10:37:02 -0700 |
commit | af262e703038106aef2e5187d120617836ffe9ce (patch) | |
tree | 4a3e1a7b6d96d7fe18c7a7234c1ff561f00b5ece /src/com/android/browser | |
parent | a229f22f88a0ae7a5e6601744c1b37795117bb4f (diff) | |
download | packages_apps_Browser-af262e703038106aef2e5187d120617836ffe9ce.zip packages_apps_Browser-af262e703038106aef2e5187d120617836ffe9ce.tar.gz packages_apps_Browser-af262e703038106aef2e5187d120617836ffe9ce.tar.bz2 |
Remove obsolete usage of WebIconDatabase
Bug: 5019676
Removes some other legacy code
Change-Id: I766d9d6f7805b5619a9769e6d72ae2f4c363d3ed
Diffstat (limited to 'src/com/android/browser')
-rw-r--r-- | src/com/android/browser/AddBookmarkPage.java | 2 | ||||
-rw-r--r-- | src/com/android/browser/Bookmarks.java | 5 | ||||
-rw-r--r-- | src/com/android/browser/Browser.java | 22 | ||||
-rw-r--r-- | src/com/android/browser/BrowserHistoryPage.java | 15 | ||||
-rw-r--r-- | src/com/android/browser/CombinedBookmarkHistoryView.java | 18 | ||||
-rw-r--r-- | src/com/android/browser/Controller.java | 47 |
6 files changed, 12 insertions, 97 deletions
diff --git a/src/com/android/browser/AddBookmarkPage.java b/src/com/android/browser/AddBookmarkPage.java index 32db550..45b1f8b 100644 --- a/src/com/android/browser/AddBookmarkPage.java +++ b/src/com/android/browser/AddBookmarkPage.java @@ -759,7 +759,7 @@ public class AddBookmarkPage extends Activity try { final ContentResolver cr = getContentResolver(); Bookmarks.addBookmark(AddBookmarkPage.this, false, url, - title, thumbnail, true, mCurrentFolder); + title, thumbnail, mCurrentFolder); if (touchIconUrl != null) { new DownloadTouchIcon(mContext, cr, url).execute(mTouchIconUrl); } diff --git a/src/com/android/browser/Bookmarks.java b/src/com/android/browser/Bookmarks.java index bd3b872..190ff9d 100644 --- a/src/com/android/browser/Bookmarks.java +++ b/src/com/android/browser/Bookmarks.java @@ -67,7 +67,7 @@ public class Bookmarks { * @param parent ID of the parent folder. */ /* package */ static void addBookmark(Context context, boolean showToast, String url, - String name, Bitmap thumbnail, boolean retainIcon, long parent) { + String name, Bitmap thumbnail, long parent) { // Want to append to the beginning of the list ContentValues values = new ContentValues(); try { @@ -82,9 +82,6 @@ public class Bookmarks { } catch (IllegalStateException e) { Log.e(LOGTAG, "addBookmark", e); } - if (retainIcon) { - WebIconDatabase.getInstance().retainIconForPageUrl(url); - } if (showToast) { Toast.makeText(context, R.string.added_to_bookmarks, Toast.LENGTH_LONG).show(); diff --git a/src/com/android/browser/Browser.java b/src/com/android/browser/Browser.java index c4412e2..76aaa0b 100644 --- a/src/com/android/browser/Browser.java +++ b/src/com/android/browser/Browser.java @@ -17,13 +17,9 @@ package com.android.browser; import android.app.Application; -import android.content.Intent; -import android.os.AsyncTask; import android.util.Log; import android.webkit.CookieSyncManager; -import dalvik.system.VMRuntime; - public class Browser extends Application { private final static String LOGTAG = "browser"; @@ -37,15 +33,6 @@ public class Browser extends Application { // Set to true to enable extra debug logging. final static boolean LOGD_ENABLED = true; - /** - * Specifies a heap utilization ratio that works better - * for the browser than the default ratio does. - */ - private final static float TARGET_HEAP_UTILIZATION = 0.75f; - - public Browser() { - } - @Override public void onCreate() { super.onCreate(); @@ -53,20 +40,11 @@ public class Browser extends Application { if (LOGV_ENABLED) Log.v(LOGTAG, "Browser.onCreate: this=" + this); - // Fix AsyncTask to use multiple threads - AsyncTask.setDefaultExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - // Fix heap utilization for better heap size characteristics. - VMRuntime.getRuntime().setTargetHeapUtilization( - TARGET_HEAP_UTILIZATION); // create CookieSyncManager with current Context CookieSyncManager.createInstance(this); BrowserSettings.initialize(getApplicationContext()); Preloader.initialize(getApplicationContext()); } - static Intent createBrowserViewIntent() { - Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); - return intent; - } } diff --git a/src/com/android/browser/BrowserHistoryPage.java b/src/com/android/browser/BrowserHistoryPage.java index 5d106ce..942a8fd 100644 --- a/src/com/android/browser/BrowserHistoryPage.java +++ b/src/com/android/browser/BrowserHistoryPage.java @@ -33,7 +33,6 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.database.Cursor; import android.database.DataSetObserver; -import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.drawable.Drawable; import android.net.Uri; @@ -50,7 +49,6 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.ViewStub; -import android.webkit.WebIconDatabase.IconListener; import android.widget.AbsListView; import android.widget.AdapterView; import android.widget.AdapterView.AdapterContextMenuInfo; @@ -86,16 +84,6 @@ public class BrowserHistoryPage extends Fragment private FragmentBreadCrumbs mFragmentBreadCrumbs; private ExpandableListView mHistoryList; - // Implementation of WebIconDatabase.IconListener - class IconReceiver implements IconListener { - @Override - public void onReceivedIcon(String url, Bitmap icon) { - mAdapter.notifyDataSetChanged(); - } - } - - // Instance of IconReceiver - final IconReceiver mIconReceiver = new IconReceiver(); private View mRoot; static interface HistoryQuery { @@ -238,8 +226,6 @@ public class BrowserHistoryPage extends Fragment getLoaderManager().restartLoader(LOADER_HISTORY, null, this); getLoaderManager().restartLoader(LOADER_MOST_VISITED, null, this); - // Register to receive icons in case they haven't all been loaded. - CombinedBookmarkHistoryView.getIconListenerSet().addListener(mIconReceiver); return mRoot; } @@ -300,7 +286,6 @@ public class BrowserHistoryPage extends Fragment @Override public void onDestroy() { super.onDestroy(); - CombinedBookmarkHistoryView.getIconListenerSet().removeListener(mIconReceiver); getLoaderManager().destroyLoader(LOADER_HISTORY); getLoaderManager().destroyLoader(LOADER_MOST_VISITED); } diff --git a/src/com/android/browser/CombinedBookmarkHistoryView.java b/src/com/android/browser/CombinedBookmarkHistoryView.java index 191368f..7903709 100644 --- a/src/com/android/browser/CombinedBookmarkHistoryView.java +++ b/src/com/android/browser/CombinedBookmarkHistoryView.java @@ -26,16 +26,13 @@ import android.app.FragmentTransaction; import android.content.res.Configuration; import android.database.Cursor; import android.graphics.Bitmap; -import android.os.AsyncTask; import android.os.Bundle; -import android.provider.Browser; import android.view.Gravity; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import android.view.ViewGroup; -import android.webkit.WebIconDatabase; import android.webkit.WebIconDatabase.IconListener; import android.widget.FrameLayout; import android.widget.LinearLayout; @@ -137,21 +134,6 @@ public class CombinedBookmarkHistoryView extends LinearLayout // Start up the default fragment initFragments(mExtras); - // XXX: Must do this before launching the AsyncTask to avoid a - // potential crash if the icon database has not been created. - WebIconDatabase.getInstance(); - - // Do this every time the view is created in case a new favicon was - // added to the webkit db. - (new AsyncTask<Void, Void, Void>() { - @Override - public Void doInBackground(Void... v) { - Browser.requestAllIcons(mActivity.getContentResolver(), - Browser.BookmarkColumns.FAVICON + " is NULL", getIconListenerSet()); - return null; - } - }).execute(); - setupActionBar(startingView); } diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index 4c05688..92682c1 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -260,7 +260,7 @@ public class Controller new SystemAllowGeolocationOrigins(mActivity.getApplicationContext()); mSystemAllowGeolocationOrigins.start(); - retainIconsOnStartup(); + openIconDatabase(); mSimulateActionBarOverlayMode = !BrowserActivity.isTablet(mActivity); } @@ -418,43 +418,17 @@ public class Controller return mTabControl.getTabs(); } - // Open the icon database and retain all the icons for visited sites. - // This is done on a background thread so as not to stall startup. - private void retainIconsOnStartup() { - // WebIconDatabase needs to be retrieved on the UI thread so that if - // it has not been created successfully yet the Handler is started on the - // UI thread. - Runnable task = new RetainIconsOnStartupTask( - mActivity, WebIconDatabase.getInstance()); - BackgroundHandler.execute(task); - } - - private static class RetainIconsOnStartupTask implements Runnable { - private WebIconDatabase mDb; - private Context mContext; - - public RetainIconsOnStartupTask(Context context, WebIconDatabase db) { - mDb = db; - mContext = context; - } + // Open the icon database. + private void openIconDatabase() { + // We have to call getInstance on the UI thread + final WebIconDatabase instance = WebIconDatabase.getInstance(); + BackgroundHandler.execute(new Runnable() { - @Override - public void run() { - mDb.open(mContext.getDir("icons", 0).getPath()); - Cursor c = null; - try { - c = Browser.getAllBookmarks(mContext.getContentResolver()); - int urlIndex = c.getColumnIndex(Browser.BookmarkColumns.URL); - while (c.moveToNext()) { - String url = c.getString(urlIndex); - mDb.retainIconForPageUrl(url); - } - } catch (Throwable e) { - Log.e(LOGTAG, "retainIconsOnStartup", e); - } finally { - if (c != null) c.close(); + @Override + public void run() { + instance.open(mActivity.getDir("icons", 0).getPath()); } - } + }); } private void startHandler() { @@ -941,7 +915,6 @@ public class Controller return; } DataController.getInstance(mActivity).updateVisitedHistory(url); - WebIconDatabase.getInstance().retainIconForPageUrl(url); if (!mActivityPaused) { // Since we clear the state in onPause, don't backup the current // state if we are already paused |