OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/message_center/web_notification_tray.h" | 5 #include "chrome/browser/ui/views/message_center/web_notification_tray.h" |
6 | 6 |
7 #include "base/i18n/number_formatting.h" | 7 #include "base/i18n/number_formatting.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/status_icons/status_icon.h" | 12 #include "chrome/browser/status_icons/status_icon.h" |
13 #include "chrome/browser/status_icons/status_icon_menu_model.h" | 13 #include "chrome/browser/status_icons/status_icon_menu_model.h" |
14 #include "chrome/browser/status_icons/status_tray.h" | 14 #include "chrome/browser/status_icons/status_tray.h" |
15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
16 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
17 #include "grit/chromium_strings.h" | 17 #include "grit/chromium_strings.h" |
| 18 #include "grit/generated_resources.h" |
18 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
19 #include "grit/ui_strings.h" | 20 #include "grit/ui_strings.h" |
20 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
21 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
22 #include "ui/gfx/canvas.h" | 23 #include "ui/gfx/canvas.h" |
23 #include "ui/gfx/image/image_skia_operations.h" | 24 #include "ui/gfx/image/image_skia_operations.h" |
24 #include "ui/gfx/rect.h" | 25 #include "ui/gfx/rect.h" |
25 #include "ui/gfx/screen.h" | 26 #include "ui/gfx/screen.h" |
26 #include "ui/gfx/size.h" | 27 #include "ui/gfx/size.h" |
27 #include "ui/message_center/message_center_tray.h" | 28 #include "ui/message_center/message_center_tray.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 NULL, message_center(), message_center_tray_.get(), false)); | 139 NULL, message_center(), message_center_tray_.get(), false)); |
139 | 140 |
140 #if defined(OS_WIN) | 141 #if defined(OS_WIN) |
141 // |local_state| can be NULL in tests. | 142 // |local_state| can be NULL in tests. |
142 if (local_state) { | 143 if (local_state) { |
143 did_force_tray_visible_.reset(new BooleanPrefMember()); | 144 did_force_tray_visible_.reset(new BooleanPrefMember()); |
144 did_force_tray_visible_->Init(prefs::kMessageCenterForcedOnTaskbar, | 145 did_force_tray_visible_->Init(prefs::kMessageCenterForcedOnTaskbar, |
145 local_state); | 146 local_state); |
146 } | 147 } |
147 #endif | 148 #endif |
| 149 title_ = l10n_util::GetStringFUTF16( |
| 150 IDS_MESSAGE_CENTER_FOOTER_WITH_PRODUCT_TITLE, |
| 151 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); |
148 } | 152 } |
149 | 153 |
150 WebNotificationTray::~WebNotificationTray() { | 154 WebNotificationTray::~WebNotificationTray() { |
151 // Reset this early so that delegated events during destruction don't cause | 155 // Reset this early so that delegated events during destruction don't cause |
152 // problems. | 156 // problems. |
153 popup_collection_.reset(); | 157 popup_collection_.reset(); |
154 message_center_tray_.reset(); | 158 message_center_tray_.reset(); |
155 DestroyStatusIcon(); | 159 DestroyStatusIcon(); |
156 } | 160 } |
157 | 161 |
158 message_center::MessageCenter* WebNotificationTray::message_center() { | 162 message_center::MessageCenter* WebNotificationTray::message_center() { |
159 return message_center_tray_->message_center(); | 163 return message_center_tray_->message_center(); |
160 } | 164 } |
161 | 165 |
162 bool WebNotificationTray::ShowPopups() { | 166 bool WebNotificationTray::ShowPopups() { |
163 popup_collection_->DoUpdateIfPossible(); | 167 popup_collection_->DoUpdateIfPossible(); |
164 return true; | 168 return true; |
165 } | 169 } |
166 | 170 |
167 void WebNotificationTray::HidePopups() { | 171 void WebNotificationTray::HidePopups() { |
168 DCHECK(popup_collection_.get()); | 172 DCHECK(popup_collection_.get()); |
169 popup_collection_->MarkAllPopupsShown(); | 173 popup_collection_->MarkAllPopupsShown(); |
170 } | 174 } |
171 | 175 |
172 bool WebNotificationTray::ShowMessageCenter() { | 176 bool WebNotificationTray::ShowMessageCenter() { |
173 message_center_delegate_ = | 177 message_center_delegate_ = |
174 new MessageCenterWidgetDelegate(this, | 178 new MessageCenterWidgetDelegate(this, |
175 message_center_tray_.get(), | 179 message_center_tray_.get(), |
176 false, // settings initally invisible | 180 false, // settings initally invisible |
177 GetPositionInfo()); | 181 GetPositionInfo(), |
| 182 title_); |
178 | 183 |
179 return true; | 184 return true; |
180 } | 185 } |
181 | 186 |
182 void WebNotificationTray::HideMessageCenter() { | 187 void WebNotificationTray::HideMessageCenter() { |
183 if (message_center_delegate_) { | 188 if (message_center_delegate_) { |
184 views::Widget* widget = message_center_delegate_->GetWidget(); | 189 views::Widget* widget = message_center_delegate_->GetWidget(); |
185 if (widget) | 190 if (widget) |
186 widget->Close(); | 191 widget->Close(); |
187 } | 192 } |
188 } | 193 } |
189 | 194 |
190 bool WebNotificationTray::ShowNotifierSettings() { | 195 bool WebNotificationTray::ShowNotifierSettings() { |
191 if (message_center_delegate_) { | 196 if (message_center_delegate_) { |
192 message_center_delegate_->SetSettingsVisible(true); | 197 message_center_delegate_->SetSettingsVisible(true); |
193 return true; | 198 return true; |
194 } | 199 } |
195 message_center_delegate_ = | 200 message_center_delegate_ = |
196 new MessageCenterWidgetDelegate(this, | 201 new MessageCenterWidgetDelegate(this, |
197 message_center_tray_.get(), | 202 message_center_tray_.get(), |
198 true, // settings initally visible | 203 true, // settings initally visible |
199 GetPositionInfo()); | 204 GetPositionInfo(), |
| 205 title_); |
200 | 206 |
201 return true; | 207 return true; |
202 } | 208 } |
203 | 209 |
204 bool WebNotificationTray::IsContextMenuEnabled() const { | 210 bool WebNotificationTray::IsContextMenuEnabled() const { |
205 // It can always return true because the notifications are invisible if | 211 // It can always return true because the notifications are invisible if |
206 // the context menu shouldn't be enabled, such as in the lock screen. | 212 // the context menu shouldn't be enabled, such as in the lock screen. |
207 return true; | 213 return true; |
208 } | 214 } |
209 | 215 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 status_icon_menu_ = menu.get(); | 386 status_icon_menu_ = menu.get(); |
381 status_icon->SetContextMenu(menu.Pass()); | 387 status_icon->SetContextMenu(menu.Pass()); |
382 } | 388 } |
383 | 389 |
384 MessageCenterWidgetDelegate* | 390 MessageCenterWidgetDelegate* |
385 WebNotificationTray::GetMessageCenterWidgetDelegateForTest() { | 391 WebNotificationTray::GetMessageCenterWidgetDelegateForTest() { |
386 return message_center_delegate_; | 392 return message_center_delegate_; |
387 } | 393 } |
388 | 394 |
389 } // namespace message_center | 395 } // namespace message_center |
OLD | NEW |