Add ICU message format support
[chromium-blink-merge.git] / ui / base / ime / mock_input_method.cc
blobf2cf8ebc67f5c4a29848e5740006f573c640027d
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
3 // found in the LICENSE file.
5 #include "ui/base/ime/mock_input_method.h"
7 #include "ui/base/ime/input_method_delegate.h"
8 #include "ui/events/event.h"
10 namespace ui {
12 MockInputMethod::MockInputMethod(internal::InputMethodDelegate* delegate)
13 : text_input_client_(NULL), delegate_(delegate) {
16 MockInputMethod::~MockInputMethod() {
17 FOR_EACH_OBSERVER(InputMethodObserver, observer_list_,
18 OnInputMethodDestroyed(this));
21 void MockInputMethod::SetDelegate(internal::InputMethodDelegate* delegate) {
22 delegate_ = delegate;
25 void MockInputMethod::SetFocusedTextInputClient(TextInputClient* client) {
26 if (text_input_client_ == client)
27 return;
28 text_input_client_ = client;
29 if (client)
30 OnTextInputTypeChanged(client);
33 void MockInputMethod::DetachTextInputClient(TextInputClient* client) {
34 if (text_input_client_ == client) {
35 text_input_client_ = NULL;
39 TextInputClient* MockInputMethod::GetTextInputClient() const {
40 return text_input_client_;
43 void MockInputMethod::DispatchKeyEvent(ui::KeyEvent* event) {
44 ignore_result(delegate_->DispatchKeyEventPostIME(event));
47 void MockInputMethod::OnFocus() {
48 FOR_EACH_OBSERVER(InputMethodObserver, observer_list_, OnFocus());
51 void MockInputMethod::OnBlur() {
52 FOR_EACH_OBSERVER(InputMethodObserver, observer_list_, OnBlur());
55 bool MockInputMethod::OnUntranslatedIMEMessage(const base::NativeEvent& event,
56 NativeEventResult* result) {
57 if (result)
58 *result = NativeEventResult();
59 return false;
62 void MockInputMethod::OnTextInputTypeChanged(const TextInputClient* client) {
63 FOR_EACH_OBSERVER(InputMethodObserver,
64 observer_list_,
65 OnTextInputTypeChanged(client));
66 FOR_EACH_OBSERVER(InputMethodObserver,
67 observer_list_,
68 OnTextInputStateChanged(client));
71 void MockInputMethod::OnCaretBoundsChanged(const TextInputClient* client) {
72 FOR_EACH_OBSERVER(InputMethodObserver,
73 observer_list_,
74 OnCaretBoundsChanged(client));
77 void MockInputMethod::CancelComposition(const TextInputClient* client) {
80 void MockInputMethod::OnInputLocaleChanged() {
83 std::string MockInputMethod::GetInputLocale() {
84 return "";
87 TextInputType MockInputMethod::GetTextInputType() const {
88 return TEXT_INPUT_TYPE_NONE;
91 TextInputMode MockInputMethod::GetTextInputMode() const {
92 return TEXT_INPUT_MODE_DEFAULT;
95 int MockInputMethod::GetTextInputFlags() const {
96 return 0;
99 bool MockInputMethod::CanComposeInline() const {
100 return true;
103 bool MockInputMethod::IsCandidatePopupOpen() const {
104 return false;
107 void MockInputMethod::ShowImeIfNeeded() {
108 FOR_EACH_OBSERVER(InputMethodObserver, observer_list_, OnShowImeIfNeeded());
111 void MockInputMethod::AddObserver(InputMethodObserver* observer) {
112 observer_list_.AddObserver(observer);
115 void MockInputMethod::RemoveObserver(InputMethodObserver* observer) {
116 observer_list_.RemoveObserver(observer);
119 } // namespace ui