Chromium Code Reviews| 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 "ui/aura/window_observer.h" | 11 #include "ui/aura/window_observer.h" |
| 11 #include "ui/base/ime/input_method_observer.h" | 12 #include "ui/base/ime/input_method_observer.h" |
| 12 #include "ui/keyboard/keyboard_export.h" | 13 #include "ui/keyboard/keyboard_export.h" |
| 13 | 14 |
| 14 namespace aura { | 15 namespace aura { |
| 15 class Window; | 16 class Window; |
| 16 } | 17 } |
| 17 | 18 namespace gfx { |
| 19 class Rect; | |
| 20 } | |
| 18 namespace ui { | 21 namespace ui { |
| 19 class InputMethod; | 22 class InputMethod; |
| 20 class TextInputClient; | 23 class TextInputClient; |
| 21 } | 24 } |
| 22 | 25 |
| 23 namespace keyboard { | 26 namespace keyboard { |
| 24 | 27 |
| 25 class KeyboardControllerProxy; | 28 class KeyboardControllerProxy; |
| 26 class KeyboardLayoutManager; | 29 class KeyboardLayoutManager; |
| 27 | 30 |
| 28 // Provides control of the virtual keyboard, including providing a container | 31 // Provides control of the virtual keyboard, including providing a container |
| 29 // and controlling visibility. | 32 // and controlling visibility. |
| 30 class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver, | 33 class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver, |
| 31 public aura::WindowObserver { | 34 public aura::WindowObserver { |
| 32 public: | 35 public: |
| 36 class Observer { | |
|
Ben Goodger (Google)
2013/04/29 16:16:38
avoid nested classes, they can't be forward-declar
bryeung
2013/04/29 18:31:43
Got it. Fixed.
| |
| 37 public: | |
| 38 // Called when the keyboard bounds or visibility are about to change. | |
| 39 virtual void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) = 0; | |
| 40 }; | |
| 41 | |
| 33 // Takes ownership of |proxy|. | 42 // Takes ownership of |proxy|. |
| 34 explicit KeyboardController(KeyboardControllerProxy* proxy); | 43 explicit KeyboardController(KeyboardControllerProxy* proxy); |
| 35 virtual ~KeyboardController(); | 44 virtual ~KeyboardController(); |
| 36 | 45 |
| 37 // Returns the container for the keyboard, which is then owned by the caller. | 46 // Returns the container for the keyboard, which is then owned by the caller. |
| 38 // It is the responsibility of the caller to Show() the returned window. | 47 // It is the responsibility of the caller to Show() the returned window. |
| 39 aura::Window* GetContainerWindow(); | 48 aura::Window* GetContainerWindow(); |
| 40 | 49 |
| 50 // Management of the observer list. | |
| 51 virtual void AddObserver(Observer* observer); | |
| 52 virtual void RemoveObserver(Observer* observer); | |
| 53 | |
| 41 private: | 54 private: |
| 42 // For access to Observer methods for simulation. | 55 // For access to Observer methods for simulation. |
| 43 friend class KeyboardControllerTest; | 56 friend class KeyboardControllerTest; |
| 44 | 57 |
| 45 // aura::WindowObserver overrides | 58 // aura::WindowObserver overrides |
| 46 virtual void OnWindowParentChanged(aura::Window* window, | 59 virtual void OnWindowParentChanged(aura::Window* window, |
| 47 aura::Window* parent) OVERRIDE; | 60 aura::Window* parent) OVERRIDE; |
| 48 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 61 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
| 49 | 62 |
| 50 // InputMethodObserver overrides | 63 // InputMethodObserver overrides |
| 51 virtual void OnTextInputStateChanged( | 64 virtual void OnTextInputStateChanged( |
| 52 const ui::TextInputClient* client) OVERRIDE; | 65 const ui::TextInputClient* client) OVERRIDE; |
| 53 virtual void OnInputMethodDestroyed( | 66 virtual void OnInputMethodDestroyed( |
| 54 const ui::InputMethod* input_method) OVERRIDE; | 67 const ui::InputMethod* input_method) OVERRIDE; |
| 55 | 68 |
| 56 scoped_ptr<KeyboardControllerProxy> proxy_; | 69 scoped_ptr<KeyboardControllerProxy> proxy_; |
| 57 aura::Window* container_; | 70 aura::Window* container_; |
| 58 ui::InputMethod* input_method_; | 71 ui::InputMethod* input_method_; |
| 59 | 72 |
| 73 ObserverList<Observer> observer_list_; | |
| 74 | |
| 60 DISALLOW_COPY_AND_ASSIGN(KeyboardController); | 75 DISALLOW_COPY_AND_ASSIGN(KeyboardController); |
| 61 }; | 76 }; |
| 62 | 77 |
| 63 } // namespace keyboard | 78 } // namespace keyboard |
| 64 | 79 |
| 65 #endif // UI_KEYBOARD_KEYBOARD_CONTROLLER_H_ | 80 #endif // UI_KEYBOARD_KEYBOARD_CONTROLLER_H_ |
| OLD | NEW |