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

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: 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 36a65e3cdc4cce17f59af8862fd119465b0805fa..1ce9874a5b97b8d4416ec86cba3494bda2eb1656 100644
--- a/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
+++ b/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
@@ -38,6 +38,8 @@ using base::android::ConvertUTF16ToJavaString;
using base::android::JavaParamRef;
using base::android::ScopedJavaLocalRef;
+// TODO(zpeng): Reorganize control flow to allow itemized metrics.
dominickn 2016/09/28 02:10:25 Nit: don't have a TODO without a crbug link.
F 2016/09/30 18:02:01 Done. Thanks for the information!
+
namespace {
bool IsInfoEmpty(const std::unique_ptr<ShortcutInfo>& info) {
@@ -194,26 +196,37 @@ bool AppBannerInfoBarDelegateAndroid::AcceptWebApk(
return true;
}
- // Request install the WebAPK.
- install_state_ = INSTALLING;
- TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED);
- 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);
+ 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.
+ return false;
+ } else {
dominickn 2016/09/28 02:10:25 Nit: remove the else clause (no else after return)
F 2016/09/30 18:02:01 Done. Thanks for the information!
+ // Bypass the installation process.
+ TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED);
pkotwicz 2016/09/29 14:18:54 Shouldn't you log: webapk::TrackUserAction(webapk:
F 2016/09/30 18:02:01 Resolved in offline discussion. Filed new issue ht
+ weak_ptr_factory_.GetWeakPtr()->OnWebApkInstallFinished(
+ true, installed_webapk_package_name);
pkotwicz 2016/09/29 14:18:54 Calling AppBannerInfoBarDelegateAndroid::OnWebApkI
F 2016/09/30 18:02:01 Resolved in offline discussion. See above.
+ return false;
+ }
}
AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid(

Powered by Google App Engine
This is Rietveld 408576698