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