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

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

Issue 2473243002: Ensure WebAPKs installed from the menu do not pollute banner statistics. (Closed)
Patch Set: Address nit Created 4 years, 1 month 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 462392375f785e004ca991ff1226f55d891e3002..75bff381c39d034184d915cd3a4666cc2dd37f4b 100644
--- a/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
+++ b/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
@@ -114,13 +114,15 @@ AppBannerInfoBarDelegateAndroid::~AppBannerInfoBarDelegateAndroid() {
if (!native_app_data_.is_null()) {
TrackUserResponse(USER_RESPONSE_NATIVE_APP_IGNORED);
} else {
- TrackUserResponse(USER_RESPONSE_WEB_APP_IGNORED);
+ if (TriggeredFromBanner())
+ TrackUserResponse(USER_RESPONSE_WEB_APP_IGNORED);
if (is_webapk_)
webapk::TrackInstallEvent(webapk::INFOBAR_IGNORED);
}
}
- TrackDismissEvent(DISMISS_EVENT_DISMISSED);
+ if (TriggeredFromBanner())
+ TrackDismissEvent(DISMISS_EVENT_DISMISSED);
JNIEnv* env = base::android::AttachCurrentThread();
Java_AppBannerInfoBarDelegateAndroid_destroy(env, java_delegate_);
java_delegate_.Reset();
@@ -184,7 +186,8 @@ bool AppBannerInfoBarDelegateAndroid::Accept() {
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
if (!web_contents) {
- TrackDismissEvent(DISMISS_EVENT_ERROR);
+ if (TriggeredFromBanner())
+ TrackDismissEvent(DISMISS_EVENT_ERROR);
return true;
}
@@ -325,10 +328,13 @@ bool AppBannerInfoBarDelegateAndroid::AcceptWebApk(
// If the WebAPK is not installed and the "Add to Home Screen" button is
// clicked, install the WebAPK.
install_state_ = INSTALLING;
- TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED);
webapk::TrackInstallSource(webapk_install_source_);
- AppBannerSettingsHelper::RecordBannerInstallEvent(
- web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB);
+
+ if (TriggeredFromBanner()) {
+ TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED);
+ AppBannerSettingsHelper::RecordBannerInstallEvent(
+ web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB);
+ }
Java_AppBannerInfoBarDelegateAndroid_setWebApkInstallingState(
env, java_delegate_, true);
@@ -346,8 +352,12 @@ bool AppBannerInfoBarDelegateAndroid::AcceptWebApk(
return false;
}
+bool AppBannerInfoBarDelegateAndroid::TriggeredFromBanner() const {
+ return !is_webapk_ || webapk_install_source_ == webapk::INSTALL_SOURCE_BANNER;
+}
+
void AppBannerInfoBarDelegateAndroid::SendBannerAccepted() {
- if (weak_manager_)
+ if (weak_manager_ && TriggeredFromBanner())
weak_manager_->SendBannerAccepted(event_request_id_);
}
@@ -399,15 +409,18 @@ void AppBannerInfoBarDelegateAndroid::InfoBarDismissed() {
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
- if (weak_manager_)
+ if (weak_manager_ && TriggeredFromBanner())
weak_manager_->SendBannerDismissed(event_request_id_);
if (native_app_data_.is_null()) {
if (is_webapk_)
TrackWebApkInstallationDismissEvents(install_state_);
- TrackUserResponse(USER_RESPONSE_WEB_APP_DISMISSED);
- AppBannerSettingsHelper::RecordBannerDismissEvent(
- web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB);
+ if (TriggeredFromBanner()) {
+ TrackUserResponse(USER_RESPONSE_WEB_APP_DISMISSED);
+ AppBannerSettingsHelper::RecordBannerDismissEvent(
+ web_contents, shortcut_info_->url.spec(),
+ AppBannerSettingsHelper::WEB);
+ }
} else {
TrackUserResponse(USER_RESPONSE_NATIVE_APP_DISMISSED);
AppBannerSettingsHelper::RecordBannerDismissEvent(
« 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