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

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

Issue 2103603002: mash: Remove StatusAreaWidget references from system tray classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments, rename SetSystemTrayHeight to SetTrayBubbleHeight 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
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/system/tray/system_tray_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/system/tray/system_tray.h" 5 #include "ash/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/session/session_state_delegate.h" 9 #include "ash/common/session/session_state_delegate.h"
10 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
11 #include "ash/common/shelf/wm_shelf_util.h" 11 #include "ash/common/shelf/wm_shelf_util.h"
12 #include "ash/common/shell_window_ids.h" 12 #include "ash/common/shell_window_ids.h"
13 #include "ash/common/system/date/tray_date.h" 13 #include "ash/common/system/date/tray_date.h"
14 #include "ash/common/system/tray/system_tray_delegate.h" 14 #include "ash/common/system/tray/system_tray_delegate.h"
15 #include "ash/common/system/tray/system_tray_item.h" 15 #include "ash/common/system/tray/system_tray_item.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_accessibility.h" 18 #include "ash/common/system/tray_accessibility.h"
19 #include "ash/common/system/update/tray_update.h" 19 #include "ash/common/system/update/tray_update.h"
20 #include "ash/common/system/user/tray_user_separator.h" 20 #include "ash/common/system/user/tray_user_separator.h"
21 #include "ash/common/system/web_notification/web_notification_tray.h"
21 #include "ash/common/wm_lookup.h" 22 #include "ash/common/wm_lookup.h"
22 #include "ash/common/wm_root_window_controller.h" 23 #include "ash/common/wm_root_window_controller.h"
23 #include "ash/common/wm_shell.h" 24 #include "ash/common/wm_shell.h"
24 #include "ash/common/wm_window.h" 25 #include "ash/common/wm_window.h"
25 #include "ash/shell.h" 26 #include "ash/shell.h"
26 #include "ash/system/cast/tray_cast.h" 27 #include "ash/system/cast/tray_cast.h"
27 #include "ash/system/status_area_widget.h"
28 #include "ash/system/user/tray_user.h" 28 #include "ash/system/user/tray_user.h"
29 #include "ash/system/web_notification/web_notification_tray.h"
30 #include "base/logging.h" 29 #include "base/logging.h"
31 #include "base/metrics/histogram.h" 30 #include "base/metrics/histogram.h"
32 #include "base/strings/utf_string_conversions.h" 31 #include "base/strings/utf_string_conversions.h"
33 #include "base/timer/timer.h" 32 #include "base/timer/timer.h"
34 #include "grit/ash_strings.h" 33 #include "grit/ash_strings.h"
35 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
36 #include "ui/compositor/layer.h" 35 #include "ui/compositor/layer.h"
37 #include "ui/display/display.h" 36 #include "ui/display/display.h"
38 #include "ui/display/screen.h" 37 #include "ui/display/screen.h"
39 #include "ui/events/event_constants.h" 38 #include "ui/events/event_constants.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 private: 119 private:
121 std::unique_ptr<SystemTrayBubble> bubble_; 120 std::unique_ptr<SystemTrayBubble> bubble_;
122 std::unique_ptr<TrayBubbleWrapper> bubble_wrapper_; 121 std::unique_ptr<TrayBubbleWrapper> bubble_wrapper_;
123 bool is_persistent_; 122 bool is_persistent_;
124 123
125 DISALLOW_COPY_AND_ASSIGN(SystemBubbleWrapper); 124 DISALLOW_COPY_AND_ASSIGN(SystemBubbleWrapper);
126 }; 125 };
127 126
128 // SystemTray 127 // SystemTray
129 128
130 SystemTray::SystemTray(StatusAreaWidget* status_area_widget) 129 SystemTray::SystemTray(WmShelf* wm_shelf)
131 : TrayBackgroundView(status_area_widget->wm_shelf()), 130 : TrayBackgroundView(wm_shelf),
132 status_area_widget_(status_area_widget), 131 web_notification_tray_(nullptr),
133 items_(),
134 detailed_item_(nullptr), 132 detailed_item_(nullptr),
135 default_bubble_height_(0), 133 default_bubble_height_(0),
136 hide_notifications_(false), 134 hide_notifications_(false),
137 full_system_tray_menu_(false), 135 full_system_tray_menu_(false),
138 tray_accessibility_(nullptr), 136 tray_accessibility_(nullptr),
139 tray_cast_(nullptr), 137 tray_cast_(nullptr),
140 tray_date_(nullptr), 138 tray_date_(nullptr),
141 tray_update_(nullptr), 139 tray_update_(nullptr),
142 screen_capture_tray_item_(nullptr), 140 screen_capture_tray_item_(nullptr),
143 screen_share_tray_item_(nullptr) { 141 screen_share_tray_item_(nullptr) {
144 DCHECK(status_area_widget_);
145 SetContentsBackground(); 142 SetContentsBackground();
146 } 143 }
147 144
148 SystemTray::~SystemTray() { 145 SystemTray::~SystemTray() {
149 // Destroy any child views that might have back pointers before ~View(). 146 // Destroy any child views that might have back pointers before ~View().
150 system_bubble_.reset(); 147 system_bubble_.reset();
151 notification_bubble_.reset(); 148 notification_bubble_.reset();
152 for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); 149 for (std::vector<SystemTrayItem*>::iterator it = items_.begin();
153 it != items_.end(); ++it) { 150 it != items_.end(); ++it) {
154 (*it)->DestroyTrayView(); 151 (*it)->DestroyTrayView();
155 } 152 }
156 } 153 }
157 154
158 void SystemTray::InitializeTrayItems(SystemTrayDelegate* delegate) { 155 void SystemTray::InitializeTrayItems(
156 SystemTrayDelegate* delegate,
157 WebNotificationTray* web_notification_tray) {
158 DCHECK(web_notification_tray);
159 web_notification_tray_ = web_notification_tray;
159 TrayBackgroundView::Initialize(); 160 TrayBackgroundView::Initialize();
160 CreateItems(delegate); 161 CreateItems(delegate);
161 } 162 }
162 163
164 void SystemTray::Shutdown() {
165 DCHECK(web_notification_tray_);
166 web_notification_tray_ = nullptr;
167 }
168
163 void SystemTray::CreateItems(SystemTrayDelegate* delegate) { 169 void SystemTray::CreateItems(SystemTrayDelegate* delegate) {
164 WmShell* wm_shell = WmShell::Get(); 170 WmShell* wm_shell = WmShell::Get();
165 #if !defined(OS_WIN) 171 #if !defined(OS_WIN)
166 // Create user items for each possible user. 172 // Create user items for each possible user.
167 int maximum_user_profiles = 173 int maximum_user_profiles =
168 wm_shell->GetSessionStateDelegate()->GetMaximumNumberOfLoggedInUsers(); 174 wm_shell->GetSessionStateDelegate()->GetMaximumNumberOfLoggedInUsers();
169 for (int i = 0; i < maximum_user_profiles; i++) 175 for (int i = 0; i < maximum_user_profiles; i++)
170 AddTrayItem(new TrayUser(this, i)); 176 AddTrayItem(new TrayUser(this, i));
171 177
172 if (maximum_user_profiles > 1) { 178 if (maximum_user_profiles > 1) {
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 587
582 int height = 0; 588 int height = 0;
583 if (bubble_view) { 589 if (bubble_view) {
584 gfx::Rect work_area = 590 gfx::Rect work_area =
585 display::Screen::GetScreen() 591 display::Screen::GetScreen()
586 ->GetDisplayNearestWindow(bubble_view->GetWidget()->GetNativeView()) 592 ->GetDisplayNearestWindow(bubble_view->GetWidget()->GetNativeView())
587 .work_area(); 593 .work_area();
588 height = 594 height =
589 std::max(0, work_area.height() - bubble_view->GetBoundsInScreen().y()); 595 std::max(0, work_area.height() - bubble_view->GetBoundsInScreen().y());
590 } 596 }
591 status_area_widget_->web_notification_tray()->SetSystemTrayHeight(height); 597 if (web_notification_tray_)
598 web_notification_tray_->SetTrayBubbleHeight(height);
592 } 599 }
593 600
594 base::string16 SystemTray::GetAccessibleTimeString( 601 base::string16 SystemTray::GetAccessibleTimeString(
595 const base::Time& now) const { 602 const base::Time& now) const {
596 base::HourClockType hour_type = 603 base::HourClockType hour_type =
597 WmShell::Get()->system_tray_delegate()->GetHourClockType(); 604 WmShell::Get()->system_tray_delegate()->GetHourClockType();
598 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type, 605 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type,
599 base::kKeepAmPm); 606 base::kKeepAmPm);
600 } 607 }
601 608
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 .work_area() 769 .work_area()
763 .height(); 770 .height();
764 if (work_area_height > 0) { 771 if (work_area_height > 0) {
765 UMA_HISTOGRAM_CUSTOM_COUNTS( 772 UMA_HISTOGRAM_CUSTOM_COUNTS(
766 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", 773 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu",
767 100 * bubble_view->height() / work_area_height, 1, 300, 100); 774 100 * bubble_view->height() / work_area_height, 1, 300, 100);
768 } 775 }
769 } 776 }
770 777
771 } // namespace ash 778 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/system/tray/system_tray_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698