OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_UI_TOUCH_KEYBOARD_KEYBOARD_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_UI_TOUCH_KEYBOARD_KEYBOARD_MANAGER_H_ |
6 #define CHROME_BROWSER_UI_TOUCH_KEYBOARD_KEYBOARD_MANAGER_H_ | 6 #define CHROME_BROWSER_UI_TOUCH_KEYBOARD_KEYBOARD_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 10 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
11 #include "chrome/browser/tabs/tab_strip_model_observer.h" | |
12 #include "chrome/browser/ui/browser_list.h" | |
13 #include "content/browser/tab_contents/tab_contents_observer.h" | 11 #include "content/browser/tab_contents/tab_contents_observer.h" |
14 #include "content/common/notification_observer.h" | 12 #include "content/common/notification_observer.h" |
15 #include "ui/base/animation/animation_delegate.h" | 13 #include "ui/base/animation/animation_delegate.h" |
| 14 #include "views/ime/text_input_type_tracker.h" |
16 #include "views/widget/widget.h" | 15 #include "views/widget/widget.h" |
17 | 16 |
18 #if defined(OS_CHROMEOS) | 17 #if defined(OS_CHROMEOS) |
19 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 18 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
20 #endif | 19 #endif |
21 | 20 |
22 namespace IPC { | 21 namespace IPC { |
23 class Message; | 22 class Message; |
24 } | 23 } |
25 | 24 |
26 namespace ui { | 25 namespace ui { |
27 class InterpolatedTransform; | 26 class InterpolatedTransform; |
28 class SlideAnimation; | 27 class SlideAnimation; |
29 } | 28 } |
30 | 29 |
31 namespace views { | 30 namespace views { |
32 class KeyEvent; | 31 class KeyEvent; |
33 } | 32 } |
34 | 33 |
35 class DOMView; | 34 class DOMView; |
36 class ExtensionHostMsg_Request_Params; | 35 class ExtensionHostMsg_Request_Params; |
37 | 36 |
38 // A singleton object to manage the virtual keyboard. | 37 // A singleton object to manage the virtual keyboard. |
39 class KeyboardManager | 38 class KeyboardManager |
40 : public views::Widget, | 39 : public views::Widget, |
41 public ui::AnimationDelegate, | 40 public ui::AnimationDelegate, |
42 public BrowserList::Observer, | |
43 public TabContentsObserver, | 41 public TabContentsObserver, |
44 public TabStripModelObserver, | |
45 public ExtensionFunctionDispatcher::Delegate, | 42 public ExtensionFunctionDispatcher::Delegate, |
46 #if defined(OS_CHROMEOS) | 43 #if defined(OS_CHROMEOS) |
47 public chromeos::input_method::InputMethodManager::VirtualKeyboardObserver
, | 44 public chromeos::input_method::InputMethodManager::VirtualKeyboardObserver
, |
48 #endif | 45 #endif |
49 public NotificationObserver, | 46 public NotificationObserver, |
50 public views::Widget::Observer { | 47 public views::Widget::Observer, |
| 48 public views::TextInputTypeObserver { |
51 public: | 49 public: |
52 // Returns the singleton object. | 50 // Returns the singleton object. |
53 static KeyboardManager* GetInstance(); | 51 static KeyboardManager* GetInstance(); |
54 | 52 |
55 // Show the keyboard for the target widget. The events from the keyboard will | 53 // Show the keyboard for the target widget. The events from the keyboard will |
56 // be sent to |widget|. | 54 // be sent to |widget|. |
57 // TODO(sad): Allow specifying the type of keyboard to show. | 55 // TODO(sad): Allow specifying the type of keyboard to show. |
58 void ShowKeyboardForWidget(views::Widget* widget); | 56 void ShowKeyboardForWidget(views::Widget* widget); |
59 | 57 |
60 // Overridden from views::Widget | 58 // Overridden from views::Widget |
61 void Hide() OVERRIDE; | 59 void Hide() OVERRIDE; |
62 | 60 |
63 private: | 61 private: |
64 // Requirement for Singleton | 62 // Requirement for Singleton |
65 friend struct DefaultSingletonTraits<KeyboardManager>; | 63 friend struct DefaultSingletonTraits<KeyboardManager>; |
66 | 64 |
67 KeyboardManager(); | 65 KeyboardManager(); |
68 virtual ~KeyboardManager(); | 66 virtual ~KeyboardManager(); |
69 | 67 |
70 // Sets the target widget, adds/removes Widget::Observer, reparents etc. | 68 // Sets the target widget, adds/removes Widget::Observer, reparents etc. |
71 void SetTarget(Widget* target); | 69 void SetTarget(Widget* target); |
72 | 70 |
73 // Overridden from views::Widget. | 71 // Overridden from views::Widget. |
74 virtual bool OnKeyEvent(const views::KeyEvent& event) OVERRIDE; | 72 virtual bool OnKeyEvent(const views::KeyEvent& event) OVERRIDE; |
75 | 73 |
76 // Overridden from ui::AnimationDelegate. | 74 // Overridden from ui::AnimationDelegate. |
77 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 75 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
78 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 76 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; |
79 | 77 |
80 // Overridden from BrowserList::Observer. | |
81 virtual void OnBrowserAdded(const Browser* browser) OVERRIDE; | |
82 virtual void OnBrowserRemoved(const Browser* browser) OVERRIDE; | |
83 | |
84 // Overridden from TabContentsObserver. | 78 // Overridden from TabContentsObserver. |
85 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 79 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
86 void OnRequest(const ExtensionHostMsg_Request_Params& params); | 80 void OnRequest(const ExtensionHostMsg_Request_Params& params); |
87 | 81 |
88 // Overridden from TabStripModelObserver. | 82 // Overridden from TextInputTypeObserver. |
89 virtual void ActiveTabChanged(TabContentsWrapper* old_contents, | 83 virtual void TextInputTypeChanged(ui::TextInputType type, |
90 TabContentsWrapper* new_contents, | 84 views::Widget *widget) OVERRIDE; |
91 int index, | |
92 bool user_gesture); | |
93 | 85 |
94 // Overridden from ExtensionFunctionDispatcher::Delegate. | 86 // Overridden from ExtensionFunctionDispatcher::Delegate. |
95 virtual Browser* GetBrowser() OVERRIDE; | 87 virtual Browser* GetBrowser() OVERRIDE; |
96 virtual gfx::NativeView GetNativeViewOfHost() OVERRIDE; | 88 virtual gfx::NativeView GetNativeViewOfHost() OVERRIDE; |
97 virtual TabContents* GetAssociatedTabContents() const OVERRIDE; | 89 virtual TabContents* GetAssociatedTabContents() const OVERRIDE; |
98 | 90 |
99 #if defined(OS_CHROMEOS) | 91 #if defined(OS_CHROMEOS) |
100 // Overridden from input_method::InputMethodManager::VirtualKeyboardObserver. | 92 // Overridden from input_method::InputMethodManager::VirtualKeyboardObserver. |
101 virtual void VirtualKeyboardChanged( | 93 virtual void VirtualKeyboardChanged( |
102 chromeos::input_method::InputMethodManager* manager, | 94 chromeos::input_method::InputMethodManager* manager, |
(...skipping 27 matching lines...) Expand all Loading... |
130 | 122 |
131 // Height of the keyboard. | 123 // Height of the keyboard. |
132 int keyboard_height_; | 124 int keyboard_height_; |
133 | 125 |
134 NotificationRegistrar registrar_; | 126 NotificationRegistrar registrar_; |
135 | 127 |
136 DISALLOW_COPY_AND_ASSIGN(KeyboardManager); | 128 DISALLOW_COPY_AND_ASSIGN(KeyboardManager); |
137 }; | 129 }; |
138 | 130 |
139 #endif // CHROME_BROWSER_UI_TOUCH_KEYBOARD_KEYBOARD_MANAGER_H_ | 131 #endif // CHROME_BROWSER_UI_TOUCH_KEYBOARD_KEYBOARD_MANAGER_H_ |
OLD | NEW |