Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h" | 5 #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 366 if (weak_manager_ && TriggeredFromBanner()) { | 366 if (weak_manager_ && TriggeredFromBanner()) { |
| 367 weak_manager_->SendBannerAccepted(event_request_id_); | 367 weak_manager_->SendBannerAccepted(event_request_id_); |
| 368 // TODO(mgiuca): Send the appinstalled event for WebAPKs (but just removing | 368 // TODO(mgiuca): Send the appinstalled event for WebAPKs (but just removing |
| 369 // this check won't be sufficient). | 369 // this check won't be sufficient). |
| 370 if (!is_webapk_) | 370 if (!is_webapk_) |
| 371 weak_manager_->OnInstall(); | 371 weak_manager_->OnInstall(); |
| 372 } | 372 } |
| 373 } | 373 } |
| 374 | 374 |
| 375 void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished( | 375 void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished( |
| 376 bool success, | 376 WebApkInstallResult result, |
| 377 const std::string& webapk_package_name) { | 377 const std::string& webapk_package_name) { |
| 378 if (!success) { | 378 if (result != WebApkInstallResult::INSTALLED) { |
| 379 OnWebApkInstallFailed(); | 379 OnWebApkInstallFailed(result); |
| 380 return; | 380 return; |
| 381 } | 381 } |
| 382 UpdateStateForInstalledWebAPK(webapk_package_name); | 382 UpdateStateForInstalledWebAPK(webapk_package_name); |
| 383 webapk::TrackInstallDuration(timer_->Elapsed()); | 383 webapk::TrackInstallDuration(timer_->Elapsed()); |
| 384 timer_.reset(); | 384 timer_.reset(); |
| 385 webapk::TrackInstallEvent(webapk::INSTALL_COMPLETED); | 385 webapk::TrackInstallEvent(webapk::INSTALL_COMPLETED); |
| 386 } | 386 } |
| 387 | 387 |
| 388 void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFailed() { | 388 void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFailed( |
| 389 WebApkInstallResult result) { | |
| 389 DVLOG(1) << "The WebAPK installation failed."; | 390 DVLOG(1) << "The WebAPK installation failed."; |
| 390 webapk::TrackInstallEvent(webapk::INSTALL_FAILED); | 391 webapk::TrackInstallEvent(webapk::INSTALL_FAILED); |
| 391 | 392 |
| 392 if (!infobar()) | 393 if (!infobar()) |
| 393 return; | 394 return; |
| 394 | 395 |
| 395 content::WebContents* web_contents = | 396 if (result == WebApkInstallResult::INSTALL_FAILED) { |
| 396 InfoBarService::WebContentsFromInfoBar(infobar()); | 397 content::WebContents* web_contents = |
| 397 // Add webapp shortcut to the homescreen. | 398 InfoBarService::WebContentsFromInfoBar(infobar()); |
| 398 // TODO(pkotwicz): Only add webapp shortcut to the homescreen if | 399 // Add webapp shortcut to the homescreen. |
| 399 // WebAPK install did not timeout. If the WebAPK install timed out | 400 ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, *shortcut_info_, |
| 400 // it is possible that Google Play is taking a long time and will | 401 *icon_.get()); |
| 401 // eventually installs the WebAPK. | 402 } else { |
| 402 ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, *shortcut_info_, | 403 // The WebAPK install timed out. Don't add shortcut because the install |
| 403 *icon_.get()); | 404 // might still succeed (e.g. the install timed out because Google Play was |
| 405 // busy with another install). It is confusing for a user to have homescreen | |
| 406 // shortcuts for both a WebAPK and a webapp for the same page URL. | |
| 407 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 408 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
| |
| 409 } | |
| 404 | 410 |
| 405 infobar()->RemoveSelf(); | 411 infobar()->RemoveSelf(); |
| 406 } | 412 } |
| 407 | 413 |
| 408 void AppBannerInfoBarDelegateAndroid::TrackWebApkInstallationDismissEvents( | 414 void AppBannerInfoBarDelegateAndroid::TrackWebApkInstallationDismissEvents( |
| 409 InstallState install_state) { | 415 InstallState install_state) { |
| 410 if (install_state == INSTALL_NOT_STARTED) { | 416 if (install_state == INSTALL_NOT_STARTED) { |
| 411 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_BEFORE_INSTALLATION); | 417 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_BEFORE_INSTALLATION); |
| 412 } else if (install_state == INSTALLING) { | 418 } else if (install_state == INSTALLING) { |
| 413 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_DURING_INSTALLATION); | 419 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_DURING_INSTALLATION); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 481 | 487 |
| 482 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); | 488 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); |
| 483 return true; | 489 return true; |
| 484 } | 490 } |
| 485 | 491 |
| 486 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { | 492 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { |
| 487 return RegisterNativesImpl(env); | 493 return RegisterNativesImpl(env); |
| 488 } | 494 } |
| 489 | 495 |
| 490 } // namespace banners | 496 } // namespace banners |
| OLD | NEW |