Index: ash/system/tray/system_tray.cc |
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc |
index d129fba629f271ca16bda49ec0d24a31ae84667f..66ca2527aa0a3fcbdf222f0f1912912471c14af7 100644 |
--- a/ash/system/tray/system_tray.cc |
+++ b/ash/system/tray/system_tray.cc |
@@ -8,7 +8,6 @@ |
#include <map> |
#include <vector> |
-#include "ash/accelerators/accelerator_controller.h" |
#include "ash/key_event_watcher.h" |
#include "ash/login_status.h" |
#include "ash/public/cpp/config.h" |
@@ -119,14 +118,19 @@ |
TrayBubbleView::InitParams* init_params, |
bool is_persistent) { |
DCHECK(anchor); |
- |
- is_persistent_ = is_persistent; |
- |
const LoginStatus login_status = |
Shell::Get()->session_controller()->login_status(); |
bubble_->InitView(anchor, login_status, init_params); |
bubble_->bubble_view()->set_anchor_view_insets(anchor_insets); |
bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_->bubble_view())); |
+ is_persistent_ = is_persistent; |
+ |
+ // If ChromeVox is enabled, focus the default item if no item is focused and |
+ // there isn't a delayed close. |
+ if (Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled() && |
+ !is_persistent) { |
+ bubble_->FocusDefaultIfNeeded(); |
+ } |
} |
// Convenience accessors: |
@@ -206,6 +210,7 @@ |
SystemTray::~SystemTray() { |
// Destroy any child views that might have back pointers before ~View(). |
activation_observer_.reset(); |
+ key_event_watcher_.reset(); |
system_bubble_.reset(); |
for (const auto& item : items_) |
item->OnTrayViewDestroyed(); |
@@ -432,6 +437,9 @@ |
if (system_bubble_.get() && creation_type == BUBBLE_USE_EXISTING) { |
system_bubble_->bubble()->UpdateView(items, bubble_type); |
+ // If ChromeVox is enabled, focus the default item if no item is focused. |
+ if (Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled()) |
+ system_bubble_->bubble()->FocusDefaultIfNeeded(); |
} else { |
// Cleanup the existing bubble before showing a new one. Otherwise, it's |
// possible to confuse the new system bubble with the old one during |
@@ -449,6 +457,8 @@ |
init_params.anchor_alignment = GetAnchorAlignment(); |
init_params.min_width = kTrayMenuMinimumWidth; |
init_params.max_width = kTrayPopupMaxWidth; |
+ // TODO(oshima): Change TrayBubbleView itself. |
+ init_params.can_activate = false; |
// The bubble is not initially activatable, but will become activatable if |
// the user presses Tab. For behavioral consistency with the non-activatable |
// scenario, don't close on deactivation after Tab either. |
@@ -477,6 +487,10 @@ |
if (!detailed) |
default_bubble_height_ = system_bubble_->bubble_view()->height(); |
+ key_event_watcher_.reset(); |
+ if (can_activate) |
+ CreateKeyEventWatcher(); |
+ |
if (detailed && items.size() > 0) |
detailed_item_ = items[0]; |
else |
@@ -567,28 +581,8 @@ |
system_bubble_->bubble()->RestartAutoCloseTimer(); |
} |
-void SystemTray::RegisterAccelerators( |
- const std::vector<ui::Accelerator>& accelerators, |
- views::TrayBubbleView* tray_bubble_view) { |
- Shell::Get()->accelerator_controller()->Register(accelerators, |
- tray_bubble_view); |
-} |
- |
-void SystemTray::UnregisterAllAccelerators( |
- views::TrayBubbleView* tray_bubble_view) { |
- Shell::Get()->accelerator_controller()->UnregisterAll(tray_bubble_view); |
-} |
- |
base::string16 SystemTray::GetAccessibleNameForBubble() { |
return GetAccessibleNameForTray(); |
-} |
- |
-bool SystemTray::ShouldEnableExtraKeyboardAccessibility() { |
- // Do not enable extra keyboard accessibility for persistent system bubble. |
- // e.g. volume slider. Persistent system bubble is a bubble which is not |
- // closed even if user clicks outside of the bubble. |
- return system_bubble_ && !system_bubble_->is_persistent() && |
- Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled(); |
} |
void SystemTray::HideBubble(const TrayBubbleView* bubble_view) { |
@@ -606,6 +600,24 @@ |
views::Widget* widget = GetSystemBubble()->bubble_view()->GetWidget(); |
widget->GetFocusManager()->OnKeyEvent(key_event); |
+} |
+ |
+void SystemTray::CreateKeyEventWatcher() { |
+ key_event_watcher_ = ShellPort::Get()->CreateKeyEventWatcher(); |
+ // mustash does not yet support KeyEventWatcher. http://crbug.com/649600. |
+ if (!key_event_watcher_) |
+ return; |
+ key_event_watcher_->AddKeyEventCallback( |
+ ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE), |
+ base::Bind(&SystemTray::CloseBubble, base::Unretained(this))); |
+ key_event_watcher_->AddKeyEventCallback( |
+ ui::Accelerator(ui::VKEY_TAB, ui::EF_NONE), |
+ base::Bind(&SystemTray::ActivateAndStartNavigation, |
+ base::Unretained(this))); |
+ key_event_watcher_->AddKeyEventCallback( |
+ ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN), |
+ base::Bind(&SystemTray::ActivateAndStartNavigation, |
+ base::Unretained(this))); |
} |
void SystemTray::ActivateBubble() { |
@@ -635,6 +647,7 @@ |
void SystemTray::CloseSystemBubbleAndDeactivateSystemTray() { |
activation_observer_.reset(); |
+ key_event_watcher_.reset(); |
system_bubble_.reset(); |
// When closing a system bubble with the alternate shelf layout, we need to |
// turn off the active tinting of the shelf. |