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

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

Issue 5682008: Make members of Singleton<T> private and only visible to the singleton type. (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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 // Perform a safe iteration over the focus listeners, as the array of 57 // Perform a safe iteration over the focus listeners, as the array of
58 // may change during notification. 58 // may change during notification.
59 WidgetFocusChangeListenerList local_listeners(focus_change_listeners_); 59 WidgetFocusChangeListenerList local_listeners(focus_change_listeners_);
60 WidgetFocusChangeListenerList::iterator iter(local_listeners.begin()); 60 WidgetFocusChangeListenerList::iterator iter(local_listeners.begin());
61 for (;iter != local_listeners.end(); ++iter) { 61 for (;iter != local_listeners.end(); ++iter) {
62 (*iter)->NativeFocusWillChange(focused_before, focused_now); 62 (*iter)->NativeFocusWillChange(focused_before, focused_now);
63 } 63 }
64 } 64 }
65 65
66 // static
67 FocusManager::WidgetFocusManager*
68 FocusManager::WidgetFocusManager::GetInstance() {
69 return Singleton<WidgetFocusManager>::get();
70 }
71
66 // FocusManager ----------------------------------------------------- 72 // FocusManager -----------------------------------------------------
67 73
68 FocusManager::FocusManager(Widget* widget) 74 FocusManager::FocusManager(Widget* widget)
69 : widget_(widget), 75 : widget_(widget),
70 focused_view_(NULL), 76 focused_view_(NULL),
71 focus_change_reason_(kReasonDirectFocusChange) { 77 focus_change_reason_(kReasonDirectFocusChange) {
72 DCHECK(widget_); 78 DCHECK(widget_);
73 stored_focused_view_storage_id_ = 79 stored_focused_view_storage_id_ =
74 ViewStorage::GetInstance()->CreateStorageID(); 80 ViewStorage::GetInstance()->CreateStorageID();
75 } 81 }
76 82
77 FocusManager::~FocusManager() { 83 FocusManager::~FocusManager() {
78 // If there are still registered FocusChange listeners, chances are they were 84 // If there are still registered FocusChange listeners, chances are they were
79 // leaked so warn about them. 85 // leaked so warn about them.
80 DCHECK(focus_change_listeners_.empty()); 86 DCHECK(focus_change_listeners_.empty());
81 } 87 }
82 88
83 // static 89 // static
84 FocusManager::WidgetFocusManager* FocusManager::GetWidgetFocusManager() { 90 FocusManager::WidgetFocusManager* FocusManager::GetWidgetFocusManager() {
85 return Singleton<WidgetFocusManager>::get(); 91 return WidgetFocusManager::GetInstance();
86 } 92 }
87 93
88 bool FocusManager::OnKeyEvent(const KeyEvent& event) { 94 bool FocusManager::OnKeyEvent(const KeyEvent& event) {
89 #if defined(OS_WIN) 95 #if defined(OS_WIN)
90 // If the focused view wants to process the key event as is, let it be. 96 // If the focused view wants to process the key event as is, let it be.
91 // On Linux we always dispatch key events to the focused view first, so 97 // On Linux we always dispatch key events to the focused view first, so
92 // we should not do this check here. See also WidgetGtk::OnKeyEvent(). 98 // we should not do this check here. See also WidgetGtk::OnKeyEvent().
93 if (focused_view_ && focused_view_->SkipDefaultKeyEventProcessing(event)) 99 if (focused_view_ && focused_view_->SkipDefaultKeyEventProcessing(event))
94 return true; 100 return true;
95 #endif 101 #endif
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 std::find(focus_change_listeners_.begin(), focus_change_listeners_.end(), 530 std::find(focus_change_listeners_.begin(), focus_change_listeners_.end(),
525 listener); 531 listener);
526 if (place == focus_change_listeners_.end()) { 532 if (place == focus_change_listeners_.end()) {
527 NOTREACHED() << "Removing a listener that isn't registered."; 533 NOTREACHED() << "Removing a listener that isn't registered.";
528 return; 534 return;
529 } 535 }
530 focus_change_listeners_.erase(place); 536 focus_change_listeners_.erase(place);
531 } 537 }
532 538
533 } // namespace views 539 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698