Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / base / ime / mock_input_method.cc
blobfb1e6bac4678123c06c51b6cd6d0fbbdb2563de2
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/text_input_focus_manager.h"
8 #include "ui/base/ui_base_switches_util.h"
10 namespace ui {
12 MockInputMethod::MockInputMethod(internal::InputMethodDelegate* delegate)
13 : text_input_client_(NULL) {
16 MockInputMethod::~MockInputMethod() {
19 void MockInputMethod::SetDelegate(internal::InputMethodDelegate* delegate) {
22 void MockInputMethod::SetFocusedTextInputClient(TextInputClient* client) {
23 if (switches::IsTextInputFocusManagerEnabled())
24 return;
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 if (switches::IsTextInputFocusManagerEnabled())
41 return TextInputFocusManager::GetInstance()->GetFocusedTextInputClient();
43 return text_input_client_;
46 bool MockInputMethod::DispatchKeyEvent(const ui::KeyEvent& event) {
47 return false;
50 void MockInputMethod::Init(bool focused) {
53 void MockInputMethod::OnFocus() {
54 FOR_EACH_OBSERVER(InputMethodObserver, observer_list_, OnFocus());
57 void MockInputMethod::OnBlur() {
58 FOR_EACH_OBSERVER(InputMethodObserver, observer_list_, OnBlur());
61 bool MockInputMethod::OnUntranslatedIMEMessage(const base::NativeEvent& event,
62 NativeEventResult* result) {
63 if (result)
64 *result = NativeEventResult();
65 return false;
68 void MockInputMethod::OnTextInputTypeChanged(const TextInputClient* client) {
69 FOR_EACH_OBSERVER(InputMethodObserver,
70 observer_list_,
71 OnTextInputTypeChanged(client));
72 FOR_EACH_OBSERVER(InputMethodObserver,
73 observer_list_,
74 OnTextInputStateChanged(client));
77 void MockInputMethod::OnCaretBoundsChanged(const TextInputClient* client) {
78 FOR_EACH_OBSERVER(InputMethodObserver,
79 observer_list_,
80 OnCaretBoundsChanged(client));
83 void MockInputMethod::CancelComposition(const TextInputClient* client) {
86 void MockInputMethod::OnInputLocaleChanged() {
89 std::string MockInputMethod::GetInputLocale() {
90 return "";
93 bool MockInputMethod::IsActive() {
94 return true;
97 TextInputType MockInputMethod::GetTextInputType() const {
98 return TEXT_INPUT_TYPE_NONE;
101 TextInputMode MockInputMethod::GetTextInputMode() const {
102 return TEXT_INPUT_MODE_DEFAULT;
105 int MockInputMethod::GetTextInputFlags() const {
106 return 0;
109 bool MockInputMethod::CanComposeInline() const {
110 return true;
113 bool MockInputMethod::IsCandidatePopupOpen() const {
114 return false;
117 void MockInputMethod::ShowImeIfNeeded() {
118 FOR_EACH_OBSERVER(InputMethodObserver, observer_list_, OnShowImeIfNeeded());
121 void MockInputMethod::AddObserver(InputMethodObserver* observer) {
122 observer_list_.AddObserver(observer);
125 void MockInputMethod::RemoveObserver(InputMethodObserver* observer) {
126 observer_list_.RemoveObserver(observer);
129 } // namespace ui