Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: ui/keyboard/keyboard_ui.h

Issue 1392713002: Extract content dependency from keyboard code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_KEYBOARD_KEYBOARD_CONTROLLER_PROXY_H_ 5 #ifndef UI_KEYBOARD_KEYBOARD_UI_H_
6 #define UI_KEYBOARD_KEYBOARD_CONTROLLER_PROXY_H_ 6 #define UI_KEYBOARD_KEYBOARD_UI_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include <vector>
sky 2015/10/09 18:23:29 nit: you shouldn't need this include.
9 #include "content/public/common/media_stream_request.h" 9
10 #include "ui/aura/window_observer.h" 10 #include "base/macros.h"
11 #include "ui/base/ime/text_input_type.h" 11 #include "ui/base/ime/text_input_type.h"
12 #include "ui/keyboard/keyboard_export.h" 12 #include "ui/keyboard/keyboard_export.h"
13 13
14 namespace aura { 14 namespace aura {
15 class Window; 15 class Window;
16 } 16 }
17 namespace content {
18 class BrowserContext;
19 class SiteInstance;
20 class WebContents;
21 }
22 namespace gfx { 17 namespace gfx {
23 class Rect; 18 class Rect;
24 } 19 }
25 namespace ui { 20 namespace ui {
26 class InputMethod; 21 class InputMethod;
27 } 22 }
28 namespace wm {
29 class Shadow;
30 }
31 23
32 namespace keyboard { 24 namespace keyboard {
33 25
34 class KeyboardController; 26 class KeyboardController;
35 27
36 // A proxy used by the KeyboardController to get access to the virtual 28 // An interface implemented by an object that implements a keyboard UI.
37 // keyboard window. 29 class KEYBOARD_EXPORT KeyboardUI {
38 class KEYBOARD_EXPORT KeyboardControllerProxy : public aura::WindowObserver {
39 public: 30 public:
40 class TestApi { 31 KeyboardUI();
41 public: 32 virtual ~KeyboardUI();
42 explicit TestApi(KeyboardControllerProxy* proxy) : proxy_(proxy) {}
43
44 const content::WebContents* keyboard_contents() {
45 return proxy_->keyboard_contents_.get();
46 }
47
48 private:
49 KeyboardControllerProxy* proxy_;
50
51 DISALLOW_COPY_AND_ASSIGN(TestApi);
52 };
53
54 explicit KeyboardControllerProxy(content::BrowserContext* context);
55 ~KeyboardControllerProxy() override;
56 33
57 // Gets the virtual keyboard window. Ownership of the returned Window remains 34 // Gets the virtual keyboard window. Ownership of the returned Window remains
58 // with the proxy. 35 // with the proxy.
sky 2015/10/09 18:23:30 proxy->'ui' or maybe 'this class'.
59 virtual aura::Window* GetKeyboardWindow(); 36 virtual aura::Window* GetKeyboardWindow();
60 37
61 // Whether the keyboard window is created. The keyboard window is tied to a 38 // Whether the keyboard window is created. The keyboard window is tied to a
62 // WebContent so we can just check if the WebContent is created or not. 39 // WebContent so we can just check if the WebContent is created or not.
sky 2015/10/09 18:23:30 nit: this comment is out of date.
63 virtual bool HasKeyboardWindow() const; 40 virtual bool HasKeyboardWindow() const;
64 41
65 // Gets the InputMethod that will provide notifications about changes in the 42 // Gets the InputMethod that will provide notifications about changes in the
66 // text input context. 43 // text input context.
67 virtual ui::InputMethod* GetInputMethod() = 0; 44 virtual ui::InputMethod* GetInputMethod() = 0;
68 45
69 // Requests the audio input from microphone for speech input.
70 virtual void RequestAudioInput(content::WebContents* web_contents,
71 const content::MediaStreamRequest& request,
72 const content::MediaResponseCallback& callback) = 0;
73
74 // Shows the container window of the keyboard. The default implementation 46 // Shows the container window of the keyboard. The default implementation
75 // simply shows the container. An overridden implementation can set up 47 // simply shows the container. An overridden implementation can set up
76 // necessary animation, or delay the visibility change as it desires. 48 // necessary animation, or delay the visibility change as it desires.
77 virtual void ShowKeyboardContainer(aura::Window* container); 49 virtual void ShowKeyboardContainer(aura::Window* container);
78 50
79 // Hides the container window of the keyboard. The default implementation 51 // Hides the container window of the keyboard. The default implementation
80 // simply hides the container. An overridden implementation can set up 52 // simply hides the container. An overridden implementation can set up
81 // necesasry animation, or delay the visibility change as it desires. 53 // necesasry animation, or delay the visibility change as it desires.
82 virtual void HideKeyboardContainer(aura::Window* container); 54 virtual void HideKeyboardContainer(aura::Window* container);
83 55
84 // Updates the type of the focused text input box. 56 // Updates the type of the focused text input box.
85 virtual void SetUpdateInputType(ui::TextInputType type); 57 virtual void SetUpdateInputType(ui::TextInputType type);
86 58
87 // Ensures caret in current work area (not occluded by virtual keyboard 59 // Ensures caret in current work area (not occluded by virtual keyboard
88 // window). 60 // window).
89 virtual void EnsureCaretInWorkArea(); 61 virtual void EnsureCaretInWorkArea();
90 62
91 // Loads system virtual keyboard. Noop if the current virtual keyboard is 63 // KeyboardController owns KeyboardControllerProxy so KeyboardControllerProxy
sky 2015/10/09 18:23:30 KeyboardControllerProxy->KeyboardUI.
92 // system virtual keyboard. 64 // or its subclasses should not take ownership of the |controller|.
93 virtual void LoadSystemKeyboard(); 65 // |controller| can be null when KeyboardController is destroying.
66 virtual void SetController(KeyboardController* controller);
94 67
95 // Reloads virtual keyboard URL if the current keyboard's web content URL is 68 // Reloads virtual keyboard URL if the current keyboard's web content URL is
96 // different. The URL can be different if user switch from password field to 69 // different. The URL can be different if user switch from password field to
97 // any other type input field. 70 // any other type input field.
98 // At password field, the system virtual keyboard is forced to load even if 71 // At password field, the system virtual keyboard is forced to load even if
99 // the current IME provides a customized virtual keyboard. This is needed to 72 // the current IME provides a customized virtual keyboard. This is needed to
100 // prevent IME virtual keyboard logging user's password. Once user switch to 73 // prevent IME virtual keyboard logging user's password. Once user switch to
101 // other input fields, the virtual keyboard should switch back to the IME 74 // other input fields, the virtual keyboard should switch back to the IME
102 // provided keyboard, or keep using the system virtual keyboard if IME doesn't 75 // provided keyboard, or keep using the system virtual keyboard if IME doesn't
103 // provide one. 76 // provide one.
104 virtual void ReloadKeyboardIfNeeded(); 77 virtual void ReloadKeyboardIfNeeded();
105 78
106 // KeyboardController owns KeyboardControllerProxy so KeyboardControllerProxy 79 // When the embedder changes the keyboard bounds, asks the keyboard to adjust
107 // or its subclasses should not take ownership of the |controller|. 80 // insets for windows affected by this.
108 // |controller| can be null when KeyboardController is destroying. 81 virtual void InitInsets(const gfx::Rect& keyboard_bounds);
109 virtual void SetController(KeyboardController* controller); 82
83 // Resets insets for affected windows.
84 virtual void ResetInsets();
110 85
111 protected: 86 protected:
112 // The implementation can choose to setup the WebContents before the virtual
113 // keyboard page is loaded (e.g. install a WebContentsObserver).
114 // SetupWebContents() is called right after creating the WebContents, before
115 // loading the keyboard page.
116 virtual void SetupWebContents(content::WebContents* contents);
117
118 // aura::WindowObserver overrides:
119 void OnWindowBoundsChanged(aura::Window* window,
120 const gfx::Rect& old_bounds,
121 const gfx::Rect& new_bounds) override;
122 void OnWindowDestroyed(aura::Window* window) override;
123
124 content::BrowserContext* browser_context() { return browser_context_; }
125 KeyboardController* keyboard_controller() { return keyboard_controller_; } 87 KeyboardController* keyboard_controller() { return keyboard_controller_; }
126 88
127 private: 89 private:
128 friend class TestApi;
129
130 // Loads the web contents for the given |url|.
131 void LoadContents(const GURL& url);
132
133 // Gets the virtual keyboard URL (either the default URL or IME override URL).
134 const GURL& GetVirtualKeyboardUrl();
135
136 // The BrowserContext to use for creating the WebContents hosting the
137 // keyboard.
138 content::BrowserContext* browser_context_;
139
140 const GURL default_url_;
141 keyboard::KeyboardController* keyboard_controller_; 90 keyboard::KeyboardController* keyboard_controller_;
142 91
143 scoped_ptr<content::WebContents> keyboard_contents_; 92 DISALLOW_COPY_AND_ASSIGN(KeyboardUI);
144 scoped_ptr<wm::Shadow> shadow_;
145
146 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerProxy);
147 }; 93 };
148 94
149 } // namespace keyboard 95 } // namespace keyboard
150 96
151 #endif // UI_KEYBOARD_KEYBOARD_CONTROLLER_PROXY_H_ 97 #endif // UI_KEYBOARD_KEYBOARD_UI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698