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

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

Issue 2644663003: Offer to open the startup pages after a crash. (Closed)
Patch Set: CR Comments Created 3 years, 11 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/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 0954fcaaa20a3f54add2878984b90b2395249829..1d69eb72288439fc937beb20ef2821251f070c8c 100644
--- a/chrome/browser/ui/views/session_crashed_bubble_view.cc
+++ b/chrome/browser/ui/views/session_crashed_bubble_view.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/metrics/metrics_reporting_state.h"
+#include "chrome/browser/prefs/session_startup_pref.h"
#include "chrome/browser/sessions/session_restore.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_list_observer.h"
@@ -68,6 +69,7 @@ enum SessionCrashedBubbleHistogramValue {
SESSION_CRASHED_BUBBLE_HELP,
SESSION_CRASHED_BUBBLE_IGNORED,
SESSION_CRASHED_BUBBLE_OPTIN_BAR_SHOWN,
+ SESSION_CRASHED_BUBBLE_STARTUP_PAGES,
SESSION_CRASHED_BUBBLE_MAX,
};
@@ -202,7 +204,8 @@ SessionCrashedBubbleView::SessionCrashedBubbleView(
uma_option_(NULL),
offer_uma_optin_(offer_uma_optin),
first_navigation_ignored_(false),
- restored_(false) {
+ restored_(false),
+ startup_pages_(false) {
set_close_on_deactivate(false);
registrar_.Add(
this,
@@ -229,7 +232,7 @@ bool SessionCrashedBubbleView::ShouldShowCloseButton() const {
}
void SessionCrashedBubbleView::OnWidgetDestroying(views::Widget* widget) {
- if (!restored_)
+ if (!restored_ && !startup_pages_)
RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_IGNORED);
BubbleDialogDelegateView::OnWidgetDestroying(widget);
}
@@ -310,6 +313,11 @@ bool SessionCrashedBubbleView::Accept() {
return true;
}
+bool SessionCrashedBubbleView::Cancel() {
+ OpenStartupPages();
+ return true;
+}
+
bool SessionCrashedBubbleView::Close() {
// Don't default to Accept() just because that's the only choice. Instead, do
// nothing.
@@ -317,12 +325,23 @@ bool SessionCrashedBubbleView::Close() {
}
int SessionCrashedBubbleView::GetDialogButtons() const {
- return ui::DIALOG_BUTTON_OK;
+ int buttons = ui::DIALOG_BUTTON_OK;
+ if (SessionStartupPref::GetStartupPref(browser_->profile()).type ==
+ SessionStartupPref::URLS) {
+ buttons |= ui::DIALOG_BUTTON_CANCEL;
+ }
+ return buttons;
}
base::string16 SessionCrashedBubbleView::GetDialogButtonLabel(
ui::DialogButton button) const {
- return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON);
+ if (button == ui::DIALOG_BUTTON_OK)
+ return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON);
+ DCHECK(button == ui::DIALOG_BUTTON_CANCEL);
+ DCHECK(SessionStartupPref::GetStartupPref(browser_->profile()).type ==
+ SessionStartupPref::URLS);
+ return l10n_util::GetStringUTF16(
+ IDS_SESSION_CRASHED_VIEW_STARTUP_PAGES_BUTTON);
}
void SessionCrashedBubbleView::StyledLabelLinkClicked(views::StyledLabel* label,
@@ -379,13 +398,26 @@ void SessionCrashedBubbleView::RestorePreviousSession() {
RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_RESTORED);
restored_ = true;
+ MaybeEnableUMA();
+ CloseBubble();
+}
+
+void SessionCrashedBubbleView::OpenStartupPages() {
+ SessionRestore::OpenStartupPagesAfterCrash(browser_);
+ RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_STARTUP_PAGES);
+ startup_pages_ = true;
+
+ MaybeEnableUMA();
+ CloseBubble();
+}
+
+void SessionCrashedBubbleView::MaybeEnableUMA() {
// Record user's choice for opt-in in to UMA.
// There's no opt-out choice in the crash restore bubble.
if (uma_option_ && uma_option_->checked()) {
ChangeMetricsReportingState(true);
RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_UMA_OPTIN);
}
- CloseBubble();
}
void SessionCrashedBubbleView::CloseBubble() {

Powered by Google App Engine
This is Rietveld 408576698