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 |
| 46 public views::TextInputTypeObserver, |
49 public NotificationObserver { | 47 public NotificationObserver { |
50 public: | 48 public: |
51 // Returns the singleton object. | 49 // Returns the singleton object. |
52 static KeyboardManager* GetInstance(); | 50 static KeyboardManager* GetInstance(); |
53 | 51 |
54 // Show the keyboard for the target widget. The events from the keyboard will | 52 // Show the keyboard for the target widget. The events from the keyboard will |
55 // be sent to |widget|. | 53 // be sent to |widget|. |
56 // TODO(sad): Allow specifying the type of keyboard to show. | 54 // TODO(sad): Allow specifying the type of keyboard to show. |
57 void ShowKeyboardForWidget(views::Widget* widget); | 55 void ShowKeyboardForWidget(views::Widget* widget); |
58 | 56 |
59 // Overridden from views::Widget | 57 // Overridden from views::Widget |
60 void Hide() OVERRIDE; | 58 void Hide() OVERRIDE; |
61 | 59 |
62 private: | 60 private: |
63 // Requirement for Singleton | 61 // Requirement for Singleton |
64 friend struct DefaultSingletonTraits<KeyboardManager>; | 62 friend struct DefaultSingletonTraits<KeyboardManager>; |
65 | 63 |
66 KeyboardManager(); | 64 KeyboardManager(); |
67 virtual ~KeyboardManager(); | 65 virtual ~KeyboardManager(); |
68 | 66 |
69 // Overridden from views::Widget. | 67 // Overridden from views::Widget. |
70 virtual bool OnKeyEvent(const views::KeyEvent& event) OVERRIDE; | 68 virtual bool OnKeyEvent(const views::KeyEvent& event) OVERRIDE; |
71 | 69 |
72 // Overridden from ui::AnimationDelegate: | 70 // Overridden from ui::AnimationDelegate: |
73 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 71 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
74 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 72 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; |
75 | 73 |
76 // Overridden from BrowserList::Observer. | |
77 virtual void OnBrowserAdded(const Browser* browser) OVERRIDE; | |
78 virtual void OnBrowserRemoved(const Browser* browser) OVERRIDE; | |
79 | |
80 // Overridden from TabContentsObserver | 74 // Overridden from TabContentsObserver |
81 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 75 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
82 void OnRequest(const ExtensionHostMsg_Request_Params& params); | 76 void OnRequest(const ExtensionHostMsg_Request_Params& params); |
83 | 77 |
84 // Overridden from TabStripModelObserver. | 78 // Overridden from TextInputTypeObserver. |
85 virtual void ActiveTabChanged(TabContentsWrapper* old_contents, | 79 virtual void TextInputTypeChanged(ui::TextInputType type, |
86 TabContentsWrapper* new_contents, | 80 views::Widget *widget) OVERRIDE; |
87 int index, | |
88 bool user_gesture); | |
89 | 81 |
90 // ExtensionFunctionDispatcher::Delegate implementation | 82 // ExtensionFunctionDispatcher::Delegate implementation |
91 virtual Browser* GetBrowser() OVERRIDE; | 83 virtual Browser* GetBrowser() OVERRIDE; |
92 virtual gfx::NativeView GetNativeViewOfHost() OVERRIDE; | 84 virtual gfx::NativeView GetNativeViewOfHost() OVERRIDE; |
93 virtual TabContents* GetAssociatedTabContents() const OVERRIDE; | 85 virtual TabContents* GetAssociatedTabContents() const OVERRIDE; |
94 | 86 |
95 #if defined(OS_CHROMEOS) | 87 #if defined(OS_CHROMEOS) |
96 // input_method::InputMethodManager::VirtualKeyboardObserver implementation. | 88 // input_method::InputMethodManager::VirtualKeyboardObserver implementation. |
97 virtual void VirtualKeyboardChanged( | 89 virtual void VirtualKeyboardChanged( |
98 chromeos::input_method::InputMethodManager* manager, | 90 chromeos::input_method::InputMethodManager* manager, |
(...skipping 22 matching lines...) Expand all Loading... |
121 | 113 |
122 // Height of the keyboard. | 114 // Height of the keyboard. |
123 int keyboard_height_; | 115 int keyboard_height_; |
124 | 116 |
125 NotificationRegistrar registrar_; | 117 NotificationRegistrar registrar_; |
126 | 118 |
127 DISALLOW_COPY_AND_ASSIGN(KeyboardManager); | 119 DISALLOW_COPY_AND_ASSIGN(KeyboardManager); |
128 }; | 120 }; |
129 | 121 |
130 #endif // CHROME_BROWSER_UI_TOUCH_KEYBOARD_KEYBOARD_MANAGER_H_ | 122 #endif // CHROME_BROWSER_UI_TOUCH_KEYBOARD_KEYBOARD_MANAGER_H_ |
OLD | NEW |