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

Side by Side Diff: ui/base/ime/input_method_base.cc

Issue 2422073002: Reduce FOR_EACH_OBSERVER usage in ui/ (Closed)
Patch Set: remove space Created 4 years, 2 months 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
« no previous file with comments | « ui/base/ime/chromeos/ime_keyboard.cc ('k') | ui/base/ime/mock_input_method.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/base/ime/input_method_base.h" 5 #include "ui/base/ime/input_method_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "ui/base/ime/ime_bridge.h" 11 #include "ui/base/ime/ime_bridge.h"
12 #include "ui/base/ime/input_method_delegate.h" 12 #include "ui/base/ime/input_method_delegate.h"
13 #include "ui/base/ime/input_method_observer.h" 13 #include "ui/base/ime/input_method_observer.h"
14 #include "ui/base/ime/text_input_client.h" 14 #include "ui/base/ime/text_input_client.h"
15 #include "ui/events/event.h" 15 #include "ui/events/event.h"
16 16
17 namespace ui { 17 namespace ui {
18 18
19 InputMethodBase::InputMethodBase() 19 InputMethodBase::InputMethodBase()
20 : sending_key_event_(false), 20 : sending_key_event_(false),
21 delegate_(nullptr), 21 delegate_(nullptr),
22 text_input_client_(nullptr) {} 22 text_input_client_(nullptr) {}
23 23
24 InputMethodBase::~InputMethodBase() { 24 InputMethodBase::~InputMethodBase() {
25 FOR_EACH_OBSERVER(InputMethodObserver, 25 for (InputMethodObserver& observer : observer_list_)
26 observer_list_, 26 observer.OnInputMethodDestroyed(this);
27 OnInputMethodDestroyed(this));
28 if (ui::IMEBridge::Get() && 27 if (ui::IMEBridge::Get() &&
29 ui::IMEBridge::Get()->GetInputContextHandler() == this) 28 ui::IMEBridge::Get()->GetInputContextHandler() == this)
30 ui::IMEBridge::Get()->SetInputContextHandler(nullptr); 29 ui::IMEBridge::Get()->SetInputContextHandler(nullptr);
31 } 30 }
32 31
33 void InputMethodBase::SetDelegate(internal::InputMethodDelegate* delegate) { 32 void InputMethodBase::SetDelegate(internal::InputMethodDelegate* delegate) {
34 delegate_ = delegate; 33 delegate_ = delegate;
35 } 34 }
36 35
37 void InputMethodBase::OnFocus() { 36 void InputMethodBase::OnFocus() {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 TextInputClient* client = GetTextInputClient(); 85 TextInputClient* client = GetTextInputClient();
87 return client ? client->GetTextInputFlags() : 0; 86 return client ? client->GetTextInputFlags() : 0;
88 } 87 }
89 88
90 bool InputMethodBase::CanComposeInline() const { 89 bool InputMethodBase::CanComposeInline() const {
91 TextInputClient* client = GetTextInputClient(); 90 TextInputClient* client = GetTextInputClient();
92 return client ? client->CanComposeInline() : true; 91 return client ? client->CanComposeInline() : true;
93 } 92 }
94 93
95 void InputMethodBase::ShowImeIfNeeded() { 94 void InputMethodBase::ShowImeIfNeeded() {
96 FOR_EACH_OBSERVER(InputMethodObserver, observer_list_, OnShowImeIfNeeded()); 95 for (InputMethodObserver& observer : observer_list_)
96 observer.OnShowImeIfNeeded();
97 } 97 }
98 98
99 void InputMethodBase::AddObserver(InputMethodObserver* observer) { 99 void InputMethodBase::AddObserver(InputMethodObserver* observer) {
100 observer_list_.AddObserver(observer); 100 observer_list_.AddObserver(observer);
101 } 101 }
102 102
103 void InputMethodBase::RemoveObserver(InputMethodObserver* observer) { 103 void InputMethodBase::RemoveObserver(InputMethodObserver* observer) {
104 observer_list_.RemoveObserver(observer); 104 observer_list_.RemoveObserver(observer);
105 } 105 }
106 106
(...skipping 14 matching lines...) Expand all
121 ui::EventDispatchDetails InputMethodBase::DispatchKeyEventPostIME( 121 ui::EventDispatchDetails InputMethodBase::DispatchKeyEventPostIME(
122 ui::KeyEvent* event) const { 122 ui::KeyEvent* event) const {
123 ui::EventDispatchDetails details; 123 ui::EventDispatchDetails details;
124 if (delegate_) 124 if (delegate_)
125 details = delegate_->DispatchKeyEventPostIME(event); 125 details = delegate_->DispatchKeyEventPostIME(event);
126 return details; 126 return details;
127 } 127 }
128 128
129 void InputMethodBase::NotifyTextInputStateChanged( 129 void InputMethodBase::NotifyTextInputStateChanged(
130 const TextInputClient* client) { 130 const TextInputClient* client) {
131 FOR_EACH_OBSERVER(InputMethodObserver, 131 for (InputMethodObserver& observer : observer_list_)
132 observer_list_, 132 observer.OnTextInputStateChanged(client);
133 OnTextInputStateChanged(client));
134 } 133 }
135 134
136 void InputMethodBase::NotifyTextInputCaretBoundsChanged( 135 void InputMethodBase::NotifyTextInputCaretBoundsChanged(
137 const TextInputClient* client) { 136 const TextInputClient* client) {
138 FOR_EACH_OBSERVER( 137 for (InputMethodObserver& observer : observer_list_)
139 InputMethodObserver, observer_list_, OnCaretBoundsChanged(client)); 138 observer.OnCaretBoundsChanged(client);
140 } 139 }
141 140
142 void InputMethodBase::SetFocusedTextInputClientInternal( 141 void InputMethodBase::SetFocusedTextInputClientInternal(
143 TextInputClient* client) { 142 TextInputClient* client) {
144 TextInputClient* old = text_input_client_; 143 TextInputClient* old = text_input_client_;
145 if (old == client) 144 if (old == client)
146 return; 145 return;
147 OnWillChangeFocusedClient(old, client); 146 OnWillChangeFocusedClient(old, client);
148 text_input_client_ = client; // nullptr allowed. 147 text_input_client_ = client; // nullptr allowed.
149 OnDidChangeFocusedClient(old, client); 148 OnDidChangeFocusedClient(old, client);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 InputMethod* InputMethodBase::GetInputMethod() { 216 InputMethod* InputMethodBase::GetInputMethod() {
218 return this; 217 return this;
219 } 218 }
220 219
221 const std::vector<std::unique_ptr<ui::KeyEvent>>& 220 const std::vector<std::unique_ptr<ui::KeyEvent>>&
222 InputMethodBase::GetKeyEventsForTesting() { 221 InputMethodBase::GetKeyEventsForTesting() {
223 return key_events_for_testing_; 222 return key_events_for_testing_;
224 } 223 }
225 224
226 } // namespace ui 225 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/chromeos/ime_keyboard.cc ('k') | ui/base/ime/mock_input_method.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698