Chromium Code Reviews| 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/common/system/web_notification/web_notification_tray.h" | 5 #include "ash/common/system/web_notification/web_notification_tray.h" |
| 6 | 6 |
| 7 #include "ash/common/ash_switches.h" | 7 #include "ash/common/ash_switches.h" |
| 8 #include "ash/common/material_design/material_design_controller.h" | 8 #include "ash/common/material_design/material_design_controller.h" |
| 9 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
| 10 #include "ash/common/shelf/shelf_constants.h" | 10 #include "ash/common/shelf/shelf_constants.h" |
| 11 #include "ash/common/shelf/wm_shelf.h" | 11 #include "ash/common/shelf/wm_shelf.h" |
| 12 #include "ash/common/shelf/wm_shelf_util.h" | 12 #include "ash/common/shelf/wm_shelf_util.h" |
| 13 #include "ash/common/shell_window_ids.h" | 13 #include "ash/common/shell_window_ids.h" |
| 14 #include "ash/common/system/tray/system_tray.h" | 14 #include "ash/common/system/tray/system_tray.h" |
| 15 #include "ash/common/system/tray/system_tray_delegate.h" | 15 #include "ash/common/system/tray/system_tray_delegate.h" |
| 16 #include "ash/common/system/tray/tray_bubble_wrapper.h" | 16 #include "ash/common/system/tray/tray_bubble_wrapper.h" |
| 17 #include "ash/common/system/tray/tray_constants.h" | 17 #include "ash/common/system/tray/tray_constants.h" |
| 18 #include "ash/common/system/tray/tray_utils.h" | 18 #include "ash/common/system/tray/tray_utils.h" |
| 19 #include "ash/common/system/web_notification/ash_popup_alignment_delegate.h" | 19 #include "ash/common/system/web_notification/ash_popup_alignment_delegate.h" |
| 20 #include "ash/common/wm_lookup.h" | 20 #include "ash/common/wm_lookup.h" |
| 21 #include "ash/common/wm_root_window_controller.h" | 21 #include "ash/common/wm_root_window_controller.h" |
| 22 #include "ash/common/wm_shell.h" | 22 #include "ash/common/wm_shell.h" |
| 23 #include "ash/common/wm_window.h" | 23 #include "ash/common/wm_window.h" |
| 24 #include "ash/resources/vector_icons/vector_icons.h" | |
| 24 #include "base/auto_reset.h" | 25 #include "base/auto_reset.h" |
| 25 #include "base/i18n/number_formatting.h" | 26 #include "base/i18n/number_formatting.h" |
| 26 #include "base/i18n/rtl.h" | 27 #include "base/i18n/rtl.h" |
| 27 #include "base/strings/utf_string_conversions.h" | 28 #include "base/strings/utf_string_conversions.h" |
| 28 #include "base/threading/thread_task_runner_handle.h" | 29 #include "base/threading/thread_task_runner_handle.h" |
| 29 #include "grit/ash_strings.h" | 30 #include "grit/ash_strings.h" |
| 30 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 31 #include "ui/display/display.h" | 32 #include "ui/display/display.h" |
| 32 #include "ui/display/screen.h" | 33 #include "ui/display/screen.h" |
| 33 #include "ui/gfx/paint_vector_icon.h" | 34 #include "ui/gfx/paint_vector_icon.h" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 61 namespace ash { | 62 namespace ash { |
| 62 namespace { | 63 namespace { |
| 63 | 64 |
| 64 // Menu commands | 65 // Menu commands |
| 65 constexpr int kToggleQuietMode = 0; | 66 constexpr int kToggleQuietMode = 0; |
| 66 constexpr int kEnableQuietModeDay = 2; | 67 constexpr int kEnableQuietModeDay = 2; |
| 67 | 68 |
| 68 constexpr int kMaximumSmallIconCount = 3; | 69 constexpr int kMaximumSmallIconCount = 3; |
| 69 | 70 |
| 70 constexpr gfx::Size kTrayItemInnerIconSize(16, 16); | 71 constexpr gfx::Size kTrayItemInnerIconSize(16, 16); |
| 71 constexpr gfx::Size kTrayItemInnerBellIconSize(18, 18); | 72 constexpr gfx::Size kTrayItemInnerBellIconSizeNonMd(18, 18); |
| 72 constexpr gfx::Size kTrayItemOuterSize(26, 26); | 73 constexpr gfx::Size kTrayItemOuterSize(26, 26); |
| 73 constexpr gfx::Insets kTrayItemInsets(3, 3); | 74 constexpr gfx::Insets kTrayItemInsets(3, 3); |
| 74 | 75 |
| 75 constexpr int kTrayItemAnimationDurationMS = 200; | 76 constexpr int kTrayItemAnimationDurationMS = 200; |
| 76 | 77 |
| 77 constexpr size_t kMaximumNotificationNumber = 99; | 78 constexpr size_t kMaximumNotificationNumber = 99; |
| 78 | 79 |
| 79 // Flag to disable animation. Only for testing. | 80 // Flag to disable animation. Only for testing. |
| 80 bool disable_animations_for_test = false; | 81 bool disable_animations_for_test = false; |
| 81 } | 82 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 std::unique_ptr<gfx::SlideAnimation> animation_; | 236 std::unique_ptr<gfx::SlideAnimation> animation_; |
| 236 bool delete_after_animation_ = false; | 237 bool delete_after_animation_ = false; |
| 237 WebNotificationTray* tray_; | 238 WebNotificationTray* tray_; |
| 238 | 239 |
| 239 DISALLOW_COPY_AND_ASSIGN(WebNotificationItem); | 240 DISALLOW_COPY_AND_ASSIGN(WebNotificationItem); |
| 240 }; | 241 }; |
| 241 | 242 |
| 242 class WebNotificationImage : public WebNotificationItem { | 243 class WebNotificationImage : public WebNotificationItem { |
| 243 public: | 244 public: |
| 244 WebNotificationImage(const gfx::ImageSkia& image, | 245 WebNotificationImage(const gfx::ImageSkia& image, |
| 245 gfx::Size size, | 246 gfx::Size size, |
|
Evan Stade
2016/09/12 21:28:28
nit: const ref on size.
but better yet, why not r
tdanderson
2016/09/13 16:48:03
Done.
| |
| 246 gfx::AnimationContainer* container, | 247 gfx::AnimationContainer* container, |
| 247 WebNotificationTray* tray) | 248 WebNotificationTray* tray) |
| 248 : WebNotificationItem(container, tray) { | 249 : WebNotificationItem(container, tray) { |
| 249 view_ = new views::ImageView(); | 250 view_ = new views::ImageView(); |
| 250 view_->SetImage(image); | 251 view_->SetImage(image); |
| 251 view_->SetImageSize(size); | 252 view_->SetImageSize(size); |
| 252 AddChildView(view_); | 253 AddChildView(view_); |
| 253 } | 254 } |
| 254 | 255 |
| 255 private: | 256 private: |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 : TrayBackgroundView(shelf), | 300 : TrayBackgroundView(shelf), |
| 300 status_area_window_(status_area_window), | 301 status_area_window_(status_area_window), |
| 301 system_tray_(system_tray), | 302 system_tray_(system_tray), |
| 302 show_message_center_on_unlock_(false), | 303 show_message_center_on_unlock_(false), |
| 303 should_update_tray_content_(false), | 304 should_update_tray_content_(false), |
| 304 should_block_shelf_auto_hide_(false) { | 305 should_block_shelf_auto_hide_(false) { |
| 305 DCHECK(shelf); | 306 DCHECK(shelf); |
| 306 DCHECK(status_area_window_); | 307 DCHECK(status_area_window_); |
| 307 DCHECK(system_tray_); | 308 DCHECK(system_tray_); |
| 308 | 309 |
| 309 gfx::ImageSkia bell_image; | 310 const bool md_shelf = MaterialDesignController::IsShelfMaterial(); |
| 310 if (MaterialDesignController::IsShelfMaterial()) { | 311 gfx::ImageSkia bell_image = |
| 311 bell_image = CreateVectorIcon(gfx::VectorIconId::SHELF_NOTIFICATIONS, | 312 md_shelf |
| 312 kShelfIconColor); | 313 ? CreateVectorIcon(kShelfNotificationsIcon, kShelfIconColor) |
| 313 } else { | 314 : CreateVectorIcon(gfx::VectorIconId::NOTIFICATIONS, |
| 314 bell_image = | 315 kNoUnreadIconSize, kWebNotificationColorNoUnread); |
| 315 CreateVectorIcon(gfx::VectorIconId::NOTIFICATIONS, kNoUnreadIconSize, | 316 const gfx::Size bell_icon_size = |
| 316 kWebNotificationColorNoUnread); | 317 md_shelf ? kTrayItemInnerIconSize : kTrayItemInnerBellIconSizeNonMd; |
| 317 } | 318 bell_icon_.reset(new WebNotificationImage(bell_image, bell_icon_size, |
| 318 bell_icon_.reset(new WebNotificationImage(bell_image, | |
| 319 kTrayItemInnerBellIconSize, | |
| 320 animation_container_.get(), this)); | 319 animation_container_.get(), this)); |
| 321 tray_container()->AddChildView(bell_icon_.get()); | 320 tray_container()->AddChildView(bell_icon_.get()); |
| 322 | 321 |
| 323 counter_.reset(new WebNotificationLabel(animation_container_.get(), this)); | 322 counter_.reset(new WebNotificationLabel(animation_container_.get(), this)); |
| 324 tray_container()->AddChildView(counter_.get()); | 323 tray_container()->AddChildView(counter_.get()); |
| 325 | 324 |
| 326 SetContentsBackground(); | 325 SetContentsBackground(); |
| 327 message_center_tray_.reset(new message_center::MessageCenterTray( | 326 message_center_tray_.reset(new message_center::MessageCenterTray( |
| 328 this, message_center::MessageCenter::Get())); | 327 this, message_center::MessageCenter::Get())); |
| 329 popup_alignment_delegate_.reset(new AshPopupAlignmentDelegate(shelf)); | 328 popup_alignment_delegate_.reset(new AshPopupAlignmentDelegate(shelf)); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 668 | 667 |
| 669 message_center::MessageCenterBubble* | 668 message_center::MessageCenterBubble* |
| 670 WebNotificationTray::GetMessageCenterBubbleForTest() { | 669 WebNotificationTray::GetMessageCenterBubbleForTest() { |
| 671 if (!message_center_bubble()) | 670 if (!message_center_bubble()) |
| 672 return NULL; | 671 return NULL; |
| 673 return static_cast<message_center::MessageCenterBubble*>( | 672 return static_cast<message_center::MessageCenterBubble*>( |
| 674 message_center_bubble()->bubble()); | 673 message_center_bubble()->bubble()); |
| 675 } | 674 } |
| 676 | 675 |
| 677 } // namespace ash | 676 } // namespace ash |
| OLD | NEW |