OLD | NEW |
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/text_input_focus_manager.h" |
| 8 #include "ui/base/ui_base_switches_util.h" |
| 9 |
7 namespace ui { | 10 namespace ui { |
8 | 11 |
9 MockInputMethod::MockInputMethod(internal::InputMethodDelegate* delegate) | 12 MockInputMethod::MockInputMethod(internal::InputMethodDelegate* delegate) |
10 : text_input_client_(NULL) { | 13 : text_input_client_(NULL) { |
11 } | 14 } |
12 | 15 |
13 MockInputMethod::~MockInputMethod() { | 16 MockInputMethod::~MockInputMethod() { |
14 } | 17 } |
15 | 18 |
16 void MockInputMethod::SetDelegate(internal::InputMethodDelegate* delegate) { | 19 void MockInputMethod::SetDelegate(internal::InputMethodDelegate* delegate) { |
17 } | 20 } |
18 | 21 |
19 void MockInputMethod::SetFocusedTextInputClient(TextInputClient* client) { | 22 void MockInputMethod::SetFocusedTextInputClient(TextInputClient* client) { |
| 23 if (switches::IsTextInputFocusManagerEnabled()) |
| 24 return; |
| 25 |
20 if (text_input_client_ == client) | 26 if (text_input_client_ == client) |
21 return; | 27 return; |
22 text_input_client_ = client; | 28 text_input_client_ = client; |
23 if (client) | 29 if (client) |
24 OnTextInputTypeChanged(client); | 30 OnTextInputTypeChanged(client); |
25 } | 31 } |
26 | 32 |
27 void MockInputMethod::DetachTextInputClient(TextInputClient* client) { | 33 void MockInputMethod::DetachTextInputClient(TextInputClient* client) { |
28 if (text_input_client_ == client) { | 34 if (text_input_client_ == client) { |
29 text_input_client_ = NULL; | 35 text_input_client_ = NULL; |
30 } | 36 } |
31 } | 37 } |
32 | 38 |
33 TextInputClient* MockInputMethod::GetTextInputClient() const { | 39 TextInputClient* MockInputMethod::GetTextInputClient() const { |
| 40 if (switches::IsTextInputFocusManagerEnabled()) |
| 41 return TextInputFocusManager::GetInstance()->GetFocusedTextInputClient(); |
| 42 |
34 return text_input_client_; | 43 return text_input_client_; |
35 } | 44 } |
36 | 45 |
37 bool MockInputMethod::DispatchKeyEvent(const ui::KeyEvent& event) { | 46 bool MockInputMethod::DispatchKeyEvent(const ui::KeyEvent& event) { |
38 return false; | 47 return false; |
39 } | 48 } |
40 | 49 |
41 void MockInputMethod::Init(bool focused) { | 50 void MockInputMethod::Init(bool focused) { |
42 } | 51 } |
43 | 52 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 116 |
108 void MockInputMethod::AddObserver(InputMethodObserver* observer) { | 117 void MockInputMethod::AddObserver(InputMethodObserver* observer) { |
109 observer_list_.AddObserver(observer); | 118 observer_list_.AddObserver(observer); |
110 } | 119 } |
111 | 120 |
112 void MockInputMethod::RemoveObserver(InputMethodObserver* observer) { | 121 void MockInputMethod::RemoveObserver(InputMethodObserver* observer) { |
113 observer_list_.RemoveObserver(observer); | 122 observer_list_.RemoveObserver(observer); |
114 } | 123 } |
115 | 124 |
116 } // namespace ui | 125 } // namespace ui |
OLD | NEW |