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/views/ime/input_method_base.h" | 5 #include "ui/views/ime/input_method_base.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/base/events/event.h" | 8 #include "ui/base/events/event.h" |
9 #include "ui/base/ime/text_input_client.h" | 9 #include "ui/base/ime/text_input_client.h" |
10 #include "ui/views/view.h" | 10 #include "ui/views/view.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 widget->GetFocusManager()->AddFocusChangeListener(this); | 36 widget->GetFocusManager()->AddFocusChangeListener(this); |
37 } | 37 } |
38 | 38 |
39 views::View* InputMethodBase::GetFocusedView() const { | 39 views::View* InputMethodBase::GetFocusedView() const { |
40 return widget_ ? widget_->GetFocusManager()->GetFocusedView() : NULL; | 40 return widget_ ? widget_->GetFocusManager()->GetFocusedView() : NULL; |
41 } | 41 } |
42 | 42 |
43 void InputMethodBase::OnTextInputTypeChanged(View* view) {} | 43 void InputMethodBase::OnTextInputTypeChanged(View* view) {} |
44 | 44 |
45 ui::TextInputClient* InputMethodBase::GetTextInputClient() const { | 45 ui::TextInputClient* InputMethodBase::GetTextInputClient() const { |
46 return (widget_ && widget_->IsActive() && GetFocusedView()) ? | 46 return GetFocusedView() ? GetFocusedView()->GetTextInputClient() : NULL; |
47 GetFocusedView()->GetTextInputClient() : NULL; | |
48 } | 47 } |
49 | 48 |
50 ui::TextInputType InputMethodBase::GetTextInputType() const { | 49 ui::TextInputType InputMethodBase::GetTextInputType() const { |
51 ui::TextInputClient* client = GetTextInputClient(); | 50 ui::TextInputClient* client = GetTextInputClient(); |
52 return client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE; | 51 return client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE; |
53 } | 52 } |
54 | 53 |
55 bool InputMethodBase::IsMock() const { | 54 bool InputMethodBase::IsMock() const { |
56 return false; | 55 return false; |
57 } | 56 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 98 |
100 void InputMethodBase::DetachFromWidget() { | 99 void InputMethodBase::DetachFromWidget() { |
101 if (!widget_) | 100 if (!widget_) |
102 return; | 101 return; |
103 | 102 |
104 widget_->GetFocusManager()->RemoveFocusChangeListener(this); | 103 widget_->GetFocusManager()->RemoveFocusChangeListener(this); |
105 widget_ = NULL; | 104 widget_ = NULL; |
106 } | 105 } |
107 | 106 |
108 } // namespace views | 107 } // namespace views |
OLD | NEW |