| 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 if (widget->widget_delegate()->ShouldAdvanceFocusToTopLevelWidget()) | 307 if (widget->widget_delegate()->ShouldAdvanceFocusToTopLevelWidget()) |
| 308 widget = widget_; | 308 widget = widget_; |
| 309 return GetNextFocusableView(NULL, widget, reverse, true); | 309 return GetNextFocusableView(NULL, widget, reverse, true); |
| 310 } | 310 } |
| 311 } | 311 } |
| 312 return NULL; | 312 return NULL; |
| 313 } | 313 } |
| 314 | 314 |
| 315 void FocusManager::SetFocusedViewWithReason( | 315 void FocusManager::SetFocusedViewWithReason( |
| 316 View* view, FocusChangeReason reason) { | 316 View* view, FocusChangeReason reason) { |
| 317 if (focused_view_ == view) | 317 if (focused_view_ == view) { |
| 318 // In the case that the widget lost the focus and gained it back without |
| 319 // changing the focused view, we have to make the text input client focused. |
| 320 // TODO(yukishiino): Remove this hack once we fix http://crbug.com/383236 |
| 321 FocusTextInputClient(focused_view_); |
| 318 return; | 322 return; |
| 323 } |
| 319 | 324 |
| 320 base::AutoReset<bool> auto_changing_focus(&is_changing_focus_, true); | 325 base::AutoReset<bool> auto_changing_focus(&is_changing_focus_, true); |
| 321 // Update the reason for the focus change (since this is checked by | 326 // Update the reason for the focus change (since this is checked by |
| 322 // some listeners), then notify all listeners. | 327 // some listeners), then notify all listeners. |
| 323 focus_change_reason_ = reason; | 328 focus_change_reason_ = reason; |
| 324 FOR_EACH_OBSERVER(FocusChangeListener, focus_change_listeners_, | 329 FOR_EACH_OBSERVER(FocusChangeListener, focus_change_listeners_, |
| 325 OnWillChangeFocus(focused_view_, view)); | 330 OnWillChangeFocus(focused_view_, view)); |
| 326 | 331 |
| 327 View* old_focused_view = focused_view_; | 332 View* old_focused_view = focused_view_; |
| 328 focused_view_ = view; | 333 focused_view_ = view; |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 } | 585 } |
| 581 if (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_DOWN) { | 586 if (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_DOWN) { |
| 582 AdvanceFocus(false); | 587 AdvanceFocus(false); |
| 583 return true; | 588 return true; |
| 584 } | 589 } |
| 585 | 590 |
| 586 return false; | 591 return false; |
| 587 } | 592 } |
| 588 | 593 |
| 589 } // namespace views | 594 } // namespace views |
| OLD | NEW |