Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / ash / ash_keyboard_controller_proxy.h
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.
4
5 #ifndef CHROME_BROWSER_UI_ASH_ASH_KEYBOARD_CONTROLLER_PROXY_H_
6 #define CHROME_BROWSER_UI_ASH_ASH_KEYBOARD_CONTROLLER_PROXY_H_
7
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"
13
14 class ExtensionFunctionDispatcher;
15
16 namespace content {
17 class WebContents;
18 }
19 namespace extensions {
20 class WindowController;
21 }
22 namespace gfx {
23 class Rect;
24 }
25 namespace ui {
26 class InputMethod;
27 }
28
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 {
35  public:
36   AshKeyboardControllerProxy();
37   virtual ~AshKeyboardControllerProxy();
38
39  private:
40   friend class AshKeyboardControllerProxyTest;
41
42   void OnRequest(const ExtensionHostMsg_Request_Params& params);
43
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;
53
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
60   // that case.
61   virtual void SetUpdateInputType(ui::TextInputType type) OVERRIDE;
62
63   // ExtensionFunctionDispatcher::Delegate overrides
64   virtual extensions::WindowController* GetExtensionWindowController() const
65       OVERRIDE;
66   virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE;
67
68   // content::WebContentsObserver overrides
69   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
70
71   scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_;
72
73   DISALLOW_COPY_AND_ASSIGN(AshKeyboardControllerProxy);
74 };
75
76 #endif  // CHROME_BROWSER_UI_ASH_ASH_KEYBOARD_CONTROLLER_PROXY_H_