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

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: merge Created 4 years, 5 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 #include "ui/message_center/message_center.h" 66 #include "ui/message_center/message_center.h"
66 #endif 67 #endif
67 68
68 using views::TrayBubbleView; 69 using views::TrayBubbleView;
69 70
70 namespace ash { 71 namespace ash {
71 72
72 // The minimum width of the system tray menu width. 73 // The minimum width of the system tray menu width.
73 const int kMinimumSystemTrayMenuWidth = 300; 74 const int kMinimumSystemTrayMenuWidth = 300;
74 75
76 // Padding used to adjust the user-visible size of status tray dark background.
77 const int kBackgroundTrayPadding = 3;
varkha 2016/07/14 21:34:47 Should this live in a common place?
yiyix 2016/07/26 20:27:31 I was thinking that the overview button padding co
78
75 // Class to initialize and manage the SystemTrayBubble and TrayBubbleWrapper 79 // Class to initialize and manage the SystemTrayBubble and TrayBubbleWrapper
76 // instances for a bubble. 80 // instances for a bubble.
77 81
78 class SystemBubbleWrapper { 82 class SystemBubbleWrapper {
79 public: 83 public:
80 // Takes ownership of |bubble|. 84 // Takes ownership of |bubble|.
81 explicit SystemBubbleWrapper(SystemTrayBubble* bubble) 85 explicit SystemBubbleWrapper(SystemTrayBubble* bubble)
82 : bubble_(bubble), is_persistent_(false) {} 86 : bubble_(bubble), is_persistent_(false) {}
83 87
84 // Initializes the bubble view and creates |bubble_wrapper_|. 88 // Initializes the bubble view and creates |bubble_wrapper_|.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 (*it)->DestroyTrayView(); 150 (*it)->DestroyTrayView();
147 } 151 }
148 } 152 }
149 153
150 void SystemTray::InitializeTrayItems( 154 void SystemTray::InitializeTrayItems(
151 SystemTrayDelegate* delegate, 155 SystemTrayDelegate* delegate,
152 WebNotificationTray* web_notification_tray) { 156 WebNotificationTray* web_notification_tray) {
153 DCHECK(web_notification_tray); 157 DCHECK(web_notification_tray);
154 web_notification_tray_ = web_notification_tray; 158 web_notification_tray_ = web_notification_tray;
155 TrayBackgroundView::Initialize(); 159 TrayBackgroundView::Initialize();
160 AdjustStatusTrayBackground();
156 CreateItems(delegate); 161 CreateItems(delegate);
157 } 162 }
158 163
159 void SystemTray::Shutdown() { 164 void SystemTray::Shutdown() {
160 DCHECK(web_notification_tray_); 165 DCHECK(web_notification_tray_);
161 web_notification_tray_ = nullptr; 166 web_notification_tray_ = nullptr;
162 } 167 }
163 168
164 void SystemTray::CreateItems(SystemTrayDelegate* delegate) { 169 void SystemTray::CreateItems(SystemTrayDelegate* delegate) {
165 WmShell* wm_shell = WmShell::Get(); 170 WmShell* wm_shell = WmShell::Get();
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 const base::Time& now) const { 605 const base::Time& now) const {
601 base::HourClockType hour_type = 606 base::HourClockType hour_type =
602 WmShell::Get()->system_tray_delegate()->GetHourClockType(); 607 WmShell::Get()->system_tray_delegate()->GetHourClockType();
603 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type, 608 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type,
604 base::kKeepAmPm); 609 base::kKeepAmPm);
605 } 610 }
606 611
607 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { 612 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) {
608 if (alignment == shelf_alignment()) 613 if (alignment == shelf_alignment())
609 return; 614 return;
615
varkha 2016/07/14 21:34:47 nit: no ws.
yiyix 2016/07/26 20:27:31 On 2016/07/14 21:34:47, varkha wrote: > nit: no ws
610 TrayBackgroundView::SetShelfAlignment(alignment); 616 TrayBackgroundView::SetShelfAlignment(alignment);
617 AdjustStatusTrayBackground();
varkha 2016/07/14 21:34:47 Same questions / comments as in overview_button_tr
yiyix 2016/07/26 20:27:31 Done.
611 UpdateAfterShelfAlignmentChange(alignment); 618 UpdateAfterShelfAlignmentChange(alignment);
612 // Destroy any existing bubble so that it is rebuilt correctly. 619 // Destroy any existing bubble so that it is rebuilt correctly.
613 CloseSystemBubbleAndDeactivateSystemTray(); 620 CloseSystemBubbleAndDeactivateSystemTray();
614 // Rebuild any notification bubble. 621 // Rebuild any notification bubble.
615 if (notification_bubble_) { 622 if (notification_bubble_) {
616 notification_bubble_.reset(); 623 notification_bubble_.reset();
617 UpdateNotificationBubble(); 624 UpdateNotificationBubble();
618 // UpdateWebNotifications() should be called in UpdateNotificationBubble(). 625 // UpdateWebNotifications() should be called in UpdateNotificationBubble().
619 } else if (!hide_notifications_) { 626 } else if (!hide_notifications_) {
620 UpdateWebNotifications(); 627 UpdateWebNotifications();
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 ->GetDisplayNearestWindow(bubble_view->GetWidget()->GetNativeView()) 773 ->GetDisplayNearestWindow(bubble_view->GetWidget()->GetNativeView())
767 .work_area() 774 .work_area()
768 .height(); 775 .height();
769 if (work_area_height > 0) { 776 if (work_area_height > 0) {
770 UMA_HISTOGRAM_CUSTOM_COUNTS( 777 UMA_HISTOGRAM_CUSTOM_COUNTS(
771 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", 778 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu",
772 100 * bubble_view->height() / work_area_height, 1, 300, 100); 779 100 * bubble_view->height() / work_area_height, 1, 300, 100);
773 } 780 }
774 } 781 }
775 782
783 void SystemTray::AdjustStatusTrayBackground() {
784 if (!ash::MaterialDesignController::IsShelfMaterial()) {
785 tray_container()->SetBorder(views::Border::CreateEmptyBorder(
786 kBackgroundTrayPadding, kBackgroundTrayPadding, kBackgroundTrayPadding,
787 kBackgroundTrayPadding));
788 }
789 }
790
776 } // namespace ash 791 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698