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

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 (result == WebApkInstallResult::FAILURE) {
397 InfoBarService::WebContentsFromInfoBar(infobar()); 398 content::WebContents* web_contents =
398 // Add webapp shortcut to the homescreen. 399 InfoBarService::WebContentsFromInfoBar(infobar());
399 // TODO(pkotwicz): Only add webapp shortcut to the homescreen if 400 // Add webapp shortcut to the homescreen.
400 // WebAPK install did not timeout. If the WebAPK install timed out 401 ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, *shortcut_info_,
401 // it is possible that Google Play is taking a long time and will 402 *icon_.get());
402 // eventually installs the WebAPK. 403 }
403 ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, *shortcut_info_, 404 // Else: the WebAPK install timed out. Don't add shortcut because the install
dominickn 2017/03/14 23:25:19 This comment is a bit weirdly placed now. Can you
pkotwicz 2017/03/14 23:43:29 Done.
404 *icon_.get()); 405 // might still succeed (e.g. the install timed out because Google Play was
406 // busy with another install). It is confusing for a user to have homescreen
407 // shortcuts for both a WebAPK and a webapp for the same page URL.
405 408
406 infobar()->RemoveSelf(); 409 infobar()->RemoveSelf();
407 } 410 }
408 411
409 void AppBannerInfoBarDelegateAndroid::TrackWebApkInstallationDismissEvents( 412 void AppBannerInfoBarDelegateAndroid::TrackWebApkInstallationDismissEvents(
410 InstallState install_state) { 413 InstallState install_state) {
411 if (install_state == INSTALL_NOT_STARTED) { 414 if (install_state == INSTALL_NOT_STARTED) {
412 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_BEFORE_INSTALLATION); 415 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_BEFORE_INSTALLATION);
413 } else if (install_state == INSTALLING) { 416 } else if (install_state == INSTALLING) {
414 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_DURING_INSTALLATION); 417 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_DURING_INSTALLATION);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 485
483 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); 486 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK);
484 return true; 487 return true;
485 } 488 }
486 489
487 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { 490 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) {
488 return RegisterNativesImpl(env); 491 return RegisterNativesImpl(env);
489 } 492 }
490 493
491 } // namespace banners 494 } // namespace banners
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698