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" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 // Provides control of the virtual keyboard, including providing a container | 33 // Provides control of the virtual keyboard, including providing a container |
34 // and controlling visibility. | 34 // and controlling visibility. |
35 class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver, | 35 class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver, |
36 public aura::WindowObserver { | 36 public aura::WindowObserver { |
37 public: | 37 public: |
38 // Takes ownership of |proxy|. | 38 // Takes ownership of |proxy|. |
39 explicit KeyboardController(KeyboardControllerProxy* proxy); | 39 explicit KeyboardController(KeyboardControllerProxy* proxy); |
40 virtual ~KeyboardController(); | 40 virtual ~KeyboardController(); |
41 | 41 |
42 // Returns the container for the keyboard, which is then owned by the caller. | 42 // Returns the container for the keyboard, which is owned by |
43 // It is the responsibility of the caller to Show() the returned window. | 43 // KeyboardController. |
44 aura::Window* GetContainerWindow(); | 44 aura::Window* GetContainerWindow(); |
45 | 45 |
46 // Hides virtual keyboard and notifies observer bounds change. | 46 // Hides virtual keyboard and notifies observer bounds change. |
47 // This function should be called with a delay to avoid layout flicker | 47 // This function should be called with a delay to avoid layout flicker |
48 // when the focus of input field quickly change. | 48 // when the focus of input field quickly change. |
49 void HideKeyboard(); | 49 void HideKeyboard(); |
50 | 50 |
51 // Management of the observer list. | 51 // Management of the observer list. |
52 virtual void AddObserver(KeyboardControllerObserver* observer); | 52 virtual void AddObserver(KeyboardControllerObserver* observer); |
53 virtual void RemoveObserver(KeyboardControllerObserver* observer); | 53 virtual void RemoveObserver(KeyboardControllerObserver* observer); |
54 | 54 |
55 private: | 55 private: |
56 // For access to Observer methods for simulation. | 56 // For access to Observer methods for simulation. |
57 friend class KeyboardControllerTest; | 57 friend class KeyboardControllerTest; |
58 | 58 |
59 // aura::WindowObserver overrides | 59 // aura::WindowObserver overrides |
60 virtual void OnWindowHierarchyChanged( | 60 virtual void OnWindowHierarchyChanged( |
61 const HierarchyChangeParams& params) OVERRIDE; | 61 const HierarchyChangeParams& params) OVERRIDE; |
62 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | |
63 | 62 |
64 // InputMethodObserver overrides | 63 // InputMethodObserver overrides |
65 virtual void OnTextInputTypeChanged( | 64 virtual void OnTextInputTypeChanged( |
66 const ui::TextInputClient* client) OVERRIDE {} | 65 const ui::TextInputClient* client) OVERRIDE {} |
67 virtual void OnFocus() OVERRIDE {} | 66 virtual void OnFocus() OVERRIDE {} |
68 virtual void OnBlur() OVERRIDE {} | 67 virtual void OnBlur() OVERRIDE {} |
69 virtual void OnUntranslatedIMEMessage( | 68 virtual void OnUntranslatedIMEMessage( |
70 const base::NativeEvent& event) OVERRIDE {} | 69 const base::NativeEvent& event) OVERRIDE {} |
71 virtual void OnCaretBoundsChanged( | 70 virtual void OnCaretBoundsChanged( |
72 const ui::TextInputClient* client) OVERRIDE {} | 71 const ui::TextInputClient* client) OVERRIDE {} |
73 virtual void OnInputLocaleChanged() OVERRIDE {} | 72 virtual void OnInputLocaleChanged() OVERRIDE {} |
74 virtual void OnTextInputStateChanged( | 73 virtual void OnTextInputStateChanged( |
75 const ui::TextInputClient* client) OVERRIDE; | 74 const ui::TextInputClient* client) OVERRIDE; |
76 virtual void OnInputMethodDestroyed( | 75 virtual void OnInputMethodDestroyed( |
77 const ui::InputMethod* input_method) OVERRIDE; | 76 const ui::InputMethod* input_method) OVERRIDE; |
78 | 77 |
79 // Returns true if keyboard is scheduled to hide. | 78 // Returns true if keyboard is scheduled to hide. |
80 bool WillHideKeyboard() const; | 79 bool WillHideKeyboard() const; |
81 | 80 |
82 scoped_ptr<KeyboardControllerProxy> proxy_; | 81 scoped_ptr<KeyboardControllerProxy> proxy_; |
83 aura::Window* container_; | 82 scoped_ptr<aura::Window> container_; |
84 ui::InputMethod* input_method_; | 83 ui::InputMethod* input_method_; |
85 bool keyboard_visible_; | 84 bool keyboard_visible_; |
86 base::WeakPtrFactory<KeyboardController> weak_factory_; | 85 base::WeakPtrFactory<KeyboardController> weak_factory_; |
87 | 86 |
88 ObserverList<KeyboardControllerObserver> observer_list_; | 87 ObserverList<KeyboardControllerObserver> observer_list_; |
89 | 88 |
90 DISALLOW_COPY_AND_ASSIGN(KeyboardController); | 89 DISALLOW_COPY_AND_ASSIGN(KeyboardController); |
91 }; | 90 }; |
92 | 91 |
93 } // namespace keyboard | 92 } // namespace keyboard |
94 | 93 |
95 #endif // UI_KEYBOARD_KEYBOARD_CONTROLLER_H_ | 94 #endif // UI_KEYBOARD_KEYBOARD_CONTROLLER_H_ |
OLD | NEW |