Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: views/focus/focus_manager.cc

Issue 5581008: Add a new GetInstance() method for singleton classes, take 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 stored_focused_view_storage_id_ = 73 stored_focused_view_storage_id_ =
74 ViewStorage::GetSharedInstance()->CreateStorageID(); 74 ViewStorage::GetSharedInstance()->CreateStorageID();
75 } 75 }
76 76
77 FocusManager::~FocusManager() { 77 FocusManager::~FocusManager() {
78 // If there are still registered FocusChange listeners, chances are they were 78 // If there are still registered FocusChange listeners, chances are they were
79 // leaked so warn about them. 79 // leaked so warn about them.
80 DCHECK(focus_change_listeners_.empty()); 80 DCHECK(focus_change_listeners_.empty());
81 } 81 }
82 82
83 // static
84 FocusManager::WidgetFocusManager* FocusManager::GetWidgetFocusManager() {
85 return Singleton<WidgetFocusManager>::get();
86 }
87
83 bool FocusManager::OnKeyEvent(const KeyEvent& event) { 88 bool FocusManager::OnKeyEvent(const KeyEvent& event) {
84 #if defined(OS_WIN) 89 #if defined(OS_WIN)
85 // If the focused view wants to process the key event as is, let it be. 90 // If the focused view wants to process the key event as is, let it be.
86 // On Linux we always dispatch key events to the focused view first, so 91 // On Linux we always dispatch key events to the focused view first, so
87 // we should not do this check here. See also WidgetGtk::OnKeyEvent(). 92 // we should not do this check here. See also WidgetGtk::OnKeyEvent().
88 if (focused_view_ && focused_view_->SkipDefaultKeyEventProcessing(event)) 93 if (focused_view_ && focused_view_->SkipDefaultKeyEventProcessing(event))
89 return true; 94 return true;
90 #endif 95 #endif
91 96
92 // Intercept Tab related messages for focus traversal. 97 // Intercept Tab related messages for focus traversal.
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 std::find(focus_change_listeners_.begin(), focus_change_listeners_.end(), 524 std::find(focus_change_listeners_.begin(), focus_change_listeners_.end(),
520 listener); 525 listener);
521 if (place == focus_change_listeners_.end()) { 526 if (place == focus_change_listeners_.end()) {
522 NOTREACHED() << "Removing a listener that isn't registered."; 527 NOTREACHED() << "Removing a listener that isn't registered.";
523 return; 528 return;
524 } 529 }
525 focus_change_listeners_.erase(place); 530 focus_change_listeners_.erase(place);
526 } 531 }
527 532
528 } // namespace views 533 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698