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

Side by Side Diff: ui/keyboard/keyboard_controller_proxy.cc

Issue 97013002: [Input View] Makes the input view window support window.resizeTo() and w3c visibility API its web c… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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 #include "ui/keyboard/keyboard_controller_proxy.h" 5 #include "ui/keyboard/keyboard_controller_proxy.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "content/public/browser/site_instance.h" 8 #include "content/public/browser/site_instance.h"
9 #include "content/public/browser/web_contents.h" 9 #include "content/public/browser/web_contents.h"
10 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // Overridden from content::WebContentsDelegate: 64 // Overridden from content::WebContentsDelegate:
65 virtual content::WebContents* OpenURLFromTab( 65 virtual content::WebContents* OpenURLFromTab(
66 content::WebContents* source, 66 content::WebContents* source,
67 const content::OpenURLParams& params) OVERRIDE { 67 const content::OpenURLParams& params) OVERRIDE {
68 source->GetController().LoadURL( 68 source->GetController().LoadURL(
69 params.url, params.referrer, params.transition, params.extra_headers); 69 params.url, params.referrer, params.transition, params.extra_headers);
70 Observe(source); 70 Observe(source);
71 return source; 71 return source;
72 } 72 }
73 73
74 virtual bool IsPopupOrPanel(const content::WebContents* source) const {
75 return true;
76 }
77
78 virtual void MoveContents(
79 content::WebContents* source, const gfx::Rect& pos) {
80 proxy_->SetKeyboardHeight(pos.height());
81 }
82
74 // Overridden from content::WebContentsDelegate: 83 // Overridden from content::WebContentsDelegate:
75 virtual void RequestMediaAccessPermission(content::WebContents* web_contents, 84 virtual void RequestMediaAccessPermission(content::WebContents* web_contents,
76 const content::MediaStreamRequest& request, 85 const content::MediaStreamRequest& request,
77 const content::MediaResponseCallback& callback) OVERRIDE { 86 const content::MediaResponseCallback& callback) OVERRIDE {
78 proxy_->RequestAudioInput(web_contents, request, callback); 87 proxy_->RequestAudioInput(web_contents, request, callback);
79 } 88 }
80 89
81 90
82 // Overridden from content::WebContentsObserver: 91 // Overridden from content::WebContentsObserver:
83 virtual void WebContentsDestroyed(content::WebContents* contents) OVERRIDE { 92 virtual void WebContentsDestroyed(content::WebContents* contents) OVERRIDE {
84 delete this; 93 delete this;
85 } 94 }
86 95
87 keyboard::KeyboardControllerProxy* proxy_; 96 keyboard::KeyboardControllerProxy* proxy_;
88 97
89 DISALLOW_COPY_AND_ASSIGN(KeyboardContentsDelegate); 98 DISALLOW_COPY_AND_ASSIGN(KeyboardContentsDelegate);
90 }; 99 };
91 100
92 } // namespace 101 } // namespace
93 102
94 namespace keyboard { 103 namespace keyboard {
95 104
96 KeyboardControllerProxy::KeyboardControllerProxy() 105 KeyboardControllerProxy::KeyboardControllerProxy()
97 : default_url_(kKeyboardWebUIURL) { 106 : default_url_(kKeyboardWebUIURL), keyboard_resizer_(NULL) {
98 } 107 }
99 108
100 KeyboardControllerProxy::~KeyboardControllerProxy() { 109 KeyboardControllerProxy::~KeyboardControllerProxy() {
101 } 110 }
102 111
103 const GURL& KeyboardControllerProxy::GetValidUrl() { 112 const GURL& KeyboardControllerProxy::GetValidUrl() {
104 return override_url_.is_valid() ? override_url_ : default_url_; 113 return override_url_.is_valid() ? override_url_ : default_url_;
105 } 114 }
106 115
107 void KeyboardControllerProxy::SetOverrideContentUrl(const GURL& url) { 116 void KeyboardControllerProxy::SetOverrideContentUrl(const GURL& url) {
108 if (override_url_ == url) 117 if (override_url_ == url)
109 return; 118 return;
110 override_url_ = url; 119 override_url_ = url;
111 120
112 ReloadContents(); 121 ReloadContents();
113 } 122 }
114 123
124 void KeyboardControllerProxy::SetKeyboardResizer(KeyboardResizer* resizer) {
125 keyboard_resizer_ = resizer;
126 }
127
128 void KeyboardControllerProxy::SetKeyboardHeight(int height) {
129 if (keyboard_resizer_) {
130 keyboard_resizer_->SetKeyboardHeight(height);
131 }
132 }
133
115 void KeyboardControllerProxy::ReloadContents() { 134 void KeyboardControllerProxy::ReloadContents() {
116 if (keyboard_contents_) { 135 if (keyboard_contents_) {
117 content::OpenURLParams params( 136 content::OpenURLParams params(
118 GetValidUrl(), 137 GetValidUrl(),
119 content::Referrer(), 138 content::Referrer(),
120 SINGLETON_TAB, 139 SINGLETON_TAB,
121 content::PAGE_TRANSITION_AUTO_TOPLEVEL, 140 content::PAGE_TRANSITION_AUTO_TOPLEVEL,
122 false); 141 false);
123 keyboard_contents_->OpenURL(params); 142 keyboard_contents_->OpenURL(params);
124 } 143 }
125 } 144 }
126 145
127 aura::Window* KeyboardControllerProxy::GetKeyboardWindow() { 146 aura::Window* KeyboardControllerProxy::GetKeyboardWindow() {
128 if (!keyboard_contents_) { 147 if (!keyboard_contents_) {
129 content::BrowserContext* context = GetBrowserContext(); 148 content::BrowserContext* context = GetBrowserContext();
130 keyboard_contents_.reset(content::WebContents::Create( 149 keyboard_contents_.reset(content::WebContents::Create(
131 content::WebContents::CreateParams(context, 150 content::WebContents::CreateParams(context,
132 content::SiteInstance::CreateForURL(context, GetValidUrl())))); 151 content::SiteInstance::CreateForURL(context, GetValidUrl()))));
133 keyboard_contents_->SetDelegate(new KeyboardContentsDelegate(this)); 152 keyboard_contents_->SetDelegate(new KeyboardContentsDelegate(this));
134 SetupWebContents(keyboard_contents_.get()); 153 SetupWebContents(keyboard_contents_.get());
135 ReloadContents(); 154 ReloadContents();
136 } 155 }
137 156
138 return keyboard_contents_->GetView()->GetNativeView(); 157 return keyboard_contents_->GetView()->GetNativeView();
139 } 158 }
140 159
141 void KeyboardControllerProxy::ShowKeyboardContainer(aura::Window* container) { 160 void KeyboardControllerProxy::ShowKeyboardContainer(aura::Window* container) {
161 GetKeyboardWindow()->Show();
kevers 2013/11/29 20:26:05 Is it necessary to show/hide the keyboard window,
Shu Chen 2013/12/02 03:54:40 It is necessary, otherwise it won't trigger the vi
142 container->Show(); 162 container->Show();
143 } 163 }
144 164
145 void KeyboardControllerProxy::HideKeyboardContainer(aura::Window* container) { 165 void KeyboardControllerProxy::HideKeyboardContainer(aura::Window* container) {
146 container->Hide(); 166 container->Hide();
167 GetKeyboardWindow()->Hide();
147 } 168 }
148 169
149 void KeyboardControllerProxy::SetUpdateInputType(ui::TextInputType type) { 170 void KeyboardControllerProxy::SetUpdateInputType(ui::TextInputType type) {
150 content::WebUI* webui = keyboard_contents_ ? 171 content::WebUI* webui = keyboard_contents_ ?
151 keyboard_contents_->GetCommittedWebUI() : NULL; 172 keyboard_contents_->GetCommittedWebUI() : NULL;
152 173
153 if (webui && 174 if (webui &&
154 (0 != (webui->GetBindings() & content::BINDINGS_POLICY_WEB_UI))) { 175 (0 != (webui->GetBindings() & content::BINDINGS_POLICY_WEB_UI))) {
155 // Only call OnTextInputBoxFocused function if it is a web ui keyboard, 176 // Only call OnTextInputBoxFocused function if it is a web ui keyboard,
156 // not an extension based keyboard. 177 // not an extension based keyboard.
157 base::DictionaryValue input_context; 178 base::DictionaryValue input_context;
158 input_context.SetString("type", TextInputTypeToString(type)); 179 input_context.SetString("type", TextInputTypeToString(type));
159 webui->CallJavascriptFunction("OnTextInputBoxFocused", input_context); 180 webui->CallJavascriptFunction("OnTextInputBoxFocused", input_context);
160 } 181 }
161 } 182 }
162 183
163 void KeyboardControllerProxy::SetupWebContents(content::WebContents* contents) { 184 void KeyboardControllerProxy::SetupWebContents(content::WebContents* contents) {
164 } 185 }
165 186
166 } // namespace keyboard 187 } // namespace keyboard
OLDNEW
« ui/keyboard/keyboard_controller_proxy.h ('K') | « ui/keyboard/keyboard_controller_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698