Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1636)

Unified Diff: chrome/browser/android/banners/app_banner_infobar_delegate_android.cc

Issue 2363183002: Skip installation process if WebAPK is already installed. (Closed)
Patch Set: Addressing comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java ('k') | chrome/browser/android/shortcut_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698