Chromium Code Reviews| Index: ash/common/system/status_area_widget.cc |
| diff --git a/ash/common/system/status_area_widget.cc b/ash/common/system/status_area_widget.cc |
| index cf5ae68e1a7ff2b35187053b56b02bf069553dae..4a96ca31610e01cdac842e04e401ff49de839347 100644 |
| --- a/ash/common/system/status_area_widget.cc |
| +++ b/ash/common/system/status_area_widget.cc |
| @@ -11,6 +11,7 @@ |
| #include "ash/common/system/status_area_widget_delegate.h" |
| #include "ash/common/system/tray/system_tray.h" |
| #include "ash/common/system/tray/system_tray_delegate.h" |
| +#include "ash/common/system/tray/system_tray_notifier.h" |
| #include "ash/common/system/web_notification/web_notification_tray.h" |
| #include "ash/common/wm_lookup.h" |
| #include "ash/common/wm_root_window_controller.h" |
| @@ -18,6 +19,7 @@ |
| #include "ash/common/wm_window.h" |
| #include "base/i18n/time_formatting.h" |
| #include "ui/native_theme/native_theme_dark_aura.h" |
| +#include "ui/views/focus/focus_manager.h" |
| #if defined(OS_CHROMEOS) |
| #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h" |
| @@ -219,6 +221,11 @@ void StatusAreaWidget::OnNativeWidgetActivationChanged(bool active) { |
| status_area_widget_delegate_->SetPaneFocusAndFocusDefault(); |
| } |
| +void StatusAreaWidget::OnKeyEvent(ui::KeyEvent* event) { |
| + HandleFocusKeyEvent(event); |
| + Widget::OnKeyEvent(event); |
| +} |
| + |
| void StatusAreaWidget::UpdateShelfItemBackground(int alpha) { |
| web_notification_tray_->UpdateShelfItemBackground(alpha); |
| system_tray_->UpdateShelfItemBackground(alpha); |
| @@ -290,4 +297,46 @@ void StatusAreaWidget::AddOverviewButtonTray() { |
| status_area_widget_delegate_->AddTray(overview_button_tray_); |
| } |
| +void StatusAreaWidget::HandleFocusKeyEvent(ui::KeyEvent* event) { |
| + WmShell* wm_shell = WmShell::Get(); |
| + LoginStatus status = wm_shell->system_tray_delegate()->GetUserLoginStatus(); |
| + bool is_tab_pressed = event->type() == ui::ET_KEY_PRESSED && |
| + views::FocusManager::IsTabTraversalKeyEvent(*event); |
| + views::FocusManager* focus_manager = GetFocusManager(); |
| + if ((status != LoginStatus::NOT_LOGGED_IN && status != LoginStatus::LOCKED) || |
| + !is_tab_pressed || !focus_manager) |
| + return; |
|
stevenjb
2016/09/02 20:05:32
{}
Qiang(Joe) Xu
2016/09/09 00:11:14
Done.
|
| + |
| + bool reverse = event->IsShiftDown(); |
| + bool notify_return_focus = false; |
| +#if defined(OS_CHROMEOS) |
| + // When |system_tray_|, |web_notification_tray_|, |virtual_keyboard_tray_| |
| + // are all visible, the reverse sequence needs special processing as |
| + // |virtual_keyboard_tray_|'s next focusable view is |system_tray_|, |
| + // however, |virtual_keyboard_tray_|'s reverse next view should be |
| + // |web_notification_tray_|. |
| + if (reverse && web_notification_tray_ && web_notification_tray_->visible() && |
| + virtual_keyboard_tray_ && virtual_keyboard_tray_->visible() && |
| + system_tray_ && system_tray_->visible()) { |
| + if (virtual_keyboard_tray_->HasFocus()) |
| + return; |
| + |
| + if (web_notification_tray_->HasFocus()) |
| + notify_return_focus = true; |
| + } |
| +#endif |
| + |
| + views::View* next_focusable_view = focus_manager->GetNextFocusableView( |
| + focus_manager->GetFocusedView(), nullptr, false, false); |
| + if (system_tray_ && system_tray_->visible() && |
| + system_tray_->Contains(next_focusable_view)) |
| + notify_return_focus = true; |
|
stevenjb
2016/09/02 20:05:32
{}
Qiang(Joe) Xu
2016/09/09 00:11:14
Done.
|
| + |
| + if (notify_return_focus) { |
| + wm_shell->system_tray_notifier()->NotifyWillReturnFocusToWebContents( |
| + reverse); |
| + event->SetHandled(); |
| + } |
| +} |
| + |
| } // namespace ash |