| 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/focus_cycler.h" | 5 #include "ash/focus_cycler.h" |
| 6 | 6 |
| 7 #include "ash/aura/wm_window_aura.h" |
| 7 #include "ash/common/wm/window_state.h" | 8 #include "ash/common/wm/window_state.h" |
| 8 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 9 #include "ash/wm/mru_window_tracker.h" | 10 #include "ash/wm/mru_window_tracker.h" |
| 10 #include "ash/wm/window_state_aura.h" | 11 #include "ash/wm/window_state_aura.h" |
| 11 #include "ash/wm/window_util.h" | 12 #include "ash/wm/window_util.h" |
| 12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 13 #include "ui/views/accessible_pane_view.h" | 14 #include "ui/views/accessible_pane_view.h" |
| 14 #include "ui/views/focus/focus_search.h" | 15 #include "ui/views/focus/focus_search.h" |
| 15 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
| 16 #include "ui/wm/public/activation_client.h" | 17 #include "ui/wm/public/activation_client.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // Ensure that we don't loop more than once. | 81 // Ensure that we don't loop more than once. |
| 81 if (index == start_index) | 82 if (index == start_index) |
| 82 break; | 83 break; |
| 83 | 84 |
| 84 if (index == browser_index) { | 85 if (index == browser_index) { |
| 85 // Activate the most recently active browser window. | 86 // Activate the most recently active browser window. |
| 86 MruWindowTracker::WindowList mru_windows( | 87 MruWindowTracker::WindowList mru_windows( |
| 87 Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList()); | 88 Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList()); |
| 88 if (mru_windows.empty()) | 89 if (mru_windows.empty()) |
| 89 break; | 90 break; |
| 90 aura::Window* window = mru_windows.front(); | 91 WmWindow* window = mru_windows.front(); |
| 91 wm::GetWindowState(window)->Activate(); | 92 window->GetWindowState()->Activate(); |
| 92 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); | 93 views::Widget* widget = views::Widget::GetWidgetForNativeWindow( |
| 94 WmWindowAura::GetAuraWindow(window)); |
| 93 if (!widget) | 95 if (!widget) |
| 94 break; | 96 break; |
| 95 views::FocusManager* focus_manager = widget->GetFocusManager(); | 97 views::FocusManager* focus_manager = widget->GetFocusManager(); |
| 96 focus_manager->ClearFocus(); | 98 focus_manager->ClearFocus(); |
| 97 focus_manager->RotatePaneFocus( | 99 focus_manager->RotatePaneFocus( |
| 98 direction == BACKWARD ? | 100 direction == BACKWARD ? |
| 99 views::FocusManager::kBackward : views::FocusManager::kForward, | 101 views::FocusManager::kBackward : views::FocusManager::kForward, |
| 100 views::FocusManager::kWrap); | 102 views::FocusManager::kWrap); |
| 101 break; | 103 break; |
| 102 } else { | 104 } else { |
| 103 if (FocusWidget(widgets_[index])) | 105 if (FocusWidget(widgets_[index])) |
| 104 break; | 106 break; |
| 105 } | 107 } |
| 106 } | 108 } |
| 107 } | 109 } |
| 108 | 110 |
| 109 bool FocusCycler::FocusWidget(views::Widget* widget) { | 111 bool FocusCycler::FocusWidget(views::Widget* widget) { |
| 110 // Note: It is not necessary to set the focus directly to the pane since that | 112 // Note: It is not necessary to set the focus directly to the pane since that |
| 111 // will be taken care of by the widget activation. | 113 // will be taken care of by the widget activation. |
| 112 widget_activating_ = widget; | 114 widget_activating_ = widget; |
| 113 widget->Activate(); | 115 widget->Activate(); |
| 114 widget_activating_ = NULL; | 116 widget_activating_ = NULL; |
| 115 return widget->IsActive(); | 117 return widget->IsActive(); |
| 116 } | 118 } |
| 117 | 119 |
| 118 } // namespace ash | 120 } // namespace ash |
| OLD | NEW |