| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/focus/focus_manager.h" | 5 #include "views/focus/focus_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 | 10 |
| 11 #if defined(OS_LINUX) | 11 #if defined(OS_LINUX) |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 // This usually just sets the focus if this view is focusable, but | 361 // This usually just sets the focus if this view is focusable, but |
| 362 // let the view override RequestFocus if necessary. | 362 // let the view override RequestFocus if necessary. |
| 363 view->RequestFocus(); | 363 view->RequestFocus(); |
| 364 | 364 |
| 365 // If it succeeded, the reason would be incorrect; set it to | 365 // If it succeeded, the reason would be incorrect; set it to |
| 366 // focus restore. | 366 // focus restore. |
| 367 if (focused_view_ == view) | 367 if (focused_view_ == view) |
| 368 focus_change_reason_ = kReasonFocusRestore; | 368 focus_change_reason_ = kReasonFocusRestore; |
| 369 } | 369 } |
| 370 } | 370 } |
| 371 } else { | |
| 372 // Clearing the focus will focus the root window, so we still get key | |
| 373 // events. | |
| 374 ClearFocus(); | |
| 375 } | 371 } |
| 376 } | 372 } |
| 377 | 373 |
| 378 void FocusManager::ClearStoredFocusedView() { | 374 void FocusManager::ClearStoredFocusedView() { |
| 379 ViewStorage* view_storage = ViewStorage::GetInstance(); | 375 ViewStorage* view_storage = ViewStorage::GetInstance(); |
| 380 if (!view_storage) { | 376 if (!view_storage) { |
| 381 // This should never happen but bug 981648 seems to indicate it could. | 377 // This should never happen but bug 981648 seems to indicate it could. |
| 382 NOTREACHED(); | 378 NOTREACHED(); |
| 383 return; | 379 return; |
| 384 } | 380 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 std::find(focus_change_listeners_.begin(), focus_change_listeners_.end(), | 500 std::find(focus_change_listeners_.begin(), focus_change_listeners_.end(), |
| 505 listener); | 501 listener); |
| 506 if (place == focus_change_listeners_.end()) { | 502 if (place == focus_change_listeners_.end()) { |
| 507 NOTREACHED() << "Removing a listener that isn't registered."; | 503 NOTREACHED() << "Removing a listener that isn't registered."; |
| 508 return; | 504 return; |
| 509 } | 505 } |
| 510 focus_change_listeners_.erase(place); | 506 focus_change_listeners_.erase(place); |
| 511 } | 507 } |
| 512 | 508 |
| 513 } // namespace views | 509 } // namespace views |
| OLD | NEW |