Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_view_host_impl.h" | 5 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 #include "ui/base/touch/touch_device.h" | 83 #include "ui/base/touch/touch_device.h" |
| 84 #include "ui/base/touch/touch_enabled.h" | 84 #include "ui/base/touch/touch_enabled.h" |
| 85 #include "ui/base/ui_base_switches.h" | 85 #include "ui/base/ui_base_switches.h" |
| 86 #include "ui/gfx/animation/animation.h" | 86 #include "ui/gfx/animation/animation.h" |
| 87 #include "ui/gfx/image/image_skia.h" | 87 #include "ui/gfx/image/image_skia.h" |
| 88 #include "ui/gfx/native_widget_types.h" | 88 #include "ui/gfx/native_widget_types.h" |
| 89 #include "ui/native_theme/native_theme_switches.h" | 89 #include "ui/native_theme/native_theme_switches.h" |
| 90 #include "url/url_constants.h" | 90 #include "url/url_constants.h" |
| 91 | 91 |
| 92 #if defined(OS_WIN) | 92 #if defined(OS_WIN) |
| 93 #include "base/memory/singleton.h" | |
| 94 #include "base/win/osk_display_manager.h" | |
| 93 #include "base/win/win_util.h" | 95 #include "base/win/win_util.h" |
| 96 #include "ui/aura/window.h" | |
| 94 #include "ui/display/win/dpi.h" | 97 #include "ui/display/win/dpi.h" |
| 95 #include "ui/gfx/platform_font_win.h" | 98 #include "ui/gfx/platform_font_win.h" |
| 96 #endif | 99 #endif |
| 97 | 100 |
| 98 using base::TimeDelta; | 101 using base::TimeDelta; |
| 99 using blink::WebConsoleMessage; | 102 using blink::WebConsoleMessage; |
| 100 using blink::WebDragOperation; | 103 using blink::WebDragOperation; |
| 101 using blink::WebDragOperationNone; | 104 using blink::WebDragOperationNone; |
| 102 using blink::WebDragOperationsMask; | 105 using blink::WebDragOperationsMask; |
| 103 using blink::WebInputEvent; | 106 using blink::WebInputEvent; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 display::win::GetSystemMetricsInDIP(SM_CYHSCROLL); | 162 display::win::GetSystemMetricsInDIP(SM_CYHSCROLL); |
| 160 prefs->arrow_bitmap_height_vertical_scroll_bar_in_dips = | 163 prefs->arrow_bitmap_height_vertical_scroll_bar_in_dips = |
| 161 display::win::GetSystemMetricsInDIP(SM_CYVSCROLL); | 164 display::win::GetSystemMetricsInDIP(SM_CYVSCROLL); |
| 162 prefs->arrow_bitmap_width_horizontal_scroll_bar_in_dips = | 165 prefs->arrow_bitmap_width_horizontal_scroll_bar_in_dips = |
| 163 display::win::GetSystemMetricsInDIP(SM_CXHSCROLL); | 166 display::win::GetSystemMetricsInDIP(SM_CXHSCROLL); |
| 164 } | 167 } |
| 165 #endif | 168 #endif |
| 166 | 169 |
| 167 } // namespace | 170 } // namespace |
| 168 | 171 |
| 172 #if defined(OS_WIN) | |
|
ncarter (slow)
2016/05/18 20:09:11
This is getting to be more OS_WIN code in this fil
ananta
2016/05/19 01:57:12
Moved this RenderWidgetHostViewAura.
This involve
| |
| 173 // This class implements the base::win::OnScreenKeyboardObserver interface | |
| 174 // which provides notifications about the on screen keyboard on Windows getting | |
| 175 // displayed or hidden in response to taps on editable fields. | |
| 176 class OnScreenKeyboardObserver : public base::win::OnScreenKeyboardObserver { | |
| 177 public: | |
| 178 OnScreenKeyboardObserver(RenderViewHostImpl* host) | |
|
ncarter (slow)
2016/05/18 20:09:11
explicit
ananta
2016/05/19 01:57:13
Done.
| |
| 179 : host_(host) { | |
| 180 } | |
| 181 | |
| 182 // base::win::OnScreenKeyboardObserver overrides. | |
| 183 void OnKeyboardVisible(const RECT& keyboard_rect) override { | |
| 184 DCHECK(host_); | |
| 185 RenderWidgetHostImpl* widget_host = host_->GetWidget(); | |
| 186 if (widget_host && widget_host->GetView()) { | |
| 187 // We use the cursor position to determine whether the tap occurred | |
| 188 // inside the bounds of the on screen keyboard. | |
| 189 POINT cursor_pos = {}; | |
| 190 ::GetCursorPos(&cursor_pos); | |
|
sky
2016/05/18 19:54:51
Is the cursor position always updated for touch? N
ananta
2016/05/19 02:18:47
It is updated for touch. I pass the cursor positio
| |
| 191 if (::PtInRect(&keyboard_rect, cursor_pos)) { | |
| 192 DVLOG(1) << "OSK covering focus point."; | |
| 193 // We set the viewport to the bounds of the keyboard with an offset of | |
| 194 // 10 to ensure that the editable field gets scrolled into view | |
| 195 // correctly. | |
| 196 gfx::Rect display_rect(keyboard_rect); | |
| 197 display_rect.set_y(display_rect.y() - 10); | |
| 198 display_rect.set_height(display_rect.height() - 10); | |
| 199 widget_host->GetView()->SetInsets( | |
| 200 gfx::Insets(0, 0, display_rect.height(), 0)); | |
|
sky
2016/05/18 19:54:52
Shouldn't this depend upon the region of the rende
ananta
2016/05/19 02:18:47
Yeah. Updated. PTAL
| |
| 201 widget_host->ScrollFocusedEditableNodeIntoRect(display_rect); | |
| 202 } else { | |
| 203 // Restore the viewport. | |
| 204 widget_host->GetView()->SetInsets(gfx::Insets()); | |
| 205 } | |
| 206 } | |
| 207 } | |
| 208 | |
| 209 void OnKeyboardHidden(const RECT& keyboard_rect) override { | |
| 210 DCHECK(host_); | |
| 211 RenderWidgetHost* widget_host = host_->GetWidget(); | |
| 212 // Restore the viewport. | |
| 213 if (widget_host && widget_host->GetView()) { | |
| 214 widget_host->GetView()->SetInsets(gfx::Insets()); | |
|
sky
2016/05/18 19:54:52
Should this be done in the constructor too?
ananta
2016/05/19 01:57:12
Done.
| |
| 215 } | |
| 216 } | |
| 217 | |
| 218 private: | |
| 219 RenderViewHostImpl* host_; | |
| 220 }; | |
|
sky
2016/05/18 19:54:51
DISALLOW...
ananta
2016/05/19 01:57:13
Done.
| |
| 221 #endif | |
| 222 | |
| 169 // static | 223 // static |
| 170 const int64_t RenderViewHostImpl::kUnloadTimeoutMS = 1000; | 224 const int64_t RenderViewHostImpl::kUnloadTimeoutMS = 1000; |
| 171 | 225 |
| 172 /////////////////////////////////////////////////////////////////////////////// | 226 /////////////////////////////////////////////////////////////////////////////// |
| 173 // RenderViewHost, public: | 227 // RenderViewHost, public: |
| 174 | 228 |
| 175 // static | 229 // static |
| 176 RenderViewHost* RenderViewHost::FromID(int render_process_id, | 230 RenderViewHost* RenderViewHost::FromID(int render_process_id, |
| 177 int render_view_id) { | 231 int render_view_id) { |
| 178 return RenderViewHostImpl::FromID(render_process_id, render_view_id); | 232 return RenderViewHostImpl::FromID(render_process_id, render_view_id); |
| (...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1292 bad_message::ReceivedBadMessage(GetProcess(), | 1346 bad_message::ReceivedBadMessage(GetProcess(), |
| 1293 bad_message::RVH_FILE_CHOOSER_PATH); | 1347 bad_message::RVH_FILE_CHOOSER_PATH); |
| 1294 return; | 1348 return; |
| 1295 } | 1349 } |
| 1296 | 1350 |
| 1297 delegate_->RunFileChooser(this, params); | 1351 delegate_->RunFileChooser(this, params); |
| 1298 } | 1352 } |
| 1299 | 1353 |
| 1300 void RenderViewHostImpl::OnFocusedNodeTouched(bool editable) { | 1354 void RenderViewHostImpl::OnFocusedNodeTouched(bool editable) { |
| 1301 #if defined(OS_WIN) | 1355 #if defined(OS_WIN) |
| 1356 base::win::OnScreenKeyboardDisplayManager* osk_display_manager = | |
| 1357 base::win::OnScreenKeyboardDisplayManager::GetInstance(); | |
| 1358 DCHECK(osk_display_manager); | |
| 1302 if (editable) { | 1359 if (editable) { |
| 1303 virtual_keyboard_requested_ = base::win::DisplayVirtualKeyboard(); | 1360 keyboard_observer_.reset(new OnScreenKeyboardObserver(this)); |
|
sky
2016/05/18 19:54:51
Is it possible the keyboard is already visible at
ananta
2016/05/19 01:57:13
I don't think that would be needed. The DisplayVir
| |
| 1361 virtual_keyboard_requested_ = osk_display_manager->DisplayVirtualKeyboard( | |
| 1362 keyboard_observer_.get()); | |
| 1304 delegate_->SetIsVirtualKeyboardRequested(true); | 1363 delegate_->SetIsVirtualKeyboardRequested(true); |
| 1305 } else { | 1364 } else { |
| 1306 virtual_keyboard_requested_ = false; | 1365 virtual_keyboard_requested_ = false; |
| 1307 delegate_->SetIsVirtualKeyboardRequested(false); | 1366 delegate_->SetIsVirtualKeyboardRequested(false); |
| 1308 base::win::DismissVirtualKeyboard(); | 1367 osk_display_manager->DismissVirtualKeyboard(keyboard_observer_.get()); |
|
ncarter (slow)
2016/05/18 20:09:11
It's not clear to me why this DismissVirtualKeyboa
ananta
2016/05/19 01:57:12
Yes. Removed the observer parameter.
| |
| 1309 } | 1368 } |
| 1310 #endif | 1369 #endif |
| 1311 } | 1370 } |
| 1312 | 1371 |
| 1313 bool RenderViewHostImpl::CanAccessFilesOfPageState( | 1372 bool RenderViewHostImpl::CanAccessFilesOfPageState( |
| 1314 const PageState& state) const { | 1373 const PageState& state) const { |
| 1315 ChildProcessSecurityPolicyImpl* policy = | 1374 ChildProcessSecurityPolicyImpl* policy = |
| 1316 ChildProcessSecurityPolicyImpl::GetInstance(); | 1375 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 1317 | 1376 |
| 1318 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles(); | 1377 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles(); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1348 } else { | 1407 } else { |
| 1349 render_view_ready_on_process_launch_ = true; | 1408 render_view_ready_on_process_launch_ = true; |
| 1350 } | 1409 } |
| 1351 } | 1410 } |
| 1352 | 1411 |
| 1353 void RenderViewHostImpl::RenderViewReady() { | 1412 void RenderViewHostImpl::RenderViewReady() { |
| 1354 delegate_->RenderViewReady(this); | 1413 delegate_->RenderViewReady(this); |
| 1355 } | 1414 } |
| 1356 | 1415 |
| 1357 } // namespace content | 1416 } // namespace content |
| OLD | NEW |