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 f9b41edbe1e24430e49b800b50c7fa85ac6d4f01..7d1ded8bd5612176ac9f5e8476902b4d6e995266 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" |
| @@ -220,6 +222,11 @@ void StatusAreaWidget::OnNativeWidgetActivationChanged(bool active) { |
| status_area_widget_delegate_->SetPaneFocusAndFocusDefault(); |
| } |
| +void StatusAreaWidget::OnKeyEvent(ui::KeyEvent* event) { |
| + HandleFocusKeyEvent(event); |
| + Widget::OnKeyEvent(event); |
|
xiyuan
2016/09/12 18:19:09
nit: Skip if event->handled() is true.
|
| +} |
| + |
| void StatusAreaWidget::UpdateShelfItemBackground(int alpha) { |
| web_notification_tray_->UpdateShelfItemBackground(alpha); |
| system_tray_->UpdateShelfItemBackground(alpha); |
| @@ -300,4 +307,26 @@ 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; |
| + } |
| + |
| + bool reverse = event->IsShiftDown(); |
| + views::View* next_focusable_view = focus_manager->GetNextFocusableView( |
| + focus_manager->GetFocusedView(), nullptr, reverse, false); |
| + if (system_tray_ && system_tray_->visible() && |
| + system_tray_->Contains(next_focusable_view)) { |
| + wm_shell->system_tray_notifier()->NotifyWillReturnFocusToWebContents( |
| + reverse); |
| + event->SetHandled(); |
| + } |
| +} |
| + |
| } // namespace ash |