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

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

Issue 1177503003: Remove the 2-level input method system & InputMethodBridge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: makes trybots green. Created 5 years, 6 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
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/text_input_focus_manager.h" 8 #include "ui/base/ime/text_input_focus_manager.h"
8 #include "ui/base/ui_base_switches_util.h" 9 #include "ui/base/ui_base_switches_util.h"
10 #include "ui/events/event.h"
9 11
10 namespace ui { 12 namespace ui {
11 13
12 MockInputMethod::MockInputMethod(internal::InputMethodDelegate* delegate) 14 MockInputMethod::MockInputMethod(internal::InputMethodDelegate* delegate)
13 : text_input_client_(NULL) { 15 : text_input_client_(NULL), delegate_(delegate) {
14 } 16 }
15 17
16 MockInputMethod::~MockInputMethod() { 18 MockInputMethod::~MockInputMethod() {
17 FOR_EACH_OBSERVER(InputMethodObserver, observer_list_, 19 FOR_EACH_OBSERVER(InputMethodObserver, observer_list_,
18 OnInputMethodDestroyed(this)); 20 OnInputMethodDestroyed(this));
19 } 21 }
20 22
21 void MockInputMethod::SetDelegate(internal::InputMethodDelegate* delegate) { 23 void MockInputMethod::SetDelegate(internal::InputMethodDelegate* delegate) {
24 delegate_ = delegate;
22 } 25 }
23 26
24 void MockInputMethod::SetFocusedTextInputClient(TextInputClient* client) { 27 void MockInputMethod::SetFocusedTextInputClient(TextInputClient* client) {
25 if (switches::IsTextInputFocusManagerEnabled()) 28 if (switches::IsTextInputFocusManagerEnabled())
26 return; 29 return;
27 30
28 if (text_input_client_ == client) 31 if (text_input_client_ == client)
29 return; 32 return;
30 text_input_client_ = client; 33 text_input_client_ = client;
31 if (client) 34 if (client)
32 OnTextInputTypeChanged(client); 35 OnTextInputTypeChanged(client);
33 } 36 }
34 37
35 void MockInputMethod::DetachTextInputClient(TextInputClient* client) { 38 void MockInputMethod::DetachTextInputClient(TextInputClient* client) {
36 if (text_input_client_ == client) { 39 if (text_input_client_ == client) {
37 text_input_client_ = NULL; 40 text_input_client_ = NULL;
38 } 41 }
39 } 42 }
40 43
41 TextInputClient* MockInputMethod::GetTextInputClient() const { 44 TextInputClient* MockInputMethod::GetTextInputClient() const {
42 if (switches::IsTextInputFocusManagerEnabled()) 45 if (switches::IsTextInputFocusManagerEnabled())
43 return TextInputFocusManager::GetInstance()->GetFocusedTextInputClient(); 46 return TextInputFocusManager::GetInstance()->GetFocusedTextInputClient();
44 47
45 return text_input_client_; 48 return text_input_client_;
46 } 49 }
47 50
48 bool MockInputMethod::DispatchKeyEvent(const ui::KeyEvent& event) { 51 bool MockInputMethod::DispatchKeyEvent(const ui::KeyEvent& event) {
49 return false; 52 return delegate_->DispatchKeyEventPostIME(event);
50 } 53 }
51 54
52 void MockInputMethod::OnFocus() { 55 void MockInputMethod::OnFocus() {
53 FOR_EACH_OBSERVER(InputMethodObserver, observer_list_, OnFocus()); 56 FOR_EACH_OBSERVER(InputMethodObserver, observer_list_, OnFocus());
54 } 57 }
55 58
56 void MockInputMethod::OnBlur() { 59 void MockInputMethod::OnBlur() {
57 FOR_EACH_OBSERVER(InputMethodObserver, observer_list_, OnBlur()); 60 FOR_EACH_OBSERVER(InputMethodObserver, observer_list_, OnBlur());
58 } 61 }
59 62
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 122
120 void MockInputMethod::AddObserver(InputMethodObserver* observer) { 123 void MockInputMethod::AddObserver(InputMethodObserver* observer) {
121 observer_list_.AddObserver(observer); 124 observer_list_.AddObserver(observer);
122 } 125 }
123 126
124 void MockInputMethod::RemoveObserver(InputMethodObserver* observer) { 127 void MockInputMethod::RemoveObserver(InputMethodObserver* observer) {
125 observer_list_.RemoveObserver(observer); 128 observer_list_.RemoveObserver(observer);
126 } 129 }
127 130
128 } // namespace ui 131 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698