Allow the externalfile scheme to be whitelisted as an allowed scheme for component...
[chromium-blink-merge.git] / ui / keyboard / keyboard_controller_proxy.h
blob2c91446460815b39bb4eee56fb7d20ff9295aa4a
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 explicit KeyboardControllerProxy(content::BrowserContext* context);
53 ~KeyboardControllerProxy() override;
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 // The implementation can choose to setup the WebContents before the virtual
106 // keyboard page is loaded (e.g. install a WebContentsObserver).
107 // SetupWebContents() is called right after creating the WebContents, before
108 // loading the keyboard page.
109 virtual void SetupWebContents(content::WebContents* contents);
111 // aura::WindowObserver overrides:
112 void OnWindowBoundsChanged(aura::Window* window,
113 const gfx::Rect& old_bounds,
114 const gfx::Rect& new_bounds) override;
115 void OnWindowDestroyed(aura::Window* window) override;
117 content::BrowserContext* browser_context() { return browser_context_; }
119 private:
120 friend class TestApi;
122 // Loads the web contents for the given |url|.
123 void LoadContents(const GURL& url);
125 // Gets the virtual keyboard URL (either the default URL or IME override URL).
126 const GURL& GetVirtualKeyboardUrl();
128 // The BrowserContext to use for creating the WebContents hosting the
129 // keyboard.
130 content::BrowserContext* browser_context_;
132 const GURL default_url_;
134 scoped_ptr<content::WebContents> keyboard_contents_;
135 scoped_ptr<wm::Shadow> shadow_;
137 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerProxy);
140 } // namespace keyboard
142 #endif // UI_KEYBOARD_KEYBOARD_CONTROLLER_PROXY_H_