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 "chrome/browser/chromeos/login/touch_login_view.h" | 5 #include "chrome/browser/chromeos/login/touch_login_view.h" |
6 | 6 |
7 #include "chrome/browser/renderer_host/render_widget_host_view_views.h" | 7 #include "chrome/browser/renderer_host/render_widget_host_view_views.h" |
8 #include "chrome/browser/ui/touch/frame/keyboard_container_view.h" | 8 #include "chrome/browser/ui/touch/frame/keyboard_container_view.h" |
9 #include "chrome/browser/ui/views/tab_contents/tab_contents_view_touch.h" | 9 #include "chrome/browser/ui/views/tab_contents/tab_contents_view_touch.h" |
10 #include "chrome/browser/ui/views/dom_view.h" | 10 #include "chrome/browser/ui/views/dom_view.h" |
| 11 #include "chrome/common/chrome_notification_types.h" |
11 #include "content/browser/tab_contents/tab_contents.h" | 12 #include "content/browser/tab_contents/tab_contents.h" |
12 #include "content/common/notification_service.h" | 13 #include "content/common/notification_service.h" |
13 #include "ui/base/animation/slide_animation.h" | 14 #include "ui/base/animation/slide_animation.h" |
14 #include "ui/gfx/transform.h" | 15 #include "ui/gfx/transform.h" |
15 #include "views/controls/textfield/textfield.h" | 16 #include "views/controls/textfield/textfield.h" |
16 #include "views/widget/widget.h" | 17 #include "views/widget/widget.h" |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 const char kViewClassName[] = "browser/chromeos/login/TouchLoginView"; | 21 const char kViewClassName[] = "browser/chromeos/login/TouchLoginView"; |
(...skipping 25 matching lines...) Expand all Loading... |
46 } | 47 } |
47 | 48 |
48 TouchLoginView::~TouchLoginView() { | 49 TouchLoginView::~TouchLoginView() { |
49 } | 50 } |
50 | 51 |
51 void TouchLoginView::Init() { | 52 void TouchLoginView::Init() { |
52 WebUILoginView::Init(); | 53 WebUILoginView::Init(); |
53 InitVirtualKeyboard(); | 54 InitVirtualKeyboard(); |
54 | 55 |
55 registrar_.Add(this, | 56 registrar_.Add(this, |
56 NotificationType::FOCUS_CHANGED_IN_PAGE, | 57 content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, |
57 NotificationService::AllSources()); | 58 NotificationService::AllSources()); |
58 registrar_.Add(this, | 59 registrar_.Add(this, |
59 NotificationType::TAB_CONTENTS_DESTROYED, | 60 content::NOTIFICATION_TAB_CONTENTS_DESTROYED, |
60 NotificationService::AllSources()); | 61 NotificationService::AllSources()); |
61 registrar_.Add(this, | 62 registrar_.Add(this, |
62 NotificationType::HIDE_KEYBOARD_INVOKED, | 63 chrome::NOTIFICATION_HIDE_KEYBOARD_INVOKED, |
63 NotificationService::AllSources()); | 64 NotificationService::AllSources()); |
64 registrar_.Add(this, | 65 registrar_.Add(this, |
65 NotificationType::SET_KEYBOARD_HEIGHT_INVOKED, | 66 chrome::NOTIFICATION_SET_KEYBOARD_HEIGHT_INVOKED, |
66 NotificationService::AllSources()); | 67 NotificationService::AllSources()); |
67 } | 68 } |
68 | 69 |
69 std::string TouchLoginView::GetClassName() const { | 70 std::string TouchLoginView::GetClassName() const { |
70 return kViewClassName; | 71 return kViewClassName; |
71 } | 72 } |
72 | 73 |
73 void TouchLoginView::FocusWillChange(views::View* focused_before, | 74 void TouchLoginView::FocusWillChange(views::View* focused_before, |
74 views::View* focused_now) { | 75 views::View* focused_now) { |
75 VirtualKeyboardType before = DecideKeyboardStateForView(focused_before); | 76 VirtualKeyboardType before = DecideKeyboardStateForView(focused_before); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 } else if (cname == RenderWidgetHostViewViews::kViewClassName) { | 144 } else if (cname == RenderWidgetHostViewViews::kViewClassName) { |
144 TabContents* contents = webui_login_->tab_contents(); | 145 TabContents* contents = webui_login_->tab_contents(); |
145 bool* editable = contents ? GetFocusedStateAccessor()->GetProperty( | 146 bool* editable = contents ? GetFocusedStateAccessor()->GetProperty( |
146 contents->property_bag()) : NULL; | 147 contents->property_bag()) : NULL; |
147 if (editable && *editable) | 148 if (editable && *editable) |
148 return GENERIC; | 149 return GENERIC; |
149 } | 150 } |
150 return NONE; | 151 return NONE; |
151 } | 152 } |
152 | 153 |
153 void TouchLoginView::Observe(NotificationType type, | 154 void TouchLoginView::Observe(int type, |
154 const NotificationSource& source, | 155 const NotificationSource& source, |
155 const NotificationDetails& details) { | 156 const NotificationDetails& details) { |
156 if (type == NotificationType::FOCUS_CHANGED_IN_PAGE) { | 157 if (type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE) { |
157 // Only modify the keyboard state if the currently active tab sent the | 158 // Only modify the keyboard state if the currently active tab sent the |
158 // notification. | 159 // notification. |
159 const TabContents* current_tab = webui_login_->tab_contents(); | 160 const TabContents* current_tab = webui_login_->tab_contents(); |
160 TabContents* source_tab = Source<TabContents>(source).ptr(); | 161 TabContents* source_tab = Source<TabContents>(source).ptr(); |
161 const bool editable = *Details<const bool>(details).ptr(); | 162 const bool editable = *Details<const bool>(details).ptr(); |
162 | 163 |
163 if (current_tab == source_tab && TabContentsHasFocus(source_tab)) | 164 if (current_tab == source_tab && TabContentsHasFocus(source_tab)) |
164 UpdateKeyboardAndLayout(editable); | 165 UpdateKeyboardAndLayout(editable); |
165 | 166 |
166 // Save the state of the focused field so that the keyboard visibility | 167 // Save the state of the focused field so that the keyboard visibility |
167 // can be determined after tab switching. | 168 // can be determined after tab switching. |
168 GetFocusedStateAccessor()->SetProperty( | 169 GetFocusedStateAccessor()->SetProperty( |
169 source_tab->property_bag(), editable); | 170 source_tab->property_bag(), editable); |
170 } else if (type == NotificationType::TAB_CONTENTS_DESTROYED) { | 171 } else if (type == content::NOTIFICATION_TAB_CONTENTS_DESTROYED) { |
171 GetFocusedStateAccessor()->DeleteProperty( | 172 GetFocusedStateAccessor()->DeleteProperty( |
172 Source<TabContents>(source).ptr()->property_bag()); | 173 Source<TabContents>(source).ptr()->property_bag()); |
173 } else if (type == NotificationType::HIDE_KEYBOARD_INVOKED) { | 174 } else if (type == chrome::NOTIFICATION_HIDE_KEYBOARD_INVOKED) { |
174 UpdateKeyboardAndLayout(false); | 175 UpdateKeyboardAndLayout(false); |
175 } else if (type == NotificationType::SET_KEYBOARD_HEIGHT_INVOKED) { | 176 } else if (type == chrome::NOTIFICATION_SET_KEYBOARD_HEIGHT_INVOKED) { |
176 // TODO(penghuang) Allow extension conrtol the virtual keyboard directly | 177 // TODO(penghuang) Allow extension conrtol the virtual keyboard directly |
177 // instead of using Notification. | 178 // instead of using Notification. |
178 int height = *(Details<int>(details).ptr()); | 179 int height = *(Details<int>(details).ptr()); |
179 if (height != keyboard_height_) { | 180 if (height != keyboard_height_) { |
180 DCHECK_GE(height, 0) << "Height of the keyboard is less than 0."; | 181 DCHECK_GE(height, 0) << "Height of the keyboard is less than 0."; |
181 DCHECK_LE(height, View::height()) << "Height of the keyboard is greater " | 182 DCHECK_LE(height, View::height()) << "Height of the keyboard is greater " |
182 "than the height of containing view."; | 183 "than the height of containing view."; |
183 keyboard_height_ = height; | 184 keyboard_height_ = height; |
184 Layout(); | 185 Layout(); |
185 } | 186 } |
(...skipping 12 matching lines...) Expand all Loading... |
198 void TouchLoginView::AnimationEnded(const ui::Animation* animation) { | 199 void TouchLoginView::AnimationEnded(const ui::Animation* animation) { |
199 if (keyboard_showing_) { | 200 if (keyboard_showing_) { |
200 Layout(); | 201 Layout(); |
201 } else { | 202 } else { |
202 // Notify the keyboard that it is hidden now. | 203 // Notify the keyboard that it is hidden now. |
203 keyboard_->SetVisible(false); | 204 keyboard_->SetVisible(false); |
204 } | 205 } |
205 } | 206 } |
206 | 207 |
207 } // namespace chromeos | 208 } // namespace chromeos |
OLD | NEW |