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

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 'start' into refactor_shortcut_helper3 Created 3 years, 9 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 04146414bc3dec3c6f1026d2b8645027a752762e..795a1b1cd0a5abea9c646ef4c6149ff501e22ae5 100644
--- a/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
+++ b/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
@@ -373,11 +373,11 @@ void AppBannerInfoBarDelegateAndroid::SendBannerAccepted() {
}
void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished(
- bool success,
+ WebApkInstallResult result,
bool relax_updates,
const std::string& webapk_package_name) {
- if (!success) {
- OnWebApkInstallFailed();
+ if (result != WebApkInstallResult::SUCCESS) {
+ OnWebApkInstallFailed(result);
return;
}
UpdateStateForInstalledWebAPK(webapk_package_name);
@@ -386,22 +386,24 @@ 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 the install didn't definitely fail, we don't add a shortcut. This could
+ // happen if Play was busy with another install and this one is still queued
+ // (and hence might succeed in the future).
+ if (result == WebApkInstallResult::FAILURE) {
+ content::WebContents* web_contents =
+ InfoBarService::WebContentsFromInfoBar(infobar());
+ // Add webapp shortcut to the homescreen.
+ ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, *shortcut_info_,
+ *icon_.get());
+ }
infobar()->RemoveSelf();
}

Powered by Google App Engine
This is Rietveld 408576698