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