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/guid.h" | 9 #include "base/guid.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 360 // Prevent the infobar from disappearing, because the infobar will show | 360 // Prevent the infobar from disappearing, because the infobar will show |
| 361 // "Adding" during the installation process. | 361 // "Adding" during the installation process. |
| 362 return false; | 362 return false; |
| 363 } | 363 } |
| 364 | 364 |
| 365 bool AppBannerInfoBarDelegateAndroid::TriggeredFromBanner() const { | 365 bool AppBannerInfoBarDelegateAndroid::TriggeredFromBanner() const { |
| 366 return !is_webapk_ || webapk_install_source_ == webapk::INSTALL_SOURCE_BANNER; | 366 return !is_webapk_ || webapk_install_source_ == webapk::INSTALL_SOURCE_BANNER; |
| 367 } | 367 } |
| 368 | 368 |
| 369 void AppBannerInfoBarDelegateAndroid::SendBannerAccepted() { | 369 void AppBannerInfoBarDelegateAndroid::SendBannerAccepted() { |
| 370 if (weak_manager_ && TriggeredFromBanner()) { | 370 if (!weak_manager_) |
| 371 return; | |
| 372 | |
| 373 if (TriggeredFromBanner()) | |
| 371 weak_manager_->SendBannerAccepted(event_request_id_); | 374 weak_manager_->SendBannerAccepted(event_request_id_); |
| 372 // TODO(mgiuca): Send the appinstalled event for WebAPKs (but just removing | 375 |
| 373 // this check won't be sufficient). | 376 // Send the appinstalled event in all cases (whether triggered from a banner |
| 374 if (!is_webapk_) | 377 // or not). |
| 375 weak_manager_->OnInstall(); | 378 weak_manager_->OnInstall(); |
|
dominickn
2017/02/03 05:54:46
This doesn't work because weak_manager_ is nullptr
Matt Giuca
2017/04/07 06:41:34
Done.
| |
| 376 } | |
| 377 } | 379 } |
| 378 | 380 |
| 379 void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished( | 381 void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished( |
| 380 bool success, | 382 bool success, |
| 381 const std::string& webapk_package_name) { | 383 const std::string& webapk_package_name) { |
| 382 JNIEnv* env = base::android::AttachCurrentThread(); | 384 JNIEnv* env = base::android::AttachCurrentThread(); |
| 383 if (!success) { | 385 if (!success) { |
| 384 DVLOG(1) << "The WebAPK installation failed."; | 386 DVLOG(1) << "The WebAPK installation failed."; |
| 385 Java_AppBannerInfoBarDelegateAndroid_showWebApkInstallFailureToast(env); | 387 Java_AppBannerInfoBarDelegateAndroid_showWebApkInstallFailureToast(env); |
| 386 webapk::TrackInstallEvent(webapk::INSTALL_FAILED); | 388 webapk::TrackInstallEvent(webapk::INSTALL_FAILED); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 469 | 471 |
| 470 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); | 472 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); |
| 471 return true; | 473 return true; |
| 472 } | 474 } |
| 473 | 475 |
| 474 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { | 476 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { |
| 475 return RegisterNativesImpl(env); | 477 return RegisterNativesImpl(env); |
| 476 } | 478 } |
| 477 | 479 |
| 478 } // namespace banners | 480 } // namespace banners |
| OLD | NEW |