| 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 "ui/views/focus/focus_manager.h" | 5 #include "ui/views/focus/focus_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 // Disabling keyboard accessibility may cause the focused view to become not | 306 // Disabling keyboard accessibility may cause the focused view to become not |
| 307 // focusable. Hence advance focus if necessary. | 307 // focusable. Hence advance focus if necessary. |
| 308 AdvanceFocusIfNecessary(); | 308 AdvanceFocusIfNecessary(); |
| 309 } | 309 } |
| 310 | 310 |
| 311 void FocusManager::SetFocusedViewWithReason( | 311 void FocusManager::SetFocusedViewWithReason( |
| 312 View* view, FocusChangeReason reason) { | 312 View* view, FocusChangeReason reason) { |
| 313 if (focused_view_ == view) | 313 if (focused_view_ == view) |
| 314 return; | 314 return; |
| 315 | 315 |
| 316 #if !defined(OS_MACOSX) |
| 317 // TODO(warx): There are some AccessiblePaneViewTest failed on macosx. |
| 318 // crbug.com/650859. Remove !defined(OS_MACOSX) once that is fixed. |
| 319 // |
| 320 // If |widget_| is not active, focus is not allowed to set within |widget_| |
| 321 // right now, we just need to store this view. |
| 322 if (view && !widget_->IsActive()) { |
| 323 SetStoredFocusView(view); |
| 324 return; |
| 325 } |
| 326 #endif |
| 327 |
| 316 base::AutoReset<bool> auto_changing_focus(&is_changing_focus_, true); | 328 base::AutoReset<bool> auto_changing_focus(&is_changing_focus_, true); |
| 317 // Update the reason for the focus change (since this is checked by | 329 // Update the reason for the focus change (since this is checked by |
| 318 // some listeners), then notify all listeners. | 330 // some listeners), then notify all listeners. |
| 319 focus_change_reason_ = reason; | 331 focus_change_reason_ = reason; |
| 320 FOR_EACH_OBSERVER(FocusChangeListener, focus_change_listeners_, | 332 FOR_EACH_OBSERVER(FocusChangeListener, focus_change_listeners_, |
| 321 OnWillChangeFocus(focused_view_, view)); | 333 OnWillChangeFocus(focused_view_, view)); |
| 322 | 334 |
| 323 View* old_focused_view = focused_view_; | 335 View* old_focused_view = focused_view_; |
| 324 focused_view_ = view; | 336 focused_view_ = view; |
| 325 if (old_focused_view) | 337 if (old_focused_view) |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 // |keyboard_accessible_| is only used on Mac. | 565 // |keyboard_accessible_| is only used on Mac. |
| 554 #if defined(OS_MACOSX) | 566 #if defined(OS_MACOSX) |
| 555 return keyboard_accessible_ ? view->IsAccessibilityFocusable() | 567 return keyboard_accessible_ ? view->IsAccessibilityFocusable() |
| 556 : view->IsFocusable(); | 568 : view->IsFocusable(); |
| 557 #else | 569 #else |
| 558 return view->IsAccessibilityFocusable(); | 570 return view->IsAccessibilityFocusable(); |
| 559 #endif | 571 #endif |
| 560 } | 572 } |
| 561 | 573 |
| 562 } // namespace views | 574 } // namespace views |
| OLD | NEW |