Index: ui/base/ime/input_method_base.cc |
diff --git a/ui/base/ime/input_method_base.cc b/ui/base/ime/input_method_base.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..768f6c27c82251df75db537cb871b1bf6fb06f39 |
--- /dev/null |
+++ b/ui/base/ime/input_method_base.cc |
@@ -0,0 +1,62 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "ui/base/ime/input_method_base.h" |
+ |
+#include "base/logging.h" |
+#include "ui/base/ime/text_input_client.h" |
+#include "ui/base/ime/input_method_delegate.h" |
+ |
+namespace ui { |
+ |
+InputMethodBase::InputMethodBase() |
+ : delegate_(NULL), |
+ text_input_client_(NULL) { |
+} |
+ |
+InputMethodBase::~InputMethodBase() { |
+} |
+ |
+void InputMethodBase::set_delegate( |
+ internal::InputMethodDelegate* delegate) { |
+ DCHECK(delegate); |
+ delegate_ = delegate; |
+} |
+ |
+void InputMethodBase::set_text_input_client(TextInputClient* client) { |
+ text_input_client_ = client; // NULL allowed. |
+} |
+ |
+TextInputClient* InputMethodBase::text_input_client() const { |
+ return text_input_client_; |
+} |
+ |
+void InputMethodBase::OnTextInputTypeChanged(gfx::NativeWindow window) { |
+ if (IsWindowFocused(window)) { |
+ // TODO(yusukes): Support TextInputTypeTracker for TOUCH_UI. |
+ } |
+} |
+ |
+TextInputType InputMethodBase::GetTextInputType() const { |
+ return text_input_client_ ? |
+ text_input_client_->GetTextInputType() : TEXT_INPUT_TYPE_NONE; |
+} |
+ |
+bool InputMethodBase::IsTextInputTypeNone() const { |
+ return GetTextInputType() == TEXT_INPUT_TYPE_NONE; |
+} |
+ |
+void InputMethodBase::OnInputMethodChanged() const { |
+ if (text_input_client_ && |
+ text_input_client_->GetTextInputType() != TEXT_INPUT_TYPE_NONE) |
+ text_input_client_->OnInputMethodChanged(); |
+} |
+ |
+void InputMethodBase::DispatchKeyEventPostIME( |
+ gfx::NativeEvent native_key_event) const { |
+ if (delegate_) |
+ delegate_->DispatchKeyEventPostIME(native_key_event); |
+} |
+ |
+} // namespace ui |