| OLD | NEW |
| 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/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 24 matching lines...) Expand all Loading... |
| 35 #include "ui/display/display.h" | 35 #include "ui/display/display.h" |
| 36 #include "ui/display/screen.h" | 36 #include "ui/display/screen.h" |
| 37 #include "ui/events/event_constants.h" | 37 #include "ui/events/event_constants.h" |
| 38 #include "ui/gfx/canvas.h" | 38 #include "ui/gfx/canvas.h" |
| 39 #include "ui/gfx/skia_util.h" | 39 #include "ui/gfx/skia_util.h" |
| 40 #include "ui/views/border.h" | 40 #include "ui/views/border.h" |
| 41 #include "ui/views/controls/label.h" | 41 #include "ui/views/controls/label.h" |
| 42 #include "ui/views/layout/box_layout.h" | 42 #include "ui/views/layout/box_layout.h" |
| 43 #include "ui/views/layout/fill_layout.h" | 43 #include "ui/views/layout/fill_layout.h" |
| 44 #include "ui/views/view.h" | 44 #include "ui/views/view.h" |
| 45 #include "ui/views/widget/widget.h" |
| 45 | 46 |
| 46 #if defined(OS_CHROMEOS) | 47 #if defined(OS_CHROMEOS) |
| 47 #include "ash/common/system/chromeos/audio/tray_audio_chromeos.h" | 48 #include "ash/common/system/chromeos/audio/tray_audio_chromeos.h" |
| 48 #include "ash/common/system/chromeos/bluetooth/tray_bluetooth.h" | 49 #include "ash/common/system/chromeos/bluetooth/tray_bluetooth.h" |
| 49 #include "ash/common/system/chromeos/brightness/tray_brightness.h" | 50 #include "ash/common/system/chromeos/brightness/tray_brightness.h" |
| 50 #include "ash/common/system/chromeos/enterprise/tray_enterprise.h" | 51 #include "ash/common/system/chromeos/enterprise/tray_enterprise.h" |
| 51 #include "ash/common/system/chromeos/media_security/multi_profile_media_tray_ite
m.h" | 52 #include "ash/common/system/chromeos/media_security/multi_profile_media_tray_ite
m.h" |
| 52 #include "ash/common/system/chromeos/network/tray_network.h" | 53 #include "ash/common/system/chromeos/network/tray_network.h" |
| 53 #include "ash/common/system/chromeos/network/tray_sms.h" | 54 #include "ash/common/system/chromeos/network/tray_sms.h" |
| 54 #include "ash/common/system/chromeos/network/tray_vpn.h" | 55 #include "ash/common/system/chromeos/network/tray_vpn.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 // SystemTray | 123 // SystemTray |
| 123 | 124 |
| 124 SystemTray::SystemTray(WmShelf* wm_shelf) | 125 SystemTray::SystemTray(WmShelf* wm_shelf) |
| 125 : TrayBackgroundView(wm_shelf), | 126 : TrayBackgroundView(wm_shelf), |
| 126 web_notification_tray_(nullptr), | 127 web_notification_tray_(nullptr), |
| 127 detailed_item_(nullptr), | 128 detailed_item_(nullptr), |
| 128 default_bubble_height_(0), | 129 default_bubble_height_(0), |
| 129 hide_notifications_(false), | 130 hide_notifications_(false), |
| 130 full_system_tray_menu_(false), | 131 full_system_tray_menu_(false), |
| 131 tray_accessibility_(nullptr), | 132 tray_accessibility_(nullptr), |
| 133 tray_audio_(nullptr), |
| 132 tray_cast_(nullptr), | 134 tray_cast_(nullptr), |
| 133 tray_date_(nullptr), | 135 tray_date_(nullptr), |
| 134 tray_update_(nullptr), | 136 tray_update_(nullptr), |
| 135 screen_capture_tray_item_(nullptr), | 137 screen_capture_tray_item_(nullptr), |
| 136 screen_share_tray_item_(nullptr) { | 138 screen_share_tray_item_(nullptr) { |
| 137 SetContentsBackground(); | 139 SetContentsBackground(); |
| 138 } | 140 } |
| 139 | 141 |
| 140 SystemTray::~SystemTray() { | 142 SystemTray::~SystemTray() { |
| 141 // Destroy any child views that might have back pointers before ~View(). | 143 // Destroy any child views that might have back pointers before ~View(). |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 // and we have a DisplayManager equivalent. See http://crbug.com/548429 | 201 // and we have a DisplayManager equivalent. See http://crbug.com/548429 |
| 200 std::unique_ptr<SystemTrayItem> tray_display = | 202 std::unique_ptr<SystemTrayItem> tray_display = |
| 201 delegate->CreateDisplayTrayItem(this); | 203 delegate->CreateDisplayTrayItem(this); |
| 202 if (tray_display) | 204 if (tray_display) |
| 203 AddTrayItem(tray_display.release()); | 205 AddTrayItem(tray_display.release()); |
| 204 screen_capture_tray_item_ = new ScreenCaptureTrayItem(this); | 206 screen_capture_tray_item_ = new ScreenCaptureTrayItem(this); |
| 205 AddTrayItem(screen_capture_tray_item_); | 207 AddTrayItem(screen_capture_tray_item_); |
| 206 screen_share_tray_item_ = new ScreenShareTrayItem(this); | 208 screen_share_tray_item_ = new ScreenShareTrayItem(this); |
| 207 AddTrayItem(screen_share_tray_item_); | 209 AddTrayItem(screen_share_tray_item_); |
| 208 AddTrayItem(new MultiProfileMediaTrayItem(this)); | 210 AddTrayItem(new MultiProfileMediaTrayItem(this)); |
| 209 AddTrayItem(new TrayAudioChromeOs(this)); | 211 tray_audio_ = new TrayAudioChromeOs(this); |
| 212 AddTrayItem(tray_audio_); |
| 210 AddTrayItem(new TrayBrightness(this)); | 213 AddTrayItem(new TrayBrightness(this)); |
| 211 AddTrayItem(new TrayCapsLock(this)); | 214 AddTrayItem(new TrayCapsLock(this)); |
| 212 // TODO(jamescook): Remove this when mus has support for display management | 215 // TODO(jamescook): Remove this when mus has support for display management |
| 213 // and we have a DisplayManager equivalent. See http://crbug.com/548429 | 216 // and we have a DisplayManager equivalent. See http://crbug.com/548429 |
| 214 std::unique_ptr<SystemTrayItem> tray_rotation_lock = | 217 std::unique_ptr<SystemTrayItem> tray_rotation_lock = |
| 215 delegate->CreateRotationLockTrayItem(this); | 218 delegate->CreateRotationLockTrayItem(this); |
| 216 if (tray_rotation_lock) | 219 if (tray_rotation_lock) |
| 217 AddTrayItem(tray_rotation_lock.release()); | 220 AddTrayItem(tray_rotation_lock.release()); |
| 218 AddTrayItem(new TraySettings(this)); | 221 AddTrayItem(new TraySettings(this)); |
| 219 AddTrayItem(tray_update_); | 222 AddTrayItem(tray_update_); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 persistent); | 273 persistent); |
| 271 if (system_bubble_) | 274 if (system_bubble_) |
| 272 system_bubble_->bubble()->StartAutoCloseTimer(close_delay); | 275 system_bubble_->bubble()->StartAutoCloseTimer(close_delay); |
| 273 } | 276 } |
| 274 | 277 |
| 275 void SystemTray::SetDetailedViewCloseDelay(int close_delay) { | 278 void SystemTray::SetDetailedViewCloseDelay(int close_delay) { |
| 276 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DETAILED)) | 279 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DETAILED)) |
| 277 system_bubble_->bubble()->StartAutoCloseTimer(close_delay); | 280 system_bubble_->bubble()->StartAutoCloseTimer(close_delay); |
| 278 } | 281 } |
| 279 | 282 |
| 280 void SystemTray::HideDetailedView(SystemTrayItem* item) { | 283 void SystemTray::HideDetailedView(SystemTrayItem* item, bool animate) { |
| 281 if (item != detailed_item_) | 284 if (item != detailed_item_) |
| 282 return; | 285 return; |
| 286 |
| 287 if (!animate) { |
| 288 // In unittest, GetSystemBubble might return nullptr. |
| 289 if (GetSystemBubble()) { |
| 290 GetSystemBubble() |
| 291 ->bubble_view() |
| 292 ->GetWidget() |
| 293 ->SetVisibilityAnimationTransition( |
| 294 views::Widget::VisibilityTransition::ANIMATE_NONE); |
| 295 } |
| 296 } |
| 297 |
| 283 DestroySystemBubble(); | 298 DestroySystemBubble(); |
| 284 UpdateNotificationBubble(); | 299 UpdateNotificationBubble(); |
| 285 } | 300 } |
| 286 | 301 |
| 287 void SystemTray::ShowNotificationView(SystemTrayItem* item) { | 302 void SystemTray::ShowNotificationView(SystemTrayItem* item) { |
| 288 if (std::find(notification_items_.begin(), notification_items_.end(), item) != | 303 if (std::find(notification_items_.begin(), notification_items_.end(), item) != |
| 289 notification_items_.end()) | 304 notification_items_.end()) |
| 290 return; | 305 return; |
| 291 notification_items_.push_back(item); | 306 notification_items_.push_back(item); |
| 292 UpdateNotificationBubble(); | 307 UpdateNotificationBubble(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 if (!system_bubble_) | 380 if (!system_bubble_) |
| 366 return false; | 381 return false; |
| 367 system_bubble_->bubble()->Close(); | 382 system_bubble_->bubble()->Close(); |
| 368 return true; | 383 return true; |
| 369 } | 384 } |
| 370 | 385 |
| 371 views::View* SystemTray::GetHelpButtonView() const { | 386 views::View* SystemTray::GetHelpButtonView() const { |
| 372 return tray_date_->GetHelpButtonView(); | 387 return tray_date_->GetHelpButtonView(); |
| 373 } | 388 } |
| 374 | 389 |
| 390 TrayAudio* SystemTray::GetTrayAudio() const { |
| 391 return tray_audio_; |
| 392 } |
| 393 |
| 375 bool SystemTray::CloseNotificationBubbleForTest() const { | 394 bool SystemTray::CloseNotificationBubbleForTest() const { |
| 376 if (!notification_bubble_) | 395 if (!notification_bubble_) |
| 377 return false; | 396 return false; |
| 378 notification_bubble_->bubble()->Close(); | 397 notification_bubble_->bubble()->Close(); |
| 379 return true; | 398 return true; |
| 380 } | 399 } |
| 381 | 400 |
| 382 // Private methods. | 401 // Private methods. |
| 383 | 402 |
| 384 bool SystemTray::HasSystemBubbleType(SystemTrayBubble::BubbleType type) { | 403 bool SystemTray::HasSystemBubbleType(SystemTrayBubble::BubbleType type) { |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 .work_area() | 788 .work_area() |
| 770 .height(); | 789 .height(); |
| 771 if (work_area_height > 0) { | 790 if (work_area_height > 0) { |
| 772 UMA_HISTOGRAM_CUSTOM_COUNTS( | 791 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 773 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", | 792 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", |
| 774 100 * bubble_view->height() / work_area_height, 1, 300, 100); | 793 100 * bubble_view->height() / work_area_height, 1, 300, 100); |
| 775 } | 794 } |
| 776 } | 795 } |
| 777 | 796 |
| 778 } // namespace ash | 797 } // namespace ash |
| OLD | NEW |