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/web_contents/web_contents_view_guest.h" | 5 #include "content/browser/web_contents/web_contents_view_guest.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "content/browser/browser_plugin/browser_plugin_embedder.h" | 8 #include "content/browser/browser_plugin/browser_plugin_embedder.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/interstitial_page_impl.h" | 10 #include "content/browser/frame_host/interstitial_page_impl.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // access embedder_web_contents(). Therefore, we do it here. | 69 // access embedder_web_contents(). Therefore, we do it here. |
70 parent_view->GetNativeView()->AddChild(platform_view_->GetNativeView()); | 70 parent_view->GetNativeView()->AddChild(platform_view_->GetNativeView()); |
71 #endif // defined(USE_AURA) | 71 #endif // defined(USE_AURA) |
72 } | 72 } |
73 | 73 |
74 ContextMenuParams WebContentsViewGuest::ConvertContextMenuParams( | 74 ContextMenuParams WebContentsViewGuest::ConvertContextMenuParams( |
75 const ContextMenuParams& params) const { | 75 const ContextMenuParams& params) const { |
76 // We need to add |offset| of the guest from the embedder to position the | 76 // We need to add |offset| of the guest from the embedder to position the |
77 // menu properly. | 77 // menu properly. |
78 gfx::Rect embedder_bounds; | 78 gfx::Rect embedder_bounds; |
79 guest_->embedder_web_contents()->GetView()->GetContainerBounds( | 79 static_cast<WebContentsImpl*>(guest_->embedder_web_contents())->GetView()-> |
80 &embedder_bounds); | 80 GetContainerBounds(&embedder_bounds); |
81 gfx::Rect guest_bounds; | 81 gfx::Rect guest_bounds; |
82 GetContainerBounds(&guest_bounds); | 82 GetContainerBounds(&guest_bounds); |
83 | 83 |
84 gfx::Vector2d offset = guest_bounds.origin() - embedder_bounds.origin(); | 84 gfx::Vector2d offset = guest_bounds.origin() - embedder_bounds.origin(); |
85 ContextMenuParams params_in_embedder = params; | 85 ContextMenuParams params_in_embedder = params; |
86 params_in_embedder.x += offset.x(); | 86 params_in_embedder.x += offset.x(); |
87 params_in_embedder.y += offset.y(); | 87 params_in_embedder.y += offset.y(); |
88 return params_in_embedder; | 88 return params_in_embedder; |
89 } | 89 } |
90 | 90 |
91 void WebContentsViewGuest::GetContainerBounds(gfx::Rect* out) const { | 91 void WebContentsViewGuest::GetContainerBounds(gfx::Rect* out) const { |
92 // We need embedder container's bounds to calculate our bounds. | 92 // We need embedder container's bounds to calculate our bounds. |
93 guest_->embedder_web_contents()->GetView()->GetContainerBounds(out); | 93 static_cast<WebContentsImpl*>(guest_->embedder_web_contents())->GetView()-> |
| 94 GetContainerBounds(out); |
94 gfx::Point guest_coordinates = guest_->GetScreenCoordinates(gfx::Point()); | 95 gfx::Point guest_coordinates = guest_->GetScreenCoordinates(gfx::Point()); |
95 out->Offset(guest_coordinates.x(), guest_coordinates.y()); | 96 out->Offset(guest_coordinates.x(), guest_coordinates.y()); |
96 out->set_size(size_); | 97 out->set_size(size_); |
97 } | 98 } |
98 | 99 |
99 void WebContentsViewGuest::SizeContents(const gfx::Size& size) { | 100 void WebContentsViewGuest::SizeContents(const gfx::Size& size) { |
100 size_ = size; | 101 size_ = size; |
101 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); | 102 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); |
102 if (rwhv) | 103 if (rwhv) |
103 rwhv->SetSize(size); | 104 rwhv->SetSize(size); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 platform_view_delegate_view_->ShowContextMenu( | 224 platform_view_delegate_view_->ShowContextMenu( |
224 render_frame_host, ConvertContextMenuParams(params)); | 225 render_frame_host, ConvertContextMenuParams(params)); |
225 } | 226 } |
226 | 227 |
227 void WebContentsViewGuest::StartDragging( | 228 void WebContentsViewGuest::StartDragging( |
228 const DropData& drop_data, | 229 const DropData& drop_data, |
229 WebDragOperationsMask ops, | 230 WebDragOperationsMask ops, |
230 const gfx::ImageSkia& image, | 231 const gfx::ImageSkia& image, |
231 const gfx::Vector2d& image_offset, | 232 const gfx::Vector2d& image_offset, |
232 const DragEventSourceInfo& event_info) { | 233 const DragEventSourceInfo& event_info) { |
233 WebContentsImpl* embedder_web_contents = guest_->embedder_web_contents(); | 234 WebContentsImpl* embedder_web_contents = static_cast<WebContentsImpl*>( |
| 235 guest_->embedder_web_contents()); |
234 embedder_web_contents->GetBrowserPluginEmbedder()->StartDrag(guest_); | 236 embedder_web_contents->GetBrowserPluginEmbedder()->StartDrag(guest_); |
235 RenderViewHostImpl* embedder_render_view_host = | 237 RenderViewHostImpl* embedder_render_view_host = |
236 static_cast<RenderViewHostImpl*>( | 238 static_cast<RenderViewHostImpl*>( |
237 embedder_web_contents->GetRenderViewHost()); | 239 embedder_web_contents->GetRenderViewHost()); |
238 CHECK(embedder_render_view_host); | 240 CHECK(embedder_render_view_host); |
239 RenderViewHostDelegateView* view = | 241 RenderViewHostDelegateView* view = |
240 embedder_render_view_host->GetDelegate()->GetDelegateView(); | 242 embedder_render_view_host->GetDelegate()->GetDelegateView(); |
241 if (view) { | 243 if (view) { |
242 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.StartDrag")); | 244 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.StartDrag")); |
243 view->StartDragging(drop_data, ops, image, image_offset, event_info); | 245 view->StartDragging(drop_data, ops, image, image_offset, event_info); |
244 } else { | 246 } else { |
245 embedder_web_contents->SystemDragEnded(); | 247 embedder_web_contents->SystemDragEnded(); |
246 } | 248 } |
247 } | 249 } |
248 | 250 |
249 } // namespace content | 251 } // namespace content |
OLD | NEW |