Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1399)

Unified Diff: ash/common/system/status_area_widget.cc

Issue 2295843006: Signin screen and locked screen status area focus advancing (Closed)
Patch Set: optimization Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698