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

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, 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"
12 #include "ash/common/shelf/wm_shelf_observer.h"
11 #include "ash/common/shelf/wm_shelf_util.h" 13 #include "ash/common/shelf/wm_shelf_util.h"
12 #include "ash/common/shell_window_ids.h" 14 #include "ash/common/shell_window_ids.h"
13 #include "ash/common/system/cast/tray_cast.h" 15 #include "ash/common/system/cast/tray_cast.h"
14 #include "ash/common/system/date/tray_date.h" 16 #include "ash/common/system/date/tray_date.h"
15 #include "ash/common/system/tray/system_tray_delegate.h" 17 #include "ash/common/system/tray/system_tray_delegate.h"
16 #include "ash/common/system/tray/system_tray_item.h" 18 #include "ash/common/system/tray/system_tray_item.h"
17 #include "ash/common/system/tray/tray_bubble_wrapper.h" 19 #include "ash/common/system/tray/tray_bubble_wrapper.h"
18 #include "ash/common/system/tray/tray_constants.h" 20 #include "ash/common/system/tray/tray_constants.h"
19 #include "ash/common/system/tray_accessibility.h" 21 #include "ash/common/system/tray_accessibility.h"
20 #include "ash/common/system/update/tray_update.h" 22 #include "ash/common/system/update/tray_update.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 #include "ui/message_center/message_center.h" 68 #include "ui/message_center/message_center.h"
67 #endif 69 #endif
68 70
69 using views::TrayBubbleView; 71 using views::TrayBubbleView;
70 72
71 namespace ash { 73 namespace ash {
72 74
73 // The minimum width of the system tray menu width. 75 // The minimum width of the system tray menu width.
74 const int kMinimumSystemTrayMenuWidth = 300; 76 const int kMinimumSystemTrayMenuWidth = 300;
75 77
78 // Padding used to adjust the user-visible size of status tray dark background.
79 const int kBackgroundTrayPadding = 3;
80
76 // Class to initialize and manage the SystemTrayBubble and TrayBubbleWrapper 81 // Class to initialize and manage the SystemTrayBubble and TrayBubbleWrapper
77 // instances for a bubble. 82 // instances for a bubble.
78 83
79 class SystemBubbleWrapper { 84 class SystemBubbleWrapper {
80 public: 85 public:
81 // Takes ownership of |bubble|. 86 // Takes ownership of |bubble|.
82 explicit SystemBubbleWrapper(SystemTrayBubble* bubble) 87 explicit SystemBubbleWrapper(SystemTrayBubble* bubble)
83 : bubble_(bubble), is_persistent_(false) {} 88 : bubble_(bubble), is_persistent_(false) {}
84 89
85 // Initializes the bubble view and creates |bubble_wrapper_|. 90 // Initializes the bubble view and creates |bubble_wrapper_|.
(...skipping 29 matching lines...) Expand all
115 private: 120 private:
116 std::unique_ptr<SystemTrayBubble> bubble_; 121 std::unique_ptr<SystemTrayBubble> bubble_;
117 std::unique_ptr<TrayBubbleWrapper> bubble_wrapper_; 122 std::unique_ptr<TrayBubbleWrapper> bubble_wrapper_;
118 bool is_persistent_; 123 bool is_persistent_;
119 124
120 DISALLOW_COPY_AND_ASSIGN(SystemBubbleWrapper); 125 DISALLOW_COPY_AND_ASSIGN(SystemBubbleWrapper);
121 }; 126 };
122 127
123 // SystemTray 128 // SystemTray
124 129
125 SystemTray::SystemTray(WmShelf* wm_shelf) 130 SystemTray::SystemTray(WmShelf* wm_shelf, WmShelfObserver* wm_shelf_observer)
126 : TrayBackgroundView(wm_shelf), 131 : TrayBackgroundView(wm_shelf, wm_shelf_observer),
127 web_notification_tray_(nullptr), 132 web_notification_tray_(nullptr),
128 detailed_item_(nullptr), 133 detailed_item_(nullptr),
129 default_bubble_height_(0), 134 default_bubble_height_(0),
130 hide_notifications_(false), 135 hide_notifications_(false),
131 full_system_tray_menu_(false), 136 full_system_tray_menu_(false),
132 tray_accessibility_(nullptr), 137 tray_accessibility_(nullptr),
133 tray_audio_(nullptr), 138 tray_audio_(nullptr),
134 tray_cast_(nullptr), 139 tray_cast_(nullptr),
135 tray_date_(nullptr), 140 tray_date_(nullptr),
136 tray_update_(nullptr), 141 tray_update_(nullptr),
(...skipping 11 matching lines...) Expand all
148 (*it)->DestroyTrayView(); 153 (*it)->DestroyTrayView();
149 } 154 }
150 } 155 }
151 156
152 void SystemTray::InitializeTrayItems( 157 void SystemTray::InitializeTrayItems(
153 SystemTrayDelegate* delegate, 158 SystemTrayDelegate* delegate,
154 WebNotificationTray* web_notification_tray) { 159 WebNotificationTray* web_notification_tray) {
155 DCHECK(web_notification_tray); 160 DCHECK(web_notification_tray);
156 web_notification_tray_ = web_notification_tray; 161 web_notification_tray_ = web_notification_tray;
157 TrayBackgroundView::Initialize(); 162 TrayBackgroundView::Initialize();
163 AdjustStatusTrayBackground();
158 CreateItems(delegate); 164 CreateItems(delegate);
159 } 165 }
160 166
161 void SystemTray::Shutdown() { 167 void SystemTray::Shutdown() {
162 DCHECK(web_notification_tray_); 168 DCHECK(web_notification_tray_);
163 web_notification_tray_ = nullptr; 169 web_notification_tray_ = nullptr;
164 } 170 }
165 171
166 void SystemTray::CreateItems(SystemTrayDelegate* delegate) { 172 void SystemTray::CreateItems(SystemTrayDelegate* delegate) {
167 WmShell* wm_shell = WmShell::Get(); 173 WmShell* wm_shell = WmShell::Get();
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 base::HourClockType hour_type = 626 base::HourClockType hour_type =
621 WmShell::Get()->system_tray_delegate()->GetHourClockType(); 627 WmShell::Get()->system_tray_delegate()->GetHourClockType();
622 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type, 628 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type,
623 base::kKeepAmPm); 629 base::kKeepAmPm);
624 } 630 }
625 631
626 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { 632 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) {
627 if (alignment == shelf_alignment()) 633 if (alignment == shelf_alignment())
628 return; 634 return;
629 TrayBackgroundView::SetShelfAlignment(alignment); 635 TrayBackgroundView::SetShelfAlignment(alignment);
636 if (!ash::MaterialDesignController::IsShelfMaterial()) {
varkha 2016/08/10 23:27:24 nit: no need for {}.
yiyix 2016/08/11 01:23:19 Done.
637 AdjustStatusTrayBackground();
638 }
630 UpdateAfterShelfAlignmentChange(alignment); 639 UpdateAfterShelfAlignmentChange(alignment);
631 // Destroy any existing bubble so that it is rebuilt correctly. 640 // Destroy any existing bubble so that it is rebuilt correctly.
632 CloseSystemBubbleAndDeactivateSystemTray(); 641 CloseSystemBubbleAndDeactivateSystemTray();
633 // Rebuild any notification bubble. 642 // Rebuild any notification bubble.
634 if (notification_bubble_) { 643 if (notification_bubble_) {
635 notification_bubble_.reset(); 644 notification_bubble_.reset();
636 UpdateNotificationBubble(); 645 UpdateNotificationBubble();
637 // UpdateWebNotifications() should be called in UpdateNotificationBubble(). 646 // UpdateWebNotifications() should be called in UpdateNotificationBubble().
638 } else if (!hide_notifications_) { 647 } else if (!hide_notifications_) {
639 UpdateWebNotifications(); 648 UpdateWebNotifications();
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 ->GetDisplayNearestWindow(bubble_view->GetWidget()->GetNativeView()) 796 ->GetDisplayNearestWindow(bubble_view->GetWidget()->GetNativeView())
788 .work_area() 797 .work_area()
789 .height(); 798 .height();
790 if (work_area_height > 0) { 799 if (work_area_height > 0) {
791 UMA_HISTOGRAM_CUSTOM_COUNTS( 800 UMA_HISTOGRAM_CUSTOM_COUNTS(
792 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", 801 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu",
793 100 * bubble_view->height() / work_area_height, 1, 300, 100); 802 100 * bubble_view->height() / work_area_height, 1, 300, 100);
794 } 803 }
795 } 804 }
796 805
806 void SystemTray::AdjustStatusTrayBackground() {
807 if (!ash::MaterialDesignController::IsShelfMaterial()) {
808 tray_container()->SetBorder(
809 views::Border::CreateEmptyBorder(gfx::Insets(kBackgroundTrayPadding)));
810 }
811 }
812
797 } // namespace ash 813 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698