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/browser_plugin/browser_plugin_embedder.h" | 5 #include "content/browser/browser_plugin/browser_plugin_embedder.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.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/browser_plugin/browser_plugin_host_factory.h" | 10 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" |
| 11 #include "content/browser/renderer_host/render_view_host_impl.h" | 11 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 12 #include "content/browser/web_contents/web_contents_impl.h" | 12 #include "content/browser/web_contents/web_contents_impl.h" |
| 13 #include "content/common/browser_plugin_messages.h" | 13 #include "content/common/browser_plugin_messages.h" |
| 14 #include "content/common/drag_messages.h" | |
| 14 #include "content/common/gpu/gpu_messages.h" | 15 #include "content/common/gpu/gpu_messages.h" |
| 15 #include "content/public/browser/notification_details.h" | 16 #include "content/public/browser/notification_details.h" |
| 16 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 17 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
| 18 #include "content/public/browser/notification_types.h" | 19 #include "content/public/browser/notification_types.h" |
| 19 #include "content/public/browser/user_metrics.h" | 20 #include "content/public/browser/user_metrics.h" |
| 20 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
| 21 #include "content/public/common/result_codes.h" | 22 #include "content/public/common/result_codes.h" |
| 22 #include "content/public/common/url_constants.h" | 23 #include "content/public/common/url_constants.h" |
| 23 #include "net/base/escape.h" | 24 #include "net/base/escape.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 | 189 |
| 189 BrowserPluginGuest* BrowserPluginEmbedder::GetGuestByInstanceID( | 190 BrowserPluginGuest* BrowserPluginEmbedder::GetGuestByInstanceID( |
| 190 int instance_id) const { | 191 int instance_id) const { |
| 191 ContainerInstanceMap::const_iterator it = | 192 ContainerInstanceMap::const_iterator it = |
| 192 guest_web_contents_by_instance_id_.find(instance_id); | 193 guest_web_contents_by_instance_id_.find(instance_id); |
| 193 if (it != guest_web_contents_by_instance_id_.end()) | 194 if (it != guest_web_contents_by_instance_id_.end()) |
| 194 return static_cast<WebContentsImpl*>(it->second)->GetBrowserPluginGuest(); | 195 return static_cast<WebContentsImpl*>(it->second)->GetBrowserPluginGuest(); |
| 195 return NULL; | 196 return NULL; |
| 196 } | 197 } |
| 197 | 198 |
| 199 BrowserPluginGuest* BrowserPluginEmbedder::GetDraggingGuest() const { | |
| 200 ContainerInstanceMap::const_iterator it = | |
| 201 guest_web_contents_by_instance_id_.begin(); | |
| 202 for (; it != guest_web_contents_by_instance_id_.end(); ++it) { | |
| 203 if (static_cast<WebContentsImpl*>( | |
| 204 it->second)->GetBrowserPluginGuest()->dragging()) | |
|
Fady Samuel
2013/02/01 15:54:55
If we're effectively only allowing one guest to be
mthiesse1
2013/02/01 16:02:58
We need a way to identify which guest is the one t
mthiesse
2013/02/01 16:53:44
Done.
| |
| 205 return static_cast<WebContentsImpl*>( | |
| 206 it->second)->GetBrowserPluginGuest(); | |
| 207 } | |
| 208 return NULL; | |
| 209 } | |
| 210 | |
| 211 bool BrowserPluginEmbedder::IsDragOverGuest() const { | |
| 212 ContainerInstanceMap::const_iterator it = | |
| 213 guest_web_contents_by_instance_id_.begin(); | |
| 214 for (; it != guest_web_contents_by_instance_id_.end(); ++it) { | |
| 215 if (static_cast<WebContentsImpl*>( | |
| 216 it->second)->GetBrowserPluginGuest()->drag_over()) | |
| 217 return true; | |
| 218 } | |
| 219 return false; | |
| 220 } | |
| 221 | |
| 198 void BrowserPluginEmbedder::DestroyGuestByInstanceID(int instance_id) { | 222 void BrowserPluginEmbedder::DestroyGuestByInstanceID(int instance_id) { |
| 199 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); | 223 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); |
| 200 if (guest) { | 224 if (guest) { |
| 201 WebContents* guest_web_contents = guest->GetWebContents(); | 225 WebContents* guest_web_contents = guest->GetWebContents(); |
| 202 | 226 |
| 203 // Destroy the guest's web_contents. | 227 // Destroy the guest's web_contents. |
| 204 delete guest_web_contents; | 228 delete guest_web_contents; |
| 205 guest_web_contents_by_instance_id_.erase(instance_id); | 229 guest_web_contents_by_instance_id_.erase(instance_id); |
| 206 } | 230 } |
| 207 } | 231 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 221 | 245 |
| 222 void BrowserPluginEmbedder::RenderViewDeleted( | 246 void BrowserPluginEmbedder::RenderViewDeleted( |
| 223 RenderViewHost* render_view_host) { | 247 RenderViewHost* render_view_host) { |
| 224 } | 248 } |
| 225 | 249 |
| 226 void BrowserPluginEmbedder::RenderViewGone(base::TerminationStatus status) { | 250 void BrowserPluginEmbedder::RenderViewGone(base::TerminationStatus status) { |
| 227 CleanUp(); | 251 CleanUp(); |
| 228 } | 252 } |
| 229 | 253 |
| 230 bool BrowserPluginEmbedder::OnMessageReceived(const IPC::Message& message) { | 254 bool BrowserPluginEmbedder::OnMessageReceived(const IPC::Message& message) { |
| 255 if (message.type() == DragHostMsg_DragStopped::ID) { | |
| 256 BrowserPluginGuest* guest = GetDraggingGuest(); | |
| 257 if (guest) | |
| 258 return guest->OnMessageReceived(message); | |
| 259 } | |
| 260 if (message.type() == DragHostMsg_UpdateDragCursor::ID){ | |
| 261 // If the guest is being dragged over we want to mark this as handled so | |
| 262 // that we don't update the cursor twice, once by the guest, and once by the | |
| 263 // embedder (and have the cursor flicker between droppable and | |
| 264 // non-droppable). | |
| 265 return IsDragOverGuest(); | |
| 266 } | |
| 231 if (ShouldForwardToBrowserPluginGuest(message)) { | 267 if (ShouldForwardToBrowserPluginGuest(message)) { |
| 232 int instance_id = 0; | 268 int instance_id = 0; |
| 233 // All allowed messages must have instance_id as their first parameter. | 269 // All allowed messages must have instance_id as their first parameter. |
| 234 PickleIterator iter(message); | 270 PickleIterator iter(message); |
| 235 bool success = iter.ReadInt(&instance_id); | 271 bool success = iter.ReadInt(&instance_id); |
| 236 DCHECK(success); | 272 DCHECK(success); |
| 237 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); | 273 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); |
| 238 if (guest && guest->OnMessageReceivedFromEmbedder(message)) | 274 if (guest && guest->OnMessageReceivedFromEmbedder(message)) |
| 239 return true; | 275 return true; |
| 240 } | 276 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 uint32 sync_point) { | 401 uint32 sync_point) { |
| 366 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | 402 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; |
| 367 ack_params.mailbox_name = mailbox_name; | 403 ack_params.mailbox_name = mailbox_name; |
| 368 ack_params.sync_point = sync_point; | 404 ack_params.sync_point = sync_point; |
| 369 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, | 405 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, |
| 370 gpu_host_id, | 406 gpu_host_id, |
| 371 ack_params); | 407 ack_params); |
| 372 } | 408 } |
| 373 | 409 |
| 374 } // namespace content | 410 } // namespace content |
| OLD | NEW |