| 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/common/ash_switches.h" | 7 #include "ash/common/ash_switches.h" |
| 8 #include "ash/common/session/session_state_delegate.h" | 8 #include "ash/common/session/session_state_delegate.h" |
| 9 #include "ash/common/shelf/wm_shelf.h" | 9 #include "ash/common/shelf/wm_shelf.h" |
| 10 #include "ash/common/shelf/wm_shelf_util.h" | 10 #include "ash/common/shelf/wm_shelf_util.h" |
| 11 #include "ash/common/shell_window_ids.h" | 11 #include "ash/common/shell_window_ids.h" |
| 12 #include "ash/common/system/date/tray_date.h" | 12 #include "ash/common/system/date/tray_date.h" |
| 13 #include "ash/common/system/tray/system_tray_delegate.h" | 13 #include "ash/common/system/tray/system_tray_delegate.h" |
| 14 #include "ash/common/system/tray/system_tray_item.h" | 14 #include "ash/common/system/tray/system_tray_item.h" |
| 15 #include "ash/common/system/tray/tray_constants.h" | 15 #include "ash/common/system/tray/tray_constants.h" |
| 16 #include "ash/common/system/tray_accessibility.h" | 16 #include "ash/common/system/tray_accessibility.h" |
| 17 #include "ash/common/system/update/tray_update.h" | 17 #include "ash/common/system/update/tray_update.h" |
| 18 #include "ash/common/wm_lookup.h" | 18 #include "ash/common/wm_lookup.h" |
| 19 #include "ash/common/wm_root_window_controller.h" | 19 #include "ash/common/wm_root_window_controller.h" |
| 20 #include "ash/common/wm_shell.h" | 20 #include "ash/common/wm_shell.h" |
| 21 #include "ash/common/wm_window.h" | 21 #include "ash/common/wm_window.h" |
| 22 #include "ash/metrics/user_metrics_recorder.h" | |
| 23 #include "ash/shell.h" | 22 #include "ash/shell.h" |
| 24 #include "ash/system/cast/tray_cast.h" | 23 #include "ash/system/cast/tray_cast.h" |
| 25 #include "ash/system/status_area_widget.h" | 24 #include "ash/system/status_area_widget.h" |
| 26 #include "ash/system/tray/tray_bubble_wrapper.h" | 25 #include "ash/system/tray/tray_bubble_wrapper.h" |
| 27 #include "ash/system/user/login_status.h" | 26 #include "ash/system/user/login_status.h" |
| 28 #include "ash/system/user/tray_user.h" | 27 #include "ash/system/user/tray_user.h" |
| 29 #include "ash/system/user/tray_user_separator.h" | 28 #include "ash/system/user/tray_user_separator.h" |
| 30 #include "ash/system/web_notification/web_notification_tray.h" | 29 #include "ash/system/web_notification/web_notification_tray.h" |
| 31 #include "base/logging.h" | 30 #include "base/logging.h" |
| 32 #include "base/metrics/histogram.h" | 31 #include "base/metrics/histogram.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 (*it)->DestroyTrayView(); | 155 (*it)->DestroyTrayView(); |
| 157 } | 156 } |
| 158 } | 157 } |
| 159 | 158 |
| 160 void SystemTray::InitializeTrayItems(SystemTrayDelegate* delegate) { | 159 void SystemTray::InitializeTrayItems(SystemTrayDelegate* delegate) { |
| 161 TrayBackgroundView::Initialize(); | 160 TrayBackgroundView::Initialize(); |
| 162 CreateItems(delegate); | 161 CreateItems(delegate); |
| 163 } | 162 } |
| 164 | 163 |
| 165 void SystemTray::CreateItems(SystemTrayDelegate* delegate) { | 164 void SystemTray::CreateItems(SystemTrayDelegate* delegate) { |
| 165 WmShell* wm_shell = WmShell::Get(); |
| 166 #if !defined(OS_WIN) | 166 #if !defined(OS_WIN) |
| 167 // Create user items for each possible user. | 167 // Create user items for each possible user. |
| 168 ash::Shell* shell = ash::Shell::GetInstance(); | |
| 169 int maximum_user_profiles = | 168 int maximum_user_profiles = |
| 170 shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers(); | 169 wm_shell->GetSessionStateDelegate()->GetMaximumNumberOfLoggedInUsers(); |
| 171 for (int i = 0; i < maximum_user_profiles; i++) | 170 for (int i = 0; i < maximum_user_profiles; i++) |
| 172 AddTrayItem(new TrayUser(this, i)); | 171 AddTrayItem(new TrayUser(this, i)); |
| 173 | 172 |
| 174 if (maximum_user_profiles > 1) { | 173 if (maximum_user_profiles > 1) { |
| 175 // Add a special double line separator between users and the rest of the | 174 // Add a special double line separator between users and the rest of the |
| 176 // menu if more then one user is logged in. | 175 // menu if more then one user is logged in. |
| 177 AddTrayItem(new TrayUserSeparator(this)); | 176 AddTrayItem(new TrayUserSeparator(this)); |
| 178 } | 177 } |
| 179 #endif | 178 #endif |
| 180 | 179 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 208 AddTrayItem(new TrayRotationLock(this)); | 207 AddTrayItem(new TrayRotationLock(this)); |
| 209 AddTrayItem(new TraySettings(this)); | 208 AddTrayItem(new TraySettings(this)); |
| 210 AddTrayItem(tray_update_); | 209 AddTrayItem(tray_update_); |
| 211 AddTrayItem(tray_date_); | 210 AddTrayItem(tray_date_); |
| 212 #elif defined(OS_WIN) | 211 #elif defined(OS_WIN) |
| 213 AddTrayItem(tray_accessibility_); | 212 AddTrayItem(tray_accessibility_); |
| 214 AddTrayItem(tray_update_); | 213 AddTrayItem(tray_update_); |
| 215 AddTrayItem(tray_date_); | 214 AddTrayItem(tray_date_); |
| 216 #endif | 215 #endif |
| 217 | 216 |
| 218 SetVisible(ash::WmShell::Get() | 217 SetVisible(wm_shell->system_tray_delegate()->GetTrayVisibilityOnStartup()); |
| 219 ->system_tray_delegate() | |
| 220 ->GetTrayVisibilityOnStartup()); | |
| 221 } | 218 } |
| 222 | 219 |
| 223 void SystemTray::AddTrayItem(SystemTrayItem* item) { | 220 void SystemTray::AddTrayItem(SystemTrayItem* item) { |
| 224 items_.push_back(item); | 221 items_.push_back(item); |
| 225 | 222 |
| 226 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); | 223 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); |
| 227 views::View* tray_item = item->CreateTrayView(delegate->GetUserLoginStatus()); | 224 views::View* tray_item = item->CreateTrayView(delegate->GetUserLoginStatus()); |
| 228 item->UpdateAfterShelfAlignmentChange(shelf_alignment()); | 225 item->UpdateAfterShelfAlignmentChange(shelf_alignment()); |
| 229 | 226 |
| 230 if (tray_item) { | 227 if (tray_item) { |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 } | 428 } |
| 432 | 429 |
| 433 gfx::Point point(item_view->width() / 2, 0); | 430 gfx::Point point(item_view->width() / 2, 0); |
| 434 ConvertPointToWidget(item_view, &point); | 431 ConvertPointToWidget(item_view, &point); |
| 435 return point.x(); | 432 return point.x(); |
| 436 } | 433 } |
| 437 | 434 |
| 438 void SystemTray::ShowDefaultViewWithOffset(BubbleCreationType creation_type, | 435 void SystemTray::ShowDefaultViewWithOffset(BubbleCreationType creation_type, |
| 439 int arrow_offset, | 436 int arrow_offset, |
| 440 bool persistent) { | 437 bool persistent) { |
| 441 if (creation_type != BUBBLE_USE_EXISTING) { | 438 if (creation_type != BUBBLE_USE_EXISTING) |
| 442 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 439 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_MENU_OPENED); |
| 443 ash::UMA_STATUS_AREA_MENU_OPENED); | |
| 444 } | |
| 445 ShowItems(items_.get(), false, true, creation_type, arrow_offset, persistent); | 440 ShowItems(items_.get(), false, true, creation_type, arrow_offset, persistent); |
| 446 } | 441 } |
| 447 | 442 |
| 448 void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items, | 443 void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items, |
| 449 bool detailed, | 444 bool detailed, |
| 450 bool can_activate, | 445 bool can_activate, |
| 451 BubbleCreationType creation_type, | 446 BubbleCreationType creation_type, |
| 452 int arrow_offset, | 447 int arrow_offset, |
| 453 bool persistent) { | 448 bool persistent) { |
| 454 // No system tray bubbles in kiosk mode. | 449 // No system tray bubbles in kiosk mode. |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 .work_area(); | 597 .work_area(); |
| 603 height = | 598 height = |
| 604 std::max(0, work_area.height() - bubble_view->GetBoundsInScreen().y()); | 599 std::max(0, work_area.height() - bubble_view->GetBoundsInScreen().y()); |
| 605 } | 600 } |
| 606 status_area_widget()->web_notification_tray()->SetSystemTrayHeight(height); | 601 status_area_widget()->web_notification_tray()->SetSystemTrayHeight(height); |
| 607 } | 602 } |
| 608 | 603 |
| 609 base::string16 SystemTray::GetAccessibleTimeString( | 604 base::string16 SystemTray::GetAccessibleTimeString( |
| 610 const base::Time& now) const { | 605 const base::Time& now) const { |
| 611 base::HourClockType hour_type = | 606 base::HourClockType hour_type = |
| 612 ash::WmShell::Get()->system_tray_delegate()->GetHourClockType(); | 607 WmShell::Get()->system_tray_delegate()->GetHourClockType(); |
| 613 return base::TimeFormatTimeOfDayWithHourClockType( | 608 return base::TimeFormatTimeOfDayWithHourClockType( |
| 614 now, hour_type, base::kKeepAmPm); | 609 now, hour_type, base::kKeepAmPm); |
| 615 } | 610 } |
| 616 | 611 |
| 617 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { | 612 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { |
| 618 if (alignment == shelf_alignment()) | 613 if (alignment == shelf_alignment()) |
| 619 return; | 614 return; |
| 620 TrayBackgroundView::SetShelfAlignment(alignment); | 615 TrayBackgroundView::SetShelfAlignment(alignment); |
| 621 UpdateAfterShelfAlignmentChange(alignment); | 616 UpdateAfterShelfAlignmentChange(alignment); |
| 622 // Destroy any existing bubble so that it is rebuilt correctly. | 617 // Destroy any existing bubble so that it is rebuilt correctly. |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 .work_area() | 768 .work_area() |
| 774 .height(); | 769 .height(); |
| 775 if (work_area_height > 0) { | 770 if (work_area_height > 0) { |
| 776 UMA_HISTOGRAM_CUSTOM_COUNTS( | 771 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 777 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", | 772 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", |
| 778 100 * bubble_view->height() / work_area_height, 1, 300, 100); | 773 100 * bubble_view->height() / work_area_height, 1, 300, 100); |
| 779 } | 774 } |
| 780 } | 775 } |
| 781 | 776 |
| 782 } // namespace ash | 777 } // namespace ash |
| OLD | NEW |