| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 explicit SystemBubbleWrapper(SystemTrayBubble* bubble) | 120 explicit SystemBubbleWrapper(SystemTrayBubble* bubble) |
| 121 : bubble_(bubble), is_persistent_(false) {} | 121 : bubble_(bubble), is_persistent_(false) {} |
| 122 | 122 |
| 123 // Initializes the bubble view and creates |bubble_wrapper_|. | 123 // Initializes the bubble view and creates |bubble_wrapper_|. |
| 124 void InitView(TrayBackgroundView* tray, | 124 void InitView(TrayBackgroundView* tray, |
| 125 views::View* anchor, | 125 views::View* anchor, |
| 126 const gfx::Insets& anchor_insets, | 126 const gfx::Insets& anchor_insets, |
| 127 TrayBubbleView::InitParams* init_params, | 127 TrayBubbleView::InitParams* init_params, |
| 128 bool is_persistent) { | 128 bool is_persistent) { |
| 129 DCHECK(anchor); | 129 DCHECK(anchor); |
| 130 LoginStatus login_status = | 130 const LoginStatus login_status = |
| 131 Shell::Get()->system_tray_delegate()->GetUserLoginStatus(); | 131 Shell::Get()->session_controller()->login_status(); |
| 132 bubble_->InitView(anchor, login_status, init_params); | 132 bubble_->InitView(anchor, login_status, init_params); |
| 133 bubble_->bubble_view()->set_anchor_view_insets(anchor_insets); | 133 bubble_->bubble_view()->set_anchor_view_insets(anchor_insets); |
| 134 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_->bubble_view())); | 134 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_->bubble_view())); |
| 135 is_persistent_ = is_persistent; | 135 is_persistent_ = is_persistent; |
| 136 | 136 |
| 137 // If ChromeVox is enabled, focus the default item if no item is focused and | 137 // If ChromeVox is enabled, focus the default item if no item is focused and |
| 138 // there isn't a delayed close. | 138 // there isn't a delayed close. |
| 139 if (Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled() && | 139 if (Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled() && |
| 140 !is_persistent) { | 140 !is_persistent) { |
| 141 bubble_->FocusDefaultIfNeeded(); | 141 bubble_->FocusDefaultIfNeeded(); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 tray_system_info_ = new TraySystemInfo(this); | 286 tray_system_info_ = new TraySystemInfo(this); |
| 287 AddTrayItem(base::WrapUnique(tray_system_info_)); | 287 AddTrayItem(base::WrapUnique(tray_system_info_)); |
| 288 // Leading padding. | 288 // Leading padding. |
| 289 AddTrayItem(base::MakeUnique<PaddingTrayItem>()); | 289 AddTrayItem(base::MakeUnique<PaddingTrayItem>()); |
| 290 } | 290 } |
| 291 | 291 |
| 292 void SystemTray::AddTrayItem(std::unique_ptr<SystemTrayItem> item) { | 292 void SystemTray::AddTrayItem(std::unique_ptr<SystemTrayItem> item) { |
| 293 SystemTrayItem* item_ptr = item.get(); | 293 SystemTrayItem* item_ptr = item.get(); |
| 294 items_.push_back(std::move(item)); | 294 items_.push_back(std::move(item)); |
| 295 | 295 |
| 296 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate(); | 296 views::View* tray_item = item_ptr->CreateTrayView( |
| 297 views::View* tray_item = | 297 Shell::Get()->session_controller()->login_status()); |
| 298 item_ptr->CreateTrayView(delegate->GetUserLoginStatus()); | |
| 299 item_ptr->UpdateAfterShelfAlignmentChange(); | 298 item_ptr->UpdateAfterShelfAlignmentChange(); |
| 300 | 299 |
| 301 if (tray_item) { | 300 if (tray_item) { |
| 302 tray_container()->AddChildViewAt(tray_item, 0); | 301 tray_container()->AddChildViewAt(tray_item, 0); |
| 303 PreferredSizeChanged(); | 302 PreferredSizeChanged(); |
| 304 } | 303 } |
| 305 } | 304 } |
| 306 | 305 |
| 307 std::vector<SystemTrayItem*> SystemTray::GetTrayItems() const { | 306 std::vector<SystemTrayItem*> SystemTray::GetTrayItems() const { |
| 308 std::vector<SystemTrayItem*> result; | 307 std::vector<SystemTrayItem*> result; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 return l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBLE_DESCRIPTION, | 425 return l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBLE_DESCRIPTION, |
| 427 time, battery); | 426 time, battery); |
| 428 } | 427 } |
| 429 | 428 |
| 430 void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items, | 429 void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items, |
| 431 bool detailed, | 430 bool detailed, |
| 432 bool can_activate, | 431 bool can_activate, |
| 433 BubbleCreationType creation_type, | 432 BubbleCreationType creation_type, |
| 434 bool persistent) { | 433 bool persistent) { |
| 435 // No system tray bubbles in kiosk mode. | 434 // No system tray bubbles in kiosk mode. |
| 436 SystemTrayDelegate* system_tray_delegate = | 435 if (Shell::Get()->session_controller()->IsKioskSession()) |
| 437 Shell::Get()->system_tray_delegate(); | |
| 438 if (system_tray_delegate->GetUserLoginStatus() == LoginStatus::KIOSK_APP || | |
| 439 system_tray_delegate->GetUserLoginStatus() == | |
| 440 LoginStatus::ARC_KIOSK_APP) { | |
| 441 return; | 436 return; |
| 442 } | |
| 443 | 437 |
| 444 // Destroy any existing bubble and create a new one. | 438 // Destroy any existing bubble and create a new one. |
| 445 SystemTrayBubble::BubbleType bubble_type = | 439 SystemTrayBubble::BubbleType bubble_type = |
| 446 detailed ? SystemTrayBubble::BUBBLE_TYPE_DETAILED | 440 detailed ? SystemTrayBubble::BUBBLE_TYPE_DETAILED |
| 447 : SystemTrayBubble::BUBBLE_TYPE_DEFAULT; | 441 : SystemTrayBubble::BUBBLE_TYPE_DEFAULT; |
| 448 | 442 |
| 449 if (system_bubble_.get() && creation_type == BUBBLE_USE_EXISTING) { | 443 if (system_bubble_.get() && creation_type == BUBBLE_USE_EXISTING) { |
| 450 system_bubble_->bubble()->UpdateView(items, bubble_type); | 444 system_bubble_->bubble()->UpdateView(items, bubble_type); |
| 451 // If ChromeVox is enabled, focus the default item if no item is focused. | 445 // If ChromeVox is enabled, focus the default item if no item is focused. |
| 452 if (Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled()) | 446 if (Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled()) |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 .work_area() | 714 .work_area() |
| 721 .height(); | 715 .height(); |
| 722 if (work_area_height > 0) { | 716 if (work_area_height > 0) { |
| 723 UMA_HISTOGRAM_CUSTOM_COUNTS( | 717 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 724 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", | 718 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", |
| 725 100 * bubble_view->height() / work_area_height, 1, 300, 100); | 719 100 * bubble_view->height() / work_area_height, 1, 300, 100); |
| 726 } | 720 } |
| 727 } | 721 } |
| 728 | 722 |
| 729 } // namespace ash | 723 } // namespace ash |
| OLD | NEW |