Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(625)

Side by Side Diff: ash/common/system/tray/system_tray.cc

Issue 2147143002: [Chrome OS MD] Draw a 1px separator between 2 tray items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/tray/system_tray.h" 5 #include "ash/common/system/tray/system_tray.h"
6 6
7 #include "ash/common/ash_switches.h" 7 #include "ash/common/ash_switches.h"
8 #include "ash/common/login_status.h" 8 #include "ash/common/login_status.h"
9 #include "ash/common/material_design/material_design_controller.h"
9 #include "ash/common/session/session_state_delegate.h" 10 #include "ash/common/session/session_state_delegate.h"
10 #include "ash/common/shelf/wm_shelf.h" 11 #include "ash/common/shelf/wm_shelf.h"
11 #include "ash/common/shelf/wm_shelf_util.h" 12 #include "ash/common/shelf/wm_shelf_util.h"
12 #include "ash/common/shell_window_ids.h" 13 #include "ash/common/shell_window_ids.h"
13 #include "ash/common/system/cast/tray_cast.h" 14 #include "ash/common/system/cast/tray_cast.h"
14 #include "ash/common/system/date/tray_date.h" 15 #include "ash/common/system/date/tray_date.h"
15 #include "ash/common/system/tray/system_tray_delegate.h" 16 #include "ash/common/system/tray/system_tray_delegate.h"
16 #include "ash/common/system/tray/system_tray_item.h" 17 #include "ash/common/system/tray/system_tray_item.h"
17 #include "ash/common/system/tray/tray_bubble_wrapper.h" 18 #include "ash/common/system/tray/tray_bubble_wrapper.h"
18 #include "ash/common/system/tray/tray_constants.h" 19 #include "ash/common/system/tray/tray_constants.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 #include "ui/message_center/message_center.h" 67 #include "ui/message_center/message_center.h"
67 #endif 68 #endif
68 69
69 using views::TrayBubbleView; 70 using views::TrayBubbleView;
70 71
71 namespace ash { 72 namespace ash {
72 73
73 // The minimum width of the system tray menu width. 74 // The minimum width of the system tray menu width.
74 const int kMinimumSystemTrayMenuWidth = 300; 75 const int kMinimumSystemTrayMenuWidth = 300;
75 76
77 // Padding used to adjust the user-visible size of status tray dark background.
78 const int kBackgroundTrayPadding = 3;
79
76 // Class to initialize and manage the SystemTrayBubble and TrayBubbleWrapper 80 // Class to initialize and manage the SystemTrayBubble and TrayBubbleWrapper
77 // instances for a bubble. 81 // instances for a bubble.
78 82
79 class SystemBubbleWrapper { 83 class SystemBubbleWrapper {
80 public: 84 public:
81 // Takes ownership of |bubble|. 85 // Takes ownership of |bubble|.
82 explicit SystemBubbleWrapper(SystemTrayBubble* bubble) 86 explicit SystemBubbleWrapper(SystemTrayBubble* bubble)
83 : bubble_(bubble), is_persistent_(false) {} 87 : bubble_(bubble), is_persistent_(false) {}
84 88
85 // Initializes the bubble view and creates |bubble_wrapper_|. 89 // Initializes the bubble view and creates |bubble_wrapper_|.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 (*it)->DestroyTrayView(); 152 (*it)->DestroyTrayView();
149 } 153 }
150 } 154 }
151 155
152 void SystemTray::InitializeTrayItems( 156 void SystemTray::InitializeTrayItems(
153 SystemTrayDelegate* delegate, 157 SystemTrayDelegate* delegate,
154 WebNotificationTray* web_notification_tray) { 158 WebNotificationTray* web_notification_tray) {
155 DCHECK(web_notification_tray); 159 DCHECK(web_notification_tray);
156 web_notification_tray_ = web_notification_tray; 160 web_notification_tray_ = web_notification_tray;
157 TrayBackgroundView::Initialize(); 161 TrayBackgroundView::Initialize();
162 AdjustStatusTrayBackground();
158 CreateItems(delegate); 163 CreateItems(delegate);
159 } 164 }
160 165
161 void SystemTray::Shutdown() { 166 void SystemTray::Shutdown() {
162 DCHECK(web_notification_tray_); 167 DCHECK(web_notification_tray_);
163 web_notification_tray_ = nullptr; 168 web_notification_tray_ = nullptr;
164 } 169 }
165 170
166 void SystemTray::CreateItems(SystemTrayDelegate* delegate) { 171 void SystemTray::CreateItems(SystemTrayDelegate* delegate) {
167 WmShell* wm_shell = WmShell::Get(); 172 WmShell* wm_shell = WmShell::Get();
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 base::HourClockType hour_type = 625 base::HourClockType hour_type =
621 WmShell::Get()->system_tray_delegate()->GetHourClockType(); 626 WmShell::Get()->system_tray_delegate()->GetHourClockType();
622 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type, 627 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type,
623 base::kKeepAmPm); 628 base::kKeepAmPm);
624 } 629 }
625 630
626 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { 631 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) {
627 if (alignment == shelf_alignment()) 632 if (alignment == shelf_alignment())
628 return; 633 return;
629 TrayBackgroundView::SetShelfAlignment(alignment); 634 TrayBackgroundView::SetShelfAlignment(alignment);
635 if (!ash::MaterialDesignController::IsShelfMaterial())
636 AdjustStatusTrayBackground();
637
630 UpdateAfterShelfAlignmentChange(alignment); 638 UpdateAfterShelfAlignmentChange(alignment);
631 // Destroy any existing bubble so that it is rebuilt correctly. 639 // Destroy any existing bubble so that it is rebuilt correctly.
632 CloseSystemBubbleAndDeactivateSystemTray(); 640 CloseSystemBubbleAndDeactivateSystemTray();
633 // Rebuild any notification bubble. 641 // Rebuild any notification bubble.
634 if (notification_bubble_) { 642 if (notification_bubble_) {
635 notification_bubble_.reset(); 643 notification_bubble_.reset();
636 UpdateNotificationBubble(); 644 UpdateNotificationBubble();
637 // UpdateWebNotifications() should be called in UpdateNotificationBubble(). 645 // UpdateWebNotifications() should be called in UpdateNotificationBubble().
638 } else if (!hide_notifications_) { 646 } else if (!hide_notifications_) {
639 UpdateWebNotifications(); 647 UpdateWebNotifications();
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 ->GetDisplayNearestWindow(bubble_view->GetWidget()->GetNativeView()) 795 ->GetDisplayNearestWindow(bubble_view->GetWidget()->GetNativeView())
788 .work_area() 796 .work_area()
789 .height(); 797 .height();
790 if (work_area_height > 0) { 798 if (work_area_height > 0) {
791 UMA_HISTOGRAM_CUSTOM_COUNTS( 799 UMA_HISTOGRAM_CUSTOM_COUNTS(
792 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", 800 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu",
793 100 * bubble_view->height() / work_area_height, 1, 300, 100); 801 100 * bubble_view->height() / work_area_height, 1, 300, 100);
794 } 802 }
795 } 803 }
796 804
805 void SystemTray::AdjustStatusTrayBackground() {
806 if (!ash::MaterialDesignController::IsShelfMaterial()) {
807 tray_container()->SetBorder(
808 views::Border::CreateEmptyBorder(gfx::Insets(kBackgroundTrayPadding)));
809 }
810 }
811
797 } // namespace ash 812 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698