NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / ui / keyboard / keyboard_controller_proxy.h
blobd8b7f3d389b681a6d7ce4755ee92dcfe0643e78c
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 UI_KEYBOARD_KEYBOARD_CONTROLLER_PROXY_H_
6 #define UI_KEYBOARD_KEYBOARD_CONTROLLER_PROXY_H_
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"
13 namespace aura {
14 class Window;
16 namespace content {
17 class BrowserContext;
18 class SiteInstance;
19 class WebContents;
21 namespace gfx {
22 class Rect;
24 namespace ui {
25 class InputMethod;
28 namespace keyboard {
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();
37 // Gets the virtual keyboard window. Ownership of the returned Window remains
38 // with the proxy.
39 virtual aura::Window* GetKeyboardWindow();
41 // Sets the override content url.
42 void SetOverrideContentUrl(const GURL& url);
44 // Whether the keyboard window is resizing from its web contents.
45 bool resizing_from_contents() const { return resizing_from_contents_; }
47 // Whether the keyboard window is created. The keyboard window is tied to a
48 // WebContent so we can just check if the WebContent is created or not.
49 virtual bool HasKeyboardWindow() const;
51 // Sets the flag of whether the keyboard window is resizing from
52 // its web contents.
53 void set_resizing_from_contents(bool resizing) {
54 resizing_from_contents_ = resizing;
57 // Gets the InputMethod that will provide notifications about changes in the
58 // text input context.
59 virtual ui::InputMethod* GetInputMethod() = 0;
61 // Requests the audio input from microphone for speech input.
62 virtual void RequestAudioInput(content::WebContents* web_contents,
63 const content::MediaStreamRequest& request,
64 const content::MediaResponseCallback& callback) = 0;
66 // Shows the container window of the keyboard. The default implementation
67 // simply shows the container. An overridden implementation can set up
68 // necessary animation, or delay the visibility change as it desires.
69 virtual void ShowKeyboardContainer(aura::Window* container);
71 // Hides the container window of the keyboard. The default implementation
72 // simply hides the container. An overridden implementation can set up
73 // necesasry animation, or delay the visibility change as it desires.
74 virtual void HideKeyboardContainer(aura::Window* container);
76 // Updates the type of the focused text input box. The default implementation
77 // calls OnTextInputBoxFocused javascript function through webui to update the
78 // type the of focused input box.
79 virtual void SetUpdateInputType(ui::TextInputType type);
81 // Ensures caret in current work area (not occluded by virtual keyboard
82 // window).
83 virtual void EnsureCaretInWorkArea();
85 protected:
86 // Gets the BrowserContext to use for creating the WebContents hosting the
87 // keyboard.
88 virtual content::BrowserContext* GetBrowserContext() = 0;
90 // The implementation can choose to setup the WebContents before the virtual
91 // keyboard page is loaded (e.g. install a WebContentsObserver).
92 // SetupWebContents() is called right after creating the WebContents, before
93 // loading the keyboard page.
94 virtual void SetupWebContents(content::WebContents* contents);
96 private:
97 // Reloads the web contents to the valid url from GetValidUrl().
98 void ReloadContents();
100 // Gets the valid url from default url or override url.
101 const GURL& GetValidUrl();
103 const GURL default_url_;
104 GURL override_url_;
106 scoped_ptr<content::WebContents> keyboard_contents_;
108 // Whether the current keyboard window is resizing from its web content.
109 bool resizing_from_contents_;
111 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerProxy);
114 } // namespace keyboard
116 #endif // UI_KEYBOARD_KEYBOARD_CONTROLLER_PROXY_H_