Disable accessible touch exploration by default.
[chromium-blink-merge.git] / ui / keyboard / keyboard_controller_proxy.h
blobd7886e2d91a6f532adb22eb100dfd26444baea5b
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/aura/window_observer.h"
11 #include "ui/base/ime/text_input_type.h"
12 #include "ui/keyboard/keyboard_export.h"
14 namespace aura {
15 class Window;
17 namespace content {
18 class BrowserContext;
19 class SiteInstance;
20 class WebContents;
22 namespace gfx {
23 class Rect;
25 namespace ui {
26 class InputMethod;
28 namespace wm {
29 class Shadow;
32 namespace keyboard {
34 // A proxy used by the KeyboardController to get access to the virtual
35 // keyboard window.
36 class KEYBOARD_EXPORT KeyboardControllerProxy : public aura::WindowObserver {
37 public:
38 class TestApi {
39 public:
40 explicit TestApi(KeyboardControllerProxy* proxy) : proxy_(proxy) {}
42 const content::WebContents* keyboard_contents() {
43 return proxy_->keyboard_contents_.get();
46 private:
47 KeyboardControllerProxy* proxy_;
49 DISALLOW_COPY_AND_ASSIGN(TestApi);
52 KeyboardControllerProxy();
53 virtual ~KeyboardControllerProxy();
55 // Gets the virtual keyboard window. Ownership of the returned Window remains
56 // with the proxy.
57 virtual aura::Window* GetKeyboardWindow();
59 // Whether the keyboard window is created. The keyboard window is tied to a
60 // WebContent so we can just check if the WebContent is created or not.
61 virtual bool HasKeyboardWindow() const;
63 // Gets the InputMethod that will provide notifications about changes in the
64 // text input context.
65 virtual ui::InputMethod* GetInputMethod() = 0;
67 // Requests the audio input from microphone for speech input.
68 virtual void RequestAudioInput(content::WebContents* web_contents,
69 const content::MediaStreamRequest& request,
70 const content::MediaResponseCallback& callback) = 0;
72 // Shows the container window of the keyboard. The default implementation
73 // simply shows the container. An overridden implementation can set up
74 // necessary animation, or delay the visibility change as it desires.
75 virtual void ShowKeyboardContainer(aura::Window* container);
77 // Hides the container window of the keyboard. The default implementation
78 // simply hides the container. An overridden implementation can set up
79 // necesasry animation, or delay the visibility change as it desires.
80 virtual void HideKeyboardContainer(aura::Window* container);
82 // Updates the type of the focused text input box.
83 virtual void SetUpdateInputType(ui::TextInputType type);
85 // Ensures caret in current work area (not occluded by virtual keyboard
86 // window).
87 virtual void EnsureCaretInWorkArea();
89 // Loads system virtual keyboard. Noop if the current virtual keyboard is
90 // system virtual keyboard.
91 virtual void LoadSystemKeyboard();
93 // Reloads virtual keyboard URL if the current keyboard's web content URL is
94 // different. The URL can be different if user switch from password field to
95 // any other type input field.
96 // At password field, the system virtual keyboard is forced to load even if
97 // the current IME provides a customized virtual keyboard. This is needed to
98 // prevent IME virtual keyboard logging user's password. Once user switch to
99 // other input fields, the virtual keyboard should switch back to the IME
100 // provided keyboard, or keep using the system virtual keyboard if IME doesn't
101 // provide one.
102 virtual void ReloadKeyboardIfNeeded();
104 protected:
105 // Gets the BrowserContext to use for creating the WebContents hosting the
106 // keyboard.
107 virtual content::BrowserContext* GetBrowserContext() = 0;
109 // The implementation can choose to setup the WebContents before the virtual
110 // keyboard page is loaded (e.g. install a WebContentsObserver).
111 // SetupWebContents() is called right after creating the WebContents, before
112 // loading the keyboard page.
113 virtual void SetupWebContents(content::WebContents* contents);
115 // aura::WindowObserver overrides:
116 virtual void OnWindowBoundsChanged(aura::Window* window,
117 const gfx::Rect& old_bounds,
118 const gfx::Rect& new_bounds) OVERRIDE;
119 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE;
121 private:
122 friend class TestApi;
124 // Loads the web contents for the given |url|.
125 void LoadContents(const GURL& url);
127 // Gets the virtual keyboard URL (either the default URL or IME override URL).
128 const GURL& GetVirtualKeyboardUrl();
130 const GURL default_url_;
132 scoped_ptr<content::WebContents> keyboard_contents_;
133 scoped_ptr<wm::Shadow> shadow_;
135 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerProxy);
138 } // namespace keyboard
140 #endif // UI_KEYBOARD_KEYBOARD_CONTROLLER_PROXY_H_