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/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/profiles/profile_manager.h" | |
11 #include "chrome/browser/status_icons/status_icon.h" | 12 #include "chrome/browser/status_icons/status_icon.h" |
12 #include "chrome/browser/status_icons/status_tray.h" | 13 #include "chrome/browser/status_icons/status_tray.h" |
14 #include "chrome/browser/ui/browser_finder.h" | |
15 #include "chrome/browser/ui/host_desktop.h" | |
16 #include "chrome/browser/ui/singleton_tabs.h" | |
13 #include "chrome/browser/ui/views/message_center/notification_bubble_wrapper.h" | 17 #include "chrome/browser/ui/views/message_center/notification_bubble_wrapper.h" |
18 #include "chrome/common/url_constants.h" | |
14 #include "content/public/browser/user_metrics.h" | 19 #include "content/public/browser/user_metrics.h" |
15 #include "grit/chromium_strings.h" | 20 #include "grit/chromium_strings.h" |
16 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
17 #include "grit/ui_strings.h" | 22 #include "grit/ui_strings.h" |
18 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
19 #include "ui/base/models/simple_menu_model.h" | 24 #include "ui/base/models/simple_menu_model.h" |
20 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
21 #include "ui/gfx/canvas.h" | 26 #include "ui/gfx/canvas.h" |
22 #include "ui/gfx/image/image_skia_operations.h" | 27 #include "ui/gfx/image/image_skia_operations.h" |
23 #include "ui/gfx/rect.h" | 28 #include "ui/gfx/rect.h" |
24 #include "ui/gfx/screen.h" | 29 #include "ui/gfx/screen.h" |
25 #include "ui/gfx/size.h" | 30 #include "ui/gfx/size.h" |
26 #include "ui/message_center/message_center_tray.h" | 31 #include "ui/message_center/message_center_tray.h" |
27 #include "ui/message_center/message_center_tray_delegate.h" | 32 #include "ui/message_center/message_center_tray_delegate.h" |
28 #include "ui/message_center/views/message_bubble_base.h" | 33 #include "ui/message_center/views/message_bubble_base.h" |
29 #include "ui/message_center/views/message_center_bubble.h" | 34 #include "ui/message_center/views/message_center_bubble.h" |
30 #include "ui/message_center/views/message_popup_collection.h" | 35 #include "ui/message_center/views/message_popup_collection.h" |
31 #include "ui/views/widget/widget.h" | 36 #include "ui/views/widget/widget.h" |
32 | 37 |
33 #if defined(OS_WIN) | |
34 #include "ui/base/win/hwnd_util.h" | |
35 #endif | |
36 | |
37 namespace { | 38 namespace { |
38 | 39 |
39 // Tray constants | 40 // Tray constants |
40 const int kScreenEdgePadding = 2; | 41 const int kScreenEdgePadding = 2; |
41 | 42 |
42 const int kSystemTrayWidth = 16; | 43 const int kSystemTrayWidth = 16; |
43 const int kSystemTrayHeight = 16; | 44 const int kSystemTrayHeight = 16; |
44 const int kNumberOfSystemTraySprites = 10; | 45 const int kNumberOfSystemTraySprites = 10; |
45 | 46 |
46 gfx::Rect GetCornerAnchorRect() { | 47 gfx::Rect GetCornerAnchorRect() { |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 } | 271 } |
271 } | 272 } |
272 | 273 |
273 void WebNotificationTray::OnStatusIconClicked() { | 274 void WebNotificationTray::OnStatusIconClicked() { |
274 // TODO(dewittj): It's possible GetNativeScreen is wrong for win-aura. | 275 // TODO(dewittj): It's possible GetNativeScreen is wrong for win-aura. |
275 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); | 276 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); |
276 mouse_click_point_ = screen->GetCursorScreenPoint(); | 277 mouse_click_point_ = screen->GetCursorScreenPoint(); |
277 message_center_tray_->ToggleMessageCenterBubble(); | 278 message_center_tray_->ToggleMessageCenterBubble(); |
278 } | 279 } |
279 | 280 |
281 void WebNotificationTray::OnBalloonClicked() { | |
282 Browser* browser = chrome::FindOrCreateTabbedBrowser( | |
sky
2013/06/20 17:22:01
If this creates a new browser who shows it?
dewittj
2013/06/20 17:51:51
line 285 shows a tab in the browser. But it's pos
sky
2013/06/20 17:56:27
That shows the tab, but if FindOrCreateTabbedBrows
| |
283 ProfileManager::GetLastUsedProfileAllowedByPolicy(), | |
284 chrome::GetActiveDesktop()); | |
285 chrome::ShowSingletonTab(browser, GURL(chrome::kNotificationsHelpURL)); | |
286 } | |
287 | |
280 void WebNotificationTray::HideBubbleWithView( | 288 void WebNotificationTray::HideBubbleWithView( |
281 const views::TrayBubbleView* bubble_view) { | 289 const views::TrayBubbleView* bubble_view) { |
282 if (message_center_bubble_.get() && | 290 if (message_center_bubble_.get() && |
283 bubble_view == message_center_bubble_->bubble_view()) { | 291 bubble_view == message_center_bubble_->bubble_view()) { |
284 message_center_tray_->HideMessageCenterBubble(); | 292 message_center_tray_->HideMessageCenterBubble(); |
285 } | 293 } |
286 } | 294 } |
287 | 295 |
288 StatusIcon* WebNotificationTray::GetStatusIcon() { | 296 StatusIcon* WebNotificationTray::GetStatusIcon() { |
289 if (status_icon_) | 297 if (status_icon_) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 | 330 |
323 message_center::MessageCenterBubble* | 331 message_center::MessageCenterBubble* |
324 WebNotificationTray::GetMessageCenterBubbleForTest() { | 332 WebNotificationTray::GetMessageCenterBubbleForTest() { |
325 if (!message_center_bubble_.get()) | 333 if (!message_center_bubble_.get()) |
326 return NULL; | 334 return NULL; |
327 return static_cast<message_center::MessageCenterBubble*>( | 335 return static_cast<message_center::MessageCenterBubble*>( |
328 message_center_bubble_->bubble()); | 336 message_center_bubble_->bubble()); |
329 } | 337 } |
330 | 338 |
331 } // namespace message_center | 339 } // namespace message_center |
OLD | NEW |