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 40faf1eab35d0faf39385069b4ea30f6cf628466..f8222a2cd208286e33b7ad0f24e204c6d078036c 100644 |
| --- a/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc |
| +++ b/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc |
| @@ -191,26 +191,37 @@ bool AppBannerInfoBarDelegateAndroid::AcceptWebApk( |
| return true; |
| } |
| - // Request install the WebAPK. |
| - install_state_ = INSTALLING; |
| - TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED); |
| - webapk::TrackInstallSource(webapk_install_source_); |
| - AppBannerSettingsHelper::RecordBannerInstallEvent( |
| - web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB); |
| + // Check whether the WebAPK has been installed. |
| + std::string installed_webapk_package_name = |
| + ShortcutHelper::QueryWebApkPackage(web_contents->GetLastCommittedURL()); |
| + if (installed_webapk_package_name.empty()) { |
| + // Request install the WebAPK. |
| + install_state_ = INSTALLING; |
| + TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED); |
| + webapk::TrackInstallSource(webapk_install_source_); |
| + AppBannerSettingsHelper::RecordBannerInstallEvent( |
| + web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB); |
| - Java_AppBannerInfoBarDelegateAndroid_setWebApkInstallingState( |
| - env, java_delegate_, true); |
| - UpdateInstallState(env, nullptr); |
| - WebApkInstaller::FinishCallback callback = |
| - base::Bind(&AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished, |
| - weak_ptr_factory_.GetWeakPtr()); |
| - ShortcutHelper::InstallWebApkWithSkBitmap(web_contents->GetBrowserContext(), |
| - *shortcut_info_, |
| - *icon_.get(), callback); |
| - SendBannerAccepted(web_contents, "web"); |
| + Java_AppBannerInfoBarDelegateAndroid_setWebApkInstallingState( |
| + env, java_delegate_, true); |
| + UpdateInstallState(env, nullptr); |
| + WebApkInstaller::FinishCallback callback = |
| + base::Bind(&AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished, |
| + weak_ptr_factory_.GetWeakPtr()); |
| + ShortcutHelper::InstallWebApkWithSkBitmap(web_contents->GetBrowserContext(), |
| + *shortcut_info_, |
| + *icon_.get(), callback); |
| + SendBannerAccepted(web_contents, "web"); |
| + |
| + // Prevent the infobar from disappearing, because the infobar will show |
| + // "Adding" during the installation process. |
| + return false; |
| + } |
| - // Prevent the infobar from disappearing, because the infobar will show |
| - // "Adding" during the installation process. |
| + // Bypass the installation process. |
|
dominickn
2016/09/30 23:32:24
If you keep this comment, make it more explicit, l
F
2016/10/03 14:13:44
Done.
|
| + TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED); |
| + weak_ptr_factory_.GetWeakPtr()->OnWebApkInstallFinished( |
|
dominickn
2016/09/30 23:32:24
Directly call OnWebApkInstallFinished(true, instal
F
2016/10/03 14:13:44
Done. Thanks!
|
| + true, installed_webapk_package_name); |
| return false; |
| } |