| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/keyboard/keyboard_controller.h" | 5 #include "ui/keyboard/keyboard_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "ui/aura/client/virtual_keyboard_observer.h" |
| 10 #include "ui/aura/layout_manager.h" |
| 9 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
| 10 #include "ui/aura/window_delegate.h" | 12 #include "ui/aura/window_delegate.h" |
| 11 #include "ui/base/cursor/cursor.h" | 13 #include "ui/base/cursor/cursor.h" |
| 12 #include "ui/base/hit_test.h" | 14 #include "ui/base/hit_test.h" |
| 13 #include "ui/base/ime/input_method.h" | 15 #include "ui/base/ime/input_method.h" |
| 14 #include "ui/base/ime/text_input_client.h" | 16 #include "ui/base/ime/text_input_client.h" |
| 15 #include "ui/compositor/layer_animation_observer.h" | 17 #include "ui/compositor/layer_animation_observer.h" |
| 16 #include "ui/compositor/scoped_layer_animation_settings.h" | 18 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 17 #include "ui/gfx/path.h" | 19 #include "ui/gfx/path.h" |
| 18 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
| 19 #include "ui/gfx/skia_util.h" | 21 #include "ui/gfx/skia_util.h" |
| 20 #include "ui/keyboard/keyboard_controller_observer.h" | |
| 21 #include "ui/keyboard/keyboard_controller_proxy.h" | 22 #include "ui/keyboard/keyboard_controller_proxy.h" |
| 22 #include "ui/keyboard/keyboard_layout_manager.h" | 23 #include "ui/keyboard/keyboard_layout_manager.h" |
| 23 #include "ui/keyboard/keyboard_switches.h" | 24 #include "ui/keyboard/keyboard_switches.h" |
| 24 #include "ui/keyboard/keyboard_util.h" | 25 #include "ui/keyboard/keyboard_util.h" |
| 25 #include "ui/wm/core/masked_window_targeter.h" | 26 #include "ui/wm/core/masked_window_targeter.h" |
| 26 | 27 |
| 27 #if defined(OS_CHROMEOS) | 28 #if defined(OS_CHROMEOS) |
| 28 #include "base/process/launch.h" | 29 #include "base/process/launch.h" |
| 29 #include "base/sys_info.h" | 30 #include "base/sys_info.h" |
| 30 #endif | 31 #endif |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 container_->Init(aura::WINDOW_LAYER_NOT_DRAWN); | 211 container_->Init(aura::WINDOW_LAYER_NOT_DRAWN); |
| 211 container_->AddObserver(this); | 212 container_->AddObserver(this); |
| 212 container_->SetLayoutManager(new KeyboardLayoutManager(this)); | 213 container_->SetLayoutManager(new KeyboardLayoutManager(this)); |
| 213 } | 214 } |
| 214 return container_.get(); | 215 return container_.get(); |
| 215 } | 216 } |
| 216 | 217 |
| 217 void KeyboardController::NotifyKeyboardBoundsChanging( | 218 void KeyboardController::NotifyKeyboardBoundsChanging( |
| 218 const gfx::Rect& new_bounds) { | 219 const gfx::Rect& new_bounds) { |
| 219 if (proxy_->HasKeyboardWindow() && proxy_->GetKeyboardWindow()->IsVisible()) { | 220 if (proxy_->HasKeyboardWindow() && proxy_->GetKeyboardWindow()->IsVisible()) { |
| 220 FOR_EACH_OBSERVER(KeyboardControllerObserver, | 221 FOR_EACH_OBSERVER(aura::client::VirtualKeyboardObserver, |
| 221 observer_list_, | 222 observer_list_, |
| 222 OnKeyboardBoundsChanging(new_bounds)); | 223 OnKeyboardBoundsChanging(new_bounds)); |
| 223 } | 224 } |
| 224 } | 225 } |
| 225 | 226 |
| 226 void KeyboardController::HideKeyboard(HideReason reason) { | 227 void KeyboardController::HideKeyboard(HideReason reason) { |
| 227 keyboard_visible_ = false; | 228 keyboard_visible_ = false; |
| 228 ToggleTouchEventLogging(true); | 229 ToggleTouchEventLogging(true); |
| 229 | 230 |
| 230 keyboard::LogKeyboardControlEvent( | 231 keyboard::LogKeyboardControlEvent( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 246 ui::ScopedLayerAnimationSettings settings(container_animator); | 247 ui::ScopedLayerAnimationSettings settings(container_animator); |
| 247 settings.SetTweenType(gfx::Tween::EASE_OUT); | 248 settings.SetTweenType(gfx::Tween::EASE_OUT); |
| 248 settings.SetTransitionDuration( | 249 settings.SetTransitionDuration( |
| 249 base::TimeDelta::FromMilliseconds(kAnimationDurationMs)); | 250 base::TimeDelta::FromMilliseconds(kAnimationDurationMs)); |
| 250 gfx::Transform transform; | 251 gfx::Transform transform; |
| 251 transform.Translate(0, proxy_->GetKeyboardWindow()->bounds().height()); | 252 transform.Translate(0, proxy_->GetKeyboardWindow()->bounds().height()); |
| 252 container_->SetTransform(transform); | 253 container_->SetTransform(transform); |
| 253 container_->layer()->SetOpacity(kAnimationStartOrAfterHideOpacity); | 254 container_->layer()->SetOpacity(kAnimationStartOrAfterHideOpacity); |
| 254 } | 255 } |
| 255 | 256 |
| 256 void KeyboardController::AddObserver(KeyboardControllerObserver* observer) { | 257 void KeyboardController::AddObserver( |
| 258 aura::client::VirtualKeyboardObserver* observer) { |
| 257 observer_list_.AddObserver(observer); | 259 observer_list_.AddObserver(observer); |
| 258 } | 260 } |
| 259 | 261 |
| 260 void KeyboardController::RemoveObserver(KeyboardControllerObserver* observer) { | 262 void KeyboardController::RemoveObserver( |
| 263 aura::client::VirtualKeyboardObserver* observer) { |
| 261 observer_list_.RemoveObserver(observer); | 264 observer_list_.RemoveObserver(observer); |
| 262 } | 265 } |
| 263 | 266 |
| 267 bool KeyboardController::IsOverscrollEnabled() { |
| 268 return keyboard::IsKeyboardOverscrollEnabled(); |
| 269 } |
| 270 |
| 264 void KeyboardController::ShowAndLockKeyboard() { | 271 void KeyboardController::ShowAndLockKeyboard() { |
| 265 set_lock_keyboard(true); | 272 set_lock_keyboard(true); |
| 266 OnShowImeIfNeeded(); | 273 OnShowImeIfNeeded(); |
| 267 } | 274 } |
| 268 | 275 |
| 269 void KeyboardController::OnWindowHierarchyChanged( | 276 void KeyboardController::OnWindowHierarchyChanged( |
| 270 const HierarchyChangeParams& params) { | 277 const HierarchyChangeParams& params) { |
| 271 if (params.new_parent && params.target == container_.get()) | 278 if (params.new_parent && params.target == container_.get()) |
| 272 OnTextInputStateChanged(proxy_->GetInputMethod()->GetTextInputClient()); | 279 OnTextInputStateChanged(proxy_->GetInputMethod()->GetTextInputClient()); |
| 273 } | 280 } |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 // background during animation. | 418 // background during animation. |
| 412 NotifyKeyboardBoundsChanging(proxy_->GetKeyboardWindow()->bounds()); | 419 NotifyKeyboardBoundsChanging(proxy_->GetKeyboardWindow()->bounds()); |
| 413 proxy_->EnsureCaretInWorkArea(); | 420 proxy_->EnsureCaretInWorkArea(); |
| 414 } | 421 } |
| 415 | 422 |
| 416 void KeyboardController::HideAnimationFinished() { | 423 void KeyboardController::HideAnimationFinished() { |
| 417 proxy_->HideKeyboardContainer(container_.get()); | 424 proxy_->HideKeyboardContainer(container_.get()); |
| 418 } | 425 } |
| 419 | 426 |
| 420 } // namespace keyboard | 427 } // namespace keyboard |
| OLD | NEW |