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 WmShell* wm_shell = WmShell::Get(); | |
226 SystemTrayDelegate* delegate = wm_shell->system_tray_delegate(); | |
227 LoginStatus status = delegate->GetUserLoginStatus(); | |
228 if (status == LoginStatus::NOT_LOGGED_IN || status == LoginStatus::LOCKED) { | |
229 if (event->type() == ui::ET_KEY_PRESSED && | |
230 views::FocusManager::IsTabTraversalKeyEvent(*event)) { | |
stevenjb
2016/09/02 16:29:53
Combine these ifs, invert the logic, call Widget::
Qiang(Joe) Xu
2016/09/02 19:32:51
Done.
| |
231 bool reverse = event->IsShiftDown(); | |
232 views::FocusManager* focus_manager = GetFocusManager(); | |
233 if (!focus_manager) { | |
234 Widget::OnKeyEvent(event); | |
235 return; | |
236 } | |
stevenjb
2016/09/02 16:29:53
Like this :)
Qiang(Joe) Xu
2016/09/02 19:32:51
Done.
| |
237 views::View* next_focusable_view = focus_manager->GetNextFocusableView( | |
238 focus_manager->GetFocusedView(), nullptr, false, false); | |
239 #if defined(OS_CHROMEOS) | |
240 // When |system_tray_|, |web_notification_tray_|, |virtual_keyboard_tray_| | |
241 // are all visible, the reverse sequence needs special processing as | |
242 // |virtual_keyboard_tray_|'s next focusable view is |system_tray_|, | |
243 // however, |virtual_keyboard_tray_|'s reverse next view should be | |
244 // |web_notification_tray_|. | |
245 if (reverse && web_notification_tray_ && | |
246 web_notification_tray_->visible() && virtual_keyboard_tray_ && | |
247 virtual_keyboard_tray_->visible() && system_tray_ && | |
248 system_tray_->visible()) { | |
249 if (virtual_keyboard_tray_->HasFocus()) { | |
250 Widget::OnKeyEvent(event); | |
251 return; | |
stevenjb
2016/09/02 16:29:53
And this. Also no else after a return.
Also, you
Qiang(Joe) Xu
2016/09/02 19:32:51
Combine this return seems to add code lines for OS
| |
252 } else if (web_notification_tray_->HasFocus()) { | |
253 wm_shell->system_tray_notifier()->NotifyWillReturnFocusToWebContents( | |
254 reverse); | |
255 event->SetHandled(); | |
256 } | |
257 } | |
258 #endif | |
259 // At most two visible trays that need focus on status area: | |
260 if (system_tray_ && system_tray_->visible() && | |
261 system_tray_->Contains(next_focusable_view)) { | |
262 wm_shell->system_tray_notifier()->NotifyWillReturnFocusToWebContents( | |
263 reverse); | |
264 event->SetHandled(); | |
265 } | |
266 } | |
267 } | |
268 Widget::OnKeyEvent(event); | |
269 } | |
270 | |
222 void StatusAreaWidget::UpdateShelfItemBackground(int alpha) { | 271 void StatusAreaWidget::UpdateShelfItemBackground(int alpha) { |
223 web_notification_tray_->UpdateShelfItemBackground(alpha); | 272 web_notification_tray_->UpdateShelfItemBackground(alpha); |
224 system_tray_->UpdateShelfItemBackground(alpha); | 273 system_tray_->UpdateShelfItemBackground(alpha); |
225 #if defined(OS_CHROMEOS) | 274 #if defined(OS_CHROMEOS) |
226 virtual_keyboard_tray_->UpdateShelfItemBackground(alpha); | 275 virtual_keyboard_tray_->UpdateShelfItemBackground(alpha); |
227 logout_button_tray_->UpdateShelfItemBackground(alpha); | 276 logout_button_tray_->UpdateShelfItemBackground(alpha); |
228 ime_menu_tray_->UpdateShelfItemBackground(alpha); | 277 ime_menu_tray_->UpdateShelfItemBackground(alpha); |
229 if (palette_tray_) | 278 if (palette_tray_) |
230 palette_tray_->UpdateShelfItemBackground(alpha); | 279 palette_tray_->UpdateShelfItemBackground(alpha); |
231 #endif | 280 #endif |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 return false; | 333 return false; |
285 } | 334 } |
286 #endif | 335 #endif |
287 | 336 |
288 void StatusAreaWidget::AddOverviewButtonTray() { | 337 void StatusAreaWidget::AddOverviewButtonTray() { |
289 overview_button_tray_ = new OverviewButtonTray(wm_shelf_); | 338 overview_button_tray_ = new OverviewButtonTray(wm_shelf_); |
290 status_area_widget_delegate_->AddTray(overview_button_tray_); | 339 status_area_widget_delegate_->AddTray(overview_button_tray_); |
291 } | 340 } |
292 | 341 |
293 } // namespace ash | 342 } // namespace ash |
OLD | NEW |