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

Unified Diff: chrome/browser/previews/previews_infobar_delegate.cc

Issue 2258283002: UMA for previews infobar and Lo-Fi context menu items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@newLoFiInfoBarRemoveAndroid
Patch Set: rebase Created 4 years, 3 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
« no previous file with comments | « chrome/browser/previews/previews_infobar_delegate.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/previews/previews_infobar_delegate.cc
diff --git a/chrome/browser/previews/previews_infobar_delegate.cc b/chrome/browser/previews/previews_infobar_delegate.cc
index adb4ed8b89ffbf6d88cfcb77a7298c9714734b73..2390e8cada6fa22b2636d3bc81d7eb3f13263837 100644
--- a/chrome/browser/previews/previews_infobar_delegate.cc
+++ b/chrome/browser/previews/previews_infobar_delegate.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/previews/previews_infobar_delegate.h"
+#include "base/metrics/histogram_macros.h"
#include "chrome/browser/android/android_theme_resources.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
@@ -15,6 +16,46 @@
#include "content/public/browser/web_contents.h"
#include "ui/base/l10n/l10n_util.h"
+namespace {
+
+// Key of the UMA Previews.InfoBarAction.LoFi histogram.
+const char kUMAPreviewsInfoBarActionLoFi[] = "Previews.InfoBarAction.LoFi";
+
+// Key of the UMA Previews.InfoBarAction.Offline histogram.
+const char kUMAPreviewsInfoBarActionOffline[] =
+ "Previews.InfoBarAction.Offline";
+
+// Key of the UMA Previews.InfoBarAction.LitePage histogram.
+const char kUMAPreviewsInfoBarActionLitePage[] =
+ "Previews.InfoBarAction.LitePage";
+
+// Actions on the previews infobar. This enum must remain synchronized with the
+// enum of the same name in metrics/histograms/histograms.xml.
+enum PreviewsInfoBarAction {
+ INFOBAR_SHOWN = 0,
+ INFOBAR_LOAD_ORIGINAL_CLICKED = 1,
+ INFOBAR_DISMISSED_BY_USER = 2,
+ INFOBAR_DISMISSED_BY_NAVIGATION = 3,
+ INFOBAR_INDEX_BOUNDARY
+};
+
+void RecordPreviewsInfoBarAction(
+ PreviewsInfoBarDelegate::PreviewsInfoBarType infobar_type,
+ PreviewsInfoBarAction action) {
+ if (infobar_type == PreviewsInfoBarDelegate::LOFI) {
+ UMA_HISTOGRAM_ENUMERATION(kUMAPreviewsInfoBarActionLoFi, action,
+ INFOBAR_INDEX_BOUNDARY);
+ } else if (infobar_type == PreviewsInfoBarDelegate::LITE_PAGE) {
+ UMA_HISTOGRAM_ENUMERATION(kUMAPreviewsInfoBarActionLitePage, action,
+ INFOBAR_INDEX_BOUNDARY);
+ } else if (infobar_type == PreviewsInfoBarDelegate::OFFLINE) {
+ UMA_HISTOGRAM_ENUMERATION(kUMAPreviewsInfoBarActionOffline, action,
+ INFOBAR_INDEX_BOUNDARY);
+ }
+}
+
+} // namespace
+
PreviewsInfoBarDelegate::~PreviewsInfoBarDelegate() {}
// static
@@ -40,6 +81,7 @@ void PreviewsInfoBarDelegate::Create(content::WebContents* web_contents,
data_reduction_proxy_settings->IncrementLoFiUIShown();
}
+ RecordPreviewsInfoBarAction(infobar_type, INFOBAR_SHOWN);
infobar_tab_helper->set_displayed_preview_infobar(true);
}
@@ -64,10 +106,14 @@ int PreviewsInfoBarDelegate::GetIconId() const {
bool PreviewsInfoBarDelegate::ShouldExpire(
const NavigationDetails& details) const {
- // TODO(megjablon): Record UMA data.
+ RecordPreviewsInfoBarAction(infobar_type_, INFOBAR_DISMISSED_BY_NAVIGATION);
return InfoBarDelegate::ShouldExpire(details);
}
+void PreviewsInfoBarDelegate::InfoBarDismissed() {
+ RecordPreviewsInfoBarAction(infobar_type_, INFOBAR_DISMISSED_BY_USER);
+}
+
base::string16 PreviewsInfoBarDelegate::GetMessageText() const {
return l10n_util::GetStringUTF16((infobar_type_ == OFFLINE)
? IDS_PREVIEWS_INFOBAR_FASTER_PAGE_TITLE
@@ -83,7 +129,8 @@ base::string16 PreviewsInfoBarDelegate::GetLinkText() const {
}
bool PreviewsInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
- // TODO(megjablon): Record UMA data.
+ RecordPreviewsInfoBarAction(infobar_type_, INFOBAR_LOAD_ORIGINAL_CLICKED);
+
if (infobar_type_ == LITE_PAGE || infobar_type_ == LOFI) {
auto* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
« no previous file with comments | « chrome/browser/previews/previews_infobar_delegate.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698