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; |
30 class KeyboardControllerObserver; | 31 class KeyboardControllerObserver; |
31 class KeyboardControllerProxy; | 32 class KeyboardControllerProxy; |
32 | 33 |
33 // Provides control of the virtual keyboard, including providing a container | 34 // Provides control of the virtual keyboard, including providing a container |
34 // and controlling visibility. | 35 // and controlling visibility. |
35 class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver, | 36 class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver, |
36 public aura::WindowObserver { | 37 public aura::WindowObserver { |
37 public: | 38 public: |
38 // Different ways to hide the keyboard. | 39 // Different ways to hide the keyboard. |
39 enum HideReason { | 40 enum HideReason { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 92 |
92 // Returns true if keyboard is currently visible. | 93 // Returns true if keyboard is currently visible. |
93 bool keyboard_visible() { return keyboard_visible_; } | 94 bool keyboard_visible() { return keyboard_visible_; } |
94 | 95 |
95 // Returns the current keyboard bounds. When the keyboard is not shown, | 96 // Returns the current keyboard bounds. When the keyboard is not shown, |
96 // an empty rectangle will get returned. | 97 // an empty rectangle will get returned. |
97 const gfx::Rect& current_keyboard_bounds() { | 98 const gfx::Rect& current_keyboard_bounds() { |
98 return current_keyboard_bounds_; | 99 return current_keyboard_bounds_; |
99 } | 100 } |
100 | 101 |
| 102 // Updates insets on web content window |
| 103 void UpdateWindowInsets(aura::Window* window); |
| 104 |
101 private: | 105 private: |
102 // For access to Observer methods for simulation. | 106 // For access to Observer methods for simulation. |
103 friend class KeyboardControllerTest; | 107 friend class KeyboardControllerTest; |
104 | 108 |
105 // aura::WindowObserver overrides | 109 // aura::WindowObserver overrides |
106 virtual void OnWindowHierarchyChanged( | 110 virtual void OnWindowHierarchyChanged( |
107 const HierarchyChangeParams& params) OVERRIDE; | 111 const HierarchyChangeParams& params) OVERRIDE; |
108 | 112 |
109 // InputMethodObserver overrides | 113 // InputMethodObserver overrides |
110 virtual void OnTextInputTypeChanged( | 114 virtual void OnTextInputTypeChanged( |
(...skipping 15 matching lines...) Expand all Loading... |
126 void ResetWindowInsets(); | 130 void ResetWindowInsets(); |
127 | 131 |
128 // Returns true if keyboard is scheduled to hide. | 132 // Returns true if keyboard is scheduled to hide. |
129 bool WillHideKeyboard() const; | 133 bool WillHideKeyboard() const; |
130 | 134 |
131 // Called when show and hide animation finished successfully. If the animation | 135 // Called when show and hide animation finished successfully. If the animation |
132 // is aborted, it won't be called. | 136 // is aborted, it won't be called. |
133 void ShowAnimationFinished(); | 137 void ShowAnimationFinished(); |
134 void HideAnimationFinished(); | 138 void HideAnimationFinished(); |
135 | 139 |
| 140 // Adds or removes an observer for tracking changes to a window size or |
| 141 // position while the keyboard is displayed. Any window repositioning |
| 142 // invalidates insets for overscrolling. |
| 143 void AddBoundsChangedObserver(aura::Window* window); |
| 144 void RemoveBoundsChangedObserver(aura::Window* window); |
| 145 |
136 scoped_ptr<KeyboardControllerProxy> proxy_; | 146 scoped_ptr<KeyboardControllerProxy> proxy_; |
137 scoped_ptr<aura::Window> container_; | 147 scoped_ptr<aura::Window> container_; |
138 // CallbackAnimationObserver should destructed before container_ because it | 148 // CallbackAnimationObserver should destructed before container_ because it |
139 // uses container_'s animator. | 149 // uses container_'s animator. |
140 scoped_ptr<CallbackAnimationObserver> animation_observer_; | 150 scoped_ptr<CallbackAnimationObserver> animation_observer_; |
141 | 151 |
| 152 scoped_ptr<WindowBoundsChangeObserver> window_bounds_observer_; |
| 153 |
142 ui::InputMethod* input_method_; | 154 ui::InputMethod* input_method_; |
143 bool keyboard_visible_; | 155 bool keyboard_visible_; |
144 bool lock_keyboard_; | 156 bool lock_keyboard_; |
145 ui::TextInputType type_; | 157 ui::TextInputType type_; |
146 | 158 |
147 ObserverList<KeyboardControllerObserver> observer_list_; | 159 ObserverList<KeyboardControllerObserver> observer_list_; |
148 | 160 |
149 base::WeakPtrFactory<KeyboardController> weak_factory_; | 161 base::WeakPtrFactory<KeyboardController> weak_factory_; |
150 | 162 |
151 // The currently used keyboard position. | 163 // The currently used keyboard position. |
152 gfx::Rect current_keyboard_bounds_; | 164 gfx::Rect current_keyboard_bounds_; |
153 | 165 |
154 static KeyboardController* instance_; | 166 static KeyboardController* instance_; |
155 | 167 |
156 DISALLOW_COPY_AND_ASSIGN(KeyboardController); | 168 DISALLOW_COPY_AND_ASSIGN(KeyboardController); |
157 }; | 169 }; |
158 | 170 |
159 } // namespace keyboard | 171 } // namespace keyboard |
160 | 172 |
161 #endif // UI_KEYBOARD_KEYBOARD_CONTROLLER_H_ | 173 #endif // UI_KEYBOARD_KEYBOARD_CONTROLLER_H_ |
OLD | NEW |