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

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

Issue 8919017: Split UserMetrics into API vs. implementation. Move API to content/public. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Version for commit (merged again). Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/ui/browser_list.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/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/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/base/resource/resource_bundle.h" 21 #include "ui/base/resource/resource_bundle.h"
22 #include "ui/views/controls/button/text_button.h" 22 #include "ui/views/controls/button/text_button.h"
23 #include "ui/views/controls/image_view.h" 23 #include "ui/views/controls/image_view.h"
24 #include "ui/views/controls/label.h" 24 #include "ui/views/controls/label.h"
25 #include "ui/views/layout/grid_layout.h" 25 #include "ui/views/layout/grid_layout.h"
26 #include "ui/views/layout/layout_constants.h" 26 #include "ui/views/layout/layout_constants.h"
27 #include "ui/views/widget/widget.h" 27 #include "ui/views/widget/widget.h"
28 28
29 using content::UserMetricsAction;
30
29 namespace { 31 namespace {
30 32
31 // Layout constants. 33 // Layout constants.
32 const int kInset = 2; 34 const int kInset = 2;
33 const int kImageHeadlinePadding = 4; 35 const int kImageHeadlinePadding = 4;
34 const int kHeadlineMessagePadding = 4; 36 const int kHeadlineMessagePadding = 4;
35 const int kMessageBubblePadding = 11; 37 const int kMessageBubblePadding = 11;
36 38
37 // How long to give the user until auto-restart if no action is taken. The code 39 // How long to give the user until auto-restart if no action is taken. The code
38 // assumes this to be less than a minute. 40 // assumes this to be less than a minute.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 headline_->SetText(UTF16ToWide( 73 headline_->SetText(UTF16ToWide(
72 l10n_util::GetStringFUTF16(IDS_CRITICAL_NOTIFICATION_HEADLINE_ALTERNATE, 74 l10n_util::GetStringFUTF16(IDS_CRITICAL_NOTIFICATION_HEADLINE_ALTERNATE,
73 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)))); 75 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))));
74 } 76 }
75 } 77 }
76 78
77 void CriticalNotificationBubbleView::OnCountdown() { 79 void CriticalNotificationBubbleView::OnCountdown() {
78 int seconds = GetRemainingTime(); 80 int seconds = GetRemainingTime();
79 if (seconds <= 0) { 81 if (seconds <= 0) {
80 // Time's up! 82 // Time's up!
81 UserMetrics::RecordAction( 83 content::RecordAction(
82 UserMetricsAction("CriticalNotification_AutoRestart")); 84 UserMetricsAction("CriticalNotification_AutoRestart"));
83 refresh_timer_.Stop(); 85 refresh_timer_.Stop();
84 BrowserList::AttemptRestart(); 86 BrowserList::AttemptRestart();
85 } 87 }
86 88
87 // Update the counter. It may seem counter-intuitive to update the message 89 // Update the counter. It may seem counter-intuitive to update the message
88 // after we attempt restart, but remember that shutdown may be aborted by 90 // after we attempt restart, but remember that shutdown may be aborted by
89 // an onbeforeunload handler, leaving the bubble up when the browser should 91 // an onbeforeunload handler, leaving the bubble up when the browser should
90 // have restarted (giving the user another chance). 92 // have restarted (giving the user another chance).
91 UpdateBubbleHeadline(seconds); 93 UpdateBubbleHeadline(seconds);
92 SchedulePaint(); 94 SchedulePaint();
93 } 95 }
94 96
95 void CriticalNotificationBubbleView::ButtonPressed( 97 void CriticalNotificationBubbleView::ButtonPressed(
96 views::Button* sender, const views::Event& event) { 98 views::Button* sender, const views::Event& event) {
97 UpgradeDetector::GetInstance()->acknowledge_critical_update(); 99 UpgradeDetector::GetInstance()->acknowledge_critical_update();
98 100
99 if (sender == restart_button_) { 101 if (sender == restart_button_) {
100 UserMetrics::RecordAction( 102 content::RecordAction(
101 UserMetricsAction("CriticalNotification_Restart")); 103 UserMetricsAction("CriticalNotification_Restart"));
102 BrowserList::AttemptRestart(); 104 BrowserList::AttemptRestart();
103 } else if (sender == dismiss_button_) { 105 } else if (sender == dismiss_button_) {
104 UserMetrics::RecordAction(UserMetricsAction("CriticalNotification_Ignore")); 106 content::RecordAction(UserMetricsAction("CriticalNotification_Ignore"));
105 // If the counter reaches 0, we set a restart flag that must be cleared if 107 // If the counter reaches 0, we set a restart flag that must be cleared if
106 // the user selects, for example, "Stay on this page" during an 108 // the user selects, for example, "Stay on this page" during an
107 // onbeforeunload handler. 109 // onbeforeunload handler.
108 PrefService* prefs = g_browser_process->local_state(); 110 PrefService* prefs = g_browser_process->local_state();
109 if (prefs->HasPrefPath(prefs::kRestartLastSessionOnShutdown)) 111 if (prefs->HasPrefPath(prefs::kRestartLastSessionOnShutdown))
110 prefs->ClearPref(prefs::kRestartLastSessionOnShutdown); 112 prefs->ClearPref(prefs::kRestartLastSessionOnShutdown);
111 } else { 113 } else {
112 NOTREACHED(); 114 NOTREACHED();
113 } 115 }
114 116
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 restart_button_->SetIsDefault(true); 191 restart_button_->SetIsDefault(true);
190 layout->AddView(restart_button_); 192 layout->AddView(restart_button_);
191 dismiss_button_ = new views::NativeTextButton(this, UTF16ToWide( 193 dismiss_button_ = new views::NativeTextButton(this, UTF16ToWide(
192 l10n_util::GetStringUTF16(IDS_CRITICAL_NOTIFICATION_DISMISS))); 194 l10n_util::GetStringUTF16(IDS_CRITICAL_NOTIFICATION_DISMISS)));
193 layout->AddView(dismiss_button_); 195 layout->AddView(dismiss_button_);
194 196
195 refresh_timer_.Start(FROM_HERE, 197 refresh_timer_.Start(FROM_HERE,
196 base::TimeDelta::FromMilliseconds(kRefreshBubbleEvery), 198 base::TimeDelta::FromMilliseconds(kRefreshBubbleEvery),
197 this, &CriticalNotificationBubbleView::OnCountdown); 199 this, &CriticalNotificationBubbleView::OnCountdown);
198 200
199 UserMetrics::RecordAction(UserMetricsAction("CriticalNotificationShown")); 201 content::RecordAction(UserMetricsAction("CriticalNotificationShown"));
200 } 202 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc ('k') | chrome/browser/ui/views/first_run_bubble.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698