| 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/fake_input_method.h" | 5 #include "ui/base/ime/fake_input_method.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "ui/base/events/event.h" | 9 #include "ui/base/events/event.h" |
| 10 #include "ui/base/events/event_constants.h" | 10 #include "ui/base/events/event_constants.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 void FakeInputMethod::SetDelegate(internal::InputMethodDelegate* delegate) { | 48 void FakeInputMethod::SetDelegate(internal::InputMethodDelegate* delegate) { |
| 49 delegate_ = delegate; | 49 delegate_ = delegate; |
| 50 } | 50 } |
| 51 | 51 |
| 52 void FakeInputMethod::SetFocusedTextInputClient(TextInputClient* client) { | 52 void FakeInputMethod::SetFocusedTextInputClient(TextInputClient* client) { |
| 53 text_input_client_ = client; | 53 text_input_client_ = client; |
| 54 FOR_EACH_OBSERVER(InputMethodObserver, observers_, | 54 FOR_EACH_OBSERVER(InputMethodObserver, observers_, |
| 55 OnTextInputStateChanged(client)); | 55 OnTextInputStateChanged(client)); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void FakeInputMethod::DetachTextInputClient(TextInputClient* client) { |
| 59 if (text_input_client_ == client) { |
| 60 text_input_client_ = NULL; |
| 61 FOR_EACH_OBSERVER(InputMethodObserver, observers_, |
| 62 OnTextInputStateChanged(client)); |
| 63 } |
| 64 } |
| 65 |
| 58 TextInputClient* FakeInputMethod::GetTextInputClient() const { | 66 TextInputClient* FakeInputMethod::GetTextInputClient() const { |
| 59 return text_input_client_; | 67 return text_input_client_; |
| 60 } | 68 } |
| 61 | 69 |
| 62 bool FakeInputMethod::DispatchKeyEvent(const base::NativeEvent& native_event) { | 70 bool FakeInputMethod::DispatchKeyEvent(const base::NativeEvent& native_event) { |
| 63 bool handled = false; | 71 bool handled = false; |
| 64 #if defined(OS_WIN) | 72 #if defined(OS_WIN) |
| 65 if (native_event.message == WM_CHAR) { | 73 if (native_event.message == WM_CHAR) { |
| 66 if (text_input_client_) { | 74 if (text_input_client_) { |
| 67 text_input_client_->InsertChar(ui::KeyboardCodeFromNative(native_event), | 75 text_input_client_->InsertChar(ui::KeyboardCodeFromNative(native_event), |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 163 |
| 156 void FakeInputMethod::AddObserver(InputMethodObserver* observer) { | 164 void FakeInputMethod::AddObserver(InputMethodObserver* observer) { |
| 157 observers_.AddObserver(observer); | 165 observers_.AddObserver(observer); |
| 158 } | 166 } |
| 159 | 167 |
| 160 void FakeInputMethod::RemoveObserver(InputMethodObserver* observer) { | 168 void FakeInputMethod::RemoveObserver(InputMethodObserver* observer) { |
| 161 observers_.RemoveObserver(observer); | 169 observers_.RemoveObserver(observer); |
| 162 } | 170 } |
| 163 | 171 |
| 164 } // namespace ui | 172 } // namespace ui |
| OLD | NEW |