| 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 "ash/system/web_notification/web_notification_tray.h" | 5 #include "ash/system/web_notification/web_notification_tray.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
| 10 #include "ash/shelf/shelf_layout_manager_observer.h" | 10 #include "ash/shelf/shelf_layout_manager_observer.h" |
| 11 #include "ash/shelf/shelf_util.h" | 11 #include "ash/shelf/shelf_util.h" |
| 12 #include "ash/shelf/shelf_widget.h" | 12 #include "ash/shelf/shelf_widget.h" |
| 13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "ash/shell_window_ids.h" | 14 #include "ash/shell_window_ids.h" |
| 15 #include "ash/system/status_area_widget.h" | 15 #include "ash/system/status_area_widget.h" |
| 16 #include "ash/system/tray/system_tray.h" | 16 #include "ash/system/tray/system_tray.h" |
| 17 #include "ash/system/tray/tray_background_view.h" | 17 #include "ash/system/tray/tray_background_view.h" |
| 18 #include "ash/system/tray/tray_bubble_wrapper.h" | 18 #include "ash/system/tray/tray_bubble_wrapper.h" |
| 19 #include "ash/system/tray/tray_constants.h" | 19 #include "ash/system/tray/tray_constants.h" |
| 20 #include "ash/system/tray/tray_utils.h" | 20 #include "ash/system/tray/tray_utils.h" |
| 21 #include "ash/system/web_notification/ash_popup_alignment_delegate.h" | 21 #include "ash/system/web_notification/ash_popup_alignment_delegate.h" |
| 22 #include "ash/wm/common/shelf/wm_shelf_util.h" | 22 #include "ash/wm/common/shelf/wm_shelf_util.h" |
| 23 #include "base/auto_reset.h" | 23 #include "base/auto_reset.h" |
| 24 #include "base/i18n/number_formatting.h" | 24 #include "base/i18n/number_formatting.h" |
| 25 #include "base/i18n/rtl.h" | 25 #include "base/i18n/rtl.h" |
| 26 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
| 27 #include "base/threading/thread_task_runner_handle.h" | 27 #include "base/threading/thread_task_runner_handle.h" |
| 28 #include "grit/ash_resources.h" | |
| 29 #include "grit/ash_strings.h" | 28 #include "grit/ash_strings.h" |
| 30 #include "ui/aura/window.h" | 29 #include "ui/aura/window.h" |
| 31 #include "ui/aura/window_event_dispatcher.h" | 30 #include "ui/aura/window_event_dispatcher.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/base/resource/resource_bundle.h" | |
| 34 #include "ui/display/display.h" | 32 #include "ui/display/display.h" |
| 35 #include "ui/display/screen.h" | 33 #include "ui/display/screen.h" |
| 34 #include "ui/gfx/paint_vector_icon.h" |
| 35 #include "ui/gfx/vector_icons_public.h" |
| 36 #include "ui/message_center/message_center_style.h" | 36 #include "ui/message_center/message_center_style.h" |
| 37 #include "ui/message_center/message_center_tray_delegate.h" | 37 #include "ui/message_center/message_center_tray_delegate.h" |
| 38 #include "ui/message_center/views/message_bubble_base.h" | 38 #include "ui/message_center/views/message_bubble_base.h" |
| 39 #include "ui/message_center/views/message_center_bubble.h" | 39 #include "ui/message_center/views/message_center_bubble.h" |
| 40 #include "ui/message_center/views/message_popup_collection.h" | 40 #include "ui/message_center/views/message_popup_collection.h" |
| 41 #include "ui/strings/grit/ui_strings.h" | 41 #include "ui/strings/grit/ui_strings.h" |
| 42 #include "ui/views/bubble/tray_bubble_view.h" | 42 #include "ui/views/bubble/tray_bubble_view.h" |
| 43 #include "ui/views/controls/button/custom_button.h" | 43 #include "ui/views/controls/button/custom_button.h" |
| 44 #include "ui/views/controls/image_view.h" | 44 #include "ui/views/controls/image_view.h" |
| 45 #include "ui/views/controls/label.h" | 45 #include "ui/views/controls/label.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 67 const int kToggleQuietMode = 0; | 67 const int kToggleQuietMode = 0; |
| 68 const int kEnableQuietModeDay = 2; | 68 const int kEnableQuietModeDay = 2; |
| 69 | 69 |
| 70 } | 70 } |
| 71 | 71 |
| 72 namespace { | 72 namespace { |
| 73 | 73 |
| 74 const SkColor kWebNotificationColorNoUnread = | 74 const SkColor kWebNotificationColorNoUnread = |
| 75 SkColorSetARGB(128, 255, 255, 255); | 75 SkColorSetARGB(128, 255, 255, 255); |
| 76 const SkColor kWebNotificationColorWithUnread = SK_ColorWHITE; | 76 const SkColor kWebNotificationColorWithUnread = SK_ColorWHITE; |
| 77 | 77 const int kNoUnreadIconSize = 18; |
| 78 } | 78 } |
| 79 | 79 |
| 80 // Class to initialize and manage the WebNotificationBubble and | 80 // Class to initialize and manage the WebNotificationBubble and |
| 81 // TrayBubbleWrapper instances for a bubble. | 81 // TrayBubbleWrapper instances for a bubble. |
| 82 class WebNotificationBubbleWrapper { | 82 class WebNotificationBubbleWrapper { |
| 83 public: | 83 public: |
| 84 // Takes ownership of |bubble| and creates |bubble_wrapper_|. | 84 // Takes ownership of |bubble| and creates |bubble_wrapper_|. |
| 85 WebNotificationBubbleWrapper(WebNotificationTray* tray, | 85 WebNotificationBubbleWrapper(WebNotificationTray* tray, |
| 86 message_center::MessageBubbleBase* bubble) { | 86 message_center::MessageBubbleBase* bubble) { |
| 87 bubble_.reset(bubble); | 87 bubble_.reset(bubble); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 class WebNotificationButton : public views::CustomButton { | 117 class WebNotificationButton : public views::CustomButton { |
| 118 public: | 118 public: |
| 119 WebNotificationButton(views::ButtonListener* listener) | 119 WebNotificationButton(views::ButtonListener* listener) |
| 120 : views::CustomButton(listener), | 120 : views::CustomButton(listener), |
| 121 is_bubble_visible_(false), | 121 is_bubble_visible_(false), |
| 122 unread_count_(0) { | 122 unread_count_(0) { |
| 123 SetLayoutManager(new views::FillLayout); | 123 SetLayoutManager(new views::FillLayout); |
| 124 | 124 |
| 125 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 125 no_unread_icon_.SetImage(gfx::CreateVectorIcon( |
| 126 no_unread_icon_.SetImage( | 126 gfx::VectorIconId::NOTIFICATIONS, kNoUnreadIconSize, |
| 127 rb.GetImageNamed(IDR_ASH_SHELF_NOTIFICATION_TRAY_BELL).ToImageSkia()); | 127 kWebNotificationColorNoUnread)); |
| 128 no_unread_icon_.SetImageSize(gfx::Size(18, 18)); | |
| 129 no_unread_icon_.set_owned_by_client(); | 128 no_unread_icon_.set_owned_by_client(); |
| 130 | 129 |
| 131 unread_label_.set_owned_by_client(); | 130 unread_label_.set_owned_by_client(); |
| 132 SetupLabelForTray(&unread_label_); | 131 SetupLabelForTray(&unread_label_); |
| 133 | 132 |
| 134 AddChildView(&unread_label_); | 133 AddChildView(&unread_label_); |
| 135 } | 134 } |
| 136 | 135 |
| 137 void SetBubbleVisible(bool visible) { | 136 void SetBubbleVisible(bool visible) { |
| 138 if (visible == is_bubble_visible_) | 137 if (visible == is_bubble_visible_) |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 | 503 |
| 505 message_center::MessageCenterBubble* | 504 message_center::MessageCenterBubble* |
| 506 WebNotificationTray::GetMessageCenterBubbleForTest() { | 505 WebNotificationTray::GetMessageCenterBubbleForTest() { |
| 507 if (!message_center_bubble()) | 506 if (!message_center_bubble()) |
| 508 return NULL; | 507 return NULL; |
| 509 return static_cast<message_center::MessageCenterBubble*>( | 508 return static_cast<message_center::MessageCenterBubble*>( |
| 510 message_center_bubble()->bubble()); | 509 message_center_bubble()->bubble()); |
| 511 } | 510 } |
| 512 | 511 |
| 513 } // namespace ash | 512 } // namespace ash |
| OLD | NEW |