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/keyboard/keyboard_controller_proxy.h"
14 class ExtensionFunctionDispatcher;
19 namespace extensions {
20 class WindowController;
29 // Subclass of KeyboardControllerProxy. It is used by KeyboardController to get
30 // access to the virtual keyboard window and setup Chrome extension functions.
31 class AshKeyboardControllerProxy
32 : public keyboard::KeyboardControllerProxy,
33 public content::WebContentsObserver,
34 public ExtensionFunctionDispatcher::Delegate {
36 AshKeyboardControllerProxy();
37 virtual ~AshKeyboardControllerProxy();
40 friend class AshKeyboardControllerProxyTest;
42 void OnRequest(const ExtensionHostMsg_Request_Params& params);
44 // keyboard::KeyboardControllerProxy overrides
45 virtual content::BrowserContext* GetBrowserContext() OVERRIDE;
46 virtual ui::InputMethod* GetInputMethod() OVERRIDE;
47 virtual void RequestAudioInput(content::WebContents* web_contents,
48 const content::MediaStreamRequest& request,
49 const content::MediaResponseCallback& callback) OVERRIDE;
50 virtual void SetupWebContents(content::WebContents* contents) OVERRIDE;
51 virtual void ShowKeyboardContainer(aura::Window* container) OVERRIDE;
52 virtual void EnsureCaretInWorkArea() OVERRIDE;
54 // The overridden implementation dispatches
55 // chrome.virtualKeyboardPrivate.onTextInputBoxFocused event to extension to
56 // provide the input type information. Naturally, when the virtual keyboard
57 // extension is used as an IME then chrome.input.ime.onFocus provides the
58 // information, but not when the virtual keyboard is used in conjunction with
59 // another IME. virtualKeyboardPrivate.onTextInputBoxFocused is the remedy in
61 virtual void SetUpdateInputType(ui::TextInputType type) OVERRIDE;
63 // ExtensionFunctionDispatcher::Delegate overrides
64 virtual extensions::WindowController* GetExtensionWindowController() const
66 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE;
68 // content::WebContentsObserver overrides
69 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
71 scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_;
73 DISALLOW_COPY_AND_ASSIGN(AshKeyboardControllerProxy);
76 #endif // CHROME_BROWSER_UI_ASH_ASH_KEYBOARD_CONTROLLER_PROXY_H_