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

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: Fix comment. Created 6 years, 5 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') | no next file with comments »
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 0b12796e6690b4ba948149c407898b7b0335b26b..b8a09683d94f4d4c7ee3afd0281f4fe6293032d2 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,6 +66,22 @@ 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,
jwd 2014/07/09 15:37:52 Is this being used anywhere anymore?
yao 2014/07/09 15:47:03 Done.
+ 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);
+}
+
// Whether or not the bubble UI should be used.
bool IsBubbleUIEnabled() {
const base::CommandLine& command_line = *CommandLine::ForCurrentProcess();
@@ -77,6 +94,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.
@@ -118,8 +141,8 @@ void SessionCrashedBubbleView::Show(Browser* browser) {
// Stats collection only applies to Google Chrome builds.
#if defined(GOOGLE_CHROME_BUILD)
- // Schedule a task to run ShouldOfferMetricsReporting() on FILE thread, since
- // GoogleUpdateSettings::GetCollectStatsConsent() does IO. Then, call
+ // Schedule a task to run GoogleUpdateSettings::GetCollectStatsConsent() on
+ // FILE thread, since it does IO. Then, call
// SessionCrashedBubbleView::ShowForReal with the result.
content::BrowserThread::PostTaskAndReplyWithResult(
content::BrowserThread::FILE,
@@ -149,21 +172,30 @@ void SessionCrashedBubbleView::ShowForReal(
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->set_before_close_callback(base::Bind(&BubbleToBeClosed));
+ }
+ RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_SHOWN);
}
SessionCrashedBubbleView::SessionCrashedBubbleView(
@@ -327,6 +359,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,
@@ -337,6 +370,7 @@ void SessionCrashedBubbleView::StyledLabelLinkClicked(const gfx::Range& range,
NEW_FOREGROUND_TAB,
content::PAGE_TRANSITION_LINK,
false));
+ RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_HELP);
}
void SessionCrashedBubbleView::DidStartNavigationToPendingEntry(
@@ -350,8 +384,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() {
@@ -366,14 +402,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) {
@@ -387,6 +427,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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698