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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_ASH_ASH_KEYBOARD_CONTROLLER_PROXY_H_
6 #define CHROME_BROWSER_UI_ASH_ASH_KEYBOARD_CONTROLLER_PROXY_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/extensions/extension_function_dispatcher.h"
11 #include "content/public/browser/web_contents_observer.h"
12 #include "ui/compositor/layer_animation_observer.h"
13 #include "ui/keyboard/keyboard_controller_proxy.h"
15 class ExtensionFunctionDispatcher
;
20 namespace extensions
{
21 class WindowController
;
30 // Subclass of KeyboardControllerProxy. It is used by KeyboardController to get
31 // access to the virtual keyboard window and setup Chrome extension functions.
32 class AshKeyboardControllerProxy
33 : public keyboard::KeyboardControllerProxy
,
34 public content::WebContentsObserver
,
35 public ExtensionFunctionDispatcher::Delegate
,
36 public ui::LayerAnimationObserver
{
38 AshKeyboardControllerProxy();
39 virtual ~AshKeyboardControllerProxy();
42 friend class AshKeyboardControllerProxyTest
;
44 void OnRequest(const ExtensionHostMsg_Request_Params
& params
);
46 // keyboard::KeyboardControllerProxy overrides
47 virtual content::BrowserContext
* GetBrowserContext() OVERRIDE
;
48 virtual ui::InputMethod
* GetInputMethod() OVERRIDE
;
49 virtual void RequestAudioInput(content::WebContents
* web_contents
,
50 const content::MediaStreamRequest
& request
,
51 const content::MediaResponseCallback
& callback
) OVERRIDE
;
52 virtual void SetupWebContents(content::WebContents
* contents
) OVERRIDE
;
53 virtual void ShowKeyboardContainer(aura::Window
* container
) OVERRIDE
;
54 virtual void HideKeyboardContainer(aura::Window
* container
) OVERRIDE
;
56 // The overridden implementation dispatches
57 // chrome.virtualKeyboardPrivate.onTextInputBoxFocused event to extension to
58 // provide the input type information. Naturally, when the virtual keyboard
59 // extension is used as an IME then chrome.input.ime.onFocus provides the
60 // information, but not when the virtual keyboard is used in conjunction with
61 // another IME. virtualKeyboardPrivate.onTextInputBoxFocused is the remedy in
63 virtual void SetUpdateInputType(ui::TextInputType type
) OVERRIDE
;
65 // ExtensionFunctionDispatcher::Delegate overrides
66 virtual extensions::WindowController
* GetExtensionWindowController() const
68 virtual content::WebContents
* GetAssociatedWebContents() const OVERRIDE
;
70 // content::WebContentsObserver overrides
71 virtual bool OnMessageReceived(const IPC::Message
& message
) OVERRIDE
;
73 // ui::LayerAnimationObserver overrides
74 virtual void OnLayerAnimationEnded(
75 ui::LayerAnimationSequence
* sequence
) OVERRIDE
;
76 virtual void OnLayerAnimationAborted(
77 ui::LayerAnimationSequence
* sequence
) OVERRIDE
;
78 virtual void OnLayerAnimationScheduled(
79 ui::LayerAnimationSequence
* sequence
) OVERRIDE
{}
81 scoped_ptr
<ExtensionFunctionDispatcher
> extension_function_dispatcher_
;
82 // The keyboard container window for animation.
83 aura::Window
* animation_window_
;
85 DISALLOW_COPY_AND_ASSIGN(AshKeyboardControllerProxy
);
88 #endif // CHROME_BROWSER_UI_ASH_ASH_KEYBOARD_CONTROLLER_PROXY_H_