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

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: Addressed comments 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) {
200 guest_dragging_over_ = guest->AsWeakPtr();
201 }
202
203 void BrowserPluginEmbedder::DragLeftGuest(BrowserPluginGuest* guest) {
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_.get() == guest) {
207 guest_dragging_over_.reset();
208 }
209 }
210
211 void BrowserPluginEmbedder::StartDrag(BrowserPluginGuest* guest) {
212 guest_started_drag_ = guest->AsWeakPtr();
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_AllocateInstanceID, 260 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_AllocateInstanceID,
244 OnAllocateInstanceID) 261 OnAllocateInstanceID)
245 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CreateGuest, 262 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CreateGuest,
246 OnCreateGuest) 263 OnCreateGuest)
247 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginAtPositionResponse, 264 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginAtPositionResponse,
248 OnPluginAtPositionResponse) 265 OnPluginAtPositionResponse)
249 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, 266 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed,
250 OnPluginDestroyed) 267 OnPluginDestroyed)
251 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_BuffersSwappedACK, 268 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_BuffersSwappedACK,
252 OnSwapBuffersACK) 269 OnSwapBuffersACK)
270 IPC_MESSAGE_HANDLER_GENERIC(DragHostMsg_UpdateDragCursor,
271 OnUpdateDragCursor(&handled));
272 IPC_MESSAGE_HANDLER_GENERIC(DragHostMsg_DragStopped,
273 OnDragStopped(message, &handled));
253 IPC_MESSAGE_UNHANDLED(handled = false) 274 IPC_MESSAGE_UNHANDLED(handled = false)
254 IPC_END_MESSAGE_MAP() 275 IPC_END_MESSAGE_MAP()
255 return handled; 276 return handled;
256 } 277 }
257 278
279 void BrowserPluginEmbedder::OnDragStopped(const IPC::Message& message,
280 bool* handled) {
281 if (guest_started_drag_.get())
282 *handled = guest_started_drag_->OnMessageReceived(message);
283 }
284
285 void BrowserPluginEmbedder::OnUpdateDragCursor(bool* handled) {
286 *handled = guest_dragging_over_.get();
287 }
288
258 void BrowserPluginEmbedder::Observe(int type, 289 void BrowserPluginEmbedder::Observe(int type,
259 const NotificationSource& source, 290 const NotificationSource& source,
260 const NotificationDetails& details) { 291 const NotificationDetails& details) {
261 switch (type) { 292 switch (type) {
262 case NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED: { 293 case NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED: {
263 bool visible = *Details<bool>(details).ptr(); 294 bool visible = *Details<bool>(details).ptr();
264 WebContentsVisibilityChanged(visible); 295 WebContentsVisibilityChanged(visible);
265 break; 296 break;
266 } 297 }
267 default: 298 default:
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 uint32 sync_point) { 396 uint32 sync_point) {
366 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; 397 AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
367 ack_params.mailbox_name = mailbox_name; 398 ack_params.mailbox_name = mailbox_name;
368 ack_params.sync_point = sync_point; 399 ack_params.sync_point = sync_point;
369 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, 400 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id,
370 gpu_host_id, 401 gpu_host_id,
371 ack_params); 402 ack_params);
372 } 403 }
373 404
374 } // namespace content 405 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698