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

Unified Diff: chrome/browser/ui/views/session_crashed_bubble_view.cc

Issue 341823005: Collects stats on how user interacts with the bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 6 years, 6 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 | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | ui/views/bubble/bubble_frame_view.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/session_crashed_bubble_view.cc
diff --git a/chrome/browser/ui/views/session_crashed_bubble_view.cc b/chrome/browser/ui/views/session_crashed_bubble_view.cc
index d1c9a5a731f8af100b2e5e5a87797b3e3ed85d51..1d67f667b6cc8d3bac6c64401c97e10ccc068b2b 100644
--- a/chrome/browser/ui/views/session_crashed_bubble_view.cc
+++ b/chrome/browser/ui/views/session_crashed_bubble_view.cc
@@ -10,6 +10,7 @@
#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/metrics/field_trial.h"
+#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
@@ -65,12 +66,30 @@ const SkColor kTextColor = SkColorSetRGB(102, 102, 102);
const char kEnableBubbleUIFinchName[] = "EnableSessionCrashedBubbleUI";
const char kEnableBubbleUIGroupEnabled[] = "Enabled";
+enum SessionCrashedBubbleHistogramValue {
+ SESSION_CRASHED_BUBBLE_SHOWN,
+ SESSION_CRASHED_BUBBLE_ERROR,
+ SESSION_CRASHED_BUBBLE_RESTORED,
+ SESSION_CRASHED_BUBBLE_ALREADY_UMA_OPTIN,
+ SESSION_CRASHED_BUBBLE_UMA_OPTIN,
+ SESSION_CRASHED_BUBBLE_HELP,
+ SESSION_CRASHED_BUBBLE_IGNORED,
+ SESSION_CRASHED_BUBBLE_MAX,
+};
+
+void RecordBubbleHistogramValue(SessionCrashedBubbleHistogramValue value) {
+ UMA_HISTOGRAM_ENUMERATION(
+ "SessionCrashed.Bubble", value, SESSION_CRASHED_BUBBLE_MAX);
+}
+
bool ShouldOfferMetricsReporting() {
// Stats collection only applies to Google Chrome builds.
#if defined(GOOGLE_CHROME_BUILD)
// Only show metrics reporting option if user didn't already consent to it.
- if (GoogleUpdateSettings::GetCollectStatsConsent())
+ if (GoogleUpdateSettings::GetCollectStatsConsent()) {
+ RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_ALREADY_UMA_OPTIN);
return false;
+ }
return g_browser_process->local_state()->FindPreference(
prefs::kMetricsReportingEnabled)->IsUserModifiable();
Alexei Svitkine (slow) 2014/07/02 15:07:26 Hmm, I just noticed that this is wrong. Since you'
yao 2014/07/07 17:47:45 CL on the way.
#else
@@ -90,6 +109,12 @@ bool IsBubbleUIEnabled() {
return group_name == kEnableBubbleUIGroupEnabled;
}
+// Will be passed in as a callback function to BubbleFrameView. Before the
+// bubble is closed (by the close button), collect the usage stats.
+void BubbleToBeClosed() {
+ RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_IGNORED);
+}
+
} // namespace
// A helper class that listens to browser removal event.
@@ -146,21 +171,30 @@ void SessionCrashedBubbleView::ShowForReal(
bool offer_uma_optin) {
Browser* browser = browser_observer->browser();
- if (!browser)
+ if (!browser) {
+ RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_ERROR);
return;
+ }
views::View* anchor_view =
BrowserView::GetBrowserViewForBrowser(browser)->toolbar()->app_menu();
content::WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
- if (!web_contents)
+ if (!web_contents) {
+ RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_ERROR);
return;
+ }
SessionCrashedBubbleView* crash_bubble =
new SessionCrashedBubbleView(anchor_view, browser, web_contents,
offer_uma_optin);
views::BubbleDelegateView::CreateBubble(crash_bubble)->Show();
+ views::BubbleFrameView* frame_view = crash_bubble->GetBubbleFrameView();
+ if (frame_view) {
+ frame_view->SetCloseCallback(base::Bind(&BubbleToBeClosed));
+ }
+ RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_SHOWN);
}
SessionCrashedBubbleView::SessionCrashedBubbleView(
@@ -324,6 +358,7 @@ void SessionCrashedBubbleView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
DCHECK_EQ(sender, restore_button_);
RestorePreviousSession(sender);
+ RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_RESTORED);
}
void SessionCrashedBubbleView::StyledLabelLinkClicked(const gfx::Range& range,
@@ -334,6 +369,7 @@ void SessionCrashedBubbleView::StyledLabelLinkClicked(const gfx::Range& range,
NEW_FOREGROUND_TAB,
content::PAGE_TRANSITION_LINK,
false));
+ RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_HELP);
}
void SessionCrashedBubbleView::DidStartNavigationToPendingEntry(
@@ -347,8 +383,10 @@ void SessionCrashedBubbleView::DidFinishLoad(
const GURL& validated_url,
bool is_main_frame,
content::RenderViewHost* render_view_host) {
- if (started_navigation_)
+ if (started_navigation_) {
+ RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_IGNORED);
CloseBubble();
+ }
}
void SessionCrashedBubbleView::WasShown() {
@@ -363,14 +401,18 @@ void SessionCrashedBubbleView::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
- if (type == chrome::NOTIFICATION_TAB_CLOSING)
+ if (type == chrome::NOTIFICATION_TAB_CLOSING) {
+ RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_IGNORED);
CloseBubble();
+ }
}
void SessionCrashedBubbleView::TabDetachedAt(content::WebContents* contents,
int index) {
- if (web_contents_ == contents)
+ if (web_contents_ == contents) {
+ RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_IGNORED);
CloseBubble();
+ }
}
void SessionCrashedBubbleView::RestorePreviousSession(views::Button* sender) {
@@ -384,6 +426,7 @@ void SessionCrashedBubbleView::RestorePreviousSession(views::Button* sender) {
OptionsUtil::ResolveMetricsReportingEnabled(true);
g_browser_process->local_state()->SetBoolean(
prefs::kMetricsReportingEnabled, true);
+ RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_UMA_OPTIN);
}
CloseBubble();
}
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | ui/views/bubble/bubble_frame_view.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698