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

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

Issue 2733543002: [Android:WebAPK] Don't add webapp to homescreen if WebAPK install times out part 1/3 (Closed)
Patch Set: Merge branch 'refactor_shortcut_helper29' into refactor_shortcut_helper3 Created 3 years, 10 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 2fa5463c2f4dcd606f3991f9f93cad2b6a4dfe84..c79e77f0459fec7e09e8a1293de6e68194a7d447 100644
--- a/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
+++ b/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
@@ -373,10 +373,10 @@ void AppBannerInfoBarDelegateAndroid::SendBannerAccepted() {
}
void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished(
- bool success,
+ WebApkInstallResult result,
const std::string& webapk_package_name) {
- if (!success) {
- OnWebApkInstallFailed();
+ if (result != WebApkInstallResult::INSTALLED) {
+ OnWebApkInstallFailed(result);
return;
}
UpdateStateForInstalledWebAPK(webapk_package_name);
@@ -385,22 +385,28 @@ void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished(
webapk::TrackInstallEvent(webapk::INSTALL_COMPLETED);
}
-void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFailed() {
+void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFailed(
+ WebApkInstallResult result) {
DVLOG(1) << "The WebAPK installation failed.";
webapk::TrackInstallEvent(webapk::INSTALL_FAILED);
if (!infobar())
return;
- content::WebContents* web_contents =
- InfoBarService::WebContentsFromInfoBar(infobar());
- // 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 (result == WebApkInstallResult::INSTALL_FAILED) {
+ content::WebContents* web_contents =
+ InfoBarService::WebContentsFromInfoBar(infobar());
+ // Add webapp shortcut to the homescreen.
+ ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, *shortcut_info_,
+ *icon_.get());
+ } else {
+ // The WebAPK install timed out. Don't add shortcut because the install
+ // might still succeed (e.g. the install timed out because Google Play was
+ // busy with another install). It is confusing for a user to have homescreen
+ // shortcuts for both a WebAPK and a webapp for the same page URL.
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_AppBannerInfoBarDelegateAndroid_showWebApkInstallFailureToast(env);
dominickn 2017/03/05 23:52:39 If the WebAPK install still might succeed, why sho
pkotwicz 2017/03/12 21:11:48 It would also be confusing if the install fails an
dominickn 2017/03/13 03:22:23 We should probably check in with UI/PM on this. Gi
pkotwicz 2017/03/14 22:38:57 We discussed this at the weekly meeting and decide
+ }
infobar()->RemoveSelf();
}

Powered by Google App Engine
This is Rietveld 408576698