- add sources.
[platform/framework/web/crosswalk.git] / src / ui / keyboard / 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 UI_KEYBOARD_KEYBOARD_CONTROLLER_PROXY_H_
6 #define UI_KEYBOARD_KEYBOARD_CONTROLLER_PROXY_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "content/public/common/media_stream_request.h"
10 #include "ui/base/ime/text_input_type.h"
11 #include "ui/keyboard/keyboard_export.h"
12
13 namespace aura {
14 class Window;
15 }
16 namespace content {
17 class BrowserContext;
18 class SiteInstance;
19 class WebContents;
20 }
21 namespace gfx {
22 class Rect;
23 }
24 namespace ui {
25 class InputMethod;
26 }
27
28 namespace keyboard {
29
30 // A proxy used by the KeyboardController to get access to the virtual
31 // keyboard window.
32 class KEYBOARD_EXPORT KeyboardControllerProxy {
33  public:
34   KeyboardControllerProxy();
35   virtual ~KeyboardControllerProxy();
36
37   // Gets the virtual keyboard window.  Ownership of the returned Window remains
38   // with the proxy.
39   virtual aura::Window* GetKeyboardWindow();
40
41   // Gets the InputMethod that will provide notifications about changes in the
42   // text input context.
43   virtual ui::InputMethod* GetInputMethod() = 0;
44
45   // Requests the audio input from microphone for speech input.
46   virtual void RequestAudioInput(content::WebContents* web_contents,
47       const content::MediaStreamRequest& request,
48       const content::MediaResponseCallback& callback) = 0;
49
50   // Shows the container window of the keyboard. The default implementation
51   // simply shows the container. An overridden implementation can set up
52   // necessary animation, or delay the visibility change as it desires.
53   virtual void ShowKeyboardContainer(aura::Window* container);
54
55   // Hides the container window of the keyboard. The default implementation
56   // simply hides the container. An overridden implementation can set up
57   // necesasry animation, or delay the visibility change as it desires.
58   virtual void HideKeyboardContainer(aura::Window* container);
59
60   // Updates the type of the focused text input box. The default implementation
61   // calls OnTextInputBoxFocused javascript function through webui to update the
62   // type the of focused input box.
63   virtual void SetUpdateInputType(ui::TextInputType type);
64
65  protected:
66   // Gets the BrowserContext to use for creating the WebContents hosting the
67   // keyboard.
68   virtual content::BrowserContext* GetBrowserContext() = 0;
69
70   // The implementation can choose to setup the WebContents before the virtual
71   // keyboard page is loaded (e.g. install a WebContentsObserver).
72   // SetupWebContents() is called right after creating the WebContents, before
73   // loading the keyboard page.
74   virtual void SetupWebContents(content::WebContents* contents);
75
76  private:
77   scoped_ptr<content::WebContents> keyboard_contents_;
78
79   DISALLOW_COPY_AND_ASSIGN(KeyboardControllerProxy);
80 };
81
82 }  // namespace keyboard
83
84 #endif  // UI_KEYBOARD_KEYBOARD_CONTROLLER_PROXY_H_