| 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 |
| 28 class KeyboardControllerObserver; |
| 25 class KeyboardControllerProxy; | 29 class KeyboardControllerProxy; |
| 26 class KeyboardLayoutManager; | 30 class KeyboardLayoutManager; |
| 27 | 31 |
| 28 // Provides control of the virtual keyboard, including providing a container | 32 // Provides control of the virtual keyboard, including providing a container |
| 29 // and controlling visibility. | 33 // and controlling visibility. |
| 30 class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver, | 34 class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver, |
| 31 public aura::WindowObserver { | 35 public aura::WindowObserver { |
| 32 public: | 36 public: |
| 33 // Takes ownership of |proxy|. | 37 // Takes ownership of |proxy|. |
| 34 explicit KeyboardController(KeyboardControllerProxy* proxy); | 38 explicit KeyboardController(KeyboardControllerProxy* proxy); |
| 35 virtual ~KeyboardController(); | 39 virtual ~KeyboardController(); |
| 36 | 40 |
| 37 // Returns the container for the keyboard, which is then owned by the caller. | 41 // 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. | 42 // It is the responsibility of the caller to Show() the returned window. |
| 39 aura::Window* GetContainerWindow(); | 43 aura::Window* GetContainerWindow(); |
| 40 | 44 |
| 45 // Management of the observer list. |
| 46 virtual void AddObserver(KeyboardControllerObserver* observer); |
| 47 virtual void RemoveObserver(KeyboardControllerObserver* observer); |
| 48 |
| 41 private: | 49 private: |
| 42 // For access to Observer methods for simulation. | 50 // For access to Observer methods for simulation. |
| 43 friend class KeyboardControllerTest; | 51 friend class KeyboardControllerTest; |
| 44 | 52 |
| 45 // aura::WindowObserver overrides | 53 // aura::WindowObserver overrides |
| 46 virtual void OnWindowParentChanged(aura::Window* window, | 54 virtual void OnWindowParentChanged(aura::Window* window, |
| 47 aura::Window* parent) OVERRIDE; | 55 aura::Window* parent) OVERRIDE; |
| 48 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 56 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
| 49 | 57 |
| 50 // InputMethodObserver overrides | 58 // InputMethodObserver overrides |
| 51 virtual void OnTextInputStateChanged( | 59 virtual void OnTextInputStateChanged( |
| 52 const ui::TextInputClient* client) OVERRIDE; | 60 const ui::TextInputClient* client) OVERRIDE; |
| 53 virtual void OnInputMethodDestroyed( | 61 virtual void OnInputMethodDestroyed( |
| 54 const ui::InputMethod* input_method) OVERRIDE; | 62 const ui::InputMethod* input_method) OVERRIDE; |
| 55 | 63 |
| 56 scoped_ptr<KeyboardControllerProxy> proxy_; | 64 scoped_ptr<KeyboardControllerProxy> proxy_; |
| 57 aura::Window* container_; | 65 aura::Window* container_; |
| 58 ui::InputMethod* input_method_; | 66 ui::InputMethod* input_method_; |
| 59 | 67 |
| 68 ObserverList<KeyboardControllerObserver> observer_list_; |
| 69 |
| 60 DISALLOW_COPY_AND_ASSIGN(KeyboardController); | 70 DISALLOW_COPY_AND_ASSIGN(KeyboardController); |
| 61 }; | 71 }; |
| 62 | 72 |
| 63 } // namespace keyboard | 73 } // namespace keyboard |
| 64 | 74 |
| 65 #endif // UI_KEYBOARD_KEYBOARD_CONTROLLER_H_ | 75 #endif // UI_KEYBOARD_KEYBOARD_CONTROLLER_H_ |
| OLD | NEW |