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 "ash/common/ash_switches.h" | 7 #include "ash/common/ash_switches.h" |
| 8 #include "ash/common/login_status.h" | 8 #include "ash/common/login_status.h" |
| 9 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
| 10 #include "ash/common/shelf/wm_shelf.h" | 10 #include "ash/common/shelf/wm_shelf.h" |
| 11 #include "ash/common/shelf/wm_shelf_util.h" | 11 #include "ash/common/shelf/wm_shelf_util.h" |
| 12 #include "ash/common/shell_window_ids.h" | 12 #include "ash/common/shell_window_ids.h" |
| 13 #include "ash/common/system/date/tray_date.h" | 13 #include "ash/common/system/date/tray_date.h" |
| 14 #include "ash/common/system/tray/system_tray_delegate.h" | 14 #include "ash/common/system/tray/system_tray_delegate.h" |
| 15 #include "ash/common/system/tray/system_tray_item.h" | 15 #include "ash/common/system/tray/system_tray_item.h" |
| 16 #include "ash/common/system/tray/tray_bubble_wrapper.h" | 16 #include "ash/common/system/tray/tray_bubble_wrapper.h" |
| 17 #include "ash/common/system/tray/tray_constants.h" | 17 #include "ash/common/system/tray/tray_constants.h" |
| 18 #include "ash/common/system/tray_accessibility.h" | 18 #include "ash/common/system/tray_accessibility.h" |
| 19 #include "ash/common/system/update/tray_update.h" | 19 #include "ash/common/system/update/tray_update.h" |
| 20 #include "ash/common/system/user/tray_user_separator.h" | 20 #include "ash/common/system/user/tray_user_separator.h" |
| 21 #include "ash/common/system/web_notification/web_notification_tray.h" | 21 #include "ash/common/system/web_notification/web_notification_tray.h" |
| 22 #include "ash/common/wm_lookup.h" | 22 #include "ash/common/wm_lookup.h" |
| 23 #include "ash/common/wm_root_window_controller.h" | 23 #include "ash/common/wm_root_window_controller.h" |
| 24 #include "ash/common/wm_shell.h" | 24 #include "ash/common/wm_shell.h" |
| 25 #include "ash/common/wm_window.h" | 25 #include "ash/common/wm_window.h" |
| 26 #include "ash/shell.h" | |
|
James Cook
2016/06/28 22:34:25
Hooray!
msw
2016/06/28 22:49:50
Acknowledged.
| |
| 27 #include "ash/system/cast/tray_cast.h" | 26 #include "ash/system/cast/tray_cast.h" |
| 28 #include "ash/system/user/tray_user.h" | 27 #include "ash/system/user/tray_user.h" |
| 29 #include "base/logging.h" | 28 #include "base/logging.h" |
| 30 #include "base/metrics/histogram.h" | 29 #include "base/metrics/histogram.h" |
| 31 #include "base/strings/utf_string_conversions.h" | 30 #include "base/strings/utf_string_conversions.h" |
| 32 #include "base/timer/timer.h" | 31 #include "base/timer/timer.h" |
| 33 #include "grit/ash_strings.h" | 32 #include "grit/ash_strings.h" |
| 34 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
| 35 #include "ui/compositor/layer.h" | 34 #include "ui/compositor/layer.h" |
| 36 #include "ui/display/display.h" | 35 #include "ui/display/display.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 LoginStatus login_status = | 92 LoginStatus login_status = |
| 94 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus(); | 93 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus(); |
| 95 bubble_->InitView(anchor, login_status, init_params); | 94 bubble_->InitView(anchor, login_status, init_params); |
| 96 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_->bubble_view())); | 95 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_->bubble_view())); |
| 97 // The system bubble should not have an arrow. | 96 // The system bubble should not have an arrow. |
| 98 bubble_->bubble_view()->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); | 97 bubble_->bubble_view()->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); |
| 99 is_persistent_ = is_persistent; | 98 is_persistent_ = is_persistent; |
| 100 | 99 |
| 101 // If ChromeVox is enabled, focus the default item if no item is focused and | 100 // If ChromeVox is enabled, focus the default item if no item is focused and |
| 102 // there isn't a delayed close. | 101 // there isn't a delayed close. |
| 103 if (Shell::GetInstance() | 102 if (WmShell::Get()->GetAccessibilityDelegate()->IsSpokenFeedbackEnabled() && |
| 104 ->accessibility_delegate() | |
| 105 ->IsSpokenFeedbackEnabled() && | |
| 106 !is_persistent) { | 103 !is_persistent) { |
| 107 bubble_->FocusDefaultIfNeeded(); | 104 bubble_->FocusDefaultIfNeeded(); |
| 108 } | 105 } |
| 109 } | 106 } |
| 110 | 107 |
| 111 // Convenience accessors: | 108 // Convenience accessors: |
| 112 SystemTrayBubble* bubble() const { return bubble_.get(); } | 109 SystemTrayBubble* bubble() const { return bubble_.get(); } |
| 113 SystemTrayBubble::BubbleType bubble_type() const { | 110 SystemTrayBubble::BubbleType bubble_type() const { |
| 114 return bubble_->bubble_type(); | 111 return bubble_->bubble_type(); |
| 115 } | 112 } |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 SystemTrayBubble::BubbleType bubble_type = | 451 SystemTrayBubble::BubbleType bubble_type = |
| 455 detailed ? SystemTrayBubble::BUBBLE_TYPE_DETAILED | 452 detailed ? SystemTrayBubble::BUBBLE_TYPE_DETAILED |
| 456 : SystemTrayBubble::BUBBLE_TYPE_DEFAULT; | 453 : SystemTrayBubble::BUBBLE_TYPE_DEFAULT; |
| 457 | 454 |
| 458 // Destroy the notification bubble here so that it doesn't get rebuilt | 455 // Destroy the notification bubble here so that it doesn't get rebuilt |
| 459 // while we add items to the main bubble_ (e.g. in HideNotificationView). | 456 // while we add items to the main bubble_ (e.g. in HideNotificationView). |
| 460 notification_bubble_.reset(); | 457 notification_bubble_.reset(); |
| 461 if (system_bubble_.get() && creation_type == BUBBLE_USE_EXISTING) { | 458 if (system_bubble_.get() && creation_type == BUBBLE_USE_EXISTING) { |
| 462 system_bubble_->bubble()->UpdateView(items, bubble_type); | 459 system_bubble_->bubble()->UpdateView(items, bubble_type); |
| 463 // If ChromeVox is enabled, focus the default item if no item is focused. | 460 // If ChromeVox is enabled, focus the default item if no item is focused. |
| 464 if (Shell::GetInstance() | 461 if (WmShell::Get()->GetAccessibilityDelegate()->IsSpokenFeedbackEnabled()) |
| 465 ->accessibility_delegate() | |
| 466 ->IsSpokenFeedbackEnabled()) { | |
| 467 system_bubble_->bubble()->FocusDefaultIfNeeded(); | 462 system_bubble_->bubble()->FocusDefaultIfNeeded(); |
| 468 } | |
| 469 } else { | 463 } else { |
| 470 // Cleanup the existing bubble before showing a new one. Otherwise, it's | 464 // Cleanup the existing bubble before showing a new one. Otherwise, it's |
| 471 // possible to confuse the new system bubble with the old one during | 465 // possible to confuse the new system bubble with the old one during |
| 472 // destruction, leading to subtle errors/crashes such as crbug.com/545166. | 466 // destruction, leading to subtle errors/crashes such as crbug.com/545166. |
| 473 DestroySystemBubble(); | 467 DestroySystemBubble(); |
| 474 | 468 |
| 475 // Remember if the menu is a single property (like e.g. volume) or the | 469 // Remember if the menu is a single property (like e.g. volume) or the |
| 476 // full tray menu. Note that in case of the |BUBBLE_USE_EXISTING| case | 470 // full tray menu. Note that in case of the |BUBBLE_USE_EXISTING| case |
| 477 // above, |full_system_tray_menu_| does not get changed since the fact that | 471 // above, |full_system_tray_menu_| does not get changed since the fact that |
| 478 // the menu is full (or not) doesn't change even if a "single property" | 472 // the menu is full (or not) doesn't change even if a "single property" |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 769 .work_area() | 763 .work_area() |
| 770 .height(); | 764 .height(); |
| 771 if (work_area_height > 0) { | 765 if (work_area_height > 0) { |
| 772 UMA_HISTOGRAM_CUSTOM_COUNTS( | 766 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 773 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", | 767 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", |
| 774 100 * bubble_view->height() / work_area_height, 1, 300, 100); | 768 100 * bubble_view->height() / work_area_height, 1, 300, 100); |
| 775 } | 769 } |
| 776 } | 770 } |
| 777 | 771 |
| 778 } // namespace ash | 772 } // namespace ash |
| OLD | NEW |