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/metrics/user_metrics_recorder.h" | 8 #include "ash/metrics/user_metrics_recorder.h" |
9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 CreateItems(delegate); | 157 CreateItems(delegate); |
158 } | 158 } |
159 | 159 |
160 void SystemTray::CreateItems(SystemTrayDelegate* delegate) { | 160 void SystemTray::CreateItems(SystemTrayDelegate* delegate) { |
161 #if !defined(OS_WIN) | 161 #if !defined(OS_WIN) |
162 AddTrayItem(new internal::TraySessionLengthLimit(this)); | 162 AddTrayItem(new internal::TraySessionLengthLimit(this)); |
163 // Create user items for each possible user. | 163 // Create user items for each possible user. |
164 ash::Shell* shell = ash::Shell::GetInstance(); | 164 ash::Shell* shell = ash::Shell::GetInstance(); |
165 int maximum_user_profiles = | 165 int maximum_user_profiles = |
166 shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers(); | 166 shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers(); |
167 for (int i = 0; i < maximum_user_profiles; i++) { | 167 for (int i = 0; i < maximum_user_profiles; i++) |
168 internal::TrayUser* tray_user = new internal::TrayUser(this, i); | 168 AddTrayItem(new internal::TrayUser(this, i)); |
169 AddTrayItem(tray_user); | 169 |
170 user_items_.push_back(tray_user); | |
171 } | |
172 if (maximum_user_profiles > 1) { | 170 if (maximum_user_profiles > 1) { |
173 // Add a special double line separator between users and the rest of the | 171 // Add a special double line separator between users and the rest of the |
174 // menu if more then one user is logged in. | 172 // menu if more then one user is logged in. |
175 AddTrayItem(new internal::TrayUserSeparator(this)); | 173 AddTrayItem(new internal::TrayUserSeparator(this)); |
176 } | 174 } |
177 #endif | 175 #endif |
178 | 176 |
179 tray_accessibility_ = new internal::TrayAccessibility(this); | 177 tray_accessibility_ = new internal::TrayAccessibility(this); |
180 tray_date_ = new internal::TrayDate(this); | 178 tray_date_ = new internal::TrayDate(this); |
181 | 179 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 } | 232 } |
235 | 233 |
236 void SystemTray::RemoveTrayItem(SystemTrayItem* item) { | 234 void SystemTray::RemoveTrayItem(SystemTrayItem* item) { |
237 NOTIMPLEMENTED(); | 235 NOTIMPLEMENTED(); |
238 } | 236 } |
239 | 237 |
240 const std::vector<SystemTrayItem*>& SystemTray::GetTrayItems() const { | 238 const std::vector<SystemTrayItem*>& SystemTray::GetTrayItems() const { |
241 return items_.get(); | 239 return items_.get(); |
242 } | 240 } |
243 | 241 |
244 const std::vector<internal::TrayUser*>& SystemTray::GetTrayUserItems() const { | |
245 return user_items_; | |
246 } | |
247 | |
248 void SystemTray::ShowDefaultView(BubbleCreationType creation_type) { | 242 void SystemTray::ShowDefaultView(BubbleCreationType creation_type) { |
249 ShowDefaultViewWithOffset( | 243 ShowDefaultViewWithOffset( |
250 creation_type, | 244 creation_type, |
251 TrayBubbleView::InitParams::kArrowDefaultOffset, | 245 TrayBubbleView::InitParams::kArrowDefaultOffset, |
252 false); | 246 false); |
253 } | 247 } |
254 | 248 |
255 void SystemTray::ShowPersistentDefaultView() { | 249 void SystemTray::ShowPersistentDefaultView() { |
256 ShowItems(items_.get(), | 250 ShowItems(items_.get(), |
257 false, | 251 false, |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 void SystemTray::HideBubble(const TrayBubbleView* bubble_view) { | 673 void SystemTray::HideBubble(const TrayBubbleView* bubble_view) { |
680 HideBubbleWithView(bubble_view); | 674 HideBubbleWithView(bubble_view); |
681 } | 675 } |
682 | 676 |
683 views::View* SystemTray::GetTrayItemViewForTest(SystemTrayItem* item) { | 677 views::View* SystemTray::GetTrayItemViewForTest(SystemTrayItem* item) { |
684 std::map<SystemTrayItem*, views::View*>::iterator it = | 678 std::map<SystemTrayItem*, views::View*>::iterator it = |
685 tray_item_map_.find(item); | 679 tray_item_map_.find(item); |
686 return it == tray_item_map_.end() ? NULL : it->second; | 680 return it == tray_item_map_.end() ? NULL : it->second; |
687 } | 681 } |
688 | 682 |
689 void SystemTray::AddTrayUserItemForTest(internal::TrayUser* tray_user) { | |
690 AddTrayItem(tray_user); | |
691 user_items_.push_back(tray_user); | |
692 } | |
693 | |
694 internal::TrayDate* SystemTray::GetTrayDateForTesting() const { | 683 internal::TrayDate* SystemTray::GetTrayDateForTesting() const { |
695 return tray_date_; | 684 return tray_date_; |
696 } | 685 } |
697 | 686 |
698 bool SystemTray::PerformAction(const ui::Event& event) { | 687 bool SystemTray::PerformAction(const ui::Event& event) { |
699 // If we're already showing the default view, hide it; otherwise, show it | 688 // If we're already showing the default view, hide it; otherwise, show it |
700 // (and hide any popup that's currently shown). | 689 // (and hide any popup that's currently shown). |
701 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DEFAULT)) { | 690 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DEFAULT)) { |
702 system_bubble_->bubble()->Close(); | 691 system_bubble_->bubble()->Close(); |
703 } else { | 692 } else { |
(...skipping 17 matching lines...) Expand all Loading... |
721 system_bubble_.reset(); | 710 system_bubble_.reset(); |
722 // When closing a system bubble with the alternate shelf layout, we need to | 711 // When closing a system bubble with the alternate shelf layout, we need to |
723 // turn off the active tinting of the shelf. | 712 // turn off the active tinting of the shelf. |
724 if (full_system_tray_menu_) { | 713 if (full_system_tray_menu_) { |
725 SetDrawBackgroundAsActive(false); | 714 SetDrawBackgroundAsActive(false); |
726 full_system_tray_menu_ = false; | 715 full_system_tray_menu_ = false; |
727 } | 716 } |
728 } | 717 } |
729 | 718 |
730 } // namespace ash | 719 } // namespace ash |
OLD | NEW |