| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 249 |
| 250 // Crucially, this trailing padding has to be inside the user item(s). | 250 // Crucially, this trailing padding has to be inside the user item(s). |
| 251 // Otherwise it could be a main axis margin on the tray's box layout. | 251 // Otherwise it could be a main axis margin on the tray's box layout. |
| 252 AddTrayItem(base::MakeUnique<PaddingTrayItem>()); | 252 AddTrayItem(base::MakeUnique<PaddingTrayItem>()); |
| 253 | 253 |
| 254 tray_accessibility_ = new TrayAccessibility(this); | 254 tray_accessibility_ = new TrayAccessibility(this); |
| 255 tray_update_ = new TrayUpdate(this); | 255 tray_update_ = new TrayUpdate(this); |
| 256 | 256 |
| 257 AddTrayItem(base::MakeUnique<TraySessionLengthLimit>(this)); | 257 AddTrayItem(base::MakeUnique<TraySessionLengthLimit>(this)); |
| 258 AddTrayItem(base::MakeUnique<TrayEnterprise>(this)); | 258 AddTrayItem(base::MakeUnique<TrayEnterprise>(this)); |
| 259 AddTrayItem(base::MakeUnique<TraySupervisedUser>(this)); | 259 tray_supervised_user_ = new TraySupervisedUser(this); |
| 260 AddTrayItem(base::WrapUnique(tray_supervised_user_)); |
| 260 AddTrayItem(base::MakeUnique<TrayIME>(this)); | 261 AddTrayItem(base::MakeUnique<TrayIME>(this)); |
| 261 AddTrayItem(base::WrapUnique(tray_accessibility_)); | 262 AddTrayItem(base::WrapUnique(tray_accessibility_)); |
| 262 AddTrayItem(base::MakeUnique<TrayTracing>(this)); | 263 AddTrayItem(base::MakeUnique<TrayTracing>(this)); |
| 263 AddTrayItem( | 264 AddTrayItem( |
| 264 base::MakeUnique<TrayPower>(this, message_center::MessageCenter::Get())); | 265 base::MakeUnique<TrayPower>(this, message_center::MessageCenter::Get())); |
| 265 tray_network_ = new TrayNetwork(this); | 266 tray_network_ = new TrayNetwork(this); |
| 266 AddTrayItem(base::WrapUnique(tray_network_)); | 267 AddTrayItem(base::WrapUnique(tray_network_)); |
| 267 AddTrayItem(base::MakeUnique<TrayVPN>(this)); | 268 AddTrayItem(base::MakeUnique<TrayVPN>(this)); |
| 268 AddTrayItem(base::MakeUnique<TrayBluetooth>(this)); | 269 AddTrayItem(base::MakeUnique<TrayBluetooth>(this)); |
| 269 tray_cast_ = new TrayCast(this); | 270 tray_cast_ = new TrayCast(this); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 297 items_.push_back(std::move(item)); | 298 items_.push_back(std::move(item)); |
| 298 | 299 |
| 299 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate(); | 300 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate(); |
| 300 views::View* tray_item = | 301 views::View* tray_item = |
| 301 item_ptr->CreateTrayView(delegate->GetUserLoginStatus()); | 302 item_ptr->CreateTrayView(delegate->GetUserLoginStatus()); |
| 302 item_ptr->UpdateAfterShelfAlignmentChange(); | 303 item_ptr->UpdateAfterShelfAlignmentChange(); |
| 303 | 304 |
| 304 if (tray_item) { | 305 if (tray_item) { |
| 305 tray_container()->AddChildViewAt(tray_item, 0); | 306 tray_container()->AddChildViewAt(tray_item, 0); |
| 306 PreferredSizeChanged(); | 307 PreferredSizeChanged(); |
| 307 tray_item_map_[item_ptr] = tray_item; | |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 | 310 |
| 311 std::vector<SystemTrayItem*> SystemTray::GetTrayItems() const { | 311 std::vector<SystemTrayItem*> SystemTray::GetTrayItems() const { |
| 312 std::vector<SystemTrayItem*> result; | 312 std::vector<SystemTrayItem*> result; |
| 313 for (const auto& item : items_) | 313 for (const auto& item : items_) |
| 314 result.push_back(item.get()); | 314 result.push_back(item.get()); |
| 315 return result; | 315 return result; |
| 316 } | 316 } |
| 317 | 317 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 WmWindow::Get(anchor_widget->GetNativeWindow()) | 605 WmWindow::Get(anchor_widget->GetNativeWindow()) |
| 606 ->GetRootWindowController() | 606 ->GetRootWindowController() |
| 607 ->ConfigureWidgetInitParamsForContainer( | 607 ->ConfigureWidgetInitParamsForContainer( |
| 608 bubble_widget, kShellWindowId_SettingBubbleContainer, params); | 608 bubble_widget, kShellWindowId_SettingBubbleContainer, params); |
| 609 } | 609 } |
| 610 | 610 |
| 611 void SystemTray::HideBubble(const TrayBubbleView* bubble_view) { | 611 void SystemTray::HideBubble(const TrayBubbleView* bubble_view) { |
| 612 HideBubbleWithView(bubble_view); | 612 HideBubbleWithView(bubble_view); |
| 613 } | 613 } |
| 614 | 614 |
| 615 views::View* SystemTray::GetTrayItemViewForTest(SystemTrayItem* item) { | |
| 616 std::map<SystemTrayItem*, views::View*>::iterator it = | |
| 617 tray_item_map_.find(item); | |
| 618 return it == tray_item_map_.end() ? NULL : it->second; | |
| 619 } | |
| 620 | |
| 621 TrayCast* SystemTray::GetTrayCastForTesting() const { | 615 TrayCast* SystemTray::GetTrayCastForTesting() const { |
| 622 return tray_cast_; | 616 return tray_cast_; |
| 623 } | 617 } |
| 624 | 618 |
| 625 TrayNetwork* SystemTray::GetTrayNetworkForTesting() const { | 619 TrayNetwork* SystemTray::GetTrayNetworkForTesting() const { |
| 626 return tray_network_; | 620 return tray_network_; |
| 627 } | 621 } |
| 628 | 622 |
| 623 TraySupervisedUser* SystemTray::GetTraySupervisedUserForTesting() const { |
| 624 return tray_supervised_user_; |
| 625 } |
| 626 |
| 629 TraySystemInfo* SystemTray::GetTraySystemInfoForTesting() const { | 627 TraySystemInfo* SystemTray::GetTraySystemInfoForTesting() const { |
| 630 return tray_system_info_; | 628 return tray_system_info_; |
| 631 } | 629 } |
| 632 | 630 |
| 633 TrayTiles* SystemTray::GetTrayTilesForTesting() const { | 631 TrayTiles* SystemTray::GetTrayTilesForTesting() const { |
| 634 return tray_tiles_; | 632 return tray_tiles_; |
| 635 } | 633 } |
| 636 | 634 |
| 637 void SystemTray::CloseBubble(const ui::KeyEvent& key_event) { | 635 void SystemTray::CloseBubble(const ui::KeyEvent& key_event) { |
| 638 CloseSystemBubble(); | 636 CloseSystemBubble(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 .work_area() | 721 .work_area() |
| 724 .height(); | 722 .height(); |
| 725 if (work_area_height > 0) { | 723 if (work_area_height > 0) { |
| 726 UMA_HISTOGRAM_CUSTOM_COUNTS( | 724 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 727 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", | 725 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", |
| 728 100 * bubble_view->height() / work_area_height, 1, 300, 100); | 726 100 * bubble_view->height() / work_area_height, 1, 300, 100); |
| 729 } | 727 } |
| 730 } | 728 } |
| 731 | 729 |
| 732 } // namespace ash | 730 } // namespace ash |
| OLD | NEW |