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/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/aura/window_delegate.h" | 10 #include "ui/aura/window_delegate.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 } | 268 } |
269 | 269 |
270 void KeyboardController::AddObserver(KeyboardControllerObserver* observer) { | 270 void KeyboardController::AddObserver(KeyboardControllerObserver* observer) { |
271 observer_list_.AddObserver(observer); | 271 observer_list_.AddObserver(observer); |
272 } | 272 } |
273 | 273 |
274 void KeyboardController::RemoveObserver(KeyboardControllerObserver* observer) { | 274 void KeyboardController::RemoveObserver(KeyboardControllerObserver* observer) { |
275 observer_list_.RemoveObserver(observer); | 275 observer_list_.RemoveObserver(observer); |
276 } | 276 } |
277 | 277 |
278 void KeyboardController::ShowAndLockKeyboard() { | 278 void KeyboardController::ShowKeyboard(bool lock) { |
279 set_lock_keyboard(true); | 279 set_lock_keyboard(lock); |
280 OnShowImeIfNeeded(); | 280 OnShowImeIfNeeded(); |
Shu Chen
2014/04/22 17:54:57
From the current call paths, I think it would be b
bshe
2014/04/23 01:08:53
Done.
| |
281 } | 281 } |
282 | 282 |
283 void KeyboardController::OnWindowHierarchyChanged( | 283 void KeyboardController::OnWindowHierarchyChanged( |
284 const HierarchyChangeParams& params) { | 284 const HierarchyChangeParams& params) { |
285 if (params.new_parent && params.target == container_.get()) | 285 if (params.new_parent && params.target == container_.get()) |
286 OnTextInputStateChanged(proxy_->GetInputMethod()->GetTextInputClient()); | 286 OnTextInputStateChanged(proxy_->GetInputMethod()->GetTextInputClient()); |
287 } | 287 } |
288 | 288 |
289 void KeyboardController::Reload() { | 289 void KeyboardController::Reload() { |
290 // Makes sure the keyboard window is initialized. | 290 // Makes sure the keyboard window is initialized. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 if (container_->children().empty()) { | 343 if (container_->children().empty()) { |
344 keyboard::MarkKeyboardLoadStarted(); | 344 keyboard::MarkKeyboardLoadStarted(); |
345 aura::Window* keyboard = proxy_->GetKeyboardWindow(); | 345 aura::Window* keyboard = proxy_->GetKeyboardWindow(); |
346 keyboard->Show(); | 346 keyboard->Show(); |
347 container_->AddChild(keyboard); | 347 container_->AddChild(keyboard); |
348 keyboard->set_owned_by_parent(false); | 348 keyboard->set_owned_by_parent(false); |
349 } | 349 } |
350 | 350 |
351 proxy_->ReloadKeyboardIfNeeded(); | 351 proxy_->ReloadKeyboardIfNeeded(); |
352 | 352 |
353 if (keyboard_visible_) | 353 if (keyboard_visible_ || proxy_->GetKeyboardWindow()->bounds().height() == 0) |
354 return; | 354 return; |
355 | 355 |
356 keyboard_visible_ = true; | 356 keyboard_visible_ = true; |
357 | 357 |
358 // If the controller is in the process of hiding the keyboard, do not log | 358 // If the controller is in the process of hiding the keyboard, do not log |
359 // the stat here since the keyboard will not actually be shown. | 359 // the stat here since the keyboard will not actually be shown. |
360 if (!WillHideKeyboard()) | 360 if (!WillHideKeyboard()) |
361 keyboard::LogKeyboardControlEvent(keyboard::KEYBOARD_CONTROL_SHOW); | 361 keyboard::LogKeyboardControlEvent(keyboard::KEYBOARD_CONTROL_SHOW); |
362 | 362 |
363 weak_factory_.InvalidateWeakPtrs(); | 363 weak_factory_.InvalidateWeakPtrs(); |
364 | 364 |
365 // If |container_| has hide animation, its visibility is set to false when | 365 // If |container_| has hide animation, its visibility is set to false when |
366 // hide animation finished. So even if the container is visible at this | 366 // hide animation finished. So even if the container is visible at this |
367 // point, it may in the process of hiding. We still need to show keyboard | 367 // point, it may in the process of hiding. We still need to show keyboard |
368 // container in this case. | 368 // container in this case. |
369 if (container_->IsVisible() && | 369 if (container_->IsVisible() && |
370 !container_->layer()->GetAnimator()->is_animating()) | 370 !container_->layer()->GetAnimator()->is_animating()) |
371 return; | 371 return; |
372 | 372 |
373 ShowKeyboard(); | 373 ShowKeyboardInternal(); |
374 } | 374 } |
375 | 375 |
376 void KeyboardController::ShowKeyboard() { | 376 void KeyboardController::ShowKeyboardInternal() { |
377 ToggleTouchEventLogging(false); | 377 ToggleTouchEventLogging(false); |
378 ui::LayerAnimator* container_animator = container_->layer()->GetAnimator(); | 378 ui::LayerAnimator* container_animator = container_->layer()->GetAnimator(); |
379 | 379 |
380 // If the container is not animating, makes sure the position and opacity | 380 // If the container is not animating, makes sure the position and opacity |
381 // are at begin states for animation. | 381 // are at begin states for animation. |
382 if (!container_animator->is_animating()) { | 382 if (!container_animator->is_animating()) { |
383 gfx::Transform transform; | 383 gfx::Transform transform; |
384 transform.Translate(0, proxy_->GetKeyboardWindow()->bounds().height()); | 384 transform.Translate(0, proxy_->GetKeyboardWindow()->bounds().height()); |
385 container_->SetTransform(transform); | 385 container_->SetTransform(transform); |
386 container_->layer()->SetOpacity(kAnimationStartOrAfterHideOpacity); | 386 container_->layer()->SetOpacity(kAnimationStartOrAfterHideOpacity); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
419 // background during animation. | 419 // background during animation. |
420 NotifyKeyboardBoundsChanging(proxy_->GetKeyboardWindow()->bounds()); | 420 NotifyKeyboardBoundsChanging(proxy_->GetKeyboardWindow()->bounds()); |
421 proxy_->EnsureCaretInWorkArea(); | 421 proxy_->EnsureCaretInWorkArea(); |
422 } | 422 } |
423 | 423 |
424 void KeyboardController::HideAnimationFinished() { | 424 void KeyboardController::HideAnimationFinished() { |
425 proxy_->HideKeyboardContainer(container_.get()); | 425 proxy_->HideKeyboardContainer(container_.get()); |
426 } | 426 } |
427 | 427 |
428 } // namespace keyboard | 428 } // namespace keyboard |
OLD | NEW |