Chromium Code Reviews| 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..72b627ac29b3c104cd39a583dc9479be004e30f4 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,22 @@ 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(SessionStartupPref::GetStartupPref(browser_->profile()).type == |
|
Georges Khalil
2017/01/24 17:18:29
nit: Not sure if it's worth it, but also a DCHECK(
MAD
2017/01/24 18:24:18
Done.
|
| + SessionStartupPref::URLS); |
| + return l10n_util::GetStringUTF16( |
| + IDS_SESSION_CRASHED_VIEW_STARTUP_PAGES_BUTTON); |
| } |
| void SessionCrashedBubbleView::StyledLabelLinkClicked(views::StyledLabel* label, |
| @@ -379,13 +397,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() { |