| Index: chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
|
| diff --git a/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc b/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
|
| index 04146414bc3dec3c6f1026d2b8645027a752762e..83c08d4f1bb3f0915c4a7373171ec182c99cf7d8 100644
|
| --- a/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
|
| +++ b/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
|
| @@ -373,11 +373,11 @@ void AppBannerInfoBarDelegateAndroid::SendBannerAccepted() {
|
| }
|
|
|
| void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished(
|
| - bool success,
|
| + WebApkInstallResult result,
|
| bool relax_updates,
|
| const std::string& webapk_package_name) {
|
| - if (!success) {
|
| - OnWebApkInstallFailed();
|
| + if (result != WebApkInstallResult::SUCCESS) {
|
| + OnWebApkInstallFailed(result);
|
| return;
|
| }
|
| UpdateStateForInstalledWebAPK(webapk_package_name);
|
| @@ -386,22 +386,28 @@ void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished(
|
| webapk::TrackInstallEvent(webapk::INSTALL_COMPLETED);
|
| }
|
|
|
| -void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFailed() {
|
| +void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFailed(
|
| + WebApkInstallResult result) {
|
| DVLOG(1) << "The WebAPK installation failed.";
|
| webapk::TrackInstallEvent(webapk::INSTALL_FAILED);
|
|
|
| if (!infobar())
|
| return;
|
|
|
| - content::WebContents* web_contents =
|
| - InfoBarService::WebContentsFromInfoBar(infobar());
|
| - // Add webapp shortcut to the homescreen.
|
| - // TODO(pkotwicz): Only add webapp shortcut to the homescreen if
|
| - // WebAPK install did not timeout. If the WebAPK install timed out
|
| - // it is possible that Google Play is taking a long time and will
|
| - // eventually installs the WebAPK.
|
| - ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, *shortcut_info_,
|
| - *icon_.get());
|
| + if (result == WebApkInstallResult::FAILURE) {
|
| + content::WebContents* web_contents =
|
| + InfoBarService::WebContentsFromInfoBar(infobar());
|
| + // Add webapp shortcut to the homescreen.
|
| + ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, *shortcut_info_,
|
| + *icon_.get());
|
| + } else {
|
| + // The WebAPK install timed out. Don't add shortcut because the install
|
| + // might still succeed (e.g. the install timed out because Google Play was
|
| + // busy with another install). It is confusing for a user to have homescreen
|
| + // shortcuts for both a WebAPK and a webapp for the same page URL.
|
| + JNIEnv* env = base::android::AttachCurrentThread();
|
| + Java_AppBannerInfoBarDelegateAndroid_showWebApkInstallFailureToast(env);
|
| + }
|
|
|
| infobar()->RemoveSelf();
|
| }
|
|
|