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

Side by Side Diff: chrome/browser/ui/views/critical_notification_bubble_view.cc

Issue 10409022: Move application lifetime functionality off BrowserList. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/critical_notification_bubble_view.h" 5 #include "chrome/browser/ui/views/critical_notification_bubble_view.h"
6 6
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/lifetime/application_lifetime.h"
10 #include "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/ui/browser_list.h"
12 #include "chrome/browser/upgrade_detector.h" 12 #include "chrome/browser/upgrade_detector.h"
13 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
14 #include "content/public/browser/user_metrics.h" 14 #include "content/public/browser/user_metrics.h"
15 #include "grit/chromium_strings.h" 15 #include "grit/chromium_strings.h"
16 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
17 #include "grit/locale_settings.h" 17 #include "grit/locale_settings.h"
18 #include "grit/theme_resources.h" 18 #include "grit/theme_resources.h"
19 #include "ui/base/accelerators/accelerator.h" 19 #include "ui/base/accelerators/accelerator.h"
20 #include "ui/base/accessibility/accessible_view_state.h" 20 #include "ui/base/accessibility/accessible_view_state.h"
21 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 90 }
91 91
92 int seconds = GetRemainingTime(); 92 int seconds = GetRemainingTime();
93 if (seconds <= 0) { 93 if (seconds <= 0) {
94 // Time's up! 94 // Time's up!
95 upgrade_detector->acknowledge_critical_update(); 95 upgrade_detector->acknowledge_critical_update();
96 96
97 content::RecordAction( 97 content::RecordAction(
98 UserMetricsAction("CriticalNotification_AutoRestart")); 98 UserMetricsAction("CriticalNotification_AutoRestart"));
99 refresh_timer_.Stop(); 99 refresh_timer_.Stop();
100 BrowserList::AttemptRestart(); 100 browser::AttemptRestart();
101 } 101 }
102 102
103 // Update the counter. It may seem counter-intuitive to update the message 103 // Update the counter. It may seem counter-intuitive to update the message
104 // after we attempt restart, but remember that shutdown may be aborted by 104 // after we attempt restart, but remember that shutdown may be aborted by
105 // an onbeforeunload handler, leaving the bubble up when the browser should 105 // an onbeforeunload handler, leaving the bubble up when the browser should
106 // have restarted (giving the user another chance). 106 // have restarted (giving the user another chance).
107 UpdateBubbleHeadline(seconds); 107 UpdateBubbleHeadline(seconds);
108 SchedulePaint(); 108 SchedulePaint();
109 } 109 }
110 110
111 void CriticalNotificationBubbleView::ButtonPressed( 111 void CriticalNotificationBubbleView::ButtonPressed(
112 views::Button* sender, const views::Event& event) { 112 views::Button* sender, const views::Event& event) {
113 // Let other bubbles know we have an answer from the user. 113 // Let other bubbles know we have an answer from the user.
114 UpgradeDetector::GetInstance()->acknowledge_critical_update(); 114 UpgradeDetector::GetInstance()->acknowledge_critical_update();
115 115
116 if (sender == restart_button_) { 116 if (sender == restart_button_) {
117 content::RecordAction( 117 content::RecordAction(
118 UserMetricsAction("CriticalNotification_Restart")); 118 UserMetricsAction("CriticalNotification_Restart"));
119 BrowserList::AttemptRestart(); 119 browser::AttemptRestart();
120 } else if (sender == dismiss_button_) { 120 } else if (sender == dismiss_button_) {
121 content::RecordAction(UserMetricsAction("CriticalNotification_Ignore")); 121 content::RecordAction(UserMetricsAction("CriticalNotification_Ignore"));
122 // If the counter reaches 0, we set a restart flag that must be cleared if 122 // If the counter reaches 0, we set a restart flag that must be cleared if
123 // the user selects, for example, "Stay on this page" during an 123 // the user selects, for example, "Stay on this page" during an
124 // onbeforeunload handler. 124 // onbeforeunload handler.
125 PrefService* prefs = g_browser_process->local_state(); 125 PrefService* prefs = g_browser_process->local_state();
126 if (prefs->HasPrefPath(prefs::kRestartLastSessionOnShutdown)) 126 if (prefs->HasPrefPath(prefs::kRestartLastSessionOnShutdown))
127 prefs->ClearPref(prefs::kRestartLastSessionOnShutdown); 127 prefs->ClearPref(prefs::kRestartLastSessionOnShutdown);
128 } else { 128 } else {
129 NOTREACHED(); 129 NOTREACHED();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 dismiss_button_ = new views::NativeTextButton(this, 218 dismiss_button_ = new views::NativeTextButton(this,
219 l10n_util::GetStringUTF16(IDS_CRITICAL_NOTIFICATION_DISMISS)); 219 l10n_util::GetStringUTF16(IDS_CRITICAL_NOTIFICATION_DISMISS));
220 layout->AddView(dismiss_button_); 220 layout->AddView(dismiss_button_);
221 221
222 refresh_timer_.Start(FROM_HERE, 222 refresh_timer_.Start(FROM_HERE,
223 base::TimeDelta::FromMilliseconds(kRefreshBubbleEvery), 223 base::TimeDelta::FromMilliseconds(kRefreshBubbleEvery),
224 this, &CriticalNotificationBubbleView::OnCountdown); 224 this, &CriticalNotificationBubbleView::OnCountdown);
225 225
226 content::RecordAction(UserMetricsAction("CriticalNotificationShown")); 226 content::RecordAction(UserMetricsAction("CriticalNotificationShown"));
227 } 227 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/ash/chrome_shell_delegate.cc ('k') | chrome/browser/ui/views/frame/browser_frame_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698