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

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: Add an unit test in keyboard_unittests. 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 OVERRIDE {
76 return true;
77 }
78
79 virtual void MoveContents(
80 content::WebContents* source, const gfx::Rect& pos) OVERRIDE {
81 aura::Window* keyboard = proxy_->GetKeyboardWindow();
82 gfx::Rect bounds = keyboard->bounds();
83 int new_height = pos.height();
84 bounds.set_y(bounds.y() + bounds.height() - new_height);
85 bounds.set_height(new_height);
86 proxy_->set_resizing_from_contents(true);
87 keyboard->SetBounds(bounds);
sadrul 2013/12/05 07:54:55 reset the state to false in here instead.
Shu Chen 2013/12/05 08:21:04 Done.
88 }
89
74 // Overridden from content::WebContentsDelegate: 90 // Overridden from content::WebContentsDelegate:
75 virtual void RequestMediaAccessPermission(content::WebContents* web_contents, 91 virtual void RequestMediaAccessPermission(content::WebContents* web_contents,
76 const content::MediaStreamRequest& request, 92 const content::MediaStreamRequest& request,
77 const content::MediaResponseCallback& callback) OVERRIDE { 93 const content::MediaResponseCallback& callback) OVERRIDE {
78 proxy_->RequestAudioInput(web_contents, request, callback); 94 proxy_->RequestAudioInput(web_contents, request, callback);
79 } 95 }
80 96
81 97
82 // Overridden from content::WebContentsObserver: 98 // Overridden from content::WebContentsObserver:
83 virtual void WebContentsDestroyed(content::WebContents* contents) OVERRIDE { 99 virtual void WebContentsDestroyed(content::WebContents* contents) OVERRIDE {
84 delete this; 100 delete this;
85 } 101 }
86 102
87 keyboard::KeyboardControllerProxy* proxy_; 103 keyboard::KeyboardControllerProxy* proxy_;
88 104
89 DISALLOW_COPY_AND_ASSIGN(KeyboardContentsDelegate); 105 DISALLOW_COPY_AND_ASSIGN(KeyboardContentsDelegate);
90 }; 106 };
91 107
92 } // namespace 108 } // namespace
93 109
94 namespace keyboard { 110 namespace keyboard {
95 111
96 KeyboardControllerProxy::KeyboardControllerProxy() 112 KeyboardControllerProxy::KeyboardControllerProxy()
97 : default_url_(kKeyboardWebUIURL) { 113 : default_url_(kKeyboardWebUIURL), resizing_from_contents_(false) {
98 } 114 }
99 115
100 KeyboardControllerProxy::~KeyboardControllerProxy() { 116 KeyboardControllerProxy::~KeyboardControllerProxy() {
101 } 117 }
102 118
103 const GURL& KeyboardControllerProxy::GetValidUrl() { 119 const GURL& KeyboardControllerProxy::GetValidUrl() {
104 return override_url_.is_valid() ? override_url_ : default_url_; 120 return override_url_.is_valid() ? override_url_ : default_url_;
105 } 121 }
106 122
107 void KeyboardControllerProxy::SetOverrideContentUrl(const GURL& url) { 123 void KeyboardControllerProxy::SetOverrideContentUrl(const GURL& url) {
(...skipping 24 matching lines...) Expand all
132 content::SiteInstance::CreateForURL(context, GetValidUrl())))); 148 content::SiteInstance::CreateForURL(context, GetValidUrl()))));
133 keyboard_contents_->SetDelegate(new KeyboardContentsDelegate(this)); 149 keyboard_contents_->SetDelegate(new KeyboardContentsDelegate(this));
134 SetupWebContents(keyboard_contents_.get()); 150 SetupWebContents(keyboard_contents_.get());
135 ReloadContents(); 151 ReloadContents();
136 } 152 }
137 153
138 return keyboard_contents_->GetView()->GetNativeView(); 154 return keyboard_contents_->GetView()->GetNativeView();
139 } 155 }
140 156
141 void KeyboardControllerProxy::ShowKeyboardContainer(aura::Window* container) { 157 void KeyboardControllerProxy::ShowKeyboardContainer(aura::Window* container) {
158 GetKeyboardWindow()->Show();
142 container->Show(); 159 container->Show();
143 } 160 }
144 161
145 void KeyboardControllerProxy::HideKeyboardContainer(aura::Window* container) { 162 void KeyboardControllerProxy::HideKeyboardContainer(aura::Window* container) {
146 container->Hide(); 163 container->Hide();
164 GetKeyboardWindow()->Hide();
147 } 165 }
148 166
149 void KeyboardControllerProxy::SetUpdateInputType(ui::TextInputType type) { 167 void KeyboardControllerProxy::SetUpdateInputType(ui::TextInputType type) {
150 content::WebUI* webui = keyboard_contents_ ? 168 content::WebUI* webui = keyboard_contents_ ?
151 keyboard_contents_->GetCommittedWebUI() : NULL; 169 keyboard_contents_->GetCommittedWebUI() : NULL;
152 170
153 if (webui && 171 if (webui &&
154 (0 != (webui->GetBindings() & content::BINDINGS_POLICY_WEB_UI))) { 172 (0 != (webui->GetBindings() & content::BINDINGS_POLICY_WEB_UI))) {
155 // Only call OnTextInputBoxFocused function if it is a web ui keyboard, 173 // Only call OnTextInputBoxFocused function if it is a web ui keyboard,
156 // not an extension based keyboard. 174 // not an extension based keyboard.
157 base::DictionaryValue input_context; 175 base::DictionaryValue input_context;
158 input_context.SetString("type", TextInputTypeToString(type)); 176 input_context.SetString("type", TextInputTypeToString(type));
159 webui->CallJavascriptFunction("OnTextInputBoxFocused", input_context); 177 webui->CallJavascriptFunction("OnTextInputBoxFocused", input_context);
160 } 178 }
161 } 179 }
162 180
163 void KeyboardControllerProxy::SetupWebContents(content::WebContents* contents) { 181 void KeyboardControllerProxy::SetupWebContents(content::WebContents* contents) {
164 } 182 }
165 183
166 } // namespace keyboard 184 } // namespace keyboard
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698