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

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

Issue 2148943002: mash: Create system tray display and rotation lock items via delegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments, add rotation lock 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/test/test_system_tray_delegate.h » ('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"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #include "ash/common/system/chromeos/power/power_status.h" 55 #include "ash/common/system/chromeos/power/power_status.h"
56 #include "ash/common/system/chromeos/power/tray_power.h" 56 #include "ash/common/system/chromeos/power/tray_power.h"
57 #include "ash/common/system/chromeos/screen_security/screen_capture_tray_item.h" 57 #include "ash/common/system/chromeos/screen_security/screen_capture_tray_item.h"
58 #include "ash/common/system/chromeos/screen_security/screen_share_tray_item.h" 58 #include "ash/common/system/chromeos/screen_security/screen_share_tray_item.h"
59 #include "ash/common/system/chromeos/session/tray_session_length_limit.h" 59 #include "ash/common/system/chromeos/session/tray_session_length_limit.h"
60 #include "ash/common/system/chromeos/settings/tray_settings.h" 60 #include "ash/common/system/chromeos/settings/tray_settings.h"
61 #include "ash/common/system/chromeos/supervised/tray_supervised_user.h" 61 #include "ash/common/system/chromeos/supervised/tray_supervised_user.h"
62 #include "ash/common/system/chromeos/tray_caps_lock.h" 62 #include "ash/common/system/chromeos/tray_caps_lock.h"
63 #include "ash/common/system/chromeos/tray_tracing.h" 63 #include "ash/common/system/chromeos/tray_tracing.h"
64 #include "ash/common/system/ime/tray_ime_chromeos.h" 64 #include "ash/common/system/ime/tray_ime_chromeos.h"
65 #include "ash/system/chromeos/rotation/tray_rotation_lock.h"
66 #include "ash/system/chromeos/tray_display.h"
67 #include "ui/message_center/message_center.h" 65 #include "ui/message_center/message_center.h"
68 #endif 66 #endif
69 67
70 using views::TrayBubbleView; 68 using views::TrayBubbleView;
71 69
72 namespace ash { 70 namespace ash {
73 71
74 // The minimum width of the system tray menu width. 72 // The minimum width of the system tray menu width.
75 const int kMinimumSystemTrayMenuWidth = 300; 73 const int kMinimumSystemTrayMenuWidth = 300;
76 74
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 AddTrayItem(new TrayIME(this)); 188 AddTrayItem(new TrayIME(this));
191 AddTrayItem(tray_accessibility_); 189 AddTrayItem(tray_accessibility_);
192 AddTrayItem(new TrayTracing(this)); 190 AddTrayItem(new TrayTracing(this));
193 AddTrayItem(new TrayPower(this, message_center::MessageCenter::Get())); 191 AddTrayItem(new TrayPower(this, message_center::MessageCenter::Get()));
194 AddTrayItem(new TrayNetwork(this)); 192 AddTrayItem(new TrayNetwork(this));
195 AddTrayItem(new TrayVPN(this)); 193 AddTrayItem(new TrayVPN(this));
196 AddTrayItem(new TraySms(this)); 194 AddTrayItem(new TraySms(this));
197 AddTrayItem(new TrayBluetooth(this)); 195 AddTrayItem(new TrayBluetooth(this));
198 tray_cast_ = new TrayCast(this); 196 tray_cast_ = new TrayCast(this);
199 AddTrayItem(tray_cast_); 197 AddTrayItem(tray_cast_);
200 AddTrayItem(new TrayDisplay(this)); 198 // TODO(jamescook): Remove this when mus has support for display management
199 // and we have a DisplayManager equivalent. See http://crbug.com/548429
200 std::unique_ptr<SystemTrayItem> tray_display =
201 delegate->CreateDisplayTrayItem(this);
202 if (tray_display)
203 AddTrayItem(tray_display.release());
201 screen_capture_tray_item_ = new ScreenCaptureTrayItem(this); 204 screen_capture_tray_item_ = new ScreenCaptureTrayItem(this);
202 AddTrayItem(screen_capture_tray_item_); 205 AddTrayItem(screen_capture_tray_item_);
203 screen_share_tray_item_ = new ScreenShareTrayItem(this); 206 screen_share_tray_item_ = new ScreenShareTrayItem(this);
204 AddTrayItem(screen_share_tray_item_); 207 AddTrayItem(screen_share_tray_item_);
205 AddTrayItem(new MultiProfileMediaTrayItem(this)); 208 AddTrayItem(new MultiProfileMediaTrayItem(this));
206 AddTrayItem(new TrayAudioChromeOs(this)); 209 AddTrayItem(new TrayAudioChromeOs(this));
207 AddTrayItem(new TrayBrightness(this)); 210 AddTrayItem(new TrayBrightness(this));
208 AddTrayItem(new TrayCapsLock(this)); 211 AddTrayItem(new TrayCapsLock(this));
209 AddTrayItem(new TrayRotationLock(this)); 212 // TODO(jamescook): Remove this when mus has support for display management
213 // and we have a DisplayManager equivalent. See http://crbug.com/548429
214 std::unique_ptr<SystemTrayItem> tray_rotation_lock =
215 delegate->CreateRotationLockTrayItem(this);
216 if (tray_rotation_lock)
217 AddTrayItem(tray_rotation_lock.release());
210 AddTrayItem(new TraySettings(this)); 218 AddTrayItem(new TraySettings(this));
211 AddTrayItem(tray_update_); 219 AddTrayItem(tray_update_);
212 AddTrayItem(tray_date_); 220 AddTrayItem(tray_date_);
213 #elif defined(OS_WIN) 221 #elif defined(OS_WIN)
214 AddTrayItem(tray_accessibility_); 222 AddTrayItem(tray_accessibility_);
215 AddTrayItem(tray_update_); 223 AddTrayItem(tray_update_);
216 AddTrayItem(tray_date_); 224 AddTrayItem(tray_date_);
217 #endif 225 #endif
218 226
219 SetVisible(wm_shell->system_tray_delegate()->GetTrayVisibilityOnStartup()); 227 SetVisible(wm_shell->system_tray_delegate()->GetTrayVisibilityOnStartup());
220 } 228 }
221 229
222 void SystemTray::AddTrayItem(SystemTrayItem* item) { 230 void SystemTray::AddTrayItem(SystemTrayItem* item) {
223 items_.push_back(item); 231 items_.push_back(item);
224 232
225 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); 233 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate();
226 views::View* tray_item = item->CreateTrayView(delegate->GetUserLoginStatus()); 234 views::View* tray_item = item->CreateTrayView(delegate->GetUserLoginStatus());
227 item->UpdateAfterShelfAlignmentChange(shelf_alignment()); 235 item->UpdateAfterShelfAlignmentChange(shelf_alignment());
228 236
229 if (tray_item) { 237 if (tray_item) {
230 tray_container()->AddChildViewAt(tray_item, 0); 238 tray_container()->AddChildViewAt(tray_item, 0);
231 PreferredSizeChanged(); 239 PreferredSizeChanged();
232 tray_item_map_[item] = tray_item; 240 tray_item_map_[item] = tray_item;
233 } 241 }
234 } 242 }
235 243
236 void SystemTray::RemoveTrayItem(SystemTrayItem* item) {
237 NOTIMPLEMENTED();
238 }
239
240 const std::vector<SystemTrayItem*>& SystemTray::GetTrayItems() const { 244 const std::vector<SystemTrayItem*>& SystemTray::GetTrayItems() const {
241 return items_.get(); 245 return items_.get();
242 } 246 }
243 247
244 void SystemTray::ShowDefaultView(BubbleCreationType creation_type) { 248 void SystemTray::ShowDefaultView(BubbleCreationType creation_type) {
245 ShowDefaultViewWithOffset( 249 ShowDefaultViewWithOffset(
246 creation_type, TrayBubbleView::InitParams::kArrowDefaultOffset, false); 250 creation_type, TrayBubbleView::InitParams::kArrowDefaultOffset, false);
247 } 251 }
248 252
249 void SystemTray::ShowPersistentDefaultView() { 253 void SystemTray::ShowPersistentDefaultView() {
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 .work_area() 767 .work_area()
764 .height(); 768 .height();
765 if (work_area_height > 0) { 769 if (work_area_height > 0) {
766 UMA_HISTOGRAM_CUSTOM_COUNTS( 770 UMA_HISTOGRAM_CUSTOM_COUNTS(
767 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", 771 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu",
768 100 * bubble_view->height() / work_area_height, 1, 300, 100); 772 100 * bubble_view->height() / work_area_height, 1, 300, 100);
769 } 773 }
770 } 774 }
771 775
772 } // namespace ash 776 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/test/test_system_tray_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698