Chromium Code Reviews| 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/status_area_widget.h" | 5 #include "ash/common/system/status_area_widget.h" |
| 6 | 6 |
| 7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/shelf/wm_shelf.h" | 8 #include "ash/common/shelf/wm_shelf.h" |
| 9 #include "ash/common/shell_window_ids.h" | 9 #include "ash/common/shell_window_ids.h" |
| 10 #include "ash/common/system/overview/overview_button_tray.h" | 10 #include "ash/common/system/overview/overview_button_tray.h" |
| 11 #include "ash/common/system/status_area_widget_delegate.h" | 11 #include "ash/common/system/status_area_widget_delegate.h" |
| 12 #include "ash/common/system/tray/system_tray.h" | 12 #include "ash/common/system/tray/system_tray.h" |
| 13 #include "ash/common/system/tray/system_tray_delegate.h" | 13 #include "ash/common/system/tray/system_tray_delegate.h" |
| 14 #include "ash/common/system/tray/system_tray_notifier.h" | |
| 14 #include "ash/common/system/web_notification/web_notification_tray.h" | 15 #include "ash/common/system/web_notification/web_notification_tray.h" |
| 15 #include "ash/common/wm_lookup.h" | 16 #include "ash/common/wm_lookup.h" |
| 16 #include "ash/common/wm_root_window_controller.h" | 17 #include "ash/common/wm_root_window_controller.h" |
| 17 #include "ash/common/wm_shell.h" | 18 #include "ash/common/wm_shell.h" |
| 18 #include "ash/common/wm_window.h" | 19 #include "ash/common/wm_window.h" |
| 19 #include "base/i18n/time_formatting.h" | 20 #include "base/i18n/time_formatting.h" |
| 20 #include "ui/native_theme/native_theme_dark_aura.h" | 21 #include "ui/native_theme/native_theme_dark_aura.h" |
| 22 #include "ui/views/focus/focus_manager.h" | |
| 21 | 23 |
| 22 #if defined(OS_CHROMEOS) | 24 #if defined(OS_CHROMEOS) |
| 23 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h" | 25 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h" |
| 24 #include "ash/common/system/chromeos/palette/palette_tray.h" | 26 #include "ash/common/system/chromeos/palette/palette_tray.h" |
| 25 #include "ash/common/system/chromeos/palette/palette_utils.h" | 27 #include "ash/common/system/chromeos/palette/palette_utils.h" |
| 26 #include "ash/common/system/chromeos/session/logout_button_tray.h" | 28 #include "ash/common/system/chromeos/session/logout_button_tray.h" |
| 27 #include "ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h" | 29 #include "ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h" |
| 28 #endif | 30 #endif |
| 29 | 31 |
| 30 namespace ash { | 32 namespace ash { |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 ? ui::NativeThemeDarkAura::instance() | 214 ? ui::NativeThemeDarkAura::instance() |
| 213 : Widget::GetNativeTheme(); | 215 : Widget::GetNativeTheme(); |
| 214 } | 216 } |
| 215 | 217 |
| 216 void StatusAreaWidget::OnNativeWidgetActivationChanged(bool active) { | 218 void StatusAreaWidget::OnNativeWidgetActivationChanged(bool active) { |
| 217 Widget::OnNativeWidgetActivationChanged(active); | 219 Widget::OnNativeWidgetActivationChanged(active); |
| 218 if (active) | 220 if (active) |
| 219 status_area_widget_delegate_->SetPaneFocusAndFocusDefault(); | 221 status_area_widget_delegate_->SetPaneFocusAndFocusDefault(); |
| 220 } | 222 } |
| 221 | 223 |
| 224 void StatusAreaWidget::OnKeyEvent(ui::KeyEvent* event) { | |
| 225 HandleFocusKeyEvent(event); | |
| 226 Widget::OnKeyEvent(event); | |
| 227 } | |
| 228 | |
| 222 void StatusAreaWidget::UpdateShelfItemBackground(int alpha) { | 229 void StatusAreaWidget::UpdateShelfItemBackground(int alpha) { |
| 223 web_notification_tray_->UpdateShelfItemBackground(alpha); | 230 web_notification_tray_->UpdateShelfItemBackground(alpha); |
| 224 system_tray_->UpdateShelfItemBackground(alpha); | 231 system_tray_->UpdateShelfItemBackground(alpha); |
| 225 #if defined(OS_CHROMEOS) | 232 #if defined(OS_CHROMEOS) |
| 226 virtual_keyboard_tray_->UpdateShelfItemBackground(alpha); | 233 virtual_keyboard_tray_->UpdateShelfItemBackground(alpha); |
| 227 logout_button_tray_->UpdateShelfItemBackground(alpha); | 234 logout_button_tray_->UpdateShelfItemBackground(alpha); |
| 228 ime_menu_tray_->UpdateShelfItemBackground(alpha); | 235 ime_menu_tray_->UpdateShelfItemBackground(alpha); |
| 229 if (palette_tray_) | 236 if (palette_tray_) |
| 230 palette_tray_->UpdateShelfItemBackground(alpha); | 237 palette_tray_->UpdateShelfItemBackground(alpha); |
| 231 #endif | 238 #endif |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 } | 290 } |
| 284 return false; | 291 return false; |
| 285 } | 292 } |
| 286 #endif | 293 #endif |
| 287 | 294 |
| 288 void StatusAreaWidget::AddOverviewButtonTray() { | 295 void StatusAreaWidget::AddOverviewButtonTray() { |
| 289 overview_button_tray_ = new OverviewButtonTray(wm_shelf_); | 296 overview_button_tray_ = new OverviewButtonTray(wm_shelf_); |
| 290 status_area_widget_delegate_->AddTray(overview_button_tray_); | 297 status_area_widget_delegate_->AddTray(overview_button_tray_); |
| 291 } | 298 } |
| 292 | 299 |
| 300 void StatusAreaWidget::HandleFocusKeyEvent(ui::KeyEvent* event) { | |
| 301 WmShell* wm_shell = WmShell::Get(); | |
| 302 LoginStatus status = wm_shell->system_tray_delegate()->GetUserLoginStatus(); | |
| 303 bool is_tab_pressed = event->type() == ui::ET_KEY_PRESSED && | |
| 304 views::FocusManager::IsTabTraversalKeyEvent(*event); | |
| 305 views::FocusManager* focus_manager = GetFocusManager(); | |
| 306 if ((status != LoginStatus::NOT_LOGGED_IN && status != LoginStatus::LOCKED) || | |
| 307 !is_tab_pressed || !focus_manager) | |
| 308 return; | |
|
stevenjb
2016/09/02 20:05:32
{}
Qiang(Joe) Xu
2016/09/09 00:11:14
Done.
| |
| 309 | |
| 310 bool reverse = event->IsShiftDown(); | |
| 311 bool notify_return_focus = false; | |
| 312 #if defined(OS_CHROMEOS) | |
| 313 // When |system_tray_|, |web_notification_tray_|, |virtual_keyboard_tray_| | |
| 314 // are all visible, the reverse sequence needs special processing as | |
| 315 // |virtual_keyboard_tray_|'s next focusable view is |system_tray_|, | |
| 316 // however, |virtual_keyboard_tray_|'s reverse next view should be | |
| 317 // |web_notification_tray_|. | |
| 318 if (reverse && web_notification_tray_ && web_notification_tray_->visible() && | |
| 319 virtual_keyboard_tray_ && virtual_keyboard_tray_->visible() && | |
| 320 system_tray_ && system_tray_->visible()) { | |
| 321 if (virtual_keyboard_tray_->HasFocus()) | |
| 322 return; | |
| 323 | |
| 324 if (web_notification_tray_->HasFocus()) | |
| 325 notify_return_focus = true; | |
| 326 } | |
| 327 #endif | |
| 328 | |
| 329 views::View* next_focusable_view = focus_manager->GetNextFocusableView( | |
| 330 focus_manager->GetFocusedView(), nullptr, false, false); | |
| 331 if (system_tray_ && system_tray_->visible() && | |
| 332 system_tray_->Contains(next_focusable_view)) | |
| 333 notify_return_focus = true; | |
|
stevenjb
2016/09/02 20:05:32
{}
Qiang(Joe) Xu
2016/09/09 00:11:14
Done.
| |
| 334 | |
| 335 if (notify_return_focus) { | |
| 336 wm_shell->system_tray_notifier()->NotifyWillReturnFocusToWebContents( | |
| 337 reverse); | |
| 338 event->SetHandled(); | |
| 339 } | |
| 340 } | |
| 341 | |
| 293 } // namespace ash | 342 } // namespace ash |
| OLD | NEW |