Chromium Code Reviews| 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 c5d1af9d35d8297f6352ba31333a2936f8ef05e8..df60ed134ebd8de7a7d59be0f58567796b404b35 100644 |
| --- a/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc |
| +++ b/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc |
| @@ -375,22 +375,36 @@ void AppBannerInfoBarDelegateAndroid::SendBannerAccepted() { |
| void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished( |
| bool success, |
| const std::string& webapk_package_name) { |
| - JNIEnv* env = base::android::AttachCurrentThread(); |
| if (!success) { |
| - DVLOG(1) << "The WebAPK installation failed."; |
| - Java_AppBannerInfoBarDelegateAndroid_showWebApkInstallFailureToast(env); |
| - webapk::TrackInstallEvent(webapk::INSTALL_FAILED); |
| - if (infobar()) |
| - infobar()->RemoveSelf(); |
| + OnWebApkInstallFailed(); |
| return; |
| } |
| - |
| UpdateStateForInstalledWebAPK(webapk_package_name); |
| webapk::TrackInstallDuration(timer_->Elapsed()); |
| timer_.reset(); |
| webapk::TrackInstallEvent(webapk::INSTALL_COMPLETED); |
| } |
| +void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFailed() { |
| + DVLOG(1) << "The WebAPK installation failed."; |
| + webapk::TrackInstallEvent(webapk::INSTALL_FAILED); |
| + |
| + if (infobar()) |
|
dominickn
2017/03/02 04:14:49
Pretty sure it should be 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()); |
| + |
| + infobar()->RemoveSelf(); |
| +} |
| + |
| void AppBannerInfoBarDelegateAndroid::TrackWebApkInstallationDismissEvents( |
| InstallState install_state) { |
| if (install_state == INSTALL_NOT_STARTED) { |