OLD | NEW |
---|---|
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/strings/string_number_conversions.h" | 7 #include "base/i18n/message_formatter.h" |
Greg Levin
2016/05/27 16:58:03
TODO: Remove in next patch
Greg Levin
2016/05/27 19:31:47
Done.
| |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/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/lifetime/application_lifetime.h" |
11 #include "chrome/browser/upgrade_detector.h" | 11 #include "chrome/browser/upgrade_detector.h" |
12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
13 #include "chrome/grit/chromium_strings.h" | 13 #include "chrome/grit/chromium_strings.h" |
14 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
15 #include "chrome/grit/locale_settings.h" | 15 #include "chrome/grit/locale_settings.h" |
16 #include "components/prefs/pref_service.h" | 16 #include "components/prefs/pref_service.h" |
17 #include "content/public/browser/user_metrics.h" | 17 #include "content/public/browser/user_metrics.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 | 76 |
77 // Update the counter. It may seem counter-intuitive to update the message | 77 // Update the counter. It may seem counter-intuitive to update the message |
78 // after we attempt restart, but remember that shutdown may be aborted by | 78 // after we attempt restart, but remember that shutdown may be aborted by |
79 // an onbeforeunload handler, leaving the bubble up when the browser should | 79 // an onbeforeunload handler, leaving the bubble up when the browser should |
80 // have restarted (giving the user another chance). | 80 // have restarted (giving the user another chance). |
81 GetBubbleFrameView()->UpdateWindowTitle(); | 81 GetBubbleFrameView()->UpdateWindowTitle(); |
82 } | 82 } |
83 | 83 |
84 base::string16 CriticalNotificationBubbleView::GetWindowTitle() const { | 84 base::string16 CriticalNotificationBubbleView::GetWindowTitle() const { |
85 int seconds = GetRemainingTime(); | 85 int seconds = GetRemainingTime(); |
86 return seconds > 0 ? l10n_util::GetStringFUTF16( | 86 return seconds > 0 ? l10n_util::GetPluralStringFUTF16( |
87 IDS_CRITICAL_NOTIFICATION_HEADLINE, | 87 IDS_CRITICAL_NOTIFICATION_HEADLINE, seconds) |
88 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | 88 : l10n_util::GetStringUTF16( |
89 base::IntToString16(seconds)) | 89 IDS_CRITICAL_NOTIFICATION_HEADLINE_ALTERNATE); |
jungshik at Google
2016/05/27 17:53:12
You can use l10n_util::GetStringUTF16(IDS_PRODUCT_
Peter Kasting
2016/05/27 18:48:29
I thought the l10n folks asked us to phase out sub
Greg Levin
2016/05/27 19:31:47
Acknowledged.
| |
90 : l10n_util::GetStringFUTF16( | |
91 IDS_CRITICAL_NOTIFICATION_HEADLINE_ALTERNATE, | |
92 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | |
93 } | 90 } |
94 | 91 |
95 gfx::ImageSkia CriticalNotificationBubbleView::GetWindowIcon() { | 92 gfx::ImageSkia CriticalNotificationBubbleView::GetWindowIcon() { |
96 return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 93 return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
97 IDR_UPDATE_MENU_SEVERITY_HIGH); | 94 IDR_UPDATE_MENU_SEVERITY_HIGH); |
98 } | 95 } |
99 | 96 |
100 bool CriticalNotificationBubbleView::ShouldShowWindowIcon() const { | 97 bool CriticalNotificationBubbleView::ShouldShowWindowIcon() const { |
101 return true; | 98 return true; |
102 } | 99 } |
(...skipping 29 matching lines...) Expand all Loading... | |
132 } | 129 } |
133 | 130 |
134 void CriticalNotificationBubbleView::Init() { | 131 void CriticalNotificationBubbleView::Init() { |
135 bubble_created_ = base::TimeTicks::Now(); | 132 bubble_created_ = base::TimeTicks::Now(); |
136 | 133 |
137 SetLayoutManager(new views::FillLayout()); | 134 SetLayoutManager(new views::FillLayout()); |
138 | 135 |
139 views::Label* message = new views::Label(); | 136 views::Label* message = new views::Label(); |
140 message->SetMultiLine(true); | 137 message->SetMultiLine(true); |
141 message->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 138 message->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
142 message->SetText(l10n_util::GetStringFUTF16(IDS_CRITICAL_NOTIFICATION_TEXT, | 139 message->SetText(l10n_util::GetStringUTF16(IDS_CRITICAL_NOTIFICATION_TEXT)); |
jungshik at Google
2016/05/27 17:53:12
Any reason NOT to use a common message along with
Peter Kasting
2016/05/27 18:48:29
Same comment.
Greg Levin
2016/05/27 19:31:47
Acknowledged.
| |
143 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | |
144 message->SizeToFit(views::Widget::GetLocalizedContentsWidth( | 140 message->SizeToFit(views::Widget::GetLocalizedContentsWidth( |
145 IDS_CRUCIAL_NOTIFICATION_BUBBLE_WIDTH_CHARS)); | 141 IDS_CRUCIAL_NOTIFICATION_BUBBLE_WIDTH_CHARS)); |
146 AddChildView(message); | 142 AddChildView(message); |
147 | 143 |
148 refresh_timer_.Start(FROM_HERE, | 144 refresh_timer_.Start(FROM_HERE, |
149 base::TimeDelta::FromMilliseconds(kRefreshBubbleEvery), | 145 base::TimeDelta::FromMilliseconds(kRefreshBubbleEvery), |
150 this, &CriticalNotificationBubbleView::OnCountdown); | 146 this, &CriticalNotificationBubbleView::OnCountdown); |
151 | 147 |
152 content::RecordAction(UserMetricsAction("CriticalNotificationShown")); | 148 content::RecordAction(UserMetricsAction("CriticalNotificationShown")); |
153 } | 149 } |
154 | 150 |
155 void CriticalNotificationBubbleView::GetAccessibleState( | 151 void CriticalNotificationBubbleView::GetAccessibleState( |
156 ui::AXViewState* state) { | 152 ui::AXViewState* state) { |
157 state->role = ui::AX_ROLE_ALERT; | 153 state->role = ui::AX_ROLE_ALERT; |
158 } | 154 } |
159 | 155 |
160 void CriticalNotificationBubbleView::ViewHierarchyChanged( | 156 void CriticalNotificationBubbleView::ViewHierarchyChanged( |
161 const ViewHierarchyChangedDetails& details) { | 157 const ViewHierarchyChangedDetails& details) { |
162 if (details.is_add && details.child == this) | 158 if (details.is_add && details.child == this) |
163 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); | 159 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); |
164 } | 160 } |
OLD | NEW |