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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); | 53 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); |
54 if (!rwhv) | 54 if (!rwhv) |
55 return NULL; | 55 return NULL; |
56 return rwhv->GetNativeView(); | 56 return rwhv->GetNativeView(); |
57 } | 57 } |
58 | 58 |
59 gfx::NativeWindow WebContentsViewGuest::GetTopLevelNativeWindow() const { | 59 gfx::NativeWindow WebContentsViewGuest::GetTopLevelNativeWindow() const { |
60 return guest_->embedder_web_contents()->GetTopLevelNativeWindow(); | 60 return guest_->embedder_web_contents()->GetTopLevelNativeWindow(); |
61 } | 61 } |
62 | 62 |
63 void WebContentsViewGuest::OnGuestInitialized(WebContentsView* parent_view) { | 63 void WebContentsViewGuest::OnGuestAttached(WebContentsView* parent_view) { |
64 #if defined(USE_AURA) | 64 #if defined(USE_AURA) |
65 // In aura, ScreenPositionClient doesn't work properly if we do | 65 // In aura, ScreenPositionClient doesn't work properly if we do |
66 // not have the native view associated with this WebContentsViewGuest in the | 66 // not have the native view associated with this WebContentsViewGuest in the |
67 // view hierarchy. We add this view as embedder's child here. | 67 // view hierarchy. We add this view as embedder's child here. |
68 // This would go in WebContentsViewGuest::CreateView, but that is too early to | 68 // This would go in WebContentsViewGuest::CreateView, but that is too early to |
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 void WebContentsViewGuest::OnGuestDetached(WebContentsView* old_parent_view) { |
| 75 #if defined(USE_AURA) |
| 76 old_parent_view->GetNativeView()->RemoveChild( |
| 77 platform_view_->GetNativeView()); |
| 78 #endif // defined(USE_AURA) |
| 79 } |
| 80 |
74 ContextMenuParams WebContentsViewGuest::ConvertContextMenuParams( | 81 ContextMenuParams WebContentsViewGuest::ConvertContextMenuParams( |
75 const ContextMenuParams& params) const { | 82 const ContextMenuParams& params) const { |
76 // We need to add |offset| of the guest from the embedder to position the | 83 // We need to add |offset| of the guest from the embedder to position the |
77 // menu properly. | 84 // menu properly. |
78 gfx::Rect embedder_bounds; | 85 gfx::Rect embedder_bounds; |
79 guest_->embedder_web_contents()->GetView()->GetContainerBounds( | 86 guest_->embedder_web_contents()->GetView()->GetContainerBounds( |
80 &embedder_bounds); | 87 &embedder_bounds); |
81 gfx::Rect guest_bounds; | 88 gfx::Rect guest_bounds; |
82 GetContainerBounds(&guest_bounds); | 89 GetContainerBounds(&guest_bounds); |
83 | 90 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 // view twice), we check for the RVH Factory, which will be set when we're | 143 // view twice), we check for the RVH Factory, which will be set when we're |
137 // making special ones (which go along with the special views). | 144 // making special ones (which go along with the special views). |
138 DCHECK(RenderViewHostFactory::has_factory()); | 145 DCHECK(RenderViewHostFactory::has_factory()); |
139 return static_cast<RenderWidgetHostViewBase*>( | 146 return static_cast<RenderWidgetHostViewBase*>( |
140 render_widget_host->GetView()); | 147 render_widget_host->GetView()); |
141 } | 148 } |
142 | 149 |
143 RenderWidgetHostViewBase* platform_widget = | 150 RenderWidgetHostViewBase* platform_widget = |
144 platform_view_->CreateViewForWidget(render_widget_host); | 151 platform_view_->CreateViewForWidget(render_widget_host); |
145 | 152 |
146 RenderWidgetHostViewBase* view = new RenderWidgetHostViewGuest( | 153 return new RenderWidgetHostViewGuest(render_widget_host, |
147 render_widget_host, | 154 guest_, |
148 guest_, | 155 platform_widget); |
149 platform_widget); | |
150 | |
151 return view; | |
152 } | 156 } |
153 | 157 |
154 RenderWidgetHostViewBase* WebContentsViewGuest::CreateViewForPopupWidget( | 158 RenderWidgetHostViewBase* WebContentsViewGuest::CreateViewForPopupWidget( |
155 RenderWidgetHost* render_widget_host) { | 159 RenderWidgetHost* render_widget_host) { |
156 return platform_view_->CreateViewForPopupWidget(render_widget_host); | 160 return platform_view_->CreateViewForPopupWidget(render_widget_host); |
157 } | 161 } |
158 | 162 |
159 void WebContentsViewGuest::SetPageTitle(const base::string16& title) { | 163 void WebContentsViewGuest::SetPageTitle(const base::string16& title) { |
160 } | 164 } |
161 | 165 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 embedder_render_view_host->GetDelegate()->GetDelegateView(); | 244 embedder_render_view_host->GetDelegate()->GetDelegateView(); |
241 if (view) { | 245 if (view) { |
242 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.StartDrag")); | 246 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.StartDrag")); |
243 view->StartDragging(drop_data, ops, image, image_offset, event_info); | 247 view->StartDragging(drop_data, ops, image, image_offset, event_info); |
244 } else { | 248 } else { |
245 embedder_web_contents->SystemDragEnded(); | 249 embedder_web_contents->SystemDragEnded(); |
246 } | 250 } |
247 } | 251 } |
248 | 252 |
249 } // namespace content | 253 } // namespace content |
OLD | NEW |