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..6f3ac6ee39d32afbf870fb6995c82093386d795a 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) { |
|
dominickn
2017/03/02 01:56:50
I wonder whether it's cleaner to have a success_ca
pkotwicz
2017/03/02 04:09:42
I'd rather not. Especially since I am going to cha
dominickn
2017/03/02 04:14:49
Acknowledged.
|
| - 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); |
| + |
| + content::WebContents* web_contents = |
|
dominickn
2017/03/02 01:56:50
This would be a bit cleaner as:
if (!infobar())
pkotwicz
2017/03/02 04:09:42
Done.
|
| + InfoBarService::WebContentsFromInfoBar(infobar()); |
| + if (web_contents) { |
| + // 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 (infobar()) |
| + infobar()->RemoveSelf(); |
| +} |
| + |
| void AppBannerInfoBarDelegateAndroid::TrackWebApkInstallationDismissEvents( |
| InstallState install_state) { |
| if (install_state == INSTALL_NOT_STARTED) { |