backout df9231393766 to fix commit message

This commit is contained in:
Wes Johnston 2013-07-02 10:10:50 -07:00
parent b75e2ac8e6
commit 262cde227f
3 changed files with 15 additions and 26 deletions

View File

@ -631,20 +631,12 @@ abstract public class BrowserApp extends GeckoApp
case R.id.add_to_launcher: {
Tab tab = Tabs.getInstance().getSelectedTab();
if (tab != null) {
final String url = tab.getURL();
final String title = tab.getDisplayTitle();
if (url == null || title == null) {
return true;
}
Favicons favicons = Favicons.getInstance();
favicons.loadFavicon(url, tab.getFaviconURL(), 0,
new Favicons.OnFaviconLoadedListener() {
@Override
public void onFaviconLoaded(String url, Bitmap favicon) {
String url = tab.getURL();
String title = tab.getDisplayTitle();
Bitmap favicon = tab.getFavicon();
if (url != null && title != null) {
GeckoAppShell.createShortcut(title, url, url, favicon == null ? null : favicon, "");
}
});
}
return true;
}
@ -1257,8 +1249,7 @@ abstract public class BrowserApp extends GeckoApp
private void loadFavicon(final Tab tab) {
maybeCancelFaviconLoad(tab);
int flags = Favicons.FLAG_SCALE | (tab.isPrivate() ? 0 : Favicons.FLAG_PERSIST);
long id = Favicons.getInstance().loadFavicon(tab.getURL(), tab.getFaviconURL(), flags,
long id = Favicons.getInstance().loadFavicon(tab.getURL(), tab.getFaviconURL(), !tab.isPrivate(),
new Favicons.OnFaviconLoadedListener() {
@Override

View File

@ -40,8 +40,6 @@ public class Favicons {
public static final long NOT_LOADING = 0;
public static final long FAILED_EXPIRY_NEVER = -1;
public static final int FLAG_PERSIST = 1;
public static final int FLAG_SCALE = 2;
private static int sFaviconSmallSize = -1;
private static int sFaviconLargeSize = -1;
@ -108,7 +106,7 @@ public class Favicons {
return BrowserDB.getFaviconUrlForHistoryUrl(mContext.getContentResolver(), pageUrl);
}
public long loadFavicon(String pageUrl, String faviconUrl, int flags,
public long loadFavicon(String pageUrl, String faviconUrl, boolean persist,
OnFaviconLoadedListener listener) {
// Handle the case where page url is empty
@ -130,7 +128,7 @@ public class Favicons {
return -1;
}
LoadFaviconTask task = new LoadFaviconTask(ThreadUtils.getBackgroundHandler(), pageUrl, faviconUrl, flags, listener);
LoadFaviconTask task = new LoadFaviconTask(ThreadUtils.getBackgroundHandler(), pageUrl, faviconUrl, persist, listener);
long taskId = task.getId();
mLoadTasks.put(taskId, task);
@ -255,10 +253,10 @@ public class Favicons {
private String mPageUrl;
private String mFaviconUrl;
private OnFaviconLoadedListener mListener;
private int mFlags;
private boolean mPersist;
public LoadFaviconTask(Handler backgroundThreadHandler,
String pageUrl, String faviconUrl, int flags,
String pageUrl, String faviconUrl, boolean persist,
OnFaviconLoadedListener listener) {
super(backgroundThreadHandler);
@ -269,7 +267,7 @@ public class Favicons {
mPageUrl = pageUrl;
mFaviconUrl = faviconUrl;
mListener = listener;
mFlags = flags;
mPersist = persist;
}
// Runs in background thread
@ -280,7 +278,7 @@ public class Favicons {
// Runs in background thread
private void saveFaviconToDb(final Bitmap favicon) {
if ((mFlags & FLAG_PERSIST) == 0) {
if (!mPersist) {
return;
}
@ -379,7 +377,7 @@ public class Favicons {
if (storedFaviconUrl != null && storedFaviconUrl.equals(mFaviconUrl)) {
image = loadFaviconFromDb();
if (image != null && image.getWidth() > 0 && image.getHeight() > 0)
return ((mFlags & FLAG_SCALE) != 0) ? scaleImage(image) : image;
return scaleImage(image);
}
if (isCancelled())
@ -389,7 +387,7 @@ public class Favicons {
if (image != null && image.getWidth() > 0 && image.getHeight() > 0) {
saveFaviconToDb(image);
image = ((mFlags & FLAG_SCALE) != 0) ? scaleImage(image) : image;
image = scaleImage(image);
} else {
image = null;
}

View File

@ -222,7 +222,7 @@ public class AddonsSection extends AboutHomeSection {
row.setOnKeyListener(GamepadUtils.getClickDispatcher());
Favicons favicons = Favicons.getInstance();
favicons.loadFavicon(pageUrl, iconUrl, Favicons.FLAG_PERSIST | Favicons.FLAG_SCALE,
favicons.loadFavicon(pageUrl, iconUrl, true,
new Favicons.OnFaviconLoadedListener() {
@Override
public void onFaviconLoaded(String url, Bitmap favicon) {