| 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/common/system/tray/system_tray.h" | 5 #include "ash/common/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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 DCHECK(anchor); | 129 DCHECK(anchor); |
| 130 LoginStatus login_status = | 130 LoginStatus login_status = |
| 131 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus(); | 131 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus(); |
| 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 (WmShell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled() && | 139 if (Shell::GetInstance() |
| 140 ->accessibility_delegate() |
| 141 ->IsSpokenFeedbackEnabled() && |
| 140 !is_persistent) { | 142 !is_persistent) { |
| 141 bubble_->FocusDefaultIfNeeded(); | 143 bubble_->FocusDefaultIfNeeded(); |
| 142 } | 144 } |
| 143 } | 145 } |
| 144 | 146 |
| 145 // Convenience accessors: | 147 // Convenience accessors: |
| 146 SystemTrayBubble* bubble() const { return bubble_.get(); } | 148 SystemTrayBubble* bubble() const { return bubble_.get(); } |
| 147 SystemTrayBubble::BubbleType bubble_type() const { | 149 SystemTrayBubble::BubbleType bubble_type() const { |
| 148 return bubble_->bubble_type(); | 150 return bubble_->bubble_type(); |
| 149 } | 151 } |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 } | 480 } |
| 479 | 481 |
| 480 // Destroy any existing bubble and create a new one. | 482 // Destroy any existing bubble and create a new one. |
| 481 SystemTrayBubble::BubbleType bubble_type = | 483 SystemTrayBubble::BubbleType bubble_type = |
| 482 detailed ? SystemTrayBubble::BUBBLE_TYPE_DETAILED | 484 detailed ? SystemTrayBubble::BUBBLE_TYPE_DETAILED |
| 483 : SystemTrayBubble::BUBBLE_TYPE_DEFAULT; | 485 : SystemTrayBubble::BUBBLE_TYPE_DEFAULT; |
| 484 | 486 |
| 485 if (system_bubble_.get() && creation_type == BUBBLE_USE_EXISTING) { | 487 if (system_bubble_.get() && creation_type == BUBBLE_USE_EXISTING) { |
| 486 system_bubble_->bubble()->UpdateView(items, bubble_type); | 488 system_bubble_->bubble()->UpdateView(items, bubble_type); |
| 487 // If ChromeVox is enabled, focus the default item if no item is focused. | 489 // If ChromeVox is enabled, focus the default item if no item is focused. |
| 488 if (WmShell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled()) | 490 if (Shell::GetInstance() |
| 491 ->accessibility_delegate() |
| 492 ->IsSpokenFeedbackEnabled()) |
| 489 system_bubble_->bubble()->FocusDefaultIfNeeded(); | 493 system_bubble_->bubble()->FocusDefaultIfNeeded(); |
| 490 } else { | 494 } else { |
| 491 // Cleanup the existing bubble before showing a new one. Otherwise, it's | 495 // Cleanup the existing bubble before showing a new one. Otherwise, it's |
| 492 // possible to confuse the new system bubble with the old one during | 496 // possible to confuse the new system bubble with the old one during |
| 493 // destruction, leading to subtle errors/crashes such as crbug.com/545166. | 497 // destruction, leading to subtle errors/crashes such as crbug.com/545166. |
| 494 DestroySystemBubble(); | 498 DestroySystemBubble(); |
| 495 | 499 |
| 496 // Remember if the menu is a single property (like e.g. volume) or the | 500 // Remember if the menu is a single property (like e.g. volume) or the |
| 497 // full tray menu. Note that in case of the |BUBBLE_USE_EXISTING| case | 501 // full tray menu. Note that in case of the |BUBBLE_USE_EXISTING| case |
| 498 // above, |full_system_tray_menu_| does not get changed since the fact that | 502 // above, |full_system_tray_menu_| does not get changed since the fact that |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 .work_area() | 774 .work_area() |
| 771 .height(); | 775 .height(); |
| 772 if (work_area_height > 0) { | 776 if (work_area_height > 0) { |
| 773 UMA_HISTOGRAM_CUSTOM_COUNTS( | 777 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 774 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", | 778 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", |
| 775 100 * bubble_view->height() / work_area_height, 1, 300, 100); | 779 100 * bubble_view->height() / work_area_height, 1, 300, 100); |
| 776 } | 780 } |
| 777 } | 781 } |
| 778 | 782 |
| 779 } // namespace ash | 783 } // namespace ash |
| OLD | NEW |