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 GetFocusedView() ? GetFocusedView()->GetTextInputClient() : NULL; | 46 return (widget_ && widget_->IsActive() && GetFocusedView()) ? |
| 47 GetFocusedView()->GetTextInputClient() : NULL; |
47 } | 48 } |
48 | 49 |
49 ui::TextInputType InputMethodBase::GetTextInputType() const { | 50 ui::TextInputType InputMethodBase::GetTextInputType() const { |
50 ui::TextInputClient* client = GetTextInputClient(); | 51 ui::TextInputClient* client = GetTextInputClient(); |
51 return client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE; | 52 return client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE; |
52 } | 53 } |
53 | 54 |
54 bool InputMethodBase::IsMock() const { | 55 bool InputMethodBase::IsMock() const { |
55 return false; | 56 return false; |
56 } | 57 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 99 |
99 void InputMethodBase::DetachFromWidget() { | 100 void InputMethodBase::DetachFromWidget() { |
100 if (!widget_) | 101 if (!widget_) |
101 return; | 102 return; |
102 | 103 |
103 widget_->GetFocusManager()->RemoveFocusChangeListener(this); | 104 widget_->GetFocusManager()->RemoveFocusChangeListener(this); |
104 widget_ = NULL; | 105 widget_ = NULL; |
105 } | 106 } |
106 | 107 |
107 } // namespace views | 108 } // namespace views |
OLD | NEW |