OLD | NEW |
---|---|
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 Loading... | |
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) { | |
kevers
2013/12/03 00:08:12
OVERRIDE
Shu Chen
2013/12/03 01:54:42
Done.
| |
80 aura::Window* keyboard = proxy_->GetKeyboardWindow(); | |
81 gfx::Rect bounds = keyboard->bounds(); | |
82 int new_height = pos.height(); | |
83 bounds.set_y(bounds.y() + bounds.height() - new_height); | |
84 bounds.set_height(new_height); | |
85 // Records the keyboard new height. So that GetHitTestMask() can set the | |
86 // same keyboard bounds as the hit test mask. | |
87 keyboard::KeyboardControllerProxy::keyboard_height = new_height; | |
88 | |
89 keyboard::KeyboardControllerProxy::keyboard_resizing_from_contents = true; | |
kevers
2013/12/03 00:08:12
Can set a non-static member and add a public acces
Shu Chen
2013/12/03 01:54:42
Done.
| |
90 keyboard->SetBounds(bounds); | |
91 keyboard::KeyboardControllerProxy::keyboard_resizing_from_contents = false; | |
kevers
2013/12/03 00:08:12
Resetting might not be strictly required. See oth
Shu Chen
2013/12/03 01:54:42
Done.
| |
92 } | |
93 | |
74 // Overridden from content::WebContentsDelegate: | 94 // Overridden from content::WebContentsDelegate: |
75 virtual void RequestMediaAccessPermission(content::WebContents* web_contents, | 95 virtual void RequestMediaAccessPermission(content::WebContents* web_contents, |
76 const content::MediaStreamRequest& request, | 96 const content::MediaStreamRequest& request, |
77 const content::MediaResponseCallback& callback) OVERRIDE { | 97 const content::MediaResponseCallback& callback) OVERRIDE { |
78 proxy_->RequestAudioInput(web_contents, request, callback); | 98 proxy_->RequestAudioInput(web_contents, request, callback); |
79 } | 99 } |
80 | 100 |
81 | 101 |
82 // Overridden from content::WebContentsObserver: | 102 // Overridden from content::WebContentsObserver: |
83 virtual void WebContentsDestroyed(content::WebContents* contents) OVERRIDE { | 103 virtual void WebContentsDestroyed(content::WebContents* contents) OVERRIDE { |
84 delete this; | 104 delete this; |
85 } | 105 } |
86 | 106 |
87 keyboard::KeyboardControllerProxy* proxy_; | 107 keyboard::KeyboardControllerProxy* proxy_; |
88 | 108 |
89 DISALLOW_COPY_AND_ASSIGN(KeyboardContentsDelegate); | 109 DISALLOW_COPY_AND_ASSIGN(KeyboardContentsDelegate); |
90 }; | 110 }; |
91 | 111 |
92 } // namespace | 112 } // namespace |
93 | 113 |
94 namespace keyboard { | 114 namespace keyboard { |
95 | 115 |
116 int KeyboardControllerProxy::keyboard_height = -1; | |
117 | |
118 bool KeyboardControllerProxy::keyboard_resizing_from_contents = false; | |
119 | |
96 KeyboardControllerProxy::KeyboardControllerProxy() | 120 KeyboardControllerProxy::KeyboardControllerProxy() |
97 : default_url_(kKeyboardWebUIURL) { | 121 : default_url_(kKeyboardWebUIURL) { |
98 } | 122 } |
99 | 123 |
100 KeyboardControllerProxy::~KeyboardControllerProxy() { | 124 KeyboardControllerProxy::~KeyboardControllerProxy() { |
101 } | 125 } |
102 | 126 |
103 const GURL& KeyboardControllerProxy::GetValidUrl() { | 127 const GURL& KeyboardControllerProxy::GetValidUrl() { |
104 return override_url_.is_valid() ? override_url_ : default_url_; | 128 return override_url_.is_valid() ? override_url_ : default_url_; |
105 } | 129 } |
(...skipping 26 matching lines...) Expand all Loading... | |
132 content::SiteInstance::CreateForURL(context, GetValidUrl())))); | 156 content::SiteInstance::CreateForURL(context, GetValidUrl())))); |
133 keyboard_contents_->SetDelegate(new KeyboardContentsDelegate(this)); | 157 keyboard_contents_->SetDelegate(new KeyboardContentsDelegate(this)); |
134 SetupWebContents(keyboard_contents_.get()); | 158 SetupWebContents(keyboard_contents_.get()); |
135 ReloadContents(); | 159 ReloadContents(); |
136 } | 160 } |
137 | 161 |
138 return keyboard_contents_->GetView()->GetNativeView(); | 162 return keyboard_contents_->GetView()->GetNativeView(); |
139 } | 163 } |
140 | 164 |
141 void KeyboardControllerProxy::ShowKeyboardContainer(aura::Window* container) { | 165 void KeyboardControllerProxy::ShowKeyboardContainer(aura::Window* container) { |
166 GetKeyboardWindow()->Show(); | |
142 container->Show(); | 167 container->Show(); |
143 } | 168 } |
144 | 169 |
145 void KeyboardControllerProxy::HideKeyboardContainer(aura::Window* container) { | 170 void KeyboardControllerProxy::HideKeyboardContainer(aura::Window* container) { |
146 container->Hide(); | 171 container->Hide(); |
172 GetKeyboardWindow()->Hide(); | |
147 } | 173 } |
148 | 174 |
149 void KeyboardControllerProxy::SetUpdateInputType(ui::TextInputType type) { | 175 void KeyboardControllerProxy::SetUpdateInputType(ui::TextInputType type) { |
150 content::WebUI* webui = keyboard_contents_ ? | 176 content::WebUI* webui = keyboard_contents_ ? |
151 keyboard_contents_->GetCommittedWebUI() : NULL; | 177 keyboard_contents_->GetCommittedWebUI() : NULL; |
152 | 178 |
153 if (webui && | 179 if (webui && |
154 (0 != (webui->GetBindings() & content::BINDINGS_POLICY_WEB_UI))) { | 180 (0 != (webui->GetBindings() & content::BINDINGS_POLICY_WEB_UI))) { |
155 // Only call OnTextInputBoxFocused function if it is a web ui keyboard, | 181 // Only call OnTextInputBoxFocused function if it is a web ui keyboard, |
156 // not an extension based keyboard. | 182 // not an extension based keyboard. |
157 base::DictionaryValue input_context; | 183 base::DictionaryValue input_context; |
158 input_context.SetString("type", TextInputTypeToString(type)); | 184 input_context.SetString("type", TextInputTypeToString(type)); |
159 webui->CallJavascriptFunction("OnTextInputBoxFocused", input_context); | 185 webui->CallJavascriptFunction("OnTextInputBoxFocused", input_context); |
160 } | 186 } |
161 } | 187 } |
162 | 188 |
163 void KeyboardControllerProxy::SetupWebContents(content::WebContents* contents) { | 189 void KeyboardControllerProxy::SetupWebContents(content::WebContents* contents) { |
164 } | 190 } |
165 | 191 |
166 } // namespace keyboard | 192 } // namespace keyboard |
OLD | NEW |