OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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. |
| 4 |
| 5 #include "ui/base/ime/input_method_base.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "ui/base/ime/text_input_client.h" |
| 9 #include "ui/base/ime/input_method_delegate.h" |
| 10 |
| 11 namespace ui { |
| 12 |
| 13 InputMethodBase::InputMethodBase() |
| 14 : delegate_(NULL), |
| 15 text_input_client_(NULL) { |
| 16 } |
| 17 |
| 18 InputMethodBase::~InputMethodBase() { |
| 19 } |
| 20 |
| 21 void InputMethodBase::set_delegate( |
| 22 internal::InputMethodDelegate* delegate) { |
| 23 DCHECK(delegate); |
| 24 delegate_ = delegate; |
| 25 } |
| 26 |
| 27 void InputMethodBase::set_text_input_client(TextInputClient* client) { |
| 28 text_input_client_ = client; // NULL allowed. |
| 29 } |
| 30 |
| 31 TextInputClient* InputMethodBase::text_input_client() const { |
| 32 return text_input_client_; |
| 33 } |
| 34 |
| 35 void InputMethodBase::OnTextInputTypeChanged(gfx::NativeWindow window) { |
| 36 if (IsWindowFocused(window)) { |
| 37 // TODO(yusukes): Support TextInputTypeTracker for TOUCH_UI. |
| 38 } |
| 39 } |
| 40 |
| 41 TextInputType InputMethodBase::GetTextInputType() const { |
| 42 return text_input_client_ ? |
| 43 text_input_client_->GetTextInputType() : TEXT_INPUT_TYPE_NONE; |
| 44 } |
| 45 |
| 46 bool InputMethodBase::IsTextInputTypeNone() const { |
| 47 return GetTextInputType() == TEXT_INPUT_TYPE_NONE; |
| 48 } |
| 49 |
| 50 void InputMethodBase::OnInputMethodChanged() const { |
| 51 if (text_input_client_ && |
| 52 text_input_client_->GetTextInputType() != TEXT_INPUT_TYPE_NONE) |
| 53 text_input_client_->OnInputMethodChanged(); |
| 54 } |
| 55 |
| 56 void InputMethodBase::DispatchKeyEventPostIME( |
| 57 gfx::NativeEvent native_key_event) const { |
| 58 if (delegate_) |
| 59 delegate_->DispatchKeyEventPostIME(native_key_event); |
| 60 } |
| 61 |
| 62 } // namespace ui |
OLD | NEW |