| 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/system/tray/system_tray.h" | 5 #include "ash/system/tray/system_tray.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/common/shelf/wm_shelf_util.h" | 8 #include "ash/common/shelf/wm_shelf_util.h" |
| 9 #include "ash/common/shell_window_ids.h" | 9 #include "ash/common/shell_window_ids.h" |
| 10 #include "ash/metrics/user_metrics_recorder.h" | 10 #include "ash/metrics/user_metrics_recorder.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // Takes ownership of |bubble|. | 86 // Takes ownership of |bubble|. |
| 87 explicit SystemBubbleWrapper(SystemTrayBubble* bubble) | 87 explicit SystemBubbleWrapper(SystemTrayBubble* bubble) |
| 88 : bubble_(bubble), is_persistent_(false) {} | 88 : bubble_(bubble), is_persistent_(false) {} |
| 89 | 89 |
| 90 // Initializes the bubble view and creates |bubble_wrapper_|. | 90 // Initializes the bubble view and creates |bubble_wrapper_|. |
| 91 void InitView(TrayBackgroundView* tray, | 91 void InitView(TrayBackgroundView* tray, |
| 92 views::View* anchor, | 92 views::View* anchor, |
| 93 TrayBubbleView::InitParams* init_params, | 93 TrayBubbleView::InitParams* init_params, |
| 94 bool is_persistent) { | 94 bool is_persistent) { |
| 95 DCHECK(anchor); | 95 DCHECK(anchor); |
| 96 user::LoginStatus login_status = | 96 LoginStatus login_status = |
| 97 Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus(); | 97 Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus(); |
| 98 bubble_->InitView(anchor, login_status, init_params); | 98 bubble_->InitView(anchor, login_status, init_params); |
| 99 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_->bubble_view())); | 99 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_->bubble_view())); |
| 100 // The system bubble should not have an arrow. | 100 // The system bubble should not have an arrow. |
| 101 bubble_->bubble_view()->SetArrowPaintType( | 101 bubble_->bubble_view()->SetArrowPaintType( |
| 102 views::BubbleBorder::PAINT_NONE); | 102 views::BubbleBorder::PAINT_NONE); |
| 103 is_persistent_ = is_persistent; | 103 is_persistent_ = is_persistent; |
| 104 | 104 |
| 105 // If ChromeVox is enabled, focus the default item if no item is focused and | 105 // If ChromeVox is enabled, focus the default item if no item is focused and |
| 106 // there isn't a delayed close. | 106 // there isn't a delayed close. |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 std::vector<SystemTrayItem*>::iterator found_iter = | 299 std::vector<SystemTrayItem*>::iterator found_iter = |
| 300 std::find(notification_items_.begin(), notification_items_.end(), item); | 300 std::find(notification_items_.begin(), notification_items_.end(), item); |
| 301 if (found_iter == notification_items_.end()) | 301 if (found_iter == notification_items_.end()) |
| 302 return; | 302 return; |
| 303 notification_items_.erase(found_iter); | 303 notification_items_.erase(found_iter); |
| 304 // Only update the notification bubble if visible (i.e. don't create one). | 304 // Only update the notification bubble if visible (i.e. don't create one). |
| 305 if (notification_bubble_) | 305 if (notification_bubble_) |
| 306 UpdateNotificationBubble(); | 306 UpdateNotificationBubble(); |
| 307 } | 307 } |
| 308 | 308 |
| 309 void SystemTray::UpdateAfterLoginStatusChange(user::LoginStatus login_status) { | 309 void SystemTray::UpdateAfterLoginStatusChange(LoginStatus login_status) { |
| 310 DestroySystemBubble(); | 310 DestroySystemBubble(); |
| 311 UpdateNotificationBubble(); | 311 UpdateNotificationBubble(); |
| 312 | 312 |
| 313 for (SystemTrayItem* item : items_) | 313 for (SystemTrayItem* item : items_) |
| 314 item->UpdateAfterLoginStatusChange(login_status); | 314 item->UpdateAfterLoginStatusChange(login_status); |
| 315 | 315 |
| 316 // Items default to SHELF_ALIGNMENT_BOTTOM. Update them if the initial | 316 // Items default to SHELF_ALIGNMENT_BOTTOM. Update them if the initial |
| 317 // position of the shelf differs. | 317 // position of the shelf differs. |
| 318 if (!IsHorizontalAlignment(shelf_alignment())) | 318 if (!IsHorizontalAlignment(shelf_alignment())) |
| 319 UpdateAfterShelfAlignmentChange(shelf_alignment()); | 319 UpdateAfterShelfAlignmentChange(shelf_alignment()); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 } | 446 } |
| 447 | 447 |
| 448 void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items, | 448 void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items, |
| 449 bool detailed, | 449 bool detailed, |
| 450 bool can_activate, | 450 bool can_activate, |
| 451 BubbleCreationType creation_type, | 451 BubbleCreationType creation_type, |
| 452 int arrow_offset, | 452 int arrow_offset, |
| 453 bool persistent) { | 453 bool persistent) { |
| 454 // No system tray bubbles in kiosk mode. | 454 // No system tray bubbles in kiosk mode. |
| 455 if (Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus() == | 455 if (Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus() == |
| 456 ash::user::LOGGED_IN_KIOSK_APP) { | 456 LoginStatus::KIOSK_APP) { |
| 457 return; | 457 return; |
| 458 } | 458 } |
| 459 | 459 |
| 460 // Destroy any existing bubble and create a new one. | 460 // Destroy any existing bubble and create a new one. |
| 461 SystemTrayBubble::BubbleType bubble_type = detailed ? | 461 SystemTrayBubble::BubbleType bubble_type = detailed ? |
| 462 SystemTrayBubble::BUBBLE_TYPE_DETAILED : | 462 SystemTrayBubble::BUBBLE_TYPE_DETAILED : |
| 463 SystemTrayBubble::BUBBLE_TYPE_DEFAULT; | 463 SystemTrayBubble::BUBBLE_TYPE_DEFAULT; |
| 464 | 464 |
| 465 // Destroy the notification bubble here so that it doesn't get rebuilt | 465 // Destroy the notification bubble here so that it doesn't get rebuilt |
| 466 // while we add items to the main bubble_ (e.g. in HideNotificationView). | 466 // while we add items to the main bubble_ (e.g. in HideNotificationView). |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 .work_area() | 756 .work_area() |
| 757 .height(); | 757 .height(); |
| 758 if (work_area_height > 0) { | 758 if (work_area_height > 0) { |
| 759 UMA_HISTOGRAM_CUSTOM_COUNTS( | 759 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 760 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", | 760 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", |
| 761 100 * bubble_view->height() / work_area_height, 1, 300, 100); | 761 100 * bubble_view->height() / work_area_height, 1, 300, 100); |
| 762 } | 762 } |
| 763 } | 763 } |
| 764 | 764 |
| 765 } // namespace ash | 765 } // namespace ash |
| OLD | NEW |