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/window_observer.h" | 12 #include "ui/aura/window_observer.h" |
13 #include "ui/base/ime/input_method_observer.h" | 13 #include "ui/base/ime/input_method_observer.h" |
14 #include "ui/base/ime/text_input_type.h" | 14 #include "ui/base/ime/text_input_type.h" |
15 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
16 #include "ui/keyboard/keyboard_export.h" | 16 #include "ui/keyboard/keyboard_export.h" |
17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
18 | 18 |
19 namespace aura { | 19 namespace aura { |
20 class Window; | 20 class Window; |
21 } | 21 } |
22 namespace ui { | 22 namespace ui { |
23 class InputMethod; | 23 class InputMethod; |
24 class TextInputClient; | 24 class TextInputClient; |
25 } | 25 } |
26 | 26 |
27 namespace keyboard { | 27 namespace keyboard { |
28 | 28 |
29 class CallbackAnimationObserver; | 29 class CallbackAnimationObserver; |
30 class WindowBoundsChangeObserver; | |
31 class KeyboardControllerObserver; | 30 class KeyboardControllerObserver; |
32 class KeyboardControllerProxy; | 31 class KeyboardControllerProxy; |
| 32 class WindowBoundsChangeObserver; |
33 | 33 |
34 // Animation distance. | 34 // Animation distance. |
35 const int kAnimationDistance = 30; | 35 const int kAnimationDistance = 30; |
36 | 36 |
37 // Provides control of the virtual keyboard, including providing a container | 37 // Provides control of the virtual keyboard, including providing a container |
38 // and controlling visibility. | 38 // and controlling visibility. |
39 class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver, | 39 class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver, |
40 public aura::WindowObserver { | 40 public aura::WindowObserver { |
41 public: | 41 public: |
42 // Different ways to hide the keyboard. | 42 // Different ways to hide the keyboard. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 void ResetWindowInsets(); | 133 void ResetWindowInsets(); |
134 | 134 |
135 // Returns true if keyboard is scheduled to hide. | 135 // Returns true if keyboard is scheduled to hide. |
136 bool WillHideKeyboard() const; | 136 bool WillHideKeyboard() const; |
137 | 137 |
138 // Called when show and hide animation finished successfully. If the animation | 138 // Called when show and hide animation finished successfully. If the animation |
139 // is aborted, it won't be called. | 139 // is aborted, it won't be called. |
140 void ShowAnimationFinished(); | 140 void ShowAnimationFinished(); |
141 void HideAnimationFinished(); | 141 void HideAnimationFinished(); |
142 | 142 |
143 // Adds an observer for tracking changes to a window size or | |
144 // position while the keyboard is displayed. Any window repositioning | |
145 // invalidates insets for overscrolling. | |
146 void AddBoundsChangedObserver(aura::Window* window); | |
147 | |
148 scoped_ptr<KeyboardControllerProxy> proxy_; | 143 scoped_ptr<KeyboardControllerProxy> proxy_; |
149 scoped_ptr<aura::Window> container_; | 144 scoped_ptr<aura::Window> container_; |
150 // CallbackAnimationObserver should destructed before container_ because it | 145 // CallbackAnimationObserver should destructed before container_ because it |
151 // uses container_'s animator. | 146 // uses container_'s animator. |
152 scoped_ptr<CallbackAnimationObserver> animation_observer_; | 147 scoped_ptr<CallbackAnimationObserver> animation_observer_; |
153 | 148 |
154 scoped_ptr<WindowBoundsChangeObserver> window_bounds_observer_; | 149 // Tracks changes to the root window's size while the keyboard is displayed |
| 150 // (e.g. due to screen rotation). |
| 151 scoped_ptr<WindowBoundsChangeObserver> root_window_bounds_observer_; |
155 | 152 |
156 ui::InputMethod* input_method_; | 153 ui::InputMethod* input_method_; |
157 bool keyboard_visible_; | 154 bool keyboard_visible_; |
158 bool show_on_resize_; | 155 bool show_on_resize_; |
159 bool lock_keyboard_; | 156 bool lock_keyboard_; |
160 ui::TextInputType type_; | 157 ui::TextInputType type_; |
161 | 158 |
162 ObserverList<KeyboardControllerObserver> observer_list_; | 159 ObserverList<KeyboardControllerObserver> observer_list_; |
163 | 160 |
164 // The currently used keyboard position. | 161 // The currently used keyboard position. |
165 gfx::Rect current_keyboard_bounds_; | 162 gfx::Rect current_keyboard_bounds_; |
166 | 163 |
167 static KeyboardController* instance_; | 164 static KeyboardController* instance_; |
168 | 165 |
169 base::WeakPtrFactory<KeyboardController> weak_factory_; | 166 base::WeakPtrFactory<KeyboardController> weak_factory_; |
170 | 167 |
171 DISALLOW_COPY_AND_ASSIGN(KeyboardController); | 168 DISALLOW_COPY_AND_ASSIGN(KeyboardController); |
172 }; | 169 }; |
173 | 170 |
174 } // namespace keyboard | 171 } // namespace keyboard |
175 | 172 |
176 #endif // UI_KEYBOARD_KEYBOARD_CONTROLLER_H_ | 173 #endif // UI_KEYBOARD_KEYBOARD_CONTROLLER_H_ |
OLD | NEW |