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 217 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 |
| 310 const bool md_shelf = MaterialDesignController::IsShelfMaterial(); | |
| 309 gfx::ImageSkia bell_image; | 311 gfx::ImageSkia bell_image; |
| 310 if (MaterialDesignController::IsShelfMaterial()) { | 312 if (md_shelf) { |
| 311 bell_image = CreateVectorIcon(gfx::VectorIconId::SHELF_NOTIFICATIONS, | 313 bell_image = CreateVectorIcon(kShelfNotificationsIcon, kShelfIconColor); |
|
Evan Stade
2016/09/09 20:39:56
ternary operator?
tdanderson
2016/09/09 21:15:10
Done.
| |
| 312 kShelfIconColor); | |
| 313 } else { | 314 } else { |
| 314 bell_image = | 315 bell_image = |
| 315 CreateVectorIcon(gfx::VectorIconId::NOTIFICATIONS, kNoUnreadIconSize, | 316 CreateVectorIcon(gfx::VectorIconId::NOTIFICATIONS, kNoUnreadIconSize, |
| 316 kWebNotificationColorNoUnread); | 317 kWebNotificationColorNoUnread); |
| 317 } | 318 } |
| 318 bell_icon_.reset(new WebNotificationImage(bell_image, | 319 const gfx::Size bell_icon_size = |
| 319 kTrayItemInnerBellIconSize, | 320 md_shelf ? kTrayItemInnerIconSize : kTrayItemInnerBellIconSizeNonMd; |
| 321 bell_icon_.reset(new WebNotificationImage(bell_image, bell_icon_size, | |
| 320 animation_container_.get(), this)); | 322 animation_container_.get(), this)); |
| 321 tray_container()->AddChildView(bell_icon_.get()); | 323 tray_container()->AddChildView(bell_icon_.get()); |
| 322 | 324 |
| 323 counter_.reset(new WebNotificationLabel(animation_container_.get(), this)); | 325 counter_.reset(new WebNotificationLabel(animation_container_.get(), this)); |
| 324 tray_container()->AddChildView(counter_.get()); | 326 tray_container()->AddChildView(counter_.get()); |
| 325 | 327 |
| 326 SetContentsBackground(); | 328 SetContentsBackground(); |
| 327 message_center_tray_.reset(new message_center::MessageCenterTray( | 329 message_center_tray_.reset(new message_center::MessageCenterTray( |
| 328 this, message_center::MessageCenter::Get())); | 330 this, message_center::MessageCenter::Get())); |
| 329 popup_alignment_delegate_.reset(new AshPopupAlignmentDelegate(shelf)); | 331 popup_alignment_delegate_.reset(new AshPopupAlignmentDelegate(shelf)); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 668 | 670 |
| 669 message_center::MessageCenterBubble* | 671 message_center::MessageCenterBubble* |
| 670 WebNotificationTray::GetMessageCenterBubbleForTest() { | 672 WebNotificationTray::GetMessageCenterBubbleForTest() { |
| 671 if (!message_center_bubble()) | 673 if (!message_center_bubble()) |
| 672 return NULL; | 674 return NULL; |
| 673 return static_cast<message_center::MessageCenterBubble*>( | 675 return static_cast<message_center::MessageCenterBubble*>( |
| 674 message_center_bubble()->bubble()); | 676 message_center_bubble()->bubble()); |
| 675 } | 677 } |
| 676 | 678 |
| 677 } // namespace ash | 679 } // namespace ash |
| OLD | NEW |