Chromium Code Reviews| 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 17 matching lines...) Expand all Loading... | |
| 28 #include "ash/system/network/tray_network.h" | 28 #include "ash/system/network/tray_network.h" |
| 29 #include "ash/system/network/tray_vpn.h" | 29 #include "ash/system/network/tray_vpn.h" |
| 30 #include "ash/system/power/power_status.h" | 30 #include "ash/system/power/power_status.h" |
| 31 #include "ash/system/power/tray_power.h" | 31 #include "ash/system/power/tray_power.h" |
| 32 #include "ash/system/screen_security/screen_capture_tray_item.h" | 32 #include "ash/system/screen_security/screen_capture_tray_item.h" |
| 33 #include "ash/system/screen_security/screen_share_tray_item.h" | 33 #include "ash/system/screen_security/screen_share_tray_item.h" |
| 34 #include "ash/system/session/tray_session_length_limit.h" | 34 #include "ash/system/session/tray_session_length_limit.h" |
| 35 #include "ash/system/supervised/tray_supervised_user.h" | 35 #include "ash/system/supervised/tray_supervised_user.h" |
| 36 #include "ash/system/tiles/tray_tiles.h" | 36 #include "ash/system/tiles/tray_tiles.h" |
| 37 #include "ash/system/tray/system_tray_controller.h" | 37 #include "ash/system/tray/system_tray_controller.h" |
| 38 #include "ash/system/tray/system_tray_delegate.h" | 38 #include "ash/system/tray/system_tray_delegate.h" |
|
James Cook
2017/05/05 17:51:53
remove?
xiyuan
2017/05/05 18:36:33
This is still in use, around Line 279
delegate->
| |
| 39 #include "ash/system/tray/system_tray_item.h" | 39 #include "ash/system/tray/system_tray_item.h" |
| 40 #include "ash/system/tray/tray_bubble_wrapper.h" | 40 #include "ash/system/tray/tray_bubble_wrapper.h" |
| 41 #include "ash/system/tray/tray_constants.h" | 41 #include "ash/system/tray/tray_constants.h" |
| 42 #include "ash/system/tray/tray_container.h" | 42 #include "ash/system/tray/tray_container.h" |
| 43 #include "ash/system/tray_accessibility.h" | 43 #include "ash/system/tray_accessibility.h" |
| 44 #include "ash/system/tray_caps_lock.h" | 44 #include "ash/system/tray_caps_lock.h" |
| 45 #include "ash/system/tray_tracing.h" | 45 #include "ash/system/tray_tracing.h" |
| 46 #include "ash/system/update/tray_update.h" | 46 #include "ash/system/update/tray_update.h" |
| 47 #include "ash/system/user/tray_user.h" | 47 #include "ash/system/user/tray_user.h" |
| 48 #include "ash/system/web_notification/web_notification_tray.h" | 48 #include "ash/system/web_notification/web_notification_tray.h" |
| (...skipping 71 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 const LoginStatus login_status = |
| 437 Shell::Get()->system_tray_delegate(); | 436 Shell::Get()->session_controller()->login_status(); |
| 438 if (system_tray_delegate->GetUserLoginStatus() == LoginStatus::KIOSK_APP || | 437 if (login_status == LoginStatus::KIOSK_APP || |
| 439 system_tray_delegate->GetUserLoginStatus() == | 438 login_status == LoginStatus::ARC_KIOSK_APP) { |
| 440 LoginStatus::ARC_KIOSK_APP) { | |
| 441 return; | 439 return; |
| 442 } | 440 } |
| 443 | 441 |
| 444 // Destroy any existing bubble and create a new one. | 442 // Destroy any existing bubble and create a new one. |
| 445 SystemTrayBubble::BubbleType bubble_type = | 443 SystemTrayBubble::BubbleType bubble_type = |
| 446 detailed ? SystemTrayBubble::BUBBLE_TYPE_DETAILED | 444 detailed ? SystemTrayBubble::BUBBLE_TYPE_DETAILED |
| 447 : SystemTrayBubble::BUBBLE_TYPE_DEFAULT; | 445 : SystemTrayBubble::BUBBLE_TYPE_DEFAULT; |
| 448 | 446 |
| 449 if (system_bubble_.get() && creation_type == BUBBLE_USE_EXISTING) { | 447 if (system_bubble_.get() && creation_type == BUBBLE_USE_EXISTING) { |
| 450 system_bubble_->bubble()->UpdateView(items, bubble_type); | 448 system_bubble_->bubble()->UpdateView(items, bubble_type); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 720 .work_area() | 718 .work_area() |
| 721 .height(); | 719 .height(); |
| 722 if (work_area_height > 0) { | 720 if (work_area_height > 0) { |
| 723 UMA_HISTOGRAM_CUSTOM_COUNTS( | 721 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 724 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", | 722 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", |
| 725 100 * bubble_view->height() / work_area_height, 1, 300, 100); | 723 100 * bubble_view->height() / work_area_height, 1, 300, 100); |
| 726 } | 724 } |
| 727 } | 725 } |
| 728 | 726 |
| 729 } // namespace ash | 727 } // namespace ash |
| OLD | NEW |