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..a42484fb8d4db0ff0a5209d5a031302f937b13bc 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,36 @@ 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 since WebAPK is already installed. |
+ TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED); |
+ OnWebApkInstallFinished(true, installed_webapk_package_name); |
return false; |
} |