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