OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_TOUCH_KEYBOARD_KEYBOARD_MANAGER_H_ |
| 6 #define CHROME_BROWSER_UI_TOUCH_KEYBOARD_KEYBOARD_MANAGER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/memory/singleton.h" |
| 10 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 11 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 12 #include "ui/base/animation/animation_delegate.h" |
| 13 #include "views/widget/widget.h" |
| 14 |
| 15 namespace IPC { |
| 16 class Message; |
| 17 } |
| 18 |
| 19 namespace ui { |
| 20 class InterpolatedTransform; |
| 21 class SlideAnimation; |
| 22 } |
| 23 |
| 24 namespace views { |
| 25 class KeyEvent; |
| 26 } |
| 27 |
| 28 class DOMView; |
| 29 class ExtensionHostMsg_Request_Params; |
| 30 |
| 31 // A singleton object to manage the virtual keyboard. |
| 32 class KeyboardManager : public views::Widget, |
| 33 public ui::AnimationDelegate, |
| 34 public TabContentsObserver, |
| 35 public ExtensionFunctionDispatcher::Delegate { |
| 36 public: |
| 37 // Returns the singleton object. |
| 38 static KeyboardManager* GetInstance(); |
| 39 |
| 40 // Show the keyboard for the target widget. The events from the keyboard will |
| 41 // be sent to |widget|. |
| 42 void ShowKeyboardForWidget(views::Widget* widget); |
| 43 |
| 44 // Overridden from views::Widget |
| 45 void Hide() OVERRIDE; |
| 46 |
| 47 private: |
| 48 // Requirement for Singleton |
| 49 friend struct DefaultSingletonTraits<KeyboardManager>; |
| 50 |
| 51 KeyboardManager(); |
| 52 virtual ~KeyboardManager(); |
| 53 |
| 54 // Overridden from views::Widget. |
| 55 virtual bool OnKeyEvent(const views::KeyEvent& event) OVERRIDE; |
| 56 |
| 57 // Overridden from ui::AnimationDelegate: |
| 58 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
| 59 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; |
| 60 |
| 61 // Overridden from TabContentsObserver |
| 62 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 63 void OnRequest(const ExtensionHostMsg_Request_Params& params); |
| 64 |
| 65 // ExtensionFunctionDispatcher::Delegate implementation |
| 66 virtual Browser* GetBrowser() OVERRIDE; |
| 67 virtual gfx::NativeView GetNativeViewOfHost() OVERRIDE; |
| 68 virtual TabContents* GetAssociatedTabContents() const OVERRIDE; |
| 69 |
| 70 // The animation. |
| 71 scoped_ptr<ui::SlideAnimation> animation_; |
| 72 |
| 73 // Interpolated transform used during animation. |
| 74 scoped_ptr<ui::InterpolatedTransform> transform_; |
| 75 |
| 76 DOMView* dom_view_; |
| 77 ExtensionFunctionDispatcher extension_dispatcher_; |
| 78 |
| 79 // The widget the events from the keyboard should be directed to. |
| 80 views::Widget* target_; |
| 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(KeyboardManager); |
| 83 }; |
| 84 |
| 85 #endif // CHROME_BROWSER_UI_TOUCH_KEYBOARD_KEYBOARD_MANAGER_H_ |
OLD | NEW |