Commit b955ae4a authored by Peter E Conn's avatar Peter E Conn Committed by Commit Bot

Reland "👹 Add adaptable homescreen shortcuts for maskable icons."

This reverts commit aa1f1cca.

Relanded CL:
  https://chromium-review.googlesource.com/c/chromium/src/+/1341998

Changes from original:
  Initialize has_maskable_primary_icon_

Bug: 904354
Change-Id: I10cbd7bcfea94ea4a1b20236b4e619be9ce415e7

TBR: mgiuca@chromium.org, peter@chromium.org, yfriedman@chromium.org, dominickn@chromium.org
Change-Id: I10cbd7bcfea94ea4a1b20236b4e619be9ce415e7
Reviewed-on: https://chromium-review.googlesource.com/c/1358062Reviewed-by: default avatarPeter Conn <peconn@chromium.org>
Commit-Queue: Peter Conn <peconn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613062}
parent be363dd3
......@@ -108,6 +108,30 @@ public class ShortcutHelper {
private static final float GENERATED_ICON_PADDING_RATIO = 1.0f / 12.0f;
private static final float GENERATED_ICON_FONT_SIZE_RATIO = 1.0f / 3.0f;
// Constants for figuring out the amount of padding required to transform a web manifest
// maskable icon to an Android adaptive icon.
//
// The web standard for maskable icons specifies a larger safe zone inside the icon
// than Android adaptive icons define. Therefore we need to pad the image so that
// the maskable icon's safe zone is reduced to the dimensions expected by Android. See
// https://github.com/w3c/manifest/issues/555#issuecomment-404097653.
//
// The *_RATIO variables give the diameter of the safe zone divided by the width of the icon.
// Sources:
// - https://www.w3.org/TR/appmanifest/#icon-masks
// - https://medium.com/google-design/designing-adaptive-icons-515af294c783
//
// We subtract 1 from the scaling factor to give the amount we need to increase by, then divide
// it by two to get the amount of padding that we will add to both sides.
private static final float MASKABLE_SAFE_ZONE_RATIO = 4.0f / 5.0f;
private static final float ADAPTABLE_SAFE_ZONE_RATIO = 66.0f / 108.0f;
private static final float MASKABLE_TO_ADAPTABLE_SCALING_FACTOR =
MASKABLE_SAFE_ZONE_RATIO / ADAPTABLE_SAFE_ZONE_RATIO;
private static final float MASKABLE_ICON_PADDING_RATIO =
(MASKABLE_TO_ADAPTABLE_SCALING_FACTOR - 1.0f) / 2.0f;
// True when Android O's ShortcutManager.requestPinShortcut() is supported.
private static boolean sIsRequestPinShortcutSupported;
......@@ -120,13 +144,15 @@ public class ShortcutHelper {
public static class Delegate {
/**
* Request Android to add a shortcut to the home screen.
* @param title Title of the shortcut.
* @param icon Image that represents the shortcut.
* @param intent Intent to fire when the shortcut is activated.
* @param title Title of the shortcut.
* @param icon Image that represents the shortcut.
* @param iconAdaptable Whether to create an Android Adaptable icon.
* @param shortcutIntent Intent to fire when the shortcut is activated.
*/
public void addShortcutToHomescreen(String title, Bitmap icon, Intent shortcutIntent) {
public void addShortcutToHomescreen(
String title, Bitmap icon, boolean iconAdaptable, Intent shortcutIntent) {
if (isRequestPinShortcutSupported()) {
addShortcutWithShortcutManager(title, icon, shortcutIntent);
addShortcutWithShortcutManager(title, icon, iconAdaptable, shortcutIntent);
return;
}
Intent intent = createAddToHomeIntent(title, icon, shortcutIntent);
......@@ -160,9 +186,9 @@ public class ShortcutHelper {
@CalledByNative
private static void addWebapp(final String id, final String url, final String scopeUrl,
final String userTitle, final String name, final String shortName, final String iconUrl,
final Bitmap icon, @WebDisplayMode final int displayMode, final int orientation,
final int source, final long themeColor, final long backgroundColor,
final String splashScreenUrl, final long callbackPointer) {
final Bitmap icon, boolean iconAdaptable, @WebDisplayMode final int displayMode,
final int orientation, final int source, final long themeColor,
final long backgroundColor, final String splashScreenUrl, final long callbackPointer) {
new AsyncTask<Intent>() {
@Override
protected Intent doInBackground() {
......@@ -183,7 +209,7 @@ public class ShortcutHelper {
}
@Override
protected void onPostExecute(final Intent resultIntent) {
sDelegate.addShortcutToHomescreen(userTitle, icon, resultIntent);
sDelegate.addShortcutToHomescreen(userTitle, icon, iconAdaptable, resultIntent);
// Store the webapp data so that it is accessible without the intent. Once this
// process is complete, call back to native code to start the splash image
......@@ -206,14 +232,14 @@ public class ShortcutHelper {
*/
@SuppressWarnings("unused")
@CalledByNative
private static void addShortcut(
String id, String url, String userTitle, Bitmap icon, int source) {
private static void addShortcut(String id, String url, String userTitle, Bitmap icon,
boolean iconAdaptable, int source) {
Context context = ContextUtils.getApplicationContext();
final Intent shortcutIntent = createShortcutIntent(url);
shortcutIntent.putExtra(EXTRA_ID, id);
shortcutIntent.putExtra(EXTRA_SOURCE, source);
shortcutIntent.setPackage(context.getPackageName());
sDelegate.addShortcutToHomescreen(userTitle, icon, shortcutIntent);
sDelegate.addShortcutToHomescreen(userTitle, icon, iconAdaptable, shortcutIntent);
if (shouldShowToastWhenAddingShortcut()) {
showAddedToHomescreenToast(userTitle);
}
......@@ -221,14 +247,17 @@ public class ShortcutHelper {
@TargetApi(Build.VERSION_CODES.O)
private static void addShortcutWithShortcutManager(
String title, Bitmap icon, Intent shortcutIntent) {
String title, Bitmap bitmap, boolean isMaskableIcon, Intent shortcutIntent) {
String id = shortcutIntent.getStringExtra(ShortcutHelper.EXTRA_ID);
Context context = ContextUtils.getApplicationContext();
Icon icon = isMaskableIcon ? Icon.createWithAdaptiveBitmap(bitmap)
: Icon.createWithBitmap(bitmap);
ShortcutInfo shortcutInfo = new ShortcutInfo.Builder(context, id)
.setShortLabel(title)
.setLongLabel(title)
.setIcon(Icon.createWithBitmap(icon))
.setIcon(icon)
.setIntent(shortcutIntent)
.build();
try {
......@@ -408,12 +437,12 @@ public class ShortcutHelper {
* Adapts a website's icon (e.g. favicon or touch icon) to make it suitable for the home screen.
* This involves adding padding if the icon is a full sized square.
*
* @param context Context used to create the intent.
* @param webIcon The website's favicon or touch icon.
* @param maskable Whether the icon is suitable for creating an adaptive icon.
* @return Bitmap Either the touch-icon or the newly created favicon.
*/
@CalledByNative
public static Bitmap createHomeScreenIconFromWebIcon(Bitmap webIcon) {
public static Bitmap createHomeScreenIconFromWebIcon(Bitmap webIcon, boolean maskable) {
// getLauncherLargeIconSize() is just a guess at the launcher icon size, and is often
// wrong -- the launcher can show icons at any size it pleases. Instead of resizing the
// icon to the supposed launcher size and then having the launcher resize the icon again,
......@@ -424,18 +453,21 @@ public class ShortcutHelper {
int maxInnerSize = Math.round(am.getLauncherLargeIconSize() * MAX_INNER_SIZE_RATIO);
int innerSize = Math.min(maxInnerSize, Math.max(webIcon.getWidth(), webIcon.getHeight()));
int outerSize = innerSize;
Rect innerBounds = new Rect(0, 0, innerSize, innerSize);
// Draw the icon with padding around it if all four corners are not transparent. Otherwise,
// don't add padding.
if (shouldPadIcon(webIcon)) {
int padding = Math.round(ICON_PADDING_RATIO * innerSize);
outerSize += 2 * padding;
innerBounds.offset(padding, padding);
int padding = 0;
if (maskable) {
// See comments for MASKABLE_ICON_PADDING_RATIO.
padding = Math.round(MASKABLE_ICON_PADDING_RATIO * innerSize);
} else if (shouldPadIcon(webIcon)) {
// Draw the icon with padding around it if all four corners are not transparent.
padding = Math.round(ICON_PADDING_RATIO * innerSize);
}
Bitmap bitmap = null;
int outerSize = 2 * padding + innerSize;
innerBounds.offset(padding, padding);
Bitmap bitmap;
try {
bitmap = Bitmap.createBitmap(outerSize, outerSize, Bitmap.Config.ARGB_8888);
} catch (OutOfMemoryError e) {
......
......@@ -4,9 +4,12 @@
package org.chromium.chrome.browser.webapps;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.graphics.drawable.Icon;
import android.os.Build;
import android.support.v7.app.AlertDialog;
import android.text.Editable;
import android.text.TextUtils;
......@@ -229,13 +232,27 @@ public class AddToHomescreenDialog implements View.OnClickListener {
/**
* Called when the home screen icon is available. Must be called after onUserTitleAvailable().
* @param icon Icon to use in the launcher.
* @param icon that will be used in the launcher.
*/
public void onIconAvailable(Bitmap icon) {
mProgressBarView.setVisibility(View.GONE);
mIconView.setVisibility(View.VISIBLE);
mIconView.setImageBitmap(icon);
setIconAvailable();
}
/**
* Called when the home screen icon is available and was generated to be an Android adaptable
* icon. Must be called after onUserTitleAvailable().
* @param icon that will be used in the launcher.
*/
@TargetApi(Build.VERSION_CODES.O)
public void onAdaptableIconAvailable(Bitmap icon) {
mIconView.setImageIcon(Icon.createWithAdaptiveBitmap(icon));
setIconAvailable();
}
private void setIconAvailable() {
mProgressBarView.setVisibility(View.GONE);
mIconView.setVisibility(View.VISIBLE);
mHasIcon = true;
updateAddButtonEnabledState();
}
......
......@@ -6,6 +6,7 @@ package org.chromium.chrome.browser.webapps;
import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Build;
import android.text.TextUtils;
import org.chromium.base.annotations.CalledByNative;
......@@ -93,8 +94,13 @@ public class AddToHomescreenManager implements AddToHomescreenDialog.Delegate {
}
@CalledByNative
private void onIconAvailable(Bitmap icon) {
mDialog.onIconAvailable(icon);
private void onIconAvailable(Bitmap icon, boolean iconAdaptable) {
if (iconAdaptable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mDialog.onAdaptableIconAvailable(icon);
} else {
assert !iconAdaptable : "Adaptive icons should not be provided pre-Android O.";
mDialog.onIconAvailable(icon);
}
}
private native long nativeInitializeAndStart(WebContents webContents);
......
......@@ -189,7 +189,8 @@ public class AppBannerManagerTest {
AppBannerManager.setIsSupported(true);
ShortcutHelper.setDelegateForTests(new ShortcutHelper.Delegate() {
@Override
public void addShortcutToHomescreen(String title, Bitmap icon, Intent shortcutIntent) {
public void addShortcutToHomescreen(
String title, Bitmap icon, boolean iconAdaptive, Intent shortcutIntent) {
// Ignore to prevent adding homescreen shortcuts.
}
});
......
......@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.webapps;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Build;
import android.support.test.filters.SmallTest;
import android.text.TextUtils;
......@@ -18,6 +19,7 @@ import org.junit.runner.RunWith;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.DisableIf;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.Restriction;
import org.chromium.base.test.util.RetryOnFailure;
......@@ -82,14 +84,23 @@ public class AddToHomescreenManagerTest {
+ "<title>" + META_APP_NAME_PAGE_TITLE + "</title>"
+ "</head><body>Webapp capable</body></html>");
private static final String NON_MASKABLE_MANIFEST_TEST_PAGE_PATH =
"/chrome/test/data/banners/manifest_test_page.html";
private static final String MASKABLE_MANIFEST_TEST_PAGE_PATH =
"/chrome/test/data/banners/manifest_test_page.html?manifest=manifest_maskable.json";
private static final String MANIFEST_TEST_PAGE_TITLE = "Web app banner test page";
private static class TestShortcutHelperDelegate extends ShortcutHelper.Delegate {
public String mRequestedShortcutTitle;
public Intent mRequestedShortcutIntent;
public boolean mRequestedShortcutAdaptable;
@Override
public void addShortcutToHomescreen(String title, Bitmap icon, Intent shortcutIntent) {
public void addShortcutToHomescreen(
String title, Bitmap icon, boolean iconAdaptable, Intent shortcutIntent) {
mRequestedShortcutTitle = title;
mRequestedShortcutIntent = shortcutIntent;
mRequestedShortcutAdaptable = iconAdaptable;
}
@Override
......@@ -100,6 +111,7 @@ public class AddToHomescreenManagerTest {
public void clearRequestedShortcutData() {
mRequestedShortcutTitle = null;
mRequestedShortcutIntent = null;
mRequestedShortcutAdaptable = false;
}
}
......@@ -197,6 +209,31 @@ public class AddToHomescreenManagerTest {
Assert.assertEquals(mActivity.getPackageName(), newLaunchIntent.getPackage());
}
@Test
@SmallTest
@Feature("{Webapp}")
// The test manifest fulfills the requirements of a WebAPK so disable WebAPKs to force plain old
// add to home screen.
@CommandLineFlags.Add({"disable-features=ImprovedA2HS"})
@DisableIf.Build(sdk_is_less_than = Build.VERSION_CODES.O)
public void testAddAdaptableShortcut() throws Exception {
// Test the baseline of no adaptive icon.
loadUrl(mTestServerRule.getServer().getURL(NON_MASKABLE_MANIFEST_TEST_PAGE_PATH),
MANIFEST_TEST_PAGE_TITLE);
addShortcutToTab(mTab, "", true);
Assert.assertFalse(mShortcutHelperDelegate.mRequestedShortcutAdaptable);
mShortcutHelperDelegate.clearRequestedShortcutData();
// Test the adaptive icon.
loadUrl(mTestServerRule.getServer().getURL(MASKABLE_MANIFEST_TEST_PAGE_PATH),
MANIFEST_TEST_PAGE_TITLE);
addShortcutToTab(mTab, "", true);
Assert.assertTrue(mShortcutHelperDelegate.mRequestedShortcutAdaptable);
}
@Test
@SmallTest
@Feature("{Webapp}")
......
......@@ -79,6 +79,7 @@ void GetHomescreenIconAndSplashImageSizes() {
void AddWebappWithSkBitmap(const ShortcutInfo& info,
const std::string& webapp_id,
const SkBitmap& icon_bitmap,
bool is_icon_maskable,
const base::Closure& splash_image_callback) {
// Send the data to the Java side to create the shortcut.
JNIEnv* env = base::android::AttachCurrentThread();
......@@ -113,8 +114,8 @@ void AddWebappWithSkBitmap(const ShortcutInfo& info,
Java_ShortcutHelper_addWebapp(
env, java_webapp_id, java_url, java_scope_url, java_user_title, java_name,
java_short_name, java_best_primary_icon_url, java_bitmap, info.display,
info.orientation, info.source,
java_short_name, java_best_primary_icon_url, java_bitmap,
is_icon_maskable, info.display, info.orientation, info.source,
OptionalSkColorToJavaColor(info.theme_color),
OptionalSkColorToJavaColor(info.background_color), java_splash_screen_url,
callback_pointer);
......@@ -123,7 +124,8 @@ void AddWebappWithSkBitmap(const ShortcutInfo& info,
// Adds a shortcut which opens in a browser tab to the launcher.
void AddShortcutWithSkBitmap(const ShortcutInfo& info,
const std::string& id,
const SkBitmap& icon_bitmap) {
const SkBitmap& icon_bitmap,
bool is_icon_maskable) {
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jstring> java_id =
base::android::ConvertUTF8ToJavaString(env, id);
......@@ -136,7 +138,7 @@ void AddShortcutWithSkBitmap(const ShortcutInfo& info,
java_bitmap = gfx::ConvertToJavaBitmap(&icon_bitmap);
Java_ShortcutHelper_addShortcut(env, java_id, java_url, java_user_title,
java_bitmap, info.source);
java_bitmap, is_icon_maskable, info.source);
}
} // anonymous namespace
......@@ -171,19 +173,20 @@ std::unique_ptr<ShortcutInfo> ShortcutHelper::CreateShortcutInfo(
void ShortcutHelper::AddToLauncherWithSkBitmap(
content::WebContents* web_contents,
const ShortcutInfo& info,
const SkBitmap& icon_bitmap) {
const SkBitmap& icon_bitmap,
bool is_icon_maskable) {
std::string webapp_id = base::GenerateGUID();
if (info.display == blink::kWebDisplayModeStandalone ||
info.display == blink::kWebDisplayModeFullscreen ||
info.display == blink::kWebDisplayModeMinimalUi) {
AddWebappWithSkBitmap(
info, webapp_id, icon_bitmap,
info, webapp_id, icon_bitmap, is_icon_maskable,
base::Bind(&ShortcutHelper::FetchSplashScreenImage, web_contents,
info.splash_image_url, info.ideal_splash_image_size_in_px,
info.minimum_splash_image_size_in_px, webapp_id));
return;
}
AddShortcutWithSkBitmap(info, webapp_id, icon_bitmap);
AddShortcutWithSkBitmap(info, webapp_id, icon_bitmap, is_icon_maskable);
}
void ShortcutHelper::ShowWebApkInstallInProgressToast() {
......@@ -255,6 +258,7 @@ void ShortcutHelper::StoreWebappSplashImage(const std::string& webapp_id,
// static
SkBitmap ShortcutHelper::FinalizeLauncherIconInBackground(
const SkBitmap& bitmap,
bool is_icon_maskable,
const GURL& url,
bool* is_generated) {
base::AssertLongCPUWorkAllowed();
......@@ -268,8 +272,8 @@ SkBitmap ShortcutHelper::FinalizeLauncherIconInBackground(
bitmap.height())) {
ScopedJavaLocalRef<jobject> java_bitmap =
gfx::ConvertToJavaBitmap(&bitmap);
result =
Java_ShortcutHelper_createHomeScreenIconFromWebIcon(env, java_bitmap);
result = Java_ShortcutHelper_createHomeScreenIconFromWebIcon(
env, java_bitmap, is_icon_maskable);
}
}
......
......@@ -42,7 +42,8 @@ class ShortcutHelper {
// added depends on the properties in |info|.
static void AddToLauncherWithSkBitmap(content::WebContents* web_contents,
const ShortcutInfo& info,
const SkBitmap& icon_bitmap);
const SkBitmap& icon_bitmap,
bool is_icon_maskable);
// Shows toast notifying user that a WebAPK install is already in progress
// when user tries to queue a new install for the same WebAPK.
......@@ -85,6 +86,7 @@ class ShortcutHelper {
// |is_generated| will be set to |true|.
// Must be called on a background worker thread.
static SkBitmap FinalizeLauncherIconInBackground(const SkBitmap& icon,
bool is_icon_maskable,
const GURL& url,
bool* is_generated);
......
......@@ -95,8 +95,10 @@ void WebApkInstallService::OnFinishedInstall(
if (!web_contents)
return;
// TODO(https://crbug.com/861643): Support maskable icons here.
ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, shortcut_info,
primary_icon);
primary_icon,
/*is_icon_maskable=*/false);
}
}
......
......@@ -46,10 +46,8 @@ GURL GetShortcutUrl(content::WebContents* web_contents) {
}
bool DoesAndroidSupportMaskableIcons() {
// TODO(peconn): Enable once Chrome on Android correctly handles maskable
// icons (https://crbug.com/904354).
return base::android::BuildInfo::GetInstance()->sdk_int() >=
base::android::SDK_VERSION_OREO && false;
base::android::SDK_VERSION_OREO;
}
InstallableParams ParamsToPerformManifestAndIconFetch() {
......@@ -77,10 +75,11 @@ InstallableParams ParamsToPerformInstallableCheck() {
// - the generated icon
// - whether |icon| was used in generating the launcher icon
std::pair<SkBitmap, bool> CreateLauncherIconInBackground(const GURL& start_url,
const SkBitmap& icon) {
const SkBitmap& icon,
bool maskable) {
bool is_generated = false;
SkBitmap primary_icon = ShortcutHelper::FinalizeLauncherIconInBackground(
icon, start_url, &is_generated);
icon, maskable, start_url, &is_generated);
return std::make_pair(primary_icon, is_generated);
}
......@@ -99,7 +98,8 @@ std::pair<SkBitmap, bool> CreateLauncherIconFromFaviconInBackground(
gfx::PNGCodec::Decode(bitmap_result.bitmap_data->front(),
bitmap_result.bitmap_data->size(), &decoded);
}
return CreateLauncherIconInBackground(start_url, decoded);
return CreateLauncherIconInBackground(start_url, decoded,
/* maskable */ false);
}
void RecordAddToHomescreenDialogDuration(base::TimeDelta duration) {
......@@ -116,6 +116,7 @@ AddToHomescreenDataFetcher::AddToHomescreenDataFetcher(
installable_manager_(InstallableManager::FromWebContents(web_contents)),
observer_(observer),
shortcut_info_(GetShortcutUrl(web_contents)),
has_maskable_primary_icon_(false),
data_timeout_ms_(base::TimeDelta::FromMilliseconds(data_timeout_ms)),
is_waiting_for_manifest_(true),
weak_ptr_factory_(this) {
......@@ -238,6 +239,7 @@ void AddToHomescreenDataFetcher::OnDidGetManifestAndIcons(
}
raw_primary_icon_ = *data.primary_icon;
has_maskable_primary_icon_ = data.has_maskable_primary_icon;
shortcut_info_.best_primary_icon_url = data.primary_icon_url;
// Save the splash screen URL for the later download.
......@@ -346,7 +348,8 @@ void AddToHomescreenDataFetcher::CreateLauncherIcon(const SkBitmap& icon) {
FROM_HERE,
{base::MayBlock(), base::TaskPriority::USER_VISIBLE,
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN},
base::BindOnce(&CreateLauncherIconInBackground, shortcut_info_.url, icon),
base::BindOnce(&CreateLauncherIconInBackground, shortcut_info_.url, icon,
has_maskable_primary_icon_),
base::BindOnce(&AddToHomescreenDataFetcher::NotifyObserver,
weak_ptr_factory_.GetWeakPtr()));
}
......
......@@ -66,6 +66,7 @@ class AddToHomescreenDataFetcher : public content::WebContentsObserver {
const SkBitmap& badge_icon() const { return badge_icon_; }
const SkBitmap& primary_icon() const { return primary_icon_; }
ShortcutInfo& shortcut_info() { return shortcut_info_; }
bool has_maskable_primary_icon() const { return has_maskable_primary_icon_; }
private:
// Called to stop the timeout timer.
......@@ -99,6 +100,7 @@ class AddToHomescreenDataFetcher : public content::WebContentsObserver {
SkBitmap badge_icon_;
SkBitmap primary_icon_;
ShortcutInfo shortcut_info_;
bool has_maskable_primary_icon_;
base::CancelableTaskTracker favicon_task_tracker_;
base::OneShotTimer data_timeout_timer_;
......
......@@ -77,9 +77,10 @@ void AddToHomescreenManager::AddToHomescreen(
base::string16 user_title =
base::android::ConvertJavaStringToUTF16(env, j_user_title);
data_fetcher_->shortcut_info().user_title = user_title;
ShortcutHelper::AddToLauncherWithSkBitmap(web_contents,
data_fetcher_->shortcut_info(),
data_fetcher_->primary_icon());
ShortcutHelper::AddToLauncherWithSkBitmap(
web_contents, data_fetcher_->shortcut_info(),
data_fetcher_->primary_icon(),
data_fetcher_->has_maskable_primary_icon());
}
// Fire the appinstalled event and do install time logging.
......@@ -143,5 +144,6 @@ void AddToHomescreenManager::OnDataAvailable(const ShortcutInfo& info,
java_bitmap = gfx::ConvertToJavaBitmap(&primary_icon);
JNIEnv* env = base::android::AttachCurrentThread();
Java_AddToHomescreenManager_onIconAvailable(env, java_ref_, java_bitmap);
Java_AddToHomescreenManager_onIconAvailable(
env, java_ref_, java_bitmap, data_fetcher_->has_maskable_primary_icon());
}
......@@ -318,8 +318,10 @@ void AppBannerUiDelegateAndroid::InstallLegacyWebApp(
AppBannerSettingsHelper::RecordBannerInstallEvent(
web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB);
// TODO(https://crbug.com/861643): Support maskable icons here.
ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, *shortcut_info_,
primary_icon_);
primary_icon_,
/*is_icon_maskable=*/false);
}
void AppBannerUiDelegateAndroid::SendBannerAccepted() {
......
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