| Index: chrome/browser/android/banners/app_banner_manager_android.cc
|
| diff --git a/chrome/browser/android/banners/app_banner_manager_android.cc b/chrome/browser/android/banners/app_banner_manager_android.cc
|
| index e5f96225074296d8df1ec0f325b08f56ee755f47..3666e47f285a8ce72a2f937b71f38a2062822006 100644
|
| --- a/chrome/browser/android/banners/app_banner_manager_android.cc
|
| +++ b/chrome/browser/android/banners/app_banner_manager_android.cc
|
| @@ -56,7 +56,8 @@ namespace banners {
|
|
|
| AppBannerManagerAndroid::AppBannerManagerAndroid(
|
| content::WebContents* web_contents)
|
| - : AppBannerManager(web_contents) {
|
| + : AppBannerManager(web_contents),
|
| + weak_ptr_factory_(this) {
|
| CreateJavaBannerManager();
|
| }
|
|
|
| @@ -202,16 +203,23 @@ void AppBannerManagerAndroid::ShowBanner() {
|
| DCHECK(contents);
|
|
|
| if (native_app_data_.is_null()) {
|
| - if (AppBannerInfoBarDelegateAndroid::Create(
|
| - contents, GetWeakPtr(), app_title_,
|
| - CreateShortcutInfo(manifest_url_, manifest_, icon_url_),
|
| - std::move(icon_), event_request_id(),
|
| - webapk::INSTALL_SOURCE_BANNER)) {
|
| - RecordDidShowBanner("AppBanner.WebApp.Shown");
|
| - TrackDisplayEvent(DISPLAY_EVENT_WEB_APP_BANNER_CREATED);
|
| - ReportStatus(contents, SHOWING_WEB_APP_BANNER);
|
| + if (!ChromeWebApkHost::AreWebApkEnabled() ||
|
| + !ChromeWebApkHost::CanUseGooglePlayToInstallWebApk()) {
|
| + // If WebAPK isn't enabled, we don't care about whether the install flow
|
| + // can be used.
|
| + // If WebAPK is enabled but the Google Play Install isn't allowed, we set
|
| + // the flag be true to conitnue with the regular WebAPK install flow.
|
| + ShowBannerImpl(contents, true);
|
| } else {
|
| - ReportStatus(contents, FAILED_TO_CREATE_BANNER);
|
| + // Checks whether Google Play install API is avaible.
|
| + // ChromeWebApkHost will delete itself after the the check whether Google
|
| + // Play Install API is done.
|
| + ChromeWebApkHost* host = new ChromeWebApkHost();
|
| + ChromeWebApkHost::CanUseGooglePlayInstallApiCallback callback
|
| + = base::Bind(&AppBannerManagerAndroid::OnCanUseGooglePlayInstallApi,
|
| + weak_ptr_factory_.GetWeakPtr(),
|
| + contents);
|
| + host->CanUseGooglePlayInstallApi(callback);
|
| }
|
| } else {
|
| if (AppBannerInfoBarDelegateAndroid::Create(
|
| @@ -226,6 +234,27 @@ void AppBannerManagerAndroid::ShowBanner() {
|
| }
|
| }
|
|
|
| +void AppBannerManagerAndroid::ShowBannerImpl(content::WebContents* contents,
|
| + bool can_use_webapk_install_flow) {
|
| + if (AppBannerInfoBarDelegateAndroid::Create(
|
| + contents, GetWeakPtr(), app_title_,
|
| + CreateShortcutInfo(manifest_url_, manifest_, icon_url_),
|
| + std::move(icon_), event_request_id(), can_use_webapk_install_flow,
|
| + webapk::INSTALL_SOURCE_BANNER)) {
|
| + RecordDidShowBanner("AppBanner.WebApp.Shown");
|
| + TrackDisplayEvent(DISPLAY_EVENT_WEB_APP_BANNER_CREATED);
|
| + ReportStatus(contents, SHOWING_WEB_APP_BANNER);
|
| + } else {
|
| + ReportStatus(contents, FAILED_TO_CREATE_BANNER);
|
| + }
|
| +}
|
| +
|
| +void AppBannerManagerAndroid::OnCanUseGooglePlayInstallApi(
|
| + content::WebContents* web_contents,
|
| + bool isAvailable) {
|
| + ShowBannerImpl(web_contents, isAvailable);
|
| +}
|
| +
|
| bool AppBannerManagerAndroid::CanHandleNonWebApp(const std::string& platform,
|
| const GURL& url,
|
| const std::string& id) {
|
|
|