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

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

Issue 2721203004: Add webapp homescreen shortcut when WebAPK install fails (Closed)
Patch Set: Merge branch 'refactor_shortcut_helper2' into launch_webapp 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
« no previous file with comments | « chrome/browser/android/banners/app_banner_infobar_delegate_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c5d1af9d35d8297f6352ba31333a2936f8ef05e8..238a5feb5007486bb748a0ef0584e88d5ca41f8d 100644
--- a/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
+++ b/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
@@ -375,22 +375,36 @@ void AppBannerInfoBarDelegateAndroid::SendBannerAccepted() {
void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished(
bool success,
const std::string& webapk_package_name) {
- JNIEnv* env = base::android::AttachCurrentThread();
if (!success) {
- DVLOG(1) << "The WebAPK installation failed.";
- Java_AppBannerInfoBarDelegateAndroid_showWebApkInstallFailureToast(env);
- webapk::TrackInstallEvent(webapk::INSTALL_FAILED);
- if (infobar())
- infobar()->RemoveSelf();
+ OnWebApkInstallFailed();
return;
}
-
UpdateStateForInstalledWebAPK(webapk_package_name);
webapk::TrackInstallDuration(timer_->Elapsed());
timer_.reset();
webapk::TrackInstallEvent(webapk::INSTALL_COMPLETED);
}
+void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFailed() {
+ 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());
+
+ infobar()->RemoveSelf();
+}
+
void AppBannerInfoBarDelegateAndroid::TrackWebApkInstallationDismissEvents(
InstallState install_state) {
if (install_state == INSTALL_NOT_STARTED) {
« no previous file with comments | « chrome/browser/android/banners/app_banner_infobar_delegate_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698