Commit f62a3b31 authored by Ioana Pandele's avatar Ioana Pandele Committed by Commit Bot

[PwdCheckAndroid] Add special favicon handling for apps

For the favicon fallback, the name of the app should be used. If that
doesn't exist, use "A" since the displayed string will be App(package name).

Bug: 1124282
Change-Id: I9f14ccaa5a152780e48f59e785c0161ee90567ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2421497Reviewed-by: default avatarFriedrich [CET] <fhorschig@chromium.org>
Commit-Queue: Ioana Pandele <ioanap@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809256}
parent bccef8e8
...@@ -186,7 +186,8 @@ class PasswordCheckViewBinder { ...@@ -186,7 +186,8 @@ class PasswordCheckViewBinder {
ImageView imageView = view.findViewById(R.id.credential_favicon); ImageView imageView = view.findViewById(R.id.credential_favicon);
PasswordCheckIconHelper.FaviconOrFallback data = model.get(FAVICON_OR_FALLBACK); PasswordCheckIconHelper.FaviconOrFallback data = model.get(FAVICON_OR_FALLBACK);
imageView.setImageDrawable(FaviconUtils.getIconDrawableWithoutFilter(data.mIcon, imageView.setImageDrawable(FaviconUtils.getIconDrawableWithoutFilter(data.mIcon,
data.mUrl, PasswordCheckIconHelper.getIconColor(data, view.getResources()), data.mUrlOrAppName,
PasswordCheckIconHelper.getIconColor(data, view.getResources()),
FaviconUtils.createCircularIconGenerator(view.getResources()), FaviconUtils.createCircularIconGenerator(view.getResources()),
view.getResources(), view.getResources(),
view.getResources().getDimensionPixelSize( view.getResources().getDimensionPixelSize(
......
...@@ -26,16 +26,16 @@ public class PasswordCheckIconHelper { ...@@ -26,16 +26,16 @@ public class PasswordCheckIconHelper {
* Data object containing all data required to set an icon or construct a fallback. * Data object containing all data required to set an icon or construct a fallback.
*/ */
public static class FaviconOrFallback { public static class FaviconOrFallback {
public final String mUrl; public final String mUrlOrAppName;
public final @Nullable Bitmap mIcon; public final @Nullable Bitmap mIcon;
public final int mFallbackColor; public final int mFallbackColor;
public final boolean mIsFallbackColorDefault; public final boolean mIsFallbackColorDefault;
public final int mIconType; public final int mIconType;
public final int mIconSize; public final int mIconSize;
FaviconOrFallback(String originUrl, @Nullable Bitmap icon, int fallbackColor, FaviconOrFallback(String urlOrAppName, @Nullable Bitmap icon, int fallbackColor,
boolean isFallbackColorDefault, int iconType, int iconSize) { boolean isFallbackColorDefault, int iconType, int iconSize) {
mUrl = originUrl; mUrlOrAppName = urlOrAppName;
mIcon = icon; mIcon = icon;
mFallbackColor = fallbackColor; mFallbackColor = fallbackColor;
mIsFallbackColorDefault = isFallbackColorDefault; mIsFallbackColorDefault = isFallbackColorDefault;
...@@ -85,6 +85,10 @@ public class PasswordCheckIconHelper { ...@@ -85,6 +85,10 @@ public class PasswordCheckIconHelper {
* @return A pair with (potentially invalid) icon origin and a fallback URL for monograms. * @return A pair with (potentially invalid) icon origin and a fallback URL for monograms.
*/ */
private static Pair<GURL, String> getIconOriginAndFallback(CompromisedCredential credential) { private static Pair<GURL, String> getIconOriginAndFallback(CompromisedCredential credential) {
if (!credential.getAssociatedApp().isEmpty()) {
return getIconOriginAndFallbackForApp(credential);
}
// Ideally, the sign-on realm is valid and has an adjacent, valid icon. // Ideally, the sign-on realm is valid and has an adjacent, valid icon.
GURL iconOrigin = new GURL(credential.getSignonRealm()); GURL iconOrigin = new GURL(credential.getSignonRealm());
String fallbackUrl = credential.getSignonRealm(); String fallbackUrl = credential.getSignonRealm();
...@@ -100,4 +104,9 @@ public class PasswordCheckIconHelper { ...@@ -100,4 +104,9 @@ public class PasswordCheckIconHelper {
} }
return new Pair<>(iconOrigin, fallbackUrl); return new Pair<>(iconOrigin, fallbackUrl);
} }
private static Pair<GURL, String> getIconOriginAndFallbackForApp(
CompromisedCredential credential) {
return new Pair<>(new GURL(credential.getDisplayOrigin()), credential.getDisplayOrigin());
}
} }
\ No newline at end of file
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