| 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 #ifndef UI_KEYBOARD_KEYBOARD_CONTROLLER_H_ | 5 #ifndef UI_KEYBOARD_KEYBOARD_CONTROLLER_H_ |
| 6 #define UI_KEYBOARD_KEYBOARD_CONTROLLER_H_ | 6 #define UI_KEYBOARD_KEYBOARD_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/event_types.h" | 9 #include "base/event_types.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "ui/aura/client/virtual_keyboard_client.h" |
| 12 #include "ui/aura/window_observer.h" | 13 #include "ui/aura/window_observer.h" |
| 13 #include "ui/base/ime/input_method_observer.h" | 14 #include "ui/base/ime/input_method_observer.h" |
| 14 #include "ui/base/ime/text_input_type.h" | 15 #include "ui/base/ime/text_input_type.h" |
| 15 #include "ui/keyboard/keyboard_export.h" | 16 #include "ui/keyboard/keyboard_export.h" |
| 16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 17 | 18 |
| 18 namespace aura { | 19 namespace aura { |
| 19 class Window; | 20 class Window; |
| 21 namespace client { |
| 22 class VirtualKeyboardObserver; |
| 23 } |
| 20 } | 24 } |
| 21 namespace gfx { | 25 namespace gfx { |
| 22 class Rect; | 26 class Rect; |
| 23 } | 27 } |
| 24 namespace ui { | 28 namespace ui { |
| 25 class InputMethod; | 29 class InputMethod; |
| 26 class TextInputClient; | 30 class TextInputClient; |
| 27 } | 31 } |
| 28 | 32 |
| 29 namespace keyboard { | 33 namespace keyboard { |
| 30 | 34 |
| 31 class CallbackAnimationObserver; | 35 class CallbackAnimationObserver; |
| 32 class KeyboardControllerObserver; | 36 class KeyboardControllerObserver; |
| 33 class KeyboardControllerProxy; | 37 class KeyboardControllerProxy; |
| 34 | 38 |
| 35 // Provides control of the virtual keyboard, including providing a container | 39 // Provides control of the virtual keyboard, including providing a container |
| 36 // and controlling visibility. | 40 // and controlling visibility. |
| 37 class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver, | 41 class KEYBOARD_EXPORT KeyboardController |
| 38 public aura::WindowObserver { | 42 : public ui::InputMethodObserver, |
| 43 public aura::WindowObserver, |
| 44 public aura::client::VirtualKeyboardClient { |
| 39 public: | 45 public: |
| 40 // Different ways to hide the keyboard. | 46 // Different ways to hide the keyboard. |
| 41 enum HideReason { | 47 enum HideReason { |
| 42 // System initiated. | 48 // System initiated. |
| 43 HIDE_REASON_AUTOMATIC, | 49 HIDE_REASON_AUTOMATIC, |
| 44 // User initiated. | 50 // User initiated. |
| 45 HIDE_REASON_MANUAL, | 51 HIDE_REASON_MANUAL, |
| 46 }; | 52 }; |
| 47 | 53 |
| 48 // Takes ownership of |proxy|. | 54 // Takes ownership of |proxy|. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 63 | 69 |
| 64 // Hides virtual keyboard and notifies observer bounds change. | 70 // Hides virtual keyboard and notifies observer bounds change. |
| 65 // This function should be called with a delay to avoid layout flicker | 71 // This function should be called with a delay to avoid layout flicker |
| 66 // when the focus of input field quickly change. |automatic| is true when the | 72 // when the focus of input field quickly change. |automatic| is true when the |
| 67 // call is made by the system rather than initiated by the user. | 73 // call is made by the system rather than initiated by the user. |
| 68 void HideKeyboard(HideReason reason); | 74 void HideKeyboard(HideReason reason); |
| 69 | 75 |
| 70 // Notifies the keyboard observer for keyboard bounds changed. | 76 // Notifies the keyboard observer for keyboard bounds changed. |
| 71 void NotifyKeyboardBoundsChanging(const gfx::Rect& new_bounds); | 77 void NotifyKeyboardBoundsChanging(const gfx::Rect& new_bounds); |
| 72 | 78 |
| 73 // Management of the observer list. | 79 // Overridden from aura::client::VirtualKeyboardClient: |
| 74 virtual void AddObserver(KeyboardControllerObserver* observer); | 80 virtual void AddObserver(aura::client::VirtualKeyboardObserver* observer) |
| 75 virtual void RemoveObserver(KeyboardControllerObserver* observer); | 81 OVERRIDE; |
| 82 virtual void RemoveObserver(aura::client::VirtualKeyboardObserver* observer) |
| 83 OVERRIDE; |
| 84 virtual bool IsOverscrollEnabled() OVERRIDE; |
| 76 | 85 |
| 77 KeyboardControllerProxy* proxy() { return proxy_.get(); } | 86 KeyboardControllerProxy* proxy() { return proxy_.get(); } |
| 78 | 87 |
| 79 void set_lock_keyboard(bool lock) { lock_keyboard_ = lock; } | 88 void set_lock_keyboard(bool lock) { lock_keyboard_ = lock; } |
| 80 | 89 |
| 81 // Force the keyboard to show up if not showing and lock the keyboard. | 90 // Force the keyboard to show up if not showing and lock the keyboard. |
| 82 void ShowAndLockKeyboard(); | 91 void ShowAndLockKeyboard(); |
| 83 | 92 |
| 84 private: | 93 private: |
| 85 // For access to Observer methods for simulation. | 94 // For access to Observer methods for simulation. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 scoped_ptr<aura::Window> container_; | 126 scoped_ptr<aura::Window> container_; |
| 118 // CallbackAnimationObserver should destructed before container_ because it | 127 // CallbackAnimationObserver should destructed before container_ because it |
| 119 // uses container_'s animator. | 128 // uses container_'s animator. |
| 120 scoped_ptr<CallbackAnimationObserver> animation_observer_; | 129 scoped_ptr<CallbackAnimationObserver> animation_observer_; |
| 121 | 130 |
| 122 ui::InputMethod* input_method_; | 131 ui::InputMethod* input_method_; |
| 123 bool keyboard_visible_; | 132 bool keyboard_visible_; |
| 124 bool lock_keyboard_; | 133 bool lock_keyboard_; |
| 125 ui::TextInputType type_; | 134 ui::TextInputType type_; |
| 126 | 135 |
| 127 ObserverList<KeyboardControllerObserver> observer_list_; | 136 ObserverList<aura::client::VirtualKeyboardObserver> observer_list_; |
| 128 | 137 |
| 129 base::WeakPtrFactory<KeyboardController> weak_factory_; | 138 base::WeakPtrFactory<KeyboardController> weak_factory_; |
| 130 | 139 |
| 131 DISALLOW_COPY_AND_ASSIGN(KeyboardController); | 140 DISALLOW_COPY_AND_ASSIGN(KeyboardController); |
| 132 }; | 141 }; |
| 133 | 142 |
| 134 } // namespace keyboard | 143 } // namespace keyboard |
| 135 | 144 |
| 136 #endif // UI_KEYBOARD_KEYBOARD_CONTROLLER_H_ | 145 #endif // UI_KEYBOARD_KEYBOARD_CONTROLLER_H_ |
| OLD | NEW |