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

Side by Side 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 unified diff | Download patch
OLDNEW
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
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 bool relax_updates, 377 bool relax_updates,
378 const std::string& webapk_package_name) { 378 const std::string& webapk_package_name) {
379 if (!success) { 379 if (result != WebApkInstallResult::SUCCESS) {
380 OnWebApkInstallFailed(); 380 OnWebApkInstallFailed(result);
381 return; 381 return;
382 } 382 }
383 UpdateStateForInstalledWebAPK(webapk_package_name); 383 UpdateStateForInstalledWebAPK(webapk_package_name);
384 webapk::TrackInstallDuration(timer_->Elapsed()); 384 webapk::TrackInstallDuration(timer_->Elapsed());
385 timer_.reset(); 385 timer_.reset();
386 webapk::TrackInstallEvent(webapk::INSTALL_COMPLETED); 386 webapk::TrackInstallEvent(webapk::INSTALL_COMPLETED);
387 } 387 }
388 388
389 void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFailed() { 389 void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFailed(
390 WebApkInstallResult result) {
390 DVLOG(1) << "The WebAPK installation failed."; 391 DVLOG(1) << "The WebAPK installation failed.";
391 webapk::TrackInstallEvent(webapk::INSTALL_FAILED); 392 webapk::TrackInstallEvent(webapk::INSTALL_FAILED);
392 393
393 if (!infobar()) 394 if (!infobar())
394 return; 395 return;
395 396
396 content::WebContents* web_contents = 397 // If the install didn't definitely fail, we don't add a shortcut. This could
397 InfoBarService::WebContentsFromInfoBar(infobar()); 398 // happen if Play was busy with another install and this one is still queued
398 // Add webapp shortcut to the homescreen. 399 // (and hence might succeed in the future).
399 // TODO(pkotwicz): Only add webapp shortcut to the homescreen if 400 if (result == WebApkInstallResult::FAILURE) {
400 // WebAPK install did not timeout. If the WebAPK install timed out 401 content::WebContents* web_contents =
401 // it is possible that Google Play is taking a long time and will 402 InfoBarService::WebContentsFromInfoBar(infobar());
402 // eventually installs the WebAPK. 403 // Add webapp shortcut to the homescreen.
403 ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, *shortcut_info_, 404 ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, *shortcut_info_,
404 *icon_.get()); 405 *icon_.get());
406 }
405 407
406 infobar()->RemoveSelf(); 408 infobar()->RemoveSelf();
407 } 409 }
408 410
409 void AppBannerInfoBarDelegateAndroid::TrackWebApkInstallationDismissEvents( 411 void AppBannerInfoBarDelegateAndroid::TrackWebApkInstallationDismissEvents(
410 InstallState install_state) { 412 InstallState install_state) {
411 if (install_state == INSTALL_NOT_STARTED) { 413 if (install_state == INSTALL_NOT_STARTED) {
412 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_BEFORE_INSTALLATION); 414 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_BEFORE_INSTALLATION);
413 } else if (install_state == INSTALLING) { 415 } else if (install_state == INSTALLING) {
414 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_DURING_INSTALLATION); 416 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_DURING_INSTALLATION);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 484
483 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); 485 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK);
484 return true; 486 return true;
485 } 487 }
486 488
487 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { 489 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) {
488 return RegisterNativesImpl(env); 490 return RegisterNativesImpl(env);
489 } 491 }
490 492
491 } // namespace banners 493 } // namespace banners
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698