| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 : bubble_(bubble), is_persistent_(false) {} | 122 : bubble_(bubble), is_persistent_(false) {} |
| 123 | 123 |
| 124 // Initializes the bubble view and creates |bubble_wrapper_|. | 124 // Initializes the bubble view and creates |bubble_wrapper_|. |
| 125 void InitView(TrayBackgroundView* tray, | 125 void InitView(TrayBackgroundView* tray, |
| 126 views::View* anchor, | 126 views::View* anchor, |
| 127 const gfx::Insets& anchor_insets, | 127 const gfx::Insets& anchor_insets, |
| 128 TrayBubbleView::InitParams* init_params, | 128 TrayBubbleView::InitParams* init_params, |
| 129 bool is_persistent) { | 129 bool is_persistent) { |
| 130 DCHECK(anchor); | 130 DCHECK(anchor); |
| 131 LoginStatus login_status = | 131 LoginStatus login_status = |
| 132 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus(); | 132 Shell::Get()->system_tray_delegate()->GetUserLoginStatus(); |
| 133 bubble_->InitView(anchor, login_status, init_params); | 133 bubble_->InitView(anchor, login_status, init_params); |
| 134 bubble_->bubble_view()->set_anchor_view_insets(anchor_insets); | 134 bubble_->bubble_view()->set_anchor_view_insets(anchor_insets); |
| 135 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_->bubble_view())); | 135 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_->bubble_view())); |
| 136 is_persistent_ = is_persistent; | 136 is_persistent_ = is_persistent; |
| 137 | 137 |
| 138 // If ChromeVox is enabled, focus the default item if no item is focused and | 138 // If ChromeVox is enabled, focus the default item if no item is focused and |
| 139 // there isn't a delayed close. | 139 // there isn't a delayed close. |
| 140 if (Shell::GetInstance() | 140 if (Shell::GetInstance() |
| 141 ->accessibility_delegate() | 141 ->accessibility_delegate() |
| 142 ->IsSpokenFeedbackEnabled() && | 142 ->IsSpokenFeedbackEnabled() && |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 AddTrayItem(base::MakeUnique<PaddingTrayItem>()); | 322 AddTrayItem(base::MakeUnique<PaddingTrayItem>()); |
| 323 } else { | 323 } else { |
| 324 AddTrayItem(base::WrapUnique(tray_date_)); | 324 AddTrayItem(base::WrapUnique(tray_date_)); |
| 325 } | 325 } |
| 326 } | 326 } |
| 327 | 327 |
| 328 void SystemTray::AddTrayItem(std::unique_ptr<SystemTrayItem> item) { | 328 void SystemTray::AddTrayItem(std::unique_ptr<SystemTrayItem> item) { |
| 329 SystemTrayItem* item_ptr = item.get(); | 329 SystemTrayItem* item_ptr = item.get(); |
| 330 items_.push_back(std::move(item)); | 330 items_.push_back(std::move(item)); |
| 331 | 331 |
| 332 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); | 332 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate(); |
| 333 views::View* tray_item = | 333 views::View* tray_item = |
| 334 item_ptr->CreateTrayView(delegate->GetUserLoginStatus()); | 334 item_ptr->CreateTrayView(delegate->GetUserLoginStatus()); |
| 335 item_ptr->UpdateAfterShelfAlignmentChange(shelf_alignment()); | 335 item_ptr->UpdateAfterShelfAlignmentChange(shelf_alignment()); |
| 336 | 336 |
| 337 if (tray_item) { | 337 if (tray_item) { |
| 338 tray_container()->AddChildViewAt(tray_item, 0); | 338 tray_container()->AddChildViewAt(tray_item, 0); |
| 339 PreferredSizeChanged(); | 339 PreferredSizeChanged(); |
| 340 tray_item_map_[item_ptr] = tray_item; | 340 tray_item_map_[item_ptr] = tray_item; |
| 341 } | 341 } |
| 342 } | 342 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 time, battery); | 472 time, battery); |
| 473 } | 473 } |
| 474 | 474 |
| 475 void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items, | 475 void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items, |
| 476 bool detailed, | 476 bool detailed, |
| 477 bool can_activate, | 477 bool can_activate, |
| 478 BubbleCreationType creation_type, | 478 BubbleCreationType creation_type, |
| 479 bool persistent) { | 479 bool persistent) { |
| 480 // No system tray bubbles in kiosk mode. | 480 // No system tray bubbles in kiosk mode. |
| 481 SystemTrayDelegate* system_tray_delegate = | 481 SystemTrayDelegate* system_tray_delegate = |
| 482 WmShell::Get()->system_tray_delegate(); | 482 Shell::Get()->system_tray_delegate(); |
| 483 if (system_tray_delegate->GetUserLoginStatus() == LoginStatus::KIOSK_APP || | 483 if (system_tray_delegate->GetUserLoginStatus() == LoginStatus::KIOSK_APP || |
| 484 system_tray_delegate->GetUserLoginStatus() == | 484 system_tray_delegate->GetUserLoginStatus() == |
| 485 LoginStatus::ARC_KIOSK_APP) { | 485 LoginStatus::ARC_KIOSK_APP) { |
| 486 return; | 486 return; |
| 487 } | 487 } |
| 488 | 488 |
| 489 // Destroy any existing bubble and create a new one. | 489 // Destroy any existing bubble and create a new one. |
| 490 SystemTrayBubble::BubbleType bubble_type = | 490 SystemTrayBubble::BubbleType bubble_type = |
| 491 detailed ? SystemTrayBubble::BUBBLE_TYPE_DETAILED | 491 detailed ? SystemTrayBubble::BUBBLE_TYPE_DETAILED |
| 492 : SystemTrayBubble::BUBBLE_TYPE_DEFAULT; | 492 : SystemTrayBubble::BUBBLE_TYPE_DEFAULT; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 510 // the menu is full (or not) doesn't change even if a "single property" | 510 // the menu is full (or not) doesn't change even if a "single property" |
| 511 // (like network) replaces most of the menu. | 511 // (like network) replaces most of the menu. |
| 512 full_system_tray_menu_ = items.size() > 1; | 512 full_system_tray_menu_ = items.size() > 1; |
| 513 | 513 |
| 514 // The menu width is fixed for all languages in material design. | 514 // The menu width is fixed for all languages in material design. |
| 515 int menu_width = kTrayMenuMinimumWidthMd; | 515 int menu_width = kTrayMenuMinimumWidthMd; |
| 516 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) { | 516 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) { |
| 517 // The menu width is fixed, and it is a per language setting. | 517 // The menu width is fixed, and it is a per language setting. |
| 518 menu_width = std::max( | 518 menu_width = std::max( |
| 519 kTrayMenuMinimumWidth, | 519 kTrayMenuMinimumWidth, |
| 520 WmShell::Get()->system_tray_delegate()->GetSystemTrayMenuWidth()); | 520 Shell::Get()->system_tray_delegate()->GetSystemTrayMenuWidth()); |
| 521 } | 521 } |
| 522 | 522 |
| 523 TrayBubbleView::InitParams init_params(GetAnchorAlignment(), menu_width, | 523 TrayBubbleView::InitParams init_params(GetAnchorAlignment(), menu_width, |
| 524 kTrayPopupMaxWidth); | 524 kTrayPopupMaxWidth); |
| 525 // TODO(oshima): Change TrayBubbleView itself. | 525 // TODO(oshima): Change TrayBubbleView itself. |
| 526 init_params.can_activate = false; | 526 init_params.can_activate = false; |
| 527 if (detailed) { | 527 if (detailed) { |
| 528 // This is the case where a volume control or brightness control bubble | 528 // This is the case where a volume control or brightness control bubble |
| 529 // is created. | 529 // is created. |
| 530 init_params.max_height = default_bubble_height_; | 530 init_params.max_height = default_bubble_height_; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 height = | 583 height = |
| 584 std::max(0, work_area.bottom() - bubble_view->GetBoundsInScreen().y()); | 584 std::max(0, work_area.bottom() - bubble_view->GetBoundsInScreen().y()); |
| 585 } | 585 } |
| 586 if (web_notification_tray_) | 586 if (web_notification_tray_) |
| 587 web_notification_tray_->SetTrayBubbleHeight(height); | 587 web_notification_tray_->SetTrayBubbleHeight(height); |
| 588 } | 588 } |
| 589 | 589 |
| 590 base::string16 SystemTray::GetAccessibleTimeString( | 590 base::string16 SystemTray::GetAccessibleTimeString( |
| 591 const base::Time& now) const { | 591 const base::Time& now) const { |
| 592 base::HourClockType hour_type = | 592 base::HourClockType hour_type = |
| 593 WmShell::Get()->system_tray_controller()->hour_clock_type(); | 593 Shell::Get()->system_tray_controller()->hour_clock_type(); |
| 594 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type, | 594 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type, |
| 595 base::kKeepAmPm); | 595 base::kKeepAmPm); |
| 596 } | 596 } |
| 597 | 597 |
| 598 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { | 598 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { |
| 599 if (alignment == shelf_alignment()) | 599 if (alignment == shelf_alignment()) |
| 600 return; | 600 return; |
| 601 TrayBackgroundView::SetShelfAlignment(alignment); | 601 TrayBackgroundView::SetShelfAlignment(alignment); |
| 602 UpdateAfterShelfAlignmentChange(alignment); | 602 UpdateAfterShelfAlignmentChange(alignment); |
| 603 // Destroy any existing bubble so that it is rebuilt correctly. | 603 // Destroy any existing bubble so that it is rebuilt correctly. |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 .work_area() | 781 .work_area() |
| 782 .height(); | 782 .height(); |
| 783 if (work_area_height > 0) { | 783 if (work_area_height > 0) { |
| 784 UMA_HISTOGRAM_CUSTOM_COUNTS( | 784 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 785 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", | 785 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", |
| 786 100 * bubble_view->height() / work_area_height, 1, 300, 100); | 786 100 * bubble_view->height() / work_area_height, 1, 300, 100); |
| 787 } | 787 } |
| 788 } | 788 } |
| 789 | 789 |
| 790 } // namespace ash | 790 } // namespace ash |
| OLD | NEW |