| 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/ui/virtual_keyboard/virtual_keyboard_manager.h" | 5 #include "chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/extensions/extension_event_router.h" | 9 #include "chrome/browser/extensions/extension_event_router.h" |
| 10 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 10 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
| 13 #include "chrome/browser/tabs/tab_strip_model.h" | 13 #include "chrome/browser/tabs/tab_strip_model.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
| 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 17 #include "chrome/browser/ui/views/dom_view.h" | 17 #include "chrome/browser/ui/views/dom_view.h" |
| 18 #include "chrome/browser/ui/views/frame/browser_view.h" | 18 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 19 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
| 20 #include "chrome/common/extensions/extension_messages.h" | 20 #include "chrome/common/extensions/extension_messages.h" |
| 21 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 22 #include "content/browser/site_instance.h" | 22 #include "content/browser/site_instance.h" |
| 23 #include "content/browser/tab_contents/tab_contents_observer.h" | 23 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 24 #include "content/common/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| 25 #include "ui/base/animation/animation_delegate.h" | 25 #include "ui/base/animation/animation_delegate.h" |
| 26 #include "ui/base/animation/slide_animation.h" | 26 #include "ui/base/animation/slide_animation.h" |
| 27 #include "ui/base/ime/text_input_type.h" | 27 #include "ui/base/ime/text_input_type.h" |
| 28 #include "ui/gfx/compositor/layer.h" | 28 #include "ui/gfx/compositor/layer.h" |
| 29 #include "ui/gfx/interpolated_transform.h" | 29 #include "ui/gfx/interpolated_transform.h" |
| 30 #include "ui/gfx/screen.h" | 30 #include "ui/gfx/screen.h" |
| 31 #include "views/ime/text_input_type_tracker.h" | 31 #include "views/ime/text_input_type_tracker.h" |
| 32 #include "views/widget/widget.h" | 32 #include "views/widget/widget.h" |
| 33 | 33 |
| 34 #if defined(OS_CHROMEOS) | 34 #if defined(OS_CHROMEOS) |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 TabContentsObserver::Observe(dom_view_->dom_contents()->tab_contents()); | 203 TabContentsObserver::Observe(dom_view_->dom_contents()->tab_contents()); |
| 204 | 204 |
| 205 // Initialize the animation. | 205 // Initialize the animation. |
| 206 animation_.reset(new ui::SlideAnimation(this)); | 206 animation_.reset(new ui::SlideAnimation(this)); |
| 207 animation_->SetTweenType(ui::Tween::LINEAR); | 207 animation_->SetTweenType(ui::Tween::LINEAR); |
| 208 animation_->SetSlideDuration(kKeyboardSlideDuration); | 208 animation_->SetSlideDuration(kKeyboardSlideDuration); |
| 209 | 209 |
| 210 views::TextInputTypeTracker::GetInstance()->AddTextInputTypeObserver(this); | 210 views::TextInputTypeTracker::GetInstance()->AddTextInputTypeObserver(this); |
| 211 registrar_.Add(this, | 211 registrar_.Add(this, |
| 212 chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED, | 212 chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED, |
| 213 NotificationService::AllSources()); | 213 content::NotificationService::AllSources()); |
| 214 registrar_.Add(this, | 214 registrar_.Add(this, |
| 215 chrome::NOTIFICATION_HIDE_KEYBOARD_INVOKED, | 215 chrome::NOTIFICATION_HIDE_KEYBOARD_INVOKED, |
| 216 NotificationService::AllSources()); | 216 content::NotificationService::AllSources()); |
| 217 registrar_.Add(this, | 217 registrar_.Add(this, |
| 218 chrome::NOTIFICATION_SET_KEYBOARD_HEIGHT_INVOKED, | 218 chrome::NOTIFICATION_SET_KEYBOARD_HEIGHT_INVOKED, |
| 219 NotificationService::AllSources()); | 219 content::NotificationService::AllSources()); |
| 220 registrar_.Add(this, | 220 registrar_.Add(this, |
| 221 content::NOTIFICATION_APP_TERMINATING, | 221 content::NOTIFICATION_APP_TERMINATING, |
| 222 NotificationService::AllSources()); | 222 content::NotificationService::AllSources()); |
| 223 | 223 |
| 224 #if defined(OS_CHROMEOS) | 224 #if defined(OS_CHROMEOS) |
| 225 chromeos::input_method::InputMethodManager* manager = | 225 chromeos::input_method::InputMethodManager* manager = |
| 226 chromeos::input_method::InputMethodManager::GetInstance(); | 226 chromeos::input_method::InputMethodManager::GetInstance(); |
| 227 manager->AddVirtualKeyboardObserver(this); | 227 manager->AddVirtualKeyboardObserver(this); |
| 228 #endif | 228 #endif |
| 229 | 229 |
| 230 #if defined(USE_AURA) | 230 #if defined(USE_AURA) |
| 231 aura::Desktop::GetInstance()->AddObserver(this); | 231 aura::Desktop::GetInstance()->AddObserver(this); |
| 232 #endif | 232 #endif |
| (...skipping 22 matching lines...) Expand all Loading... |
| 255 | 255 |
| 256 transform_.reset(new ui::InterpolatedTranslation( | 256 transform_.reset(new ui::InterpolatedTranslation( |
| 257 gfx::Point(0, keyboard_height_), gfx::Point())); | 257 gfx::Point(0, keyboard_height_), gfx::Point())); |
| 258 | 258 |
| 259 UpdateForAnimation(); | 259 UpdateForAnimation(); |
| 260 animation_->Show(); | 260 animation_->Show(); |
| 261 | 261 |
| 262 Show(); | 262 Show(); |
| 263 | 263 |
| 264 bool visible = true; | 264 bool visible = true; |
| 265 NotificationService::current()->Notify( | 265 content::NotificationService::current()->Notify( |
| 266 chrome::NOTIFICATION_KEYBOARD_VISIBILITY_CHANGED, | 266 chrome::NOTIFICATION_KEYBOARD_VISIBILITY_CHANGED, |
| 267 content::Source<KeyboardWidget>(this), | 267 content::Source<KeyboardWidget>(this), |
| 268 content::Details<bool>(&visible)); | 268 content::Details<bool>(&visible)); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void KeyboardWidget::ResetBounds() { | 271 void KeyboardWidget::ResetBounds() { |
| 272 SetBounds(GetKeyboardPosition(keyboard_height_)); | 272 SetBounds(GetKeyboardPosition(keyboard_height_)); |
| 273 } | 273 } |
| 274 | 274 |
| 275 void KeyboardWidget::Hide() { | 275 void KeyboardWidget::Hide() { |
| 276 animation_->Hide(); | 276 animation_->Hide(); |
| 277 | 277 |
| 278 bool visible = false; | 278 bool visible = false; |
| 279 NotificationService::current()->Notify( | 279 content::NotificationService::current()->Notify( |
| 280 chrome::NOTIFICATION_KEYBOARD_VISIBILITY_CHANGED, | 280 chrome::NOTIFICATION_KEYBOARD_VISIBILITY_CHANGED, |
| 281 content::Source<KeyboardWidget>(this), | 281 content::Source<KeyboardWidget>(this), |
| 282 content::Details<bool>(&visible)); | 282 content::Details<bool>(&visible)); |
| 283 } | 283 } |
| 284 | 284 |
| 285 void KeyboardWidget::SetTarget(views::Widget* target) { | 285 void KeyboardWidget::SetTarget(views::Widget* target) { |
| 286 if (target_) | 286 if (target_) |
| 287 target_->RemoveObserver(this); | 287 target_->RemoveObserver(this); |
| 288 | 288 |
| 289 target_ = target; | 289 target_ = target; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 UpdateForAnimation(); | 321 UpdateForAnimation(); |
| 322 } | 322 } |
| 323 | 323 |
| 324 void KeyboardWidget::AnimationEnded(const ui::Animation* animation) { | 324 void KeyboardWidget::AnimationEnded(const ui::Animation* animation) { |
| 325 gfx::Rect keyboard_rect; | 325 gfx::Rect keyboard_rect; |
| 326 if (animation_->GetCurrentValue() < 0.01) | 326 if (animation_->GetCurrentValue() < 0.01) |
| 327 Widget::Hide(); | 327 Widget::Hide(); |
| 328 else | 328 else |
| 329 keyboard_rect = GetWindowScreenBounds(); | 329 keyboard_rect = GetWindowScreenBounds(); |
| 330 | 330 |
| 331 NotificationService::current()->Notify( | 331 content::NotificationService::current()->Notify( |
| 332 chrome::NOTIFICATION_KEYBOARD_VISIBLE_BOUNDS_CHANGED, | 332 chrome::NOTIFICATION_KEYBOARD_VISIBLE_BOUNDS_CHANGED, |
| 333 content::Source<KeyboardWidget>(this), | 333 content::Source<KeyboardWidget>(this), |
| 334 content::Details<gfx::Rect>(&keyboard_rect)); | 334 content::Details<gfx::Rect>(&keyboard_rect)); |
| 335 } | 335 } |
| 336 | 336 |
| 337 bool KeyboardWidget::OnMessageReceived(const IPC::Message& message) { | 337 bool KeyboardWidget::OnMessageReceived(const IPC::Message& message) { |
| 338 bool handled = true; | 338 bool handled = true; |
| 339 IPC_BEGIN_MESSAGE_MAP(KeyboardWidget, message) | 339 IPC_BEGIN_MESSAGE_MAP(KeyboardWidget, message) |
| 340 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) | 340 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) |
| 341 IPC_MESSAGE_UNHANDLED(handled = false) | 341 IPC_MESSAGE_UNHANDLED(handled = false) |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 | 554 |
| 555 void VirtualKeyboardManager::OnDesktopBoundsChanged( | 555 void VirtualKeyboardManager::OnDesktopBoundsChanged( |
| 556 const gfx::Rect& prev_bounds) { | 556 const gfx::Rect& prev_bounds) { |
| 557 keyboard_->ResetBounds(); | 557 keyboard_->ResetBounds(); |
| 558 } | 558 } |
| 559 | 559 |
| 560 // static | 560 // static |
| 561 VirtualKeyboardManager* VirtualKeyboardManager::GetInstance() { | 561 VirtualKeyboardManager* VirtualKeyboardManager::GetInstance() { |
| 562 return Singleton<VirtualKeyboardManager>::get(); | 562 return Singleton<VirtualKeyboardManager>::get(); |
| 563 } | 563 } |
| OLD | NEW |