Commit e2e5602c authored by Michael Thiessen's avatar Michael Thiessen Committed by Commit Bot

Migrate LargeIconBridge to GURL

After some trial and error, I think the best strategy for migrating our
java code to GURL is to convert all of the leaf nodes (typically jni
boundaries) to GURL, providing a deprecated interface for existing
usage, then convert the rest.

Bug: 783819
Change-Id: I8c00386e70008a588e0d5e249e3c398112c94e99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2044759Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743402}
parent a7752d87
...@@ -228,7 +228,7 @@ class PasswordAccessorySheetViewBinder { ...@@ -228,7 +228,7 @@ class PasswordAccessorySheetViewBinder {
void fetchFavicon(String origin, Callback<Drawable> setIconCallback) { void fetchFavicon(String origin, Callback<Drawable> setIconCallback) {
final LargeIconBridge mIconBridge = final LargeIconBridge mIconBridge =
new LargeIconBridge(Profile.getLastUsedRegularProfile()); new LargeIconBridge(Profile.getLastUsedRegularProfile());
mIconBridge.getLargeIconForUrl(origin, mDesiredSize, mIconBridge.getLargeIconForStringUrl(origin, mDesiredSize,
(icon, fallbackColor, isFallbackColorDefault, iconType) -> { (icon, fallbackColor, isFallbackColorDefault, iconType) -> {
Drawable drawable = FaviconUtils.getIconDrawableWithoutFilter(icon, origin, Drawable drawable = FaviconUtils.getIconDrawableWithoutFilter(icon, origin,
fallbackColor, mIconGenerator, mResources, mDesiredSize); fallbackColor, mIconGenerator, mResources, mDesiredSize);
......
...@@ -63,7 +63,7 @@ public class BookmarkItemRow extends BookmarkRow implements LargeIconCallback { ...@@ -63,7 +63,7 @@ public class BookmarkItemRow extends BookmarkRow implements LargeIconCallback {
mStartIconView.setImageDrawable(null); mStartIconView.setImageDrawable(null);
mTitleView.setText(item.getTitle()); mTitleView.setText(item.getTitle());
mDescriptionView.setText(item.getUrlForDisplay()); mDescriptionView.setText(item.getUrlForDisplay());
mDelegate.getLargeIconBridge().getLargeIconForUrl(mUrl, mMinIconSize, this); mDelegate.getLargeIconBridge().getLargeIconForStringUrl(mUrl, mMinIconSize, this);
return item; return item;
} }
......
...@@ -36,6 +36,7 @@ import org.chromium.components.browser_ui.widget.dragreorder.DragStateDelegate; ...@@ -36,6 +36,7 @@ import org.chromium.components.browser_ui.widget.dragreorder.DragStateDelegate;
import org.chromium.components.browser_ui.widget.selectable_list.SelectableListLayout; import org.chromium.components.browser_ui.widget.selectable_list.SelectableListLayout;
import org.chromium.components.browser_ui.widget.selectable_list.SelectableListToolbar.SearchDelegate; import org.chromium.components.browser_ui.widget.selectable_list.SelectableListToolbar.SearchDelegate;
import org.chromium.components.browser_ui.widget.selectable_list.SelectionDelegate; import org.chromium.components.browser_ui.widget.selectable_list.SelectionDelegate;
import org.chromium.url.GURL;
import java.util.Stack; import java.util.Stack;
...@@ -282,7 +283,7 @@ public class BookmarkManager ...@@ -282,7 +283,7 @@ public class BookmarkManager
@Override @Override
public void onUpdateFavicon(String url) { public void onUpdateFavicon(String url) {
mLargeIconBridge.clearFavicon(url); mLargeIconBridge.clearFavicon(new GURL(url));
mFaviconsNeedRefresh = true; mFaviconsNeedRefresh = true;
} }
......
...@@ -254,7 +254,7 @@ public class BookmarkWidgetService extends RemoteViewsService { ...@@ -254,7 +254,7 @@ public class BookmarkWidgetService extends RemoteViewsService {
taskFinished(); taskFinished();
} }
}; };
mLargeIconBridge.getLargeIconForUrl(bookmark.url, mMinIconSizeDp, callback); mLargeIconBridge.getLargeIconForStringUrl(bookmark.url, mMinIconSizeDp, callback);
} }
@UiThread @UiThread
......
...@@ -49,7 +49,7 @@ class RevampedContextMenuHeaderMediator implements View.OnClickListener { ...@@ -49,7 +49,7 @@ class RevampedContextMenuHeaderMediator implements View.OnClickListener {
if (!params.isImage() && !params.isVideo()) { if (!params.isImage() && !params.isVideo()) {
LargeIconBridge iconBridge = new LargeIconBridge(Profile.getLastUsedProfile()); LargeIconBridge iconBridge = new LargeIconBridge(Profile.getLastUsedProfile());
iconBridge.getLargeIconForUrl(mPlainUrl, iconBridge.getLargeIconForStringUrl(mPlainUrl,
context.getResources().getDimensionPixelSize(R.dimen.default_favicon_min_size), context.getResources().getDimensionPixelSize(R.dimen.default_favicon_min_size),
this::onFaviconAvailable); this::onFaviconAvailable);
} else if (params.isVideo()) { } else if (params.isVideo()) {
......
...@@ -14,6 +14,7 @@ import org.chromium.base.annotations.CalledByNative; ...@@ -14,6 +14,7 @@ import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.NativeMethods; import org.chromium.base.annotations.NativeMethods;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.util.ConversionUtils; import org.chromium.chrome.browser.util.ConversionUtils;
import org.chromium.url.GURL;
/** /**
* A Java API for using the C++ LargeIconService. * A Java API for using the C++ LargeIconService.
...@@ -24,7 +25,7 @@ public class LargeIconBridge { ...@@ -24,7 +25,7 @@ public class LargeIconBridge {
private static final int CACHE_ENTRY_MIN_SIZE_BYTES = ConversionUtils.BYTES_PER_KILOBYTE; private static final int CACHE_ENTRY_MIN_SIZE_BYTES = ConversionUtils.BYTES_PER_KILOBYTE;
private final Profile mProfile; private final Profile mProfile;
private long mNativeLargeIconBridge; private long mNativeLargeIconBridge;
private LruCache<String, CachedFavicon> mFaviconCache; private LruCache<GURL, CachedFavicon> mFaviconCache;
private static class CachedFavicon { private static class CachedFavicon {
public Bitmap icon; public Bitmap icon;
...@@ -70,8 +71,8 @@ public class LargeIconBridge { ...@@ -70,8 +71,8 @@ public class LargeIconBridge {
/** /**
* Constructor that leaves the bridge independent from the native side. * Constructor that leaves the bridge independent from the native side.
* Note: {@link #getLargeIconForUrl(String, int, LargeIconCallback)} will crash with the default * Note: {@link #getLargeIconForStringUrl(String, int, LargeIconCallback)} will crash with the
* implementation, it should then be overridden. * default implementation, it should then be overridden.
*/ */
@VisibleForTesting @VisibleForTesting
public LargeIconBridge() { public LargeIconBridge() {
...@@ -88,9 +89,9 @@ public class LargeIconBridge { ...@@ -88,9 +89,9 @@ public class LargeIconBridge {
public void createCache(int cacheSizeBytes) { public void createCache(int cacheSizeBytes) {
assert cacheSizeBytes > 0; assert cacheSizeBytes > 0;
mFaviconCache = new LruCache<String, CachedFavicon>(cacheSizeBytes) { mFaviconCache = new LruCache<GURL, CachedFavicon>(cacheSizeBytes) {
@Override @Override
protected int sizeOf(String key, CachedFavicon favicon) { protected int sizeOf(GURL key, CachedFavicon favicon) {
int iconBitmapSize = favicon.icon == null ? 0 : favicon.icon.getByteCount(); int iconBitmapSize = favicon.icon == null ? 0 : favicon.icon.getByteCount();
return Math.max(CACHE_ENTRY_MIN_SIZE_BYTES, iconBitmapSize); return Math.max(CACHE_ENTRY_MIN_SIZE_BYTES, iconBitmapSize);
} }
...@@ -107,6 +108,17 @@ public class LargeIconBridge { ...@@ -107,6 +108,17 @@ public class LargeIconBridge {
} }
} }
/**
* See {@link #getLargeIconForUrl(GURL, int, LargeIconCallback)}
*
* @deprecated please use getLargeIconForUrl instead.
*/
@Deprecated
public boolean getLargeIconForStringUrl(
final String pageUrl, int desiredSizePx, final LargeIconCallback callback) {
return getLargeIconForUrl(new GURL(pageUrl), desiredSizePx, callback);
}
/** /**
* Given a URL, returns a large icon for that URL if one is available (e.g. a favicon or * Given a URL, returns a large icon for that URL if one is available (e.g. a favicon or
* touch icon). If none is available, a fallback color is returned, based on the dominant color * touch icon). If none is available, a fallback color is returned, based on the dominant color
...@@ -120,8 +132,8 @@ public class LargeIconBridge { ...@@ -120,8 +132,8 @@ public class LargeIconBridge {
* will not be called if this method returns false. * will not be called if this method returns false.
* @return True if a callback should be expected. * @return True if a callback should be expected.
*/ */
public boolean getLargeIconForUrl(final String pageUrl, int desiredSizePx, public boolean getLargeIconForUrl(
final LargeIconCallback callback) { final GURL pageUrl, int desiredSizePx, final LargeIconCallback callback) {
assert mNativeLargeIconBridge != 0; assert mNativeLargeIconBridge != 0;
assert callback != null; assert callback != null;
...@@ -155,7 +167,7 @@ public class LargeIconBridge { ...@@ -155,7 +167,7 @@ public class LargeIconBridge {
/** /**
* Removes the favicon from the local cache for the given URL. * Removes the favicon from the local cache for the given URL.
*/ */
public void clearFavicon(String url) { public void clearFavicon(GURL url) {
mFaviconCache.remove(url); mFaviconCache.remove(url);
} }
...@@ -163,7 +175,7 @@ public class LargeIconBridge { ...@@ -163,7 +175,7 @@ public class LargeIconBridge {
interface Natives { interface Natives {
long init(); long init();
void destroy(long nativeLargeIconBridge); void destroy(long nativeLargeIconBridge);
boolean getLargeIconForURL(long nativeLargeIconBridge, Profile profile, String pageUrl, boolean getLargeIconForURL(long nativeLargeIconBridge, Profile profile, GURL pageUrl,
int desiredSizePx, LargeIconCallback callback); int desiredSizePx, LargeIconCallback callback);
} }
} }
...@@ -179,7 +179,7 @@ public class HistoryItemView extends SelectableItemView<HistoryItem> implements ...@@ -179,7 +179,7 @@ public class HistoryItemView extends SelectableItemView<HistoryItem> implements
private void requestIcon() { private void requestIcon() {
if (mHistoryManager == null || mHistoryManager.getLargeIconBridge() == null) return; if (mHistoryManager == null || mHistoryManager.getLargeIconBridge() == null) return;
mHistoryManager.getLargeIconBridge().getLargeIconForUrl( mHistoryManager.getLargeIconBridge().getLargeIconForStringUrl(
getItem().getUrl(), mMinIconSize, this); getItem().getUrl(), mMinIconSize, this);
} }
......
...@@ -580,7 +580,7 @@ public class MediaSessionTabHelper implements MediaImageCallback { ...@@ -580,7 +580,7 @@ public class MediaSessionTabHelper implements MediaImageCallback {
} }
}; };
return mLargeIconBridge.getLargeIconForUrl(pageUrl, size, callback); return mLargeIconBridge.getLargeIconForStringUrl(pageUrl, size, callback);
} }
private boolean isNotificationHiddingOrHidden() { private boolean isNotificationHiddingOrHidden() {
......
...@@ -217,7 +217,7 @@ public class BasicSuggestionProcessor extends BaseSuggestionViewProcessor { ...@@ -217,7 +217,7 @@ public class BasicSuggestionProcessor extends BaseSuggestionViewProcessor {
final LargeIconBridge iconBridge = mIconBridgeSupplier.get(); final LargeIconBridge iconBridge = mIconBridgeSupplier.get();
if (iconBridge == null) return; if (iconBridge == null) return;
iconBridge.getLargeIconForUrl(url, mDesiredFaviconWidthPx, iconBridge.getLargeIconForStringUrl(url, mDesiredFaviconWidthPx,
(Bitmap icon, int fallbackColor, boolean isFallbackColorDefault, int iconType) -> { (Bitmap icon, int fallbackColor, boolean isFallbackColorDefault, int iconType) -> {
if (icon == null) return; if (icon == null) return;
......
...@@ -189,7 +189,7 @@ public class EditUrlSuggestionProcessor implements OnClickListener, SuggestionPr ...@@ -189,7 +189,7 @@ public class EditUrlSuggestionProcessor implements OnClickListener, SuggestionPr
final LargeIconBridge iconBridge = mIconBridgeSupplier.get(); final LargeIconBridge iconBridge = mIconBridgeSupplier.get();
if (iconBridge == null) return; if (iconBridge == null) return;
iconBridge.getLargeIconForUrl(url, mDesiredFaviconWidthPx, iconBridge.getLargeIconForStringUrl(url, mDesiredFaviconWidthPx,
(Bitmap icon, int fallbackColor, boolean isFallbackColorDefault, (Bitmap icon, int fallbackColor, boolean isFallbackColorDefault,
int iconType) -> model.set(EditUrlSuggestionProperties.SITE_FAVICON, icon)); int iconType) -> model.set(EditUrlSuggestionProperties.SITE_FAVICON, icon));
} }
......
...@@ -122,7 +122,7 @@ public class ConfirmImportantSitesDialogFragment extends DialogFragment { ...@@ -122,7 +122,7 @@ public class ConfirmImportantSitesDialogFragment extends DialogFragment {
viewHolder.imageView.setImageDrawable(image); viewHolder.imageView.setImageDrawable(image);
} }
}; };
mLargeIconBridge.getLargeIconForUrl(url, mFaviconSize, viewHolder.imageCallback); mLargeIconBridge.getLargeIconForStringUrl(url, mFaviconSize, viewHolder.imageCallback);
} }
} }
......
...@@ -99,7 +99,7 @@ public class ImageFetcher { ...@@ -99,7 +99,7 @@ public class ImageFetcher {
String url, int size, LargeIconBridge.LargeIconCallback callback) { String url, int size, LargeIconBridge.LargeIconCallback callback) {
assert !mIsDestroyed; assert !mIsDestroyed;
getLargeIconBridge().getLargeIconForUrl(url, size, callback); getLargeIconBridge().getLargeIconForStringUrl(url, size, callback);
} }
public void onDestroy() { public void onDestroy() {
......
...@@ -93,7 +93,7 @@ public class NewTabPageLoadTest { ...@@ -93,7 +93,7 @@ public class NewTabPageLoadTest {
private static class AsyncMockLargeIconBridge extends LargeIconBridge { private static class AsyncMockLargeIconBridge extends LargeIconBridge {
@Override @Override
public boolean getLargeIconForUrl(String pageUrl, int desiredSizePx, public boolean getLargeIconForStringUrl(String pageUrl, int desiredSizePx,
final LargeIconBridge.LargeIconCallback callback) { final LargeIconBridge.LargeIconCallback callback) {
new Handler().postDelayed(new Runnable() { new Handler().postDelayed(new Runnable() {
@Override @Override
......
...@@ -192,7 +192,7 @@ public class NtpUiCaptureTestData { ...@@ -192,7 +192,7 @@ public class NtpUiCaptureTestData {
} }
return new LargeIconBridge() { return new LargeIconBridge() {
@Override @Override
public boolean getLargeIconForUrl( public boolean getLargeIconForStringUrl(
String url, int desiredSizePx, LargeIconCallback callback) { String url, int desiredSizePx, LargeIconCallback callback) {
PostTask.postTask(UiThreadTaskTraits.DEFAULT, () -> { PostTask.postTask(UiThreadTaskTraits.DEFAULT, () -> {
int fallbackColor = int fallbackColor =
......
...@@ -57,7 +57,7 @@ public class MediaNotificationFaviconTest extends MediaNotificationManagerTestBa ...@@ -57,7 +57,7 @@ public class MediaNotificationFaviconTest extends MediaNotificationManagerTestBa
} }
@Override @Override
public boolean getLargeIconForUrl( public boolean getLargeIconForStringUrl(
final String pageUrl, int desiredSizePx, final LargeIconCallback callback) { final String pageUrl, int desiredSizePx, final LargeIconCallback callback) {
mGetIconCalledAtLeastOnce = true; mGetIconCalledAtLeastOnce = true;
mCallback = callback; mCallback = callback;
......
...@@ -49,7 +49,7 @@ public class MediaNotificationTestTabHolder { ...@@ -49,7 +49,7 @@ public class MediaNotificationTestTabHolder {
// Mock LargeIconBridge that always returns false. // Mock LargeIconBridge that always returns false.
private class TestLargeIconBridge extends LargeIconBridge { private class TestLargeIconBridge extends LargeIconBridge {
@Override @Override
public boolean getLargeIconForUrl( public boolean getLargeIconForStringUrl(
final String pageUrl, int desiredSizePx, final LargeIconCallback callback) { final String pageUrl, int desiredSizePx, final LargeIconCallback callback) {
return false; return false;
} }
......
...@@ -299,7 +299,7 @@ public class BasicSuggestionProcessorTest { ...@@ -299,7 +299,7 @@ public class BasicSuggestionProcessorTest {
SuggestionDrawableState icon1 = mModel.get(BaseSuggestionViewProperties.ICON); SuggestionDrawableState icon1 = mModel.get(BaseSuggestionViewProperties.ICON);
Assert.assertNotNull(icon1); Assert.assertNotNull(icon1);
verify(mIconBridge).getLargeIconForUrl(eq(url), anyInt(), callback.capture()); verify(mIconBridge).getLargeIconForStringUrl(eq(url), anyInt(), callback.capture());
callback.getValue().onLargeIconAvailable(mFakeBitmap, 0, false, 0); callback.getValue().onLargeIconAvailable(mFakeBitmap, 0, false, 0);
SuggestionDrawableState icon2 = mModel.get(BaseSuggestionViewProperties.ICON); SuggestionDrawableState icon2 = mModel.get(BaseSuggestionViewProperties.ICON);
Assert.assertNotNull(icon2); Assert.assertNotNull(icon2);
...@@ -318,7 +318,7 @@ public class BasicSuggestionProcessorTest { ...@@ -318,7 +318,7 @@ public class BasicSuggestionProcessorTest {
SuggestionDrawableState icon1 = mModel.get(BaseSuggestionViewProperties.ICON); SuggestionDrawableState icon1 = mModel.get(BaseSuggestionViewProperties.ICON);
Assert.assertNotNull(icon1); Assert.assertNotNull(icon1);
verify(mIconBridge).getLargeIconForUrl(eq(url), anyInt(), callback.capture()); verify(mIconBridge).getLargeIconForStringUrl(eq(url), anyInt(), callback.capture());
callback.getValue().onLargeIconAvailable(null, 0, false, 0); callback.getValue().onLargeIconAvailable(null, 0, false, 0);
SuggestionDrawableState icon2 = mModel.get(BaseSuggestionViewProperties.ICON); SuggestionDrawableState icon2 = mModel.get(BaseSuggestionViewProperties.ICON);
Assert.assertNotNull(icon2); Assert.assertNotNull(icon2);
......
...@@ -122,7 +122,7 @@ public class SuggestionsImageFetcherTest { ...@@ -122,7 +122,7 @@ public class SuggestionsImageFetcherTest {
imageFetcher.makeLargeIconRequest(URL_STRING, IMAGE_SIZE_PX, mock(LargeIconCallback.class)); imageFetcher.makeLargeIconRequest(URL_STRING, IMAGE_SIZE_PX, mock(LargeIconCallback.class));
verify(mLargeIconBridge) verify(mLargeIconBridge)
.getLargeIconForUrl( .getLargeIconForStringUrl(
eq(URL_STRING), eq(IMAGE_SIZE_PX), any(LargeIconCallback.class)); eq(URL_STRING), eq(IMAGE_SIZE_PX), any(LargeIconCallback.class));
} }
} }
...@@ -7,10 +7,8 @@ ...@@ -7,10 +7,8 @@
#include <jni.h> #include <jni.h>
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "base/android/scoped_java_ref.h" #include "base/android/scoped_java_ref.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/android/chrome_jni_headers/LargeIconBridge_jni.h" #include "chrome/android/chrome_jni_headers/LargeIconBridge_jni.h"
#include "chrome/browser/favicon/large_icon_service_factory.h" #include "chrome/browser/favicon/large_icon_service_factory.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
...@@ -21,9 +19,10 @@ ...@@ -21,9 +19,10 @@
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/android/java_bitmap.h" #include "ui/gfx/android/java_bitmap.h"
#include "ui/gfx/codec/png_codec.h" #include "ui/gfx/codec/png_codec.h"
#include "url/android/gurl_android.h"
#include "url/gurl.h"
using base::android::AttachCurrentThread; using base::android::AttachCurrentThread;
using base::android::ConvertJavaStringToUTF16;
using base::android::JavaParamRef; using base::android::JavaParamRef;
using base::android::JavaRef; using base::android::JavaRef;
using base::android::ScopedJavaGlobalRef; using base::android::ScopedJavaGlobalRef;
...@@ -72,7 +71,7 @@ void LargeIconBridge::Destroy(JNIEnv* env) { ...@@ -72,7 +71,7 @@ void LargeIconBridge::Destroy(JNIEnv* env) {
jboolean LargeIconBridge::GetLargeIconForURL( jboolean LargeIconBridge::GetLargeIconForURL(
JNIEnv* env, JNIEnv* env,
const JavaParamRef<jobject>& j_profile, const JavaParamRef<jobject>& j_profile,
const JavaParamRef<jstring>& j_page_url, const JavaParamRef<jobject>& j_page_url,
jint min_source_size_px, jint min_source_size_px,
const JavaParamRef<jobject>& j_callback) { const JavaParamRef<jobject>& j_callback) {
Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile); Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile);
...@@ -87,10 +86,12 @@ jboolean LargeIconBridge::GetLargeIconForURL( ...@@ -87,10 +86,12 @@ jboolean LargeIconBridge::GetLargeIconForURL(
favicon_base::LargeIconCallback callback_runner = base::BindOnce( favicon_base::LargeIconCallback callback_runner = base::BindOnce(
&OnLargeIconAvailable, ScopedJavaGlobalRef<jobject>(env, j_callback)); &OnLargeIconAvailable, ScopedJavaGlobalRef<jobject>(env, j_callback));
std::unique_ptr<GURL> url = url::GURLAndroid::ToNativeGURL(env, j_page_url);
// Use desired_size = 0 for getting the icon from the cache (so that // Use desired_size = 0 for getting the icon from the cache (so that
// the icon is not poorly rescaled by LargeIconService). // the icon is not poorly rescaled by LargeIconService).
large_icon_service->GetLargeIconRawBitmapOrFallbackStyleForPageUrl( large_icon_service->GetLargeIconRawBitmapOrFallbackStyleForPageUrl(
GURL(ConvertJavaStringToUTF16(env, j_page_url)), min_source_size_px, *url, min_source_size_px,
/*desired_size_in_pixel=*/0, std::move(callback_runner), /*desired_size_in_pixel=*/0, std::move(callback_runner),
&cancelable_task_tracker_); &cancelable_task_tracker_);
......
...@@ -22,7 +22,7 @@ class LargeIconBridge { ...@@ -22,7 +22,7 @@ class LargeIconBridge {
jboolean GetLargeIconForURL( jboolean GetLargeIconForURL(
JNIEnv* env, JNIEnv* env,
const base::android::JavaParamRef<jobject>& j_profile, const base::android::JavaParamRef<jobject>& j_profile,
const base::android::JavaParamRef<jstring>& j_page_url, const base::android::JavaParamRef<jobject>& j_page_url,
jint min_source_size_px, jint min_source_size_px,
const base::android::JavaParamRef<jobject>& j_callback); const base::android::JavaParamRef<jobject>& j_callback);
......
...@@ -110,12 +110,12 @@ class TouchToFillMediator { ...@@ -110,12 +110,12 @@ class TouchToFillMediator {
}; };
final LargeIconCallback setIconOrRetry = (icon, fallbackColor, hasDefaultColor, type) -> { final LargeIconCallback setIconOrRetry = (icon, fallbackColor, hasDefaultColor, type) -> {
if (icon == null && iconOrigin.equals(credential.getOriginUrl())) { if (icon == null && iconOrigin.equals(credential.getOriginUrl())) {
mLargeIconBridge.getLargeIconForUrl(url, mDesiredIconSize, setIcon); mLargeIconBridge.getLargeIconForStringUrl(url, mDesiredIconSize, setIcon);
return; // Unlikely but retry for exact path if there is no icon for the origin. return; // Unlikely but retry for exact path if there is no icon for the origin.
} }
setIcon.onLargeIconAvailable(icon, fallbackColor, hasDefaultColor, type); setIcon.onLargeIconAvailable(icon, fallbackColor, hasDefaultColor, type);
}; };
mLargeIconBridge.getLargeIconForUrl(iconOrigin, mDesiredIconSize, setIconOrRetry); mLargeIconBridge.getLargeIconForStringUrl(iconOrigin, mDesiredIconSize, setIconOrRetry);
} }
private String getIconOrigin(String credentialOrigin, String siteUrl) { private String getIconOrigin(String credentialOrigin, String siteUrl) {
......
...@@ -163,11 +163,11 @@ public class TouchToFillControllerTest { ...@@ -163,11 +163,11 @@ public class TouchToFillControllerTest {
assertThat(itemList.get(3).model.get(FAVICON_OR_FALLBACK), is(nullValue())); assertThat(itemList.get(3).model.get(FAVICON_OR_FALLBACK), is(nullValue()));
verify(mMockIconBridge) verify(mMockIconBridge)
.getLargeIconForUrl(eq(CARL.getOriginUrl()), eq(DESIRED_FAVICON_SIZE), any()); .getLargeIconForStringUrl(eq(CARL.getOriginUrl()), eq(DESIRED_FAVICON_SIZE), any());
verify(mMockIconBridge) verify(mMockIconBridge)
.getLargeIconForUrl(eq(ANA.getOriginUrl()), eq(DESIRED_FAVICON_SIZE), any()); .getLargeIconForStringUrl(eq(ANA.getOriginUrl()), eq(DESIRED_FAVICON_SIZE), any());
verify(mMockIconBridge) verify(mMockIconBridge)
.getLargeIconForUrl(eq(BOB.getOriginUrl()), eq(DESIRED_FAVICON_SIZE), any()); .getLargeIconForStringUrl(eq(BOB.getOriginUrl()), eq(DESIRED_FAVICON_SIZE), any());
} }
@Test @Test
...@@ -181,7 +181,7 @@ public class TouchToFillControllerTest { ...@@ -181,7 +181,7 @@ public class TouchToFillControllerTest {
// ANA and CARL both have TEST_URL as their origin URL // ANA and CARL both have TEST_URL as their origin URL
verify(mMockIconBridge) verify(mMockIconBridge)
.getLargeIconForUrl( .getLargeIconForStringUrl(
eq(TEST_URL), eq(DESIRED_FAVICON_SIZE), mCallbackArgumentCaptor.capture()); eq(TEST_URL), eq(DESIRED_FAVICON_SIZE), mCallbackArgumentCaptor.capture());
LargeIconBridge.LargeIconCallback callback = mCallbackArgumentCaptor.getValue(); LargeIconBridge.LargeIconCallback callback = mCallbackArgumentCaptor.getValue();
Bitmap bitmap = Bitmap.createBitmap( Bitmap bitmap = Bitmap.createBitmap(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment