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

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

Issue 287653004: Schedule posttask to decide Uma optin option offering (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address comments Created 6 years, 7 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/ui/views/session_crashed_bubble_view.h ('k') | no next file » | 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 6fdd0a2bd455b5018d8e2023c09436bcf88e2a7a..66c539429e6a83c18185222366faada610ec2601 100644
--- a/chrome/browser/ui/views/session_crashed_bubble_view.cc
+++ b/chrome/browser/ui/views/session_crashed_bubble_view.cc
@@ -6,6 +6,7 @@
#include <vector>
+#include "base/bind.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
@@ -20,6 +21,7 @@
#include "chrome/common/url_constants.h"
#include "chrome/installer/util/google_update_settings.h"
#include "content/public/browser/browser_context.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/web_contents.h"
#include "grit/chromium_strings.h"
@@ -73,22 +75,39 @@ bool ShouldOfferMetricsReporting() {
// static
void SessionCrashedBubbleView::Show(Browser* browser) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+
if (browser->profile()->IsOffTheRecord())
return;
+ // Schedule a task to run ShouldOfferMetricsReporting() on FILE thread, since
+ // GoogleUpdateSettings::GetCollectStatsConsent() does IO. Then, call
+ // SessionCrashedBubbleView::ShowForReal with the result.
+ content::BrowserThread::PostTaskAndReplyWithResult(
+ content::BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(&ShouldOfferMetricsReporting),
+ base::Bind(&SessionCrashedBubbleView::ShowForReal, browser));
sky 2014/05/14 23:22:58 Won't you crash if browser is destroyed by the tim
yao 2014/05/15 21:56:14 Added the check to make sure browser is still live
+}
+
+// static
+void SessionCrashedBubbleView::ShowForReal(Browser* browser,
+ bool offer_uma_optin) {
views::View* anchor_view =
BrowserView::GetBrowserViewForBrowser(browser)->toolbar()->app_menu();
content::WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
SessionCrashedBubbleView* crash_bubble =
- new SessionCrashedBubbleView(anchor_view, browser, web_contents);
+ new SessionCrashedBubbleView(anchor_view, browser, web_contents,
+ offer_uma_optin);
views::BubbleDelegateView::CreateBubble(crash_bubble)->Show();
}
SessionCrashedBubbleView::SessionCrashedBubbleView(
views::View* anchor_view,
Browser* browser,
- content::WebContents* web_contents)
+ content::WebContents* web_contents,
+ bool offer_uma_optin)
: BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT),
content::WebContentsObserver(web_contents),
browser_(browser),
@@ -96,6 +115,7 @@ SessionCrashedBubbleView::SessionCrashedBubbleView(
restore_button_(NULL),
close_(NULL),
uma_option_(NULL),
+ offer_uma_optin_(offer_uma_optin),
started_navigation_(false) {
set_close_on_deactivate(false);
registrar_.Add(
@@ -193,7 +213,7 @@ void SessionCrashedBubbleView::Init() {
layout->AddPaddingRow(0, kMarginHeight);
// Metrics reporting option.
- if (ShouldOfferMetricsReporting())
+ if (offer_uma_optin_)
CreateUmaOptinView(layout);
set_color(kWhiteBackgroundColor);
« no previous file with comments | « chrome/browser/ui/views/session_crashed_bubble_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698