OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/bind_helpers.h" | 5 #include "base/bind_helpers.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 9 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
10 #include "content/browser/frame_host/render_widget_host_view_guest.h" | 10 #include "content/browser/frame_host/render_widget_host_view_guest.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 void RenderWidgetHostViewGuest::WasShown() { | 79 void RenderWidgetHostViewGuest::WasShown() { |
80 // If the WebContents associated with us showed an interstitial page in the | 80 // If the WebContents associated with us showed an interstitial page in the |
81 // beginning, the teardown path might call WasShown() while |host_| is in | 81 // beginning, the teardown path might call WasShown() while |host_| is in |
82 // the process of destruction. Avoid calling WasShown below in this case. | 82 // the process of destruction. Avoid calling WasShown below in this case. |
83 // TODO(lazyboy): We shouldn't be showing interstitial pages in guests in the | 83 // TODO(lazyboy): We shouldn't be showing interstitial pages in guests in the |
84 // first place: http://crbug.com/273089. | 84 // first place: http://crbug.com/273089. |
85 // | 85 // |
86 // |guest_| is NULL during test. | 86 // |guest_| is NULL during test. |
87 if ((guest_ && guest_->is_in_destruction()) || !host_->is_hidden()) | 87 if ((guest_ && guest_->is_in_destruction()) || !host_->is_hidden()) |
88 return; | 88 return; |
| 89 // Make sure the size of this view matches the size of the WebContentsView. |
| 90 // The two sizes may fall out of sync if we switch RenderWidgetHostViews, |
| 91 // resize, and then switch page, as is the case with interstitial pages. |
| 92 // NOTE: |guest_| is NULL in unit tests. |
| 93 if (guest_) |
| 94 SetSize(guest_->web_contents()->GetViewBounds().size()); |
89 host_->WasShown(ui::LatencyInfo()); | 95 host_->WasShown(ui::LatencyInfo()); |
90 } | 96 } |
91 | 97 |
92 void RenderWidgetHostViewGuest::WasHidden() { | 98 void RenderWidgetHostViewGuest::WasHidden() { |
93 // |guest_| is NULL during test. | 99 // |guest_| is NULL during test. |
94 if ((guest_ && guest_->is_in_destruction()) || host_->is_hidden()) | 100 if ((guest_ && guest_->is_in_destruction()) || host_->is_hidden()) |
95 return; | 101 return; |
96 host_->WasHidden(); | 102 host_->WasHidden(); |
97 } | 103 } |
98 | 104 |
99 void RenderWidgetHostViewGuest::SetSize(const gfx::Size& size) { | 105 void RenderWidgetHostViewGuest::SetSize(const gfx::Size& size) { |
100 size_ = size; | 106 size_ = size; |
101 host_->WasResized(); | 107 host_->WasResized(); |
102 } | 108 } |
103 | 109 |
104 void RenderWidgetHostViewGuest::SetBounds(const gfx::Rect& rect) { | 110 void RenderWidgetHostViewGuest::SetBounds(const gfx::Rect& rect) { |
105 SetSize(rect.size()); | 111 SetSize(rect.size()); |
106 } | 112 } |
107 | 113 |
| 114 void RenderWidgetHostViewGuest::Focus() { |
| 115 // InterstitialPageImpl focuses views directly, so we place focus logic here. |
| 116 // InterstitialPages are not WebContents, and so BrowserPluginGuest does not |
| 117 // have direct access to the interstitial page's RenderWidgetHost. |
| 118 if (guest_) |
| 119 guest_->SetFocus(host_, true); |
| 120 } |
| 121 |
| 122 bool RenderWidgetHostViewGuest::HasFocus() const { |
| 123 if (!guest_) |
| 124 return false; |
| 125 return guest_->focused(); |
| 126 } |
| 127 |
108 #if defined(USE_AURA) | 128 #if defined(USE_AURA) |
109 void RenderWidgetHostViewGuest::ProcessAckedTouchEvent( | 129 void RenderWidgetHostViewGuest::ProcessAckedTouchEvent( |
110 const TouchEventWithLatencyInfo& touch, InputEventAckState ack_result) { | 130 const TouchEventWithLatencyInfo& touch, InputEventAckState ack_result) { |
111 // TODO(fsamuel): Currently we will only take this codepath if the guest has | 131 // TODO(fsamuel): Currently we will only take this codepath if the guest has |
112 // requested touch events. A better solution is to always forward touchpresses | 132 // requested touch events. A better solution is to always forward touchpresses |
113 // to the embedder process to target a BrowserPlugin, and then route all | 133 // to the embedder process to target a BrowserPlugin, and then route all |
114 // subsequent touch points of that touchdown to the appropriate guest until | 134 // subsequent touch points of that touchdown to the appropriate guest until |
115 // that touch point is released. | 135 // that touch point is released. |
116 ScopedVector<ui::TouchEvent> events; | 136 ScopedVector<ui::TouchEvent> events; |
117 if (!MakeUITouchEventsFromWebTouchEvents(touch, &events, LOCAL_COORDINATES)) | 137 if (!MakeUITouchEventsFromWebTouchEvents(touch, &events, LOCAL_COORDINATES)) |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 return gfx::NativeViewAccessible(); | 279 return gfx::NativeViewAccessible(); |
260 return rwhv->GetNativeViewAccessible(); | 280 return rwhv->GetNativeViewAccessible(); |
261 } | 281 } |
262 | 282 |
263 void RenderWidgetHostViewGuest::MovePluginWindows( | 283 void RenderWidgetHostViewGuest::MovePluginWindows( |
264 const std::vector<WebPluginGeometry>& moves) { | 284 const std::vector<WebPluginGeometry>& moves) { |
265 platform_view_->MovePluginWindows(moves); | 285 platform_view_->MovePluginWindows(moves); |
266 } | 286 } |
267 | 287 |
268 void RenderWidgetHostViewGuest::UpdateCursor(const WebCursor& cursor) { | 288 void RenderWidgetHostViewGuest::UpdateCursor(const WebCursor& cursor) { |
269 platform_view_->UpdateCursor(cursor); | 289 // InterstitialPages are not WebContents so we cannot intercept |
| 290 // ViewHostMsg_SetCursor for interstitial pages in BrowserPluginGuest. |
| 291 // All guest RenderViewHosts have RenderWidgetHostViewGuests however, |
| 292 // and so we will always hit this code path. |
| 293 if (!guest_) |
| 294 return; |
| 295 guest_->SendMessageToEmbedder( |
| 296 new BrowserPluginMsg_SetCursor(guest_->browser_plugin_instance_id(), |
| 297 cursor)); |
| 298 |
270 } | 299 } |
271 | 300 |
272 void RenderWidgetHostViewGuest::SetIsLoading(bool is_loading) { | 301 void RenderWidgetHostViewGuest::SetIsLoading(bool is_loading) { |
273 platform_view_->SetIsLoading(is_loading); | 302 platform_view_->SetIsLoading(is_loading); |
274 } | 303 } |
275 | 304 |
276 void RenderWidgetHostViewGuest::TextInputStateChanged( | 305 void RenderWidgetHostViewGuest::TextInputStateChanged( |
277 const ViewHostMsg_TextInputState_Params& params) { | 306 const ViewHostMsg_TextInputState_Params& params) { |
278 if (!guest_) | 307 if (!guest_) |
279 return; | 308 return; |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 | 585 |
557 if (event->type == blink::WebInputEvent::MouseWheel) { | 586 if (event->type == blink::WebInputEvent::MouseWheel) { |
558 host_->ForwardWheelEvent( | 587 host_->ForwardWheelEvent( |
559 *static_cast<const blink::WebMouseWheelEvent*>(event)); | 588 *static_cast<const blink::WebMouseWheelEvent*>(event)); |
560 return; | 589 return; |
561 } | 590 } |
562 | 591 |
563 if (blink::WebInputEvent::isKeyboardEventType(event->type)) { | 592 if (blink::WebInputEvent::isKeyboardEventType(event->type)) { |
564 if (!embedder->GetLastKeyboardEvent()) | 593 if (!embedder->GetLastKeyboardEvent()) |
565 return; | 594 return; |
566 NativeWebKeyboardEvent keyboard_event( | 595 NativeWebKeyboardEvent keyboard_event(*embedder->GetLastKeyboardEvent()); |
567 *embedder->GetLastKeyboardEvent()); | |
568 host_->ForwardKeyboardEvent(keyboard_event); | 596 host_->ForwardKeyboardEvent(keyboard_event); |
569 return; | 597 return; |
570 } | 598 } |
571 | 599 |
572 if (blink::WebInputEvent::isTouchEventType(event->type)) { | 600 if (blink::WebInputEvent::isTouchEventType(event->type)) { |
573 host_->ForwardTouchEventWithLatencyInfo( | 601 host_->ForwardTouchEventWithLatencyInfo( |
574 *static_cast<const blink::WebTouchEvent*>(event), | 602 *static_cast<const blink::WebTouchEvent*>(event), |
575 ui::LatencyInfo()); | 603 ui::LatencyInfo()); |
576 return; | 604 return; |
577 } | 605 } |
578 | 606 |
579 if (blink::WebInputEvent::isGestureEventType(event->type)) { | 607 if (blink::WebInputEvent::isGestureEventType(event->type)) { |
580 host_->ForwardGestureEvent( | 608 host_->ForwardGestureEvent( |
581 *static_cast<const blink::WebGestureEvent*>(event)); | 609 *static_cast<const blink::WebGestureEvent*>(event)); |
582 return; | 610 return; |
583 } | 611 } |
584 } | 612 } |
585 | 613 |
586 } // namespace content | 614 } // namespace content |
OLD | NEW |