Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: content/browser/browser_plugin/browser_plugin_embedder.cc

Issue 12086095: Fixed drag and drop into and out of Browser Plugin. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Moved state to embedder. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 void BrowserPluginEmbedder::DragEnteredGuest(BrowserPluginGuest* guest) {
Fady Samuel 2013/02/01 16:59:53 SetDragEnteredGuest I'm a bit concerned about life
mthiesse 2013/02/07 15:28:55 Done.
200 guest_dragging_over = guest;
201 }
202
203 void BrowserPluginEmbedder::DragLeftGuest(BrowserPluginGuest* guest) {
Fady Samuel 2013/02/01 16:59:53 SetDragLeftGuest. I'm a bit concerned about lifeti
mthiesse 2013/02/07 15:28:55 Done.
204 // Avoid race conditions in switching between guests being hovered over by
205 // only un-setting if the caller is marked as the guest being dragged over.
206 if (guest_dragging_over == guest) {
207 guest_dragging_over = NULL;
208 }
209 }
210
211 void BrowserPluginEmbedder::StartDrag(BrowserPluginGuest* guest) {
212 guest_started_drag = guest;
213 }
214
198 void BrowserPluginEmbedder::DestroyGuestByInstanceID(int instance_id) { 215 void BrowserPluginEmbedder::DestroyGuestByInstanceID(int instance_id) {
199 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); 216 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id);
200 if (guest) { 217 if (guest) {
201 WebContents* guest_web_contents = guest->GetWebContents(); 218 WebContents* guest_web_contents = guest->GetWebContents();
202 219
203 // Destroy the guest's web_contents. 220 // Destroy the guest's web_contents.
204 delete guest_web_contents; 221 delete guest_web_contents;
205 guest_web_contents_by_instance_id_.erase(instance_id); 222 guest_web_contents_by_instance_id_.erase(instance_id);
206 } 223 }
207 } 224 }
(...skipping 13 matching lines...) Expand all
221 238
222 void BrowserPluginEmbedder::RenderViewDeleted( 239 void BrowserPluginEmbedder::RenderViewDeleted(
223 RenderViewHost* render_view_host) { 240 RenderViewHost* render_view_host) {
224 } 241 }
225 242
226 void BrowserPluginEmbedder::RenderViewGone(base::TerminationStatus status) { 243 void BrowserPluginEmbedder::RenderViewGone(base::TerminationStatus status) {
227 CleanUp(); 244 CleanUp();
228 } 245 }
229 246
230 bool BrowserPluginEmbedder::OnMessageReceived(const IPC::Message& message) { 247 bool BrowserPluginEmbedder::OnMessageReceived(const IPC::Message& message) {
248 if (message.type() == DragHostMsg_DragStopped::ID) {
249 if (guest_started_drag)
Fady Samuel 2013/02/01 16:59:53 Please move this and UpdateDragCursor to separate
mthiesse 2013/02/07 15:28:55 Done.
250 return guest_started_drag->OnMessageReceived(message);
251 }
252 if (message.type() == DragHostMsg_UpdateDragCursor::ID){
253 // If the guest is being dragged over we want to mark this as handled so
254 // that we don't update the cursor twice, once by the guest, and once by the
255 // embedder (and have the cursor flicker between droppable and
256 // non-droppable).
257 return (guest_dragging_over);
258 }
231 if (ShouldForwardToBrowserPluginGuest(message)) { 259 if (ShouldForwardToBrowserPluginGuest(message)) {
232 int instance_id = 0; 260 int instance_id = 0;
233 // All allowed messages must have instance_id as their first parameter. 261 // All allowed messages must have instance_id as their first parameter.
234 PickleIterator iter(message); 262 PickleIterator iter(message);
235 bool success = iter.ReadInt(&instance_id); 263 bool success = iter.ReadInt(&instance_id);
236 DCHECK(success); 264 DCHECK(success);
237 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); 265 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id);
238 if (guest && guest->OnMessageReceivedFromEmbedder(message)) 266 if (guest && guest->OnMessageReceivedFromEmbedder(message))
239 return true; 267 return true;
240 } 268 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 uint32 sync_point) { 393 uint32 sync_point) {
366 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; 394 AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
367 ack_params.mailbox_name = mailbox_name; 395 ack_params.mailbox_name = mailbox_name;
368 ack_params.sync_point = sync_point; 396 ack_params.sync_point = sync_point;
369 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, 397 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id,
370 gpu_host_id, 398 gpu_host_id,
371 ack_params); 399 ack_params);
372 } 400 }
373 401
374 } // namespace content 402 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_embedder.h ('k') | content/browser/browser_plugin/browser_plugin_guest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698