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

Side by Side Diff: ui/base/ime/mock_input_method.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/input_method_base.cc ('k') | ui/base/user_activity/user_activity_detector.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/mock_input_method.h" 5 #include "ui/base/ime/mock_input_method.h"
6 6
7 #include "ui/base/ime/input_method_delegate.h" 7 #include "ui/base/ime/input_method_delegate.h"
8 #include "ui/events/event.h" 8 #include "ui/events/event.h"
9 9
10 namespace ui { 10 namespace ui {
11 11
12 MockInputMethod::MockInputMethod(internal::InputMethodDelegate* delegate) 12 MockInputMethod::MockInputMethod(internal::InputMethodDelegate* delegate)
13 : text_input_client_(NULL), delegate_(delegate) { 13 : text_input_client_(NULL), delegate_(delegate) {
14 } 14 }
15 15
16 MockInputMethod::~MockInputMethod() { 16 MockInputMethod::~MockInputMethod() {
17 FOR_EACH_OBSERVER(InputMethodObserver, observer_list_, 17 for (InputMethodObserver& observer : observer_list_)
18 OnInputMethodDestroyed(this)); 18 observer.OnInputMethodDestroyed(this);
19 } 19 }
20 20
21 void MockInputMethod::SetDelegate(internal::InputMethodDelegate* delegate) { 21 void MockInputMethod::SetDelegate(internal::InputMethodDelegate* delegate) {
22 delegate_ = delegate; 22 delegate_ = delegate;
23 } 23 }
24 24
25 void MockInputMethod::SetFocusedTextInputClient(TextInputClient* client) { 25 void MockInputMethod::SetFocusedTextInputClient(TextInputClient* client) {
26 if (text_input_client_ == client) 26 if (text_input_client_ == client)
27 return; 27 return;
28 text_input_client_ = client; 28 text_input_client_ = client;
29 if (client) 29 if (client)
30 OnTextInputTypeChanged(client); 30 OnTextInputTypeChanged(client);
31 } 31 }
32 32
33 void MockInputMethod::DetachTextInputClient(TextInputClient* client) { 33 void MockInputMethod::DetachTextInputClient(TextInputClient* client) {
34 if (text_input_client_ == client) { 34 if (text_input_client_ == client) {
35 text_input_client_ = NULL; 35 text_input_client_ = NULL;
36 } 36 }
37 } 37 }
38 38
39 TextInputClient* MockInputMethod::GetTextInputClient() const { 39 TextInputClient* MockInputMethod::GetTextInputClient() const {
40 return text_input_client_; 40 return text_input_client_;
41 } 41 }
42 42
43 void MockInputMethod::DispatchKeyEvent(ui::KeyEvent* event) { 43 void MockInputMethod::DispatchKeyEvent(ui::KeyEvent* event) {
44 ignore_result(delegate_->DispatchKeyEventPostIME(event)); 44 ignore_result(delegate_->DispatchKeyEventPostIME(event));
45 } 45 }
46 46
47 void MockInputMethod::OnFocus() { 47 void MockInputMethod::OnFocus() {
48 FOR_EACH_OBSERVER(InputMethodObserver, observer_list_, OnFocus()); 48 for (InputMethodObserver& observer : observer_list_)
49 observer.OnFocus();
49 } 50 }
50 51
51 void MockInputMethod::OnBlur() { 52 void MockInputMethod::OnBlur() {
52 FOR_EACH_OBSERVER(InputMethodObserver, observer_list_, OnBlur()); 53 for (InputMethodObserver& observer : observer_list_)
54 observer.OnBlur();
53 } 55 }
54 56
55 bool MockInputMethod::OnUntranslatedIMEMessage(const base::NativeEvent& event, 57 bool MockInputMethod::OnUntranslatedIMEMessage(const base::NativeEvent& event,
56 NativeEventResult* result) { 58 NativeEventResult* result) {
57 if (result) 59 if (result)
58 *result = NativeEventResult(); 60 *result = NativeEventResult();
59 return false; 61 return false;
60 } 62 }
61 63
62 void MockInputMethod::OnTextInputTypeChanged(const TextInputClient* client) { 64 void MockInputMethod::OnTextInputTypeChanged(const TextInputClient* client) {
63 FOR_EACH_OBSERVER(InputMethodObserver, 65 for (InputMethodObserver& observer : observer_list_)
64 observer_list_, 66 observer.OnTextInputTypeChanged(client);
65 OnTextInputTypeChanged(client)); 67 for (InputMethodObserver& observer : observer_list_)
66 FOR_EACH_OBSERVER(InputMethodObserver, 68 observer.OnTextInputStateChanged(client);
67 observer_list_,
68 OnTextInputStateChanged(client));
69 } 69 }
70 70
71 void MockInputMethod::OnCaretBoundsChanged(const TextInputClient* client) { 71 void MockInputMethod::OnCaretBoundsChanged(const TextInputClient* client) {
72 FOR_EACH_OBSERVER(InputMethodObserver, 72 for (InputMethodObserver& observer : observer_list_)
73 observer_list_, 73 observer.OnCaretBoundsChanged(client);
74 OnCaretBoundsChanged(client));
75 } 74 }
76 75
77 void MockInputMethod::CancelComposition(const TextInputClient* client) { 76 void MockInputMethod::CancelComposition(const TextInputClient* client) {
78 } 77 }
79 78
80 void MockInputMethod::OnInputLocaleChanged() { 79 void MockInputMethod::OnInputLocaleChanged() {
81 } 80 }
82 81
83 bool MockInputMethod::IsInputLocaleCJK() const { 82 bool MockInputMethod::IsInputLocaleCJK() const {
84 return false; 83 return false;
(...skipping 13 matching lines...) Expand all
98 97
99 bool MockInputMethod::CanComposeInline() const { 98 bool MockInputMethod::CanComposeInline() const {
100 return true; 99 return true;
101 } 100 }
102 101
103 bool MockInputMethod::IsCandidatePopupOpen() const { 102 bool MockInputMethod::IsCandidatePopupOpen() const {
104 return false; 103 return false;
105 } 104 }
106 105
107 void MockInputMethod::ShowImeIfNeeded() { 106 void MockInputMethod::ShowImeIfNeeded() {
108 FOR_EACH_OBSERVER(InputMethodObserver, observer_list_, OnShowImeIfNeeded()); 107 for (InputMethodObserver& observer : observer_list_)
108 observer.OnShowImeIfNeeded();
109 } 109 }
110 110
111 void MockInputMethod::AddObserver(InputMethodObserver* observer) { 111 void MockInputMethod::AddObserver(InputMethodObserver* observer) {
112 observer_list_.AddObserver(observer); 112 observer_list_.AddObserver(observer);
113 } 113 }
114 114
115 void MockInputMethod::RemoveObserver(InputMethodObserver* observer) { 115 void MockInputMethod::RemoveObserver(InputMethodObserver* observer) {
116 observer_list_.RemoveObserver(observer); 116 observer_list_.RemoveObserver(observer);
117 } 117 }
118 118
119 const std::vector<std::unique_ptr<ui::KeyEvent>>& 119 const std::vector<std::unique_ptr<ui::KeyEvent>>&
120 MockInputMethod::GetKeyEventsForTesting() { 120 MockInputMethod::GetKeyEventsForTesting() {
121 return key_events_for_testing_; 121 return key_events_for_testing_;
122 } 122 }
123 123
124 } // namespace ui 124 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/input_method_base.cc ('k') | ui/base/user_activity/user_activity_detector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698