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

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

Issue 929533002: [App banners] Add UMA metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@banner_cleanup
Patch Set: Fixing rebase Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/banners/app_banner_infobar_delegate.cc
diff --git a/chrome/browser/android/banners/app_banner_infobar_delegate.cc b/chrome/browser/android/banners/app_banner_infobar_delegate.cc
index 18f146f7c8688d8575398cecb799c1b36625fd11..789fecf17119b6fed599a0a5f29e0e47401b5a0f 100644
--- a/chrome/browser/android/banners/app_banner_infobar_delegate.cc
+++ b/chrome/browser/android/banners/app_banner_infobar_delegate.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/android/shortcut_helper.h"
#include "chrome/browser/android/shortcut_info.h"
#include "chrome/browser/android/tab_android.h"
+#include "chrome/browser/banners/app_banner_metrics.h"
#include "chrome/browser/banners/app_banner_settings_helper.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/ui/android/infobars/app_banner_infobar.h"
@@ -87,6 +88,7 @@ AppBannerInfoBarDelegate::AppBannerInfoBarDelegate(
}
AppBannerInfoBarDelegate::~AppBannerInfoBarDelegate() {
+ TrackDismissEvent(DISMISS_EVENT_DISMISSED);
JNIEnv* env = base::android::AttachCurrentThread();
Java_AppBannerInfoBarDelegate_destroy(env,
java_delegate_.obj());
@@ -111,6 +113,8 @@ void AppBannerInfoBarDelegate::InfoBarDismissed() {
if (!web_contents)
return;
+ TrackDismissEvent(DISMISS_EVENT_CLOSE_BUTTON);
+
if (!native_app_data_.is_null()) {
AppBannerSettingsHelper::RecordBannerEvent(
web_contents, web_contents->GetURL(),
@@ -129,21 +133,32 @@ void AppBannerInfoBarDelegate::InfoBarDismissed() {
bool AppBannerInfoBarDelegate::Accept() {
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
- if (!web_contents)
+ if (!web_contents) {
+ TrackDismissEvent(DISMISS_EVENT_ERROR);
return true;
+ }
if (!native_app_data_.is_null()) {
JNIEnv* env = base::android::AttachCurrentThread();
TabAndroid* tab = TabAndroid::FromWebContents(web_contents);
- if (tab == nullptr)
+ if (tab == nullptr) {
+ TrackDismissEvent(DISMISS_EVENT_ERROR);
return true;
+ }
- return Java_AppBannerInfoBarDelegate_installOrOpenNativeApp(
+ bool was_opened = Java_AppBannerInfoBarDelegate_installOrOpenNativeApp(
env,
java_delegate_.obj(),
tab->GetJavaObject().obj(),
native_app_data_.obj());
+
+ if (was_opened) {
+ TrackDismissEvent(DISMISS_EVENT_APP_OPEN);
+ } else {
+ TrackInstallEvent(INSTALL_EVENT_NATIVE_APP_INSTALL_TRIGGERED);
+ }
+ return was_opened;
} else if (!web_app_data_.IsEmpty()) {
AppBannerSettingsHelper::RecordBannerEvent(
web_contents, web_contents->GetURL(),
@@ -159,6 +174,8 @@ bool AppBannerInfoBarDelegate::Accept() {
info,
*app_icon_.get()),
true);
+
+ TrackInstallEvent(INSTALL_EVENT_WEB_APP_INSTALLED);
return true;
}
@@ -176,13 +193,17 @@ bool AppBannerInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
InfoBarService::WebContentsFromInfoBar(infobar());
TabAndroid* tab = web_contents ? TabAndroid::FromWebContents(web_contents)
: nullptr;
- if (tab == nullptr)
+ if (tab == nullptr) {
+ TrackDismissEvent(DISMISS_EVENT_ERROR);
return true;
+ }
Java_AppBannerInfoBarDelegate_showAppDetails(env,
java_delegate_.obj(),
tab->GetJavaObject().obj(),
native_app_data_.obj());
+
+ TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK);
return true;
}
@@ -205,6 +226,8 @@ void AppBannerInfoBarDelegate::OnInstallIntentReturned(
native_app_package_,
AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN,
AppBannerManager::GetCurrentTime());
+
+ TrackInstallEvent(INSTALL_EVENT_NATIVE_APP_INSTALL_STARTED);
}
UpdateInstallState(env, obj);
@@ -217,8 +240,10 @@ void AppBannerInfoBarDelegate::OnInstallFinished(JNIEnv* env,
return;
if (success) {
+ TrackInstallEvent(INSTALL_EVENT_NATIVE_APP_INSTALL_COMPLETED);
UpdateInstallState(env, obj);
} else if (infobar()->owner()) {
+ TrackDismissEvent(DISMISS_EVENT_INSTALL_TIMEOUT);
infobar()->owner()->RemoveInfoBar(infobar());
}
}

Powered by Google App Engine
This is Rietveld 408576698