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

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: new approach 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"
19 #include "ash/common/system/tray_accessibility.h" 20 #include "ash/common/system/tray_accessibility.h"
20 #include "ash/common/system/update/tray_update.h" 21 #include "ash/common/system/update/tray_update.h"
21 #include "ash/common/system/user/tray_user.h" 22 #include "ash/common/system/user/tray_user.h"
22 #include "ash/common/system/user/tray_user_separator.h" 23 #include "ash/common/system/user/tray_user_separator.h"
24 #include "ash/common/system/view_observer.h"
23 #include "ash/common/system/web_notification/web_notification_tray.h" 25 #include "ash/common/system/web_notification/web_notification_tray.h"
24 #include "ash/common/wm_lookup.h" 26 #include "ash/common/wm_lookup.h"
25 #include "ash/common/wm_root_window_controller.h" 27 #include "ash/common/wm_root_window_controller.h"
26 #include "ash/common/wm_shell.h" 28 #include "ash/common/wm_shell.h"
27 #include "ash/common/wm_window.h" 29 #include "ash/common/wm_window.h"
28 #include "base/logging.h" 30 #include "base/logging.h"
29 #include "base/metrics/histogram.h" 31 #include "base/metrics/histogram.h"
30 #include "base/strings/utf_string_conversions.h" 32 #include "base/strings/utf_string_conversions.h"
31 #include "base/timer/timer.h" 33 #include "base/timer/timer.h"
32 #include "grit/ash_strings.h" 34 #include "grit/ash_strings.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 #include "ui/message_center/message_center.h" 67 #include "ui/message_center/message_center.h"
66 #endif 68 #endif
67 69
68 using views::TrayBubbleView; 70 using views::TrayBubbleView;
69 71
70 namespace ash { 72 namespace ash {
71 73
72 // The minimum width of the system tray menu width. 74 // The minimum width of the system tray menu width.
73 const int kMinimumSystemTrayMenuWidth = 300; 75 const int kMinimumSystemTrayMenuWidth = 300;
74 76
77 // Padding used to adjust the user-visible size of status tray dark background.
78 const int kBackgroundTrayPadding = 3;
79
75 // Class to initialize and manage the SystemTrayBubble and TrayBubbleWrapper 80 // Class to initialize and manage the SystemTrayBubble and TrayBubbleWrapper
76 // instances for a bubble. 81 // instances for a bubble.
77 82
78 class SystemBubbleWrapper { 83 class SystemBubbleWrapper {
79 public: 84 public:
80 // Takes ownership of |bubble|. 85 // Takes ownership of |bubble|.
81 explicit SystemBubbleWrapper(SystemTrayBubble* bubble) 86 explicit SystemBubbleWrapper(SystemTrayBubble* bubble)
82 : bubble_(bubble), is_persistent_(false) {} 87 : bubble_(bubble), is_persistent_(false) {}
83 88
84 // Initializes the bubble view and creates |bubble_wrapper_|. 89 // Initializes the bubble view and creates |bubble_wrapper_|.
(...skipping 29 matching lines...) Expand all
114 private: 119 private:
115 std::unique_ptr<SystemTrayBubble> bubble_; 120 std::unique_ptr<SystemTrayBubble> bubble_;
116 std::unique_ptr<TrayBubbleWrapper> bubble_wrapper_; 121 std::unique_ptr<TrayBubbleWrapper> bubble_wrapper_;
117 bool is_persistent_; 122 bool is_persistent_;
118 123
119 DISALLOW_COPY_AND_ASSIGN(SystemBubbleWrapper); 124 DISALLOW_COPY_AND_ASSIGN(SystemBubbleWrapper);
120 }; 125 };
121 126
122 // SystemTray 127 // SystemTray
123 128
124 SystemTray::SystemTray(WmShelf* wm_shelf) 129 SystemTray::SystemTray(WmShelf* wm_shelf, ViewObserver* view_observer)
125 : TrayBackgroundView(wm_shelf), 130 : TrayBackgroundView(wm_shelf, view_observer),
126 web_notification_tray_(nullptr), 131 web_notification_tray_(nullptr),
127 detailed_item_(nullptr), 132 detailed_item_(nullptr),
128 default_bubble_height_(0), 133 default_bubble_height_(0),
129 hide_notifications_(false), 134 hide_notifications_(false),
130 full_system_tray_menu_(false), 135 full_system_tray_menu_(false),
131 tray_accessibility_(nullptr), 136 tray_accessibility_(nullptr),
132 tray_cast_(nullptr), 137 tray_cast_(nullptr),
133 tray_date_(nullptr), 138 tray_date_(nullptr),
134 tray_update_(nullptr), 139 tray_update_(nullptr),
135 screen_capture_tray_item_(nullptr), 140 screen_capture_tray_item_(nullptr),
(...skipping 10 matching lines...) Expand all
146 (*it)->DestroyTrayView(); 151 (*it)->DestroyTrayView();
147 } 152 }
148 } 153 }
149 154
150 void SystemTray::InitializeTrayItems( 155 void SystemTray::InitializeTrayItems(
151 SystemTrayDelegate* delegate, 156 SystemTrayDelegate* delegate,
152 WebNotificationTray* web_notification_tray) { 157 WebNotificationTray* web_notification_tray) {
153 DCHECK(web_notification_tray); 158 DCHECK(web_notification_tray);
154 web_notification_tray_ = web_notification_tray; 159 web_notification_tray_ = web_notification_tray;
155 TrayBackgroundView::Initialize(); 160 TrayBackgroundView::Initialize();
161 AdjustStatusTrayBackground();
156 CreateItems(delegate); 162 CreateItems(delegate);
157 } 163 }
158 164
159 void SystemTray::Shutdown() { 165 void SystemTray::Shutdown() {
160 DCHECK(web_notification_tray_); 166 DCHECK(web_notification_tray_);
161 web_notification_tray_ = nullptr; 167 web_notification_tray_ = nullptr;
162 } 168 }
163 169
164 void SystemTray::CreateItems(SystemTrayDelegate* delegate) { 170 void SystemTray::CreateItems(SystemTrayDelegate* delegate) {
165 WmShell* wm_shell = WmShell::Get(); 171 WmShell* wm_shell = WmShell::Get();
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 base::HourClockType hour_type = 607 base::HourClockType hour_type =
602 WmShell::Get()->system_tray_delegate()->GetHourClockType(); 608 WmShell::Get()->system_tray_delegate()->GetHourClockType();
603 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type, 609 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type,
604 base::kKeepAmPm); 610 base::kKeepAmPm);
605 } 611 }
606 612
607 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { 613 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) {
608 if (alignment == shelf_alignment()) 614 if (alignment == shelf_alignment())
609 return; 615 return;
610 TrayBackgroundView::SetShelfAlignment(alignment); 616 TrayBackgroundView::SetShelfAlignment(alignment);
617 if (!ash::MaterialDesignController::IsShelfMaterial()) {
618 AdjustStatusTrayBackground();
619 }
611 UpdateAfterShelfAlignmentChange(alignment); 620 UpdateAfterShelfAlignmentChange(alignment);
612 // Destroy any existing bubble so that it is rebuilt correctly. 621 // Destroy any existing bubble so that it is rebuilt correctly.
613 CloseSystemBubbleAndDeactivateSystemTray(); 622 CloseSystemBubbleAndDeactivateSystemTray();
614 // Rebuild any notification bubble. 623 // Rebuild any notification bubble.
615 if (notification_bubble_) { 624 if (notification_bubble_) {
616 notification_bubble_.reset(); 625 notification_bubble_.reset();
617 UpdateNotificationBubble(); 626 UpdateNotificationBubble();
618 // UpdateWebNotifications() should be called in UpdateNotificationBubble(). 627 // UpdateWebNotifications() should be called in UpdateNotificationBubble().
619 } else if (!hide_notifications_) { 628 } else if (!hide_notifications_) {
620 UpdateWebNotifications(); 629 UpdateWebNotifications();
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 ->GetDisplayNearestWindow(bubble_view->GetWidget()->GetNativeView()) 777 ->GetDisplayNearestWindow(bubble_view->GetWidget()->GetNativeView())
769 .work_area() 778 .work_area()
770 .height(); 779 .height();
771 if (work_area_height > 0) { 780 if (work_area_height > 0) {
772 UMA_HISTOGRAM_CUSTOM_COUNTS( 781 UMA_HISTOGRAM_CUSTOM_COUNTS(
773 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", 782 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu",
774 100 * bubble_view->height() / work_area_height, 1, 300, 100); 783 100 * bubble_view->height() / work_area_height, 1, 300, 100);
775 } 784 }
776 } 785 }
777 786
787 void SystemTray::AdjustStatusTrayBackground() {
788 if (!ash::MaterialDesignController::IsShelfMaterial()) {
789 tray_container()->SetBorder(
790 views::Border::CreateEmptyBorder(gfx::Insets(kBackgroundTrayPadding)));
791 }
792 }
793
778 } // namespace ash 794 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698