Commit 810787b4 authored by Dominick Ng's avatar Dominick Ng Committed by Commit Bot

Ensure maskable icons are padded correctly in the A2HS prompt.

This CL refactors the handling of icons in AddToHomescreenDataFetcher so
that WebAPKs which have maskable icons have that icon correctly masked
in the A2HS prompt, but still use the raw icon in the WebAPK itself.

Using the raw icon in the WebAPK is necessary to ensure that the OS and
WebAPK server always have the original icon on which to apply their own
masks. However, that original icon is inappropriate to show the user in
the A2HS prompt, so ensure we mask it manually before it is shown.

BUG=977173

Change-Id: Ib3e469d31e236ef961f72d25dfb2170723fa73c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1869151
Commit-Queue: Dominick Ng <dominickn@chromium.org>
Commit-Queue: Mehran Mahmoudi <mahmoudi@chromium.org>
Reviewed-by: default avatarMehran Mahmoudi <mahmoudi@chromium.org>
Auto-Submit: Dominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708049}
parent 35612281
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#ifndef CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_ #ifndef CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_
#define CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_ #define CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_
#include <utility>
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
...@@ -39,7 +37,8 @@ class AddToHomescreenDataFetcher : public content::WebContentsObserver { ...@@ -39,7 +37,8 @@ class AddToHomescreenDataFetcher : public content::WebContentsObserver {
const GURL& url, const GURL& url,
bool is_webapk_compatible) = 0; bool is_webapk_compatible) = 0;
// Called when all the data needed to create a shortcut is available. // Called when all the data needed to prompt the user to add to home screen
// is available.
virtual void OnDataAvailable(const ShortcutInfo& info, virtual void OnDataAvailable(const ShortcutInfo& info,
const SkBitmap& primary_icon, const SkBitmap& primary_icon,
const SkBitmap& badge_icon) = 0; const SkBitmap& badge_icon) = 0;
...@@ -88,11 +87,15 @@ class AddToHomescreenDataFetcher : public content::WebContentsObserver { ...@@ -88,11 +87,15 @@ class AddToHomescreenDataFetcher : public content::WebContentsObserver {
void OnFaviconFetched( void OnFaviconFetched(
const favicon_base::FaviconRawBitmapResult& bitmap_result); const favicon_base::FaviconRawBitmapResult& bitmap_result);
// Creates the primary launcher icon from the given |icon|. // Creates an icon to display to the user to confirm the add to home screen
void CreateLauncherIcon(const SkBitmap& icon); // from the given |base_icon|. If |use_for_launcher| is true, the created icon
// will also be used as the launcher icon.
void CreateIconForView(const SkBitmap& base_icon, bool use_for_launcher);
// Notifies the observer that the shortcut data is all available. // Notifies the observer that the shortcut data is all available.
void NotifyObserver(const std::pair<SkBitmap, bool /*is_generated*/>& icon); void OnIconCreated(bool use_for_launcher,
const SkBitmap& icon_for_view,
bool is_icon_generated);
InstallableManager* installable_manager_; InstallableManager* installable_manager_;
Observer* observer_; Observer* observer_;
......
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