Commit 1fd959d6 authored by zpeng's avatar zpeng Committed by Commit bot

Update WebApkInstaller to support badge icon in installation.

This CL updates WebApkInstaller so that the murmur2 hash of the best
badge icon would be calculated and passed to the WAM server in WebAPK
proto along with the url of the best badge icon.

BUG=649771

Review-Url: https://codereview.chromium.org/2676863002
Cr-Commit-Position: refs/heads/master@{#462963}
parent 9f64905e
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h" #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h"
#include <utility>
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "base/android/jni_string.h" #include "base/android/jni_string.h"
#include "base/location.h" #include "base/location.h"
...@@ -50,15 +52,16 @@ bool AppBannerInfoBarDelegateAndroid::Create( ...@@ -50,15 +52,16 @@ bool AppBannerInfoBarDelegateAndroid::Create(
base::WeakPtr<AppBannerManager> weak_manager, base::WeakPtr<AppBannerManager> weak_manager,
const base::string16& app_title, const base::string16& app_title,
std::unique_ptr<ShortcutInfo> shortcut_info, std::unique_ptr<ShortcutInfo> shortcut_info,
std::unique_ptr<SkBitmap> icon, const SkBitmap& primary_icon,
const SkBitmap& badge_icon,
int event_request_id, int event_request_id,
webapk::InstallSource webapk_install_source) { webapk::InstallSource webapk_install_source) {
bool is_webapk = ChromeWebApkHost::CanInstallWebApk(); bool is_webapk = ChromeWebApkHost::CanInstallWebApk();
const GURL url = shortcut_info->url; const GURL url = shortcut_info->url;
auto infobar_delegate = auto infobar_delegate =
base::WrapUnique(new banners::AppBannerInfoBarDelegateAndroid( base::WrapUnique(new banners::AppBannerInfoBarDelegateAndroid(
weak_manager, app_title, std::move(shortcut_info), std::move(icon), weak_manager, app_title, std::move(shortcut_info), primary_icon,
event_request_id, is_webapk, webapk_install_source)); badge_icon, event_request_id, is_webapk, webapk_install_source));
auto* raw_delegate = infobar_delegate.get(); auto* raw_delegate = infobar_delegate.get();
auto infobar = base::MakeUnique<AppBannerInfoBarAndroid>( auto infobar = base::MakeUnique<AppBannerInfoBarAndroid>(
std::move(infobar_delegate), url, is_webapk); std::move(infobar_delegate), url, is_webapk);
...@@ -85,12 +88,12 @@ bool AppBannerInfoBarDelegateAndroid::Create( ...@@ -85,12 +88,12 @@ bool AppBannerInfoBarDelegateAndroid::Create(
content::WebContents* web_contents, content::WebContents* web_contents,
const base::string16& app_title, const base::string16& app_title,
const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, const base::android::ScopedJavaGlobalRef<jobject>& native_app_data,
std::unique_ptr<SkBitmap> icon, const SkBitmap& icon,
const std::string& native_app_package, const std::string& native_app_package,
const std::string& referrer, const std::string& referrer,
int event_request_id) { int event_request_id) {
auto infobar_delegate = base::WrapUnique(new AppBannerInfoBarDelegateAndroid( auto infobar_delegate = base::WrapUnique(new AppBannerInfoBarDelegateAndroid(
app_title, native_app_data, std::move(icon), native_app_package, referrer, app_title, native_app_data, icon, native_app_package, referrer,
event_request_id)); event_request_id));
return InfoBarService::FromWebContents(web_contents) return InfoBarService::FromWebContents(web_contents)
->AddInfoBar(base::MakeUnique<AppBannerInfoBarAndroid>( ->AddInfoBar(base::MakeUnique<AppBannerInfoBarAndroid>(
...@@ -207,14 +210,16 @@ AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid( ...@@ -207,14 +210,16 @@ AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid(
base::WeakPtr<AppBannerManager> weak_manager, base::WeakPtr<AppBannerManager> weak_manager,
const base::string16& app_title, const base::string16& app_title,
std::unique_ptr<ShortcutInfo> shortcut_info, std::unique_ptr<ShortcutInfo> shortcut_info,
std::unique_ptr<SkBitmap> icon, const SkBitmap& primary_icon,
const SkBitmap& badge_icon,
int event_request_id, int event_request_id,
bool is_webapk, bool is_webapk,
webapk::InstallSource webapk_install_source) webapk::InstallSource webapk_install_source)
: weak_manager_(weak_manager), : weak_manager_(weak_manager),
app_title_(app_title), app_title_(app_title),
shortcut_info_(std::move(shortcut_info)), shortcut_info_(std::move(shortcut_info)),
icon_(std::move(icon)), primary_icon_(primary_icon),
badge_icon_(badge_icon),
event_request_id_(event_request_id), event_request_id_(event_request_id),
has_user_interaction_(false), has_user_interaction_(false),
is_webapk_(is_webapk), is_webapk_(is_webapk),
...@@ -228,13 +233,13 @@ AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid( ...@@ -228,13 +233,13 @@ AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid(
AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid( AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid(
const base::string16& app_title, const base::string16& app_title,
const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, const base::android::ScopedJavaGlobalRef<jobject>& native_app_data,
std::unique_ptr<SkBitmap> icon, const SkBitmap& icon,
const std::string& native_app_package, const std::string& native_app_package,
const std::string& referrer, const std::string& referrer,
int event_request_id) int event_request_id)
: app_title_(app_title), : app_title_(app_title),
native_app_data_(native_app_data), native_app_data_(native_app_data),
icon_(std::move(icon)), primary_icon_(icon),
native_app_package_(native_app_package), native_app_package_(native_app_package),
referrer_(referrer), referrer_(referrer),
event_request_id_(event_request_id), event_request_id_(event_request_id),
...@@ -284,7 +289,7 @@ bool AppBannerInfoBarDelegateAndroid::AcceptWebApp( ...@@ -284,7 +289,7 @@ bool AppBannerInfoBarDelegateAndroid::AcceptWebApp(
web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB); web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB);
ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, *shortcut_info_, ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, *shortcut_info_,
*icon_.get()); primary_icon_);
SendBannerAccepted(); SendBannerAccepted();
return true; return true;
...@@ -332,8 +337,9 @@ bool AppBannerInfoBarDelegateAndroid::AcceptWebApk( ...@@ -332,8 +337,9 @@ bool AppBannerInfoBarDelegateAndroid::AcceptWebApk(
WebApkInstallService::FinishCallback callback = WebApkInstallService::FinishCallback callback =
base::Bind(&AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished, base::Bind(&AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished,
weak_ptr_factory_.GetWeakPtr()); weak_ptr_factory_.GetWeakPtr());
ShortcutHelper::InstallWebApkWithSkBitmap(web_contents, *shortcut_info_, ShortcutHelper::InstallWebApkWithSkBitmap(
*icon_.get(), callback); web_contents, *shortcut_info_, primary_icon_, badge_icon_, callback);
SendBannerAccepted(); SendBannerAccepted();
// Prevent the infobar from disappearing, because the infobar will show // Prevent the infobar from disappearing, because the infobar will show
...@@ -379,7 +385,7 @@ void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFailed( ...@@ -379,7 +385,7 @@ void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFailed(
InfoBarService::WebContentsFromInfoBar(infobar()); InfoBarService::WebContentsFromInfoBar(infobar());
// Add webapp shortcut to the homescreen. // Add webapp shortcut to the homescreen.
ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, *shortcut_info_, ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, *shortcut_info_,
*icon_.get()); primary_icon_);
} }
infobar()->RemoveSelf(); infobar()->RemoveSelf();
...@@ -404,7 +410,7 @@ AppBannerInfoBarDelegateAndroid::GetIdentifier() const { ...@@ -404,7 +410,7 @@ AppBannerInfoBarDelegateAndroid::GetIdentifier() const {
} }
gfx::Image AppBannerInfoBarDelegateAndroid::GetIcon() const { gfx::Image AppBannerInfoBarDelegateAndroid::GetIcon() const {
return gfx::Image::CreateFrom1xBitmap(*icon_.get()); return gfx::Image::CreateFrom1xBitmap(primary_icon_);
} }
void AppBannerInfoBarDelegateAndroid::InfoBarDismissed() { void AppBannerInfoBarDelegateAndroid::InfoBarDismissed() {
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "chrome/browser/android/webapk/webapk_metrics.h" #include "chrome/browser/android/webapk/webapk_metrics.h"
#include "components/infobars/core/confirm_infobar_delegate.h" #include "components/infobars/core/confirm_infobar_delegate.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
namespace content { namespace content {
...@@ -36,14 +37,14 @@ class AppBannerInfoBarDelegateAndroid : public ConfirmInfoBarDelegate { ...@@ -36,14 +37,14 @@ class AppBannerInfoBarDelegateAndroid : public ConfirmInfoBarDelegate {
public: public:
// Creates an infobar and delegate for promoting the installation of a web // Creates an infobar and delegate for promoting the installation of a web
// app, and adds the infobar to the InfoBarManager for |web_contents|. // app, and adds the infobar to the InfoBarManager for |web_contents|.
static bool Create( static bool Create(content::WebContents* web_contents,
content::WebContents* web_contents, base::WeakPtr<AppBannerManager> weak_manager,
base::WeakPtr<AppBannerManager> weak_manager, const base::string16& app_title,
const base::string16& app_title, std::unique_ptr<ShortcutInfo> info,
std::unique_ptr<ShortcutInfo> info, const SkBitmap& primary_icon,
std::unique_ptr<SkBitmap> icon, const SkBitmap& badge_icon,
int event_request_id, int event_request_id,
webapk::InstallSource webapk_install_source); webapk::InstallSource webapk_install_source);
// Creates an infobar and delegate for promoting the installation of an // Creates an infobar and delegate for promoting the installation of an
// Android app, and adds the infobar to the InfoBarManager for |web_contents|. // Android app, and adds the infobar to the InfoBarManager for |web_contents|.
...@@ -51,7 +52,7 @@ class AppBannerInfoBarDelegateAndroid : public ConfirmInfoBarDelegate { ...@@ -51,7 +52,7 @@ class AppBannerInfoBarDelegateAndroid : public ConfirmInfoBarDelegate {
content::WebContents* web_contents, content::WebContents* web_contents,
const base::string16& app_title, const base::string16& app_title,
const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, const base::android::ScopedJavaGlobalRef<jobject>& native_app_data,
std::unique_ptr<SkBitmap> icon, const SkBitmap& icon,
const std::string& native_app_package, const std::string& native_app_package,
const std::string& referrer, const std::string& referrer,
int event_request_id); int event_request_id);
...@@ -94,7 +95,8 @@ class AppBannerInfoBarDelegateAndroid : public ConfirmInfoBarDelegate { ...@@ -94,7 +95,8 @@ class AppBannerInfoBarDelegateAndroid : public ConfirmInfoBarDelegate {
base::WeakPtr<AppBannerManager> weak_manager, base::WeakPtr<AppBannerManager> weak_manager,
const base::string16& app_title, const base::string16& app_title,
std::unique_ptr<ShortcutInfo> info, std::unique_ptr<ShortcutInfo> info,
std::unique_ptr<SkBitmap> icon, const SkBitmap& primary_icon,
const SkBitmap& badge_icon,
int event_request_id, int event_request_id,
bool is_webapk, bool is_webapk,
webapk::InstallSource webapk_install_source); webapk::InstallSource webapk_install_source);
...@@ -103,7 +105,7 @@ class AppBannerInfoBarDelegateAndroid : public ConfirmInfoBarDelegate { ...@@ -103,7 +105,7 @@ class AppBannerInfoBarDelegateAndroid : public ConfirmInfoBarDelegate {
AppBannerInfoBarDelegateAndroid( AppBannerInfoBarDelegateAndroid(
const base::string16& app_title, const base::string16& app_title,
const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, const base::android::ScopedJavaGlobalRef<jobject>& native_app_data,
std::unique_ptr<SkBitmap> icon, const SkBitmap& icon,
const std::string& native_app_package, const std::string& native_app_package,
const std::string& referrer, const std::string& referrer,
int event_request_id); int event_request_id);
...@@ -148,7 +150,8 @@ class AppBannerInfoBarDelegateAndroid : public ConfirmInfoBarDelegate { ...@@ -148,7 +150,8 @@ class AppBannerInfoBarDelegateAndroid : public ConfirmInfoBarDelegate {
base::android::ScopedJavaGlobalRef<jobject> native_app_data_; base::android::ScopedJavaGlobalRef<jobject> native_app_data_;
std::unique_ptr<SkBitmap> icon_; const SkBitmap primary_icon_;
const SkBitmap badge_icon_;
std::string native_app_package_; std::string native_app_package_;
std::string referrer_; std::string referrer_;
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "chrome/browser/android/banners/app_banner_manager_android.h" #include "chrome/browser/android/banners/app_banner_manager_android.h"
#include <memory> #include <memory>
#include <utility>
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "base/android/jni_string.h" #include "base/android/jni_string.h"
...@@ -24,7 +23,6 @@ ...@@ -24,7 +23,6 @@
#include "content/public/common/frame_navigate_params.h" #include "content/public/common/frame_navigate_params.h"
#include "jni/AppBannerManager_jni.h" #include "jni/AppBannerManager_jni.h"
#include "net/base/url_util.h" #include "net/base/url_util.h"
#include "third_party/skia/include/core/SkBitmap.h"
using base::android::ConvertJavaStringToUTF8; using base::android::ConvertJavaStringToUTF8;
using base::android::ConvertJavaStringToUTF16; using base::android::ConvertJavaStringToUTF16;
...@@ -39,12 +37,14 @@ namespace { ...@@ -39,12 +37,14 @@ namespace {
std::unique_ptr<ShortcutInfo> CreateShortcutInfo( std::unique_ptr<ShortcutInfo> CreateShortcutInfo(
const GURL& manifest_url, const GURL& manifest_url,
const content::Manifest& manifest, const content::Manifest& manifest,
const GURL& icon_url) { const GURL& primary_icon_url,
const GURL& badge_icon_url) {
auto shortcut_info = base::MakeUnique<ShortcutInfo>(GURL()); auto shortcut_info = base::MakeUnique<ShortcutInfo>(GURL());
if (!manifest.IsEmpty()) { if (!manifest.IsEmpty()) {
shortcut_info->UpdateFromManifest(manifest); shortcut_info->UpdateFromManifest(manifest);
shortcut_info->manifest_url = manifest_url; shortcut_info->manifest_url = manifest_url;
shortcut_info->best_primary_icon_url = icon_url; shortcut_info->best_primary_icon_url = primary_icon_url;
shortcut_info->best_badge_icon_url = badge_icon_url;
shortcut_info->UpdateSource(ShortcutInfo::SOURCE_APP_BANNER); shortcut_info->UpdateSource(ShortcutInfo::SOURCE_APP_BANNER);
} }
...@@ -210,7 +210,7 @@ void AppBannerManagerAndroid::OnDidPerformInstallableCheck( ...@@ -210,7 +210,7 @@ void AppBannerManagerAndroid::OnDidPerformInstallableCheck(
DCHECK(!data.badge_icon_url.is_empty()); DCHECK(!data.badge_icon_url.is_empty());
badge_icon_url_ = data.badge_icon_url; badge_icon_url_ = data.badge_icon_url;
badge_icon_.reset(new SkBitmap(*data.badge_icon)); badge_icon_ = *data.badge_icon;
} }
AppBannerManager::OnDidPerformInstallableCheck(data); AppBannerManager::OnDidPerformInstallableCheck(data);
...@@ -225,7 +225,7 @@ void AppBannerManagerAndroid::OnAppIconFetched(const SkBitmap& bitmap) { ...@@ -225,7 +225,7 @@ void AppBannerManagerAndroid::OnAppIconFetched(const SkBitmap& bitmap) {
if (!is_active()) if (!is_active())
return; return;
primary_icon_.reset(new SkBitmap(bitmap)); primary_icon_ = bitmap;
SendBannerPromptRequest(); SendBannerPromptRequest();
} }
...@@ -240,11 +240,11 @@ void AppBannerManagerAndroid::ShowBanner() { ...@@ -240,11 +240,11 @@ void AppBannerManagerAndroid::ShowBanner() {
DCHECK(contents); DCHECK(contents);
if (native_app_data_.is_null()) { if (native_app_data_.is_null()) {
// TODO(zpeng): Add badge to WebAPK installation flow.
if (AppBannerInfoBarDelegateAndroid::Create( if (AppBannerInfoBarDelegateAndroid::Create(
contents, GetWeakPtr(), app_title_, contents, GetWeakPtr(), app_title_,
CreateShortcutInfo(manifest_url_, manifest_, primary_icon_url_), CreateShortcutInfo(manifest_url_, manifest_, primary_icon_url_,
std::move(primary_icon_), event_request_id(), badge_icon_url_),
primary_icon_, badge_icon_, event_request_id(),
webapk::INSTALL_SOURCE_BANNER)) { webapk::INSTALL_SOURCE_BANNER)) {
RecordDidShowBanner("AppBanner.WebApp.Shown"); RecordDidShowBanner("AppBanner.WebApp.Shown");
TrackDisplayEvent(DISPLAY_EVENT_WEB_APP_BANNER_CREATED); TrackDisplayEvent(DISPLAY_EVENT_WEB_APP_BANNER_CREATED);
...@@ -254,7 +254,7 @@ void AppBannerManagerAndroid::ShowBanner() { ...@@ -254,7 +254,7 @@ void AppBannerManagerAndroid::ShowBanner() {
} }
} else { } else {
if (AppBannerInfoBarDelegateAndroid::Create( if (AppBannerInfoBarDelegateAndroid::Create(
contents, app_title_, native_app_data_, std::move(primary_icon_), contents, app_title_, native_app_data_, primary_icon_,
native_app_package_, referrer_, event_request_id())) { native_app_package_, referrer_, event_request_id())) {
RecordDidShowBanner("AppBanner.NativeApp.Shown"); RecordDidShowBanner("AppBanner.NativeApp.Shown");
TrackDisplayEvent(DISPLAY_EVENT_NATIVE_APP_BANNER_CREATED); TrackDisplayEvent(DISPLAY_EVENT_NATIVE_APP_BANNER_CREATED);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/banners/app_banner_manager.h" #include "chrome/browser/banners/app_banner_manager.h"
#include "content/public/browser/web_contents_user_data.h" #include "content/public/browser/web_contents_user_data.h"
#include "third_party/skia/include/core/SkBitmap.h"
namespace banners { namespace banners {
...@@ -116,7 +117,7 @@ class AppBannerManagerAndroid ...@@ -116,7 +117,7 @@ class AppBannerManagerAndroid
GURL badge_icon_url_; GURL badge_icon_url_;
// The badge icon object. // The badge icon object.
std::unique_ptr<SkBitmap> badge_icon_; SkBitmap badge_icon_;
// The Java-side AppBannerManager. // The Java-side AppBannerManager.
base::android::ScopedJavaGlobalRef<jobject> java_banner_manager_; base::android::ScopedJavaGlobalRef<jobject> java_banner_manager_;
......
...@@ -157,10 +157,11 @@ void ShortcutHelper::AddToLauncherWithSkBitmap( ...@@ -157,10 +157,11 @@ void ShortcutHelper::AddToLauncherWithSkBitmap(
void ShortcutHelper::InstallWebApkWithSkBitmap( void ShortcutHelper::InstallWebApkWithSkBitmap(
content::WebContents* web_contents, content::WebContents* web_contents,
const ShortcutInfo& info, const ShortcutInfo& info,
const SkBitmap& icon_bitmap, const SkBitmap& primary_icon_bitmap,
const SkBitmap& badge_icon_bitmap,
const WebApkInstallService::FinishCallback& callback) { const WebApkInstallService::FinishCallback& callback) {
WebApkInstallService::Get(web_contents->GetBrowserContext()) WebApkInstallService::Get(web_contents->GetBrowserContext())
->InstallAsync(info, icon_bitmap, callback); ->InstallAsync(info, primary_icon_bitmap, badge_icon_bitmap, callback);
webapk::TrackGooglePlayInstallState(GooglePlayInstallState::SUPPORTED); webapk::TrackGooglePlayInstallState(GooglePlayInstallState::SUPPORTED);
} }
......
...@@ -33,18 +33,17 @@ class ShortcutHelper { ...@@ -33,18 +33,17 @@ class ShortcutHelper {
static bool RegisterShortcutHelper(JNIEnv* env); static bool RegisterShortcutHelper(JNIEnv* env);
// Adds a shortcut to the launcher using a SkBitmap. The type of shortcut // Adds a shortcut to the launcher using a SkBitmap. The type of shortcut
// added depends on the properties in |info|. Calls one of // added depends on the properties in |info|.
// InstallWebApkInBackgroundWithSkBitmap, AddWebappInBackgroundWithSkBitmap,
// or AddShortcutInBackgroundWithSkBitmap.
static void AddToLauncherWithSkBitmap(content::WebContents* web_contents, static void AddToLauncherWithSkBitmap(content::WebContents* web_contents,
const ShortcutInfo& info, const ShortcutInfo& info,
const SkBitmap& icon_bitmap); const SkBitmap& icon_bitmap);
// Installs WebAPK and adds shortcut to the launcher. // Installs WebAPK and adds shortcut to the launcher.
static void InstallWebApkWithSkBitmap( static void InstallWebApkWithSkBitmap(
content::WebContents* web_conetnts, content::WebContents* web_contents,
const ShortcutInfo& info, const ShortcutInfo& info,
const SkBitmap& icon_bitmap, const SkBitmap& primary_icon_bitmap,
const SkBitmap& badge_icon_bitmap,
const WebApkInstallService::FinishCallback& callback); const WebApkInstallService::FinishCallback& callback);
// Shows toast notifying user that a WebAPK install is already in progress // Shows toast notifying user that a WebAPK install is already in progress
...@@ -70,8 +69,8 @@ class ShortcutHelper { ...@@ -70,8 +69,8 @@ class ShortcutHelper {
// Fetches the splash screen image and stores it inside the WebappDataStorage // Fetches the splash screen image and stores it inside the WebappDataStorage
// of the webapp. The WebappDataStorage object *must* have been previously // of the webapp. The WebappDataStorage object *must* have been previously
// created by |AddShortcutInBackgroundWithSkBitmap|; this method should be // created by AddToLauncherWithSkBitmap(); this method should be passed as a
// passed as a closure to that method. // closure to that method.
static void FetchSplashScreenImage(content::WebContents* web_contents, static void FetchSplashScreenImage(content::WebContents* web_contents,
const GURL& image_url, const GURL& image_url,
const int ideal_splash_image_size_in_px, const int ideal_splash_image_size_in_px,
......
...@@ -27,14 +27,15 @@ bool WebApkInstallService::IsInstallInProgress(const GURL& web_manifest_url) { ...@@ -27,14 +27,15 @@ bool WebApkInstallService::IsInstallInProgress(const GURL& web_manifest_url) {
} }
void WebApkInstallService::InstallAsync(const ShortcutInfo& shortcut_info, void WebApkInstallService::InstallAsync(const ShortcutInfo& shortcut_info,
const SkBitmap& shortcut_icon, const SkBitmap& primary_icon,
const SkBitmap& badge_icon,
const FinishCallback& finish_callback) { const FinishCallback& finish_callback) {
DCHECK(!IsInstallInProgress(shortcut_info.manifest_url)); DCHECK(!IsInstallInProgress(shortcut_info.manifest_url));
installs_.insert(shortcut_info.manifest_url); installs_.insert(shortcut_info.manifest_url);
WebApkInstaller::InstallAsync( WebApkInstaller::InstallAsync(
browser_context_, shortcut_info, shortcut_icon, browser_context_, shortcut_info, primary_icon, badge_icon,
base::Bind(&WebApkInstallService::OnFinishedInstall, base::Bind(&WebApkInstallService::OnFinishedInstall,
weak_ptr_factory_.GetWeakPtr(), shortcut_info.manifest_url, weak_ptr_factory_.GetWeakPtr(), shortcut_info.manifest_url,
finish_callback)); finish_callback));
......
...@@ -58,7 +58,8 @@ class WebApkInstallService : public KeyedService { ...@@ -58,7 +58,8 @@ class WebApkInstallService : public KeyedService {
// Google Play to install the downloaded WebAPK. Calls |callback| once the // Google Play to install the downloaded WebAPK. Calls |callback| once the
// install completed or failed. // install completed or failed.
void InstallAsync(const ShortcutInfo& shortcut_info, void InstallAsync(const ShortcutInfo& shortcut_info,
const SkBitmap& shortcut_icon, const SkBitmap& primary_icon,
const SkBitmap& badge_icon,
const FinishCallback& finish_callback); const FinishCallback& finish_callback);
// Talks to the Chrome WebAPK server to update a WebAPK on the server and to // Talks to the Chrome WebAPK server to update a WebAPK on the server and to
......
...@@ -98,11 +98,19 @@ std::string getCurrentAbi() { ...@@ -98,11 +98,19 @@ std::string getCurrentAbi() {
#endif #endif
} }
// Populates the webapk::Image::image_data field of |image| with |icon|.
void SetImageData(webapk::Image* image, const SkBitmap& icon) {
std::vector<unsigned char> png_bytes;
gfx::PNGCodec::EncodeBGRASkBitmap(icon, false, &png_bytes);
image->set_image_data(&png_bytes.front(), png_bytes.size());
}
// Populates webapk::WebApk and returns it. // Populates webapk::WebApk and returns it.
// Must be called on a worker thread because it encodes an SkBitmap. // Must be called on a worker thread because it encodes an SkBitmap.
std::unique_ptr<webapk::WebApk> BuildWebApkProtoInBackground( std::unique_ptr<webapk::WebApk> BuildWebApkProtoInBackground(
const ShortcutInfo& shortcut_info, const ShortcutInfo& shortcut_info,
const SkBitmap& shortcut_icon, const SkBitmap& primary_icon,
const SkBitmap& badge_icon,
const std::map<std::string, std::string>& icon_url_to_murmur2_hash, const std::map<std::string, std::string>& icon_url_to_murmur2_hash,
bool is_manifest_stale) { bool is_manifest_stale) {
DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
...@@ -130,21 +138,32 @@ std::unique_ptr<webapk::WebApk> BuildWebApkProtoInBackground( ...@@ -130,21 +138,32 @@ std::unique_ptr<webapk::WebApk> BuildWebApkProtoInBackground(
std::string* scope = web_app_manifest->add_scopes(); std::string* scope = web_app_manifest->add_scopes();
scope->assign(GetScope(shortcut_info).spec()); scope->assign(GetScope(shortcut_info).spec());
webapk::Image* best_image = web_app_manifest->add_icons(); if (shortcut_info.best_primary_icon_url.is_empty()) {
std::string best_primary_icon_url = // Update when web manifest is no longer available.
shortcut_info.best_primary_icon_url.spec(); webapk::Image* best_primary_icon_image = web_app_manifest->add_icons();
best_image->set_src(best_primary_icon_url); SetImageData(best_primary_icon_image, primary_icon);
auto it = icon_url_to_murmur2_hash.find(best_primary_icon_url); best_primary_icon_image->add_usages(webapk::Image::PRIMARY_ICON);
if (it != icon_url_to_murmur2_hash.end())
best_image->set_hash(it->second); if (!badge_icon.drawsNothing()) {
std::vector<unsigned char> png_bytes; webapk::Image* best_badge_icon_image = web_app_manifest->add_icons();
gfx::PNGCodec::EncodeBGRASkBitmap(shortcut_icon, false, &png_bytes); SetImageData(best_badge_icon_image, badge_icon);
best_image->set_image_data(&png_bytes.front(), png_bytes.size()); best_badge_icon_image->add_usages(webapk::Image::BADGE_ICON);
}
}
for (const auto& entry : icon_url_to_murmur2_hash) { for (const auto& entry : icon_url_to_murmur2_hash) {
if (entry.first == shortcut_info.best_primary_icon_url.spec())
continue;
webapk::Image* image = web_app_manifest->add_icons(); webapk::Image* image = web_app_manifest->add_icons();
if (entry.first == shortcut_info.best_primary_icon_url.spec()) {
SetImageData(image, primary_icon);
image->add_usages(webapk::Image::PRIMARY_ICON);
}
if (entry.first == shortcut_info.best_badge_icon_url.spec()) {
if (shortcut_info.best_badge_icon_url !=
shortcut_info.best_primary_icon_url) {
SetImageData(image, badge_icon);
}
image->add_usages(webapk::Image::BADGE_ICON);
}
image->set_src(entry.first); image->set_src(entry.first);
image->set_hash(entry.second); image->set_hash(entry.second);
} }
...@@ -177,11 +196,12 @@ WebApkInstaller::~WebApkInstaller() { ...@@ -177,11 +196,12 @@ WebApkInstaller::~WebApkInstaller() {
// static // static
void WebApkInstaller::InstallAsync(content::BrowserContext* context, void WebApkInstaller::InstallAsync(content::BrowserContext* context,
const ShortcutInfo& shortcut_info, const ShortcutInfo& shortcut_info,
const SkBitmap& shortcut_icon, const SkBitmap& primary_icon,
const SkBitmap& badge_icon,
const FinishCallback& finish_callback) { const FinishCallback& finish_callback) {
// The installer will delete itself when it is done. // The installer will delete itself when it is done.
WebApkInstaller* installer = WebApkInstaller* installer =
new WebApkInstaller(context, shortcut_info, shortcut_icon); new WebApkInstaller(context, shortcut_info, primary_icon, badge_icon);
installer->InstallAsync(finish_callback); installer->InstallAsync(finish_callback);
} }
...@@ -189,15 +209,15 @@ void WebApkInstaller::InstallAsync(content::BrowserContext* context, ...@@ -189,15 +209,15 @@ void WebApkInstaller::InstallAsync(content::BrowserContext* context,
void WebApkInstaller::UpdateAsync( void WebApkInstaller::UpdateAsync(
content::BrowserContext* context, content::BrowserContext* context,
const ShortcutInfo& shortcut_info, const ShortcutInfo& shortcut_info,
const SkBitmap& shortcut_icon, const SkBitmap& primary_icon,
const std::string& webapk_package, const std::string& webapk_package,
int webapk_version, int webapk_version,
const std::map<std::string, std::string>& icon_url_to_murmur2_hash, const std::map<std::string, std::string>& icon_url_to_murmur2_hash,
bool is_manifest_stale, bool is_manifest_stale,
const FinishCallback& finish_callback) { const FinishCallback& finish_callback) {
// The installer will delete itself when it is done. // The installer will delete itself when it is done.
WebApkInstaller* installer = WebApkInstaller* installer = new WebApkInstaller(
new WebApkInstaller(context, shortcut_info, shortcut_icon); context, shortcut_info, primary_icon, SkBitmap());
installer->UpdateAsync(webapk_package, webapk_version, installer->UpdateAsync(webapk_package, webapk_version,
icon_url_to_murmur2_hash, is_manifest_stale, icon_url_to_murmur2_hash, is_manifest_stale,
finish_callback); finish_callback);
...@@ -240,8 +260,8 @@ void WebApkInstaller::BuildWebApkProtoInBackgroundForTesting( ...@@ -240,8 +260,8 @@ void WebApkInstaller::BuildWebApkProtoInBackgroundForTesting(
bool is_manifest_stale) { bool is_manifest_stale) {
base::PostTaskAndReplyWithResult( base::PostTaskAndReplyWithResult(
GetBackgroundTaskRunner().get(), FROM_HERE, GetBackgroundTaskRunner().get(), FROM_HERE,
base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, shortcut_icon_, base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, primary_icon_,
icon_url_to_murmur2_hash, is_manifest_stale), badge_icon_, icon_url_to_murmur2_hash, is_manifest_stale),
base::Bind(&OnWebApkProtoBuilt, callback)); base::Bind(&OnWebApkProtoBuilt, callback));
} }
...@@ -299,11 +319,13 @@ void WebApkInstaller::OnResult(WebApkInstallResult result) { ...@@ -299,11 +319,13 @@ void WebApkInstaller::OnResult(WebApkInstallResult result) {
WebApkInstaller::WebApkInstaller(content::BrowserContext* browser_context, WebApkInstaller::WebApkInstaller(content::BrowserContext* browser_context,
const ShortcutInfo& shortcut_info, const ShortcutInfo& shortcut_info,
const SkBitmap& shortcut_icon) const SkBitmap& primary_icon,
const SkBitmap& badge_icon)
: request_context_getter_( : request_context_getter_(
Profile::FromBrowserContext(browser_context)->GetRequestContext()), Profile::FromBrowserContext(browser_context)->GetRequestContext()),
shortcut_info_(shortcut_info), shortcut_info_(shortcut_info),
shortcut_icon_(shortcut_icon), primary_icon_(primary_icon),
badge_icon_(badge_icon),
server_url_(GetServerUrl()), server_url_(GetServerUrl()),
webapk_server_timeout_ms_(kWebApkDownloadUrlTimeoutMs), webapk_server_timeout_ms_(kWebApkDownloadUrlTimeoutMs),
relax_updates_(false), relax_updates_(false),
...@@ -334,7 +356,7 @@ void WebApkInstaller::InstallAsync(const FinishCallback& finish_callback) { ...@@ -334,7 +356,7 @@ void WebApkInstaller::InstallAsync(const FinishCallback& finish_callback) {
// should be fast because the icon should be in the HTTP cache. // should be fast because the icon should be in the HTTP cache.
WebApkIconHasher::DownloadAndComputeMurmur2Hash( WebApkIconHasher::DownloadAndComputeMurmur2Hash(
request_context_getter_, shortcut_info_.best_primary_icon_url, request_context_getter_, shortcut_info_.best_primary_icon_url,
base::Bind(&WebApkInstaller::OnGotIconMurmur2Hash, base::Bind(&WebApkInstaller::OnGotPrimaryIconMurmur2Hash,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
...@@ -350,8 +372,8 @@ void WebApkInstaller::UpdateAsync( ...@@ -350,8 +372,8 @@ void WebApkInstaller::UpdateAsync(
base::PostTaskAndReplyWithResult( base::PostTaskAndReplyWithResult(
GetBackgroundTaskRunner().get(), FROM_HERE, GetBackgroundTaskRunner().get(), FROM_HERE,
base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, shortcut_icon_, base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, primary_icon_,
icon_url_to_murmur2_hash, is_manifest_stale), badge_icon_, icon_url_to_murmur2_hash, is_manifest_stale),
base::Bind(&WebApkInstaller::SendUpdateWebApkRequest, base::Bind(&WebApkInstaller::SendUpdateWebApkRequest,
weak_ptr_factory_.GetWeakPtr(), webapk_version)); weak_ptr_factory_.GetWeakPtr(), webapk_version));
} }
...@@ -402,26 +424,52 @@ void WebApkInstaller::OnURLFetchComplete(const net::URLFetcher* source) { ...@@ -402,26 +424,52 @@ void WebApkInstaller::OnURLFetchComplete(const net::URLFetcher* source) {
InstallOrUpdateWebApk(response->package_name(), version, response->token()); InstallOrUpdateWebApk(response->package_name(), version, response->token());
} }
void WebApkInstaller::OnGotIconMurmur2Hash( void WebApkInstaller::OnGotPrimaryIconMurmur2Hash(
const std::string& icon_murmur2_hash) { const std::string& primary_icon_hash) {
// An empty hash indicates that |icon_hasher_| encountered an error. // An empty hash indicates an error during hash calculation.
if (icon_murmur2_hash.empty()) { if (primary_icon_hash.empty()) {
OnResult(WebApkInstallResult::FAILURE); OnResult(WebApkInstallResult::FAILURE);
return; return;
} }
if (!shortcut_info_.best_badge_icon_url.is_empty() &&
shortcut_info_.best_badge_icon_url !=
shortcut_info_.best_primary_icon_url) {
WebApkIconHasher::DownloadAndComputeMurmur2Hash(
request_context_getter_, shortcut_info_.best_badge_icon_url,
base::Bind(&WebApkInstaller::OnGotBadgeIconMurmur2Hash,
weak_ptr_factory_.GetWeakPtr(), true, primary_icon_hash));
} else {
OnGotBadgeIconMurmur2Hash(false, primary_icon_hash, "");
}
}
void WebApkInstaller::OnGotBadgeIconMurmur2Hash(
bool did_fetch_badge_icon,
const std::string& primary_icon_hash,
const std::string& badge_icon_hash) {
// An empty hash indicates an error during hash calculation.
if (did_fetch_badge_icon && badge_icon_hash.empty()) {
OnResult(WebApkInstallResult::FAILURE);
return;
}
// Maps icon URLs to Murmur2 hashes.
std::map<std::string, std::string> icon_url_to_murmur2_hash; std::map<std::string, std::string> icon_url_to_murmur2_hash;
for (const std::string& icon_url : shortcut_info_.icon_urls) { for (const std::string& icon_url : shortcut_info_.icon_urls) {
if (icon_url != shortcut_info_.best_primary_icon_url.spec()) if (icon_url == shortcut_info_.best_primary_icon_url.spec())
icon_url_to_murmur2_hash[icon_url] = ""; icon_url_to_murmur2_hash[icon_url] = primary_icon_hash;
else if (icon_url == shortcut_info_.best_badge_icon_url.spec())
icon_url_to_murmur2_hash[icon_url] = badge_icon_hash;
else else
icon_url_to_murmur2_hash[icon_url] = icon_murmur2_hash; icon_url_to_murmur2_hash[icon_url] = "";
} }
base::PostTaskAndReplyWithResult( base::PostTaskAndReplyWithResult(
GetBackgroundTaskRunner().get(), FROM_HERE, GetBackgroundTaskRunner().get(), FROM_HERE,
base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, shortcut_icon_, base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, primary_icon_,
icon_url_to_murmur2_hash, false /* is_manifest_stale */), badge_icon_, icon_url_to_murmur2_hash,
false /* is_manifest_stale */),
base::Bind(&WebApkInstaller::SendCreateWebApkRequest, base::Bind(&WebApkInstaller::SendCreateWebApkRequest,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
......
...@@ -46,16 +46,18 @@ class WebApkInstaller : public net::URLFetcherDelegate { ...@@ -46,16 +46,18 @@ class WebApkInstaller : public net::URLFetcherDelegate {
// APK to be installed. Calls |callback| once the install completed or failed. // APK to be installed. Calls |callback| once the install completed or failed.
static void InstallAsync(content::BrowserContext* context, static void InstallAsync(content::BrowserContext* context,
const ShortcutInfo& shortcut_info, const ShortcutInfo& shortcut_info,
const SkBitmap& shortcut_icon, const SkBitmap& primary_icon,
const SkBitmap& badge_icon,
const FinishCallback& finish_callback); const FinishCallback& finish_callback);
// TODO(zpeng): Add badge icon to WebAPK update route.
// Creates a self-owned WebApkInstaller instance and talks to the Chrome // Creates a self-owned WebApkInstaller instance and talks to the Chrome
// WebAPK server to update a WebAPK on the server and locally requests the // WebAPK server to update a WebAPK on the server and locally requests the
// APK to be installed. Calls |callback| once the install completed or failed. // APK to be installed. Calls |callback| once the install completed or failed.
static void UpdateAsync( static void UpdateAsync(
content::BrowserContext* context, content::BrowserContext* context,
const ShortcutInfo& shortcut_info, const ShortcutInfo& shortcut_info,
const SkBitmap& shortcut_icon, const SkBitmap& primary_icon,
const std::string& webapk_package, const std::string& webapk_package,
int webapk_version, int webapk_version,
const std::map<std::string, std::string>& icon_url_to_murmur2_hash, const std::map<std::string, std::string>& icon_url_to_murmur2_hash,
...@@ -98,7 +100,8 @@ class WebApkInstaller : public net::URLFetcherDelegate { ...@@ -98,7 +100,8 @@ class WebApkInstaller : public net::URLFetcherDelegate {
protected: protected:
WebApkInstaller(content::BrowserContext* browser_context, WebApkInstaller(content::BrowserContext* browser_context,
const ShortcutInfo& shortcut_info, const ShortcutInfo& shortcut_info,
const SkBitmap& shortcut_icon); const SkBitmap& primary_icon,
const SkBitmap& badge_icon);
// Returns whether the device supports installing WebAPKs. // Returns whether the device supports installing WebAPKs.
virtual bool CanInstallWebApks(); virtual bool CanInstallWebApks();
...@@ -140,8 +143,15 @@ class WebApkInstaller : public net::URLFetcherDelegate { ...@@ -140,8 +143,15 @@ class WebApkInstaller : public net::URLFetcherDelegate {
// net::URLFetcherDelegate: // net::URLFetcherDelegate:
void OnURLFetchComplete(const net::URLFetcher* source) override; void OnURLFetchComplete(const net::URLFetcher* source) override;
// Called with the computed Murmur2 hash for the app icon. // Called with the computed Murmur2 hash for the primary icon.
void OnGotIconMurmur2Hash(const std::string& icon_murmur2_hash); void OnGotPrimaryIconMurmur2Hash(const std::string& primary_icon_hash);
// Called with the computed Murmur2 hash for the badge icon, and
// |did_fetch_badge_icon| to indicate whether there was an attempt to fetch
// badge icon.
void OnGotBadgeIconMurmur2Hash(bool did_fetch_badge_icon,
const std::string& primary_icon_hash,
const std::string& badge_icon_hash);
// Sends request to WebAPK server to create WebAPK. During a successful // Sends request to WebAPK server to create WebAPK. During a successful
// request the WebAPK server responds with the URL of the generated WebAPK. // request the WebAPK server responds with the URL of the generated WebAPK.
...@@ -178,8 +188,11 @@ class WebApkInstaller : public net::URLFetcherDelegate { ...@@ -178,8 +188,11 @@ class WebApkInstaller : public net::URLFetcherDelegate {
// Web Manifest info. // Web Manifest info.
const ShortcutInfo shortcut_info_; const ShortcutInfo shortcut_info_;
// WebAPK app icon. // WebAPK primary icon.
const SkBitmap shortcut_icon_; const SkBitmap primary_icon_;
// WebAPK badge icon.
const SkBitmap badge_icon_;
// WebAPK server URL. // WebAPK server URL.
GURL server_url_; GURL server_url_;
......
...@@ -163,14 +163,13 @@ void AddToHomescreenManager::OnDataAvailable(const ShortcutInfo& info, ...@@ -163,14 +163,13 @@ void AddToHomescreenManager::OnDataAvailable(const ShortcutInfo& info,
const SkBitmap& primary_icon, const SkBitmap& primary_icon,
const SkBitmap& badge_icon) { const SkBitmap& badge_icon) {
if (is_webapk_compatible_) { if (is_webapk_compatible_) {
// TODO(zpeng): Add badge to WebAPK installation flow.
WebApkInstallService* install_service = WebApkInstallService* install_service =
WebApkInstallService::Get( WebApkInstallService::Get(
data_fetcher_->web_contents()->GetBrowserContext()); data_fetcher_->web_contents()->GetBrowserContext());
if (install_service->IsInstallInProgress(info.manifest_url)) if (install_service->IsInstallInProgress(info.manifest_url))
ShortcutHelper::ShowWebApkInstallInProgressToast(); ShortcutHelper::ShowWebApkInstallInProgressToast();
else else
CreateInfoBarForWebApk(info, primary_icon); CreateInfoBarForWebApk(info, primary_icon, badge_icon);
JNIEnv* env = base::android::AttachCurrentThread(); JNIEnv* env = base::android::AttachCurrentThread();
Java_AddToHomescreenManager_onFinished(env, java_ref_); Java_AddToHomescreenManager_onFinished(env, java_ref_);
...@@ -188,11 +187,13 @@ void AddToHomescreenManager::OnDataAvailable(const ShortcutInfo& info, ...@@ -188,11 +187,13 @@ void AddToHomescreenManager::OnDataAvailable(const ShortcutInfo& info,
AddShortcut(info, primary_icon); AddShortcut(info, primary_icon);
} }
void AddToHomescreenManager::CreateInfoBarForWebApk(const ShortcutInfo& info, void AddToHomescreenManager::CreateInfoBarForWebApk(
const SkBitmap& icon) { const ShortcutInfo& info,
const SkBitmap& primary_icon,
const SkBitmap& badge_icon) {
banners::AppBannerInfoBarDelegateAndroid::Create( banners::AppBannerInfoBarDelegateAndroid::Create(
data_fetcher_->web_contents(), nullptr, info.user_title, data_fetcher_->web_contents(), nullptr, info.user_title,
base::MakeUnique<ShortcutInfo>(info), base::MakeUnique<SkBitmap>(icon), base::MakeUnique<ShortcutInfo>(info), primary_icon, badge_icon,
-1 /* event_request_id */, webapk::INSTALL_SOURCE_MENU); -1 /* event_request_id */, webapk::INSTALL_SOURCE_MENU);
} }
......
...@@ -52,7 +52,9 @@ class AddToHomescreenManager : public AddToHomescreenDataFetcher::Observer { ...@@ -52,7 +52,9 @@ class AddToHomescreenManager : public AddToHomescreenDataFetcher::Observer {
// Called only when the AddToHomescreenDataFetcher has retrieved all of the // Called only when the AddToHomescreenDataFetcher has retrieved all of the
// data needed to install a WebAPK. // data needed to install a WebAPK.
void CreateInfoBarForWebApk(const ShortcutInfo& info, const SkBitmap& icon); void CreateInfoBarForWebApk(const ShortcutInfo& info,
const SkBitmap& primary_icon,
const SkBitmap& badge_icon);
void RecordAddToHomescreen(); void RecordAddToHomescreen();
......
...@@ -267,7 +267,7 @@ void AppBannerManager::OnDidPerformInstallableCheck( ...@@ -267,7 +267,7 @@ void AppBannerManager::OnDidPerformInstallableCheck(
DCHECK(data.primary_icon); DCHECK(data.primary_icon);
primary_icon_url_ = data.primary_icon_url; primary_icon_url_ = data.primary_icon_url;
primary_icon_.reset(new SkBitmap(*data.primary_icon)); primary_icon_ = *data.primary_icon;
// If we triggered the installability check on page load, then it's possible // If we triggered the installability check on page load, then it's possible
// we don't have enough engagement yet. If that's the case, return here but // we don't have enough engagement yet. If that's the case, return here but
...@@ -540,7 +540,7 @@ void AppBannerManager::OnBannerPromptReply( ...@@ -540,7 +540,7 @@ void AppBannerManager::OnBannerPromptReply(
DCHECK(!manifest_url_.is_empty()); DCHECK(!manifest_url_.is_empty());
DCHECK(!manifest_.IsEmpty()); DCHECK(!manifest_.IsEmpty());
DCHECK(!primary_icon_url_.is_empty()); DCHECK(!primary_icon_url_.is_empty());
DCHECK(primary_icon_.get()); DCHECK(!primary_icon_.drawsNothing());
TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_COMPLETE); TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_COMPLETE);
ShowBanner(); ShowBanner();
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#ifndef CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_ #ifndef CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_
#define CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_ #define CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_
#include <memory>
#include <vector> #include <vector>
#include "base/macros.h" #include "base/macros.h"
...@@ -243,7 +242,7 @@ class AppBannerManager : public content::WebContentsObserver, ...@@ -243,7 +242,7 @@ class AppBannerManager : public content::WebContentsObserver,
GURL primary_icon_url_; GURL primary_icon_url_;
// The primary icon object. // The primary icon object.
std::unique_ptr<SkBitmap> primary_icon_; SkBitmap primary_icon_;
// The referrer string (if any) specified in the app URL. Used only for native // The referrer string (if any) specified in the app URL. Used only for native
// app banners. // app banners.
......
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