OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "views/ime/input_method_base.h" | 5 #include "views/ime/input_method_base.h" |
| 6 #include "views/ime/text_input_type_tracker.h" |
6 #include "views/view.h" | 7 #include "views/view.h" |
7 #include "views/widget/widget.h" | 8 #include "views/widget/widget.h" |
8 | 9 |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 | 11 |
11 namespace views { | 12 namespace views { |
12 | 13 |
13 InputMethodBase::InputMethodBase() | 14 InputMethodBase::InputMethodBase() |
14 : delegate_(NULL), | 15 : delegate_(NULL), |
15 widget_(NULL), | 16 widget_(NULL), |
(...skipping 24 matching lines...) Expand all Loading... |
40 | 41 |
41 widget_ = widget; | 42 widget_ = widget; |
42 View* focused = widget->GetFocusManager()->GetFocusedView(); | 43 View* focused = widget->GetFocusManager()->GetFocusedView(); |
43 if (focused) | 44 if (focused) |
44 FocusWillChange(NULL, focused); | 45 FocusWillChange(NULL, focused); |
45 widget->GetFocusManager()->AddFocusChangeListener(this); | 46 widget->GetFocusManager()->AddFocusChangeListener(this); |
46 } | 47 } |
47 | 48 |
48 void InputMethodBase::OnFocus() { | 49 void InputMethodBase::OnFocus() { |
49 widget_focused_ = true; | 50 widget_focused_ = true; |
| 51 TextInputTypeTracker::GetInstance()->OnTextInputTypeChanged( |
| 52 GetTextInputType(), widget_); |
50 } | 53 } |
51 | 54 |
52 void InputMethodBase::OnBlur() { | 55 void InputMethodBase::OnBlur() { |
53 widget_focused_ = false; | 56 widget_focused_ = false; |
| 57 TextInputTypeTracker::GetInstance()->OnTextInputTypeChanged( |
| 58 GetTextInputType(), widget_); |
| 59 } |
| 60 |
| 61 void InputMethodBase::OnTextInputTypeChanged(View* view) { |
| 62 if (IsViewFocused(view)) { |
| 63 TextInputTypeTracker::GetInstance()->OnTextInputTypeChanged( |
| 64 GetTextInputType(), widget_); |
| 65 } |
54 } | 66 } |
55 | 67 |
56 TextInputClient* InputMethodBase::GetTextInputClient() const { | 68 TextInputClient* InputMethodBase::GetTextInputClient() const { |
57 return (widget_focused_ && focused_view_) ? | 69 return (widget_focused_ && focused_view_) ? |
58 focused_view_->GetTextInputClient() : NULL; | 70 focused_view_->GetTextInputClient() : NULL; |
59 } | 71 } |
60 | 72 |
61 ui::TextInputType InputMethodBase::GetTextInputType() const { | 73 ui::TextInputType InputMethodBase::GetTextInputType() const { |
62 TextInputClient* client = GetTextInputClient(); | 74 TextInputClient* client = GetTextInputClient(); |
63 return client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE; | 75 return client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE; |
64 } | 76 } |
65 | 77 |
66 void InputMethodBase::FocusWillChange(View* focused_before, View* focused) { | 78 void InputMethodBase::FocusWillChange(View* focused_before, View* focused) { |
67 DCHECK_EQ(focused_view_, focused_before); | 79 DCHECK_EQ(focused_view_, focused_before); |
68 FocusedViewWillChange(); | 80 FocusedViewWillChange(); |
69 focused_view_ = focused; | 81 focused_view_ = focused; |
70 FocusedViewDidChange(); | 82 FocusedViewDidChange(); |
| 83 |
| 84 if (widget_focused_) { |
| 85 TextInputTypeTracker::GetInstance()->OnTextInputTypeChanged( |
| 86 GetTextInputType(), widget_); |
| 87 } |
71 } | 88 } |
72 | 89 |
73 bool InputMethodBase::IsViewFocused(View* view) const { | 90 bool InputMethodBase::IsViewFocused(View* view) const { |
74 return widget_focused_ && view && focused_view_ == view; | 91 return widget_focused_ && view && focused_view_ == view; |
75 } | 92 } |
76 | 93 |
77 bool InputMethodBase::IsTextInputTypeNone() const { | 94 bool InputMethodBase::IsTextInputTypeNone() const { |
78 return GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE; | 95 return GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE; |
79 } | 96 } |
80 | 97 |
(...skipping 23 matching lines...) Expand all Loading... |
104 return true; | 121 return true; |
105 } | 122 } |
106 | 123 |
107 void InputMethodBase::FocusedViewWillChange() { | 124 void InputMethodBase::FocusedViewWillChange() { |
108 } | 125 } |
109 | 126 |
110 void InputMethodBase::FocusedViewDidChange() { | 127 void InputMethodBase::FocusedViewDidChange() { |
111 } | 128 } |
112 | 129 |
113 } // namespace views | 130 } // namespace views |
OLD | NEW |