Index: content/browser/browser_plugin/browser_plugin_embedder.cc |
diff --git a/content/browser/browser_plugin/browser_plugin_embedder.cc b/content/browser/browser_plugin/browser_plugin_embedder.cc |
index 324fee769c7794d5896f2713a8647e0d706fde84..d652ef5f398587576e8c10c281a963805422f79f 100644 |
--- a/content/browser/browser_plugin/browser_plugin_embedder.cc |
+++ b/content/browser/browser_plugin/browser_plugin_embedder.cc |
@@ -28,6 +28,8 @@ namespace content { |
BrowserPluginEmbedder::BrowserPluginEmbedder(WebContentsImpl* web_contents) |
: WebContentsObserver(web_contents), |
+ seen_system_drag_ended_(false), |
+ seen_drag_source_ended_at_(false), |
Fady Samuel
2014/08/21 23:36:31
Can we do this with one flag?
lazyboy
2014/08/22 00:03:27
Done.
|
weak_ptr_factory_(this) { |
} |
@@ -54,6 +56,8 @@ void BrowserPluginEmbedder::DragLeftGuest(BrowserPluginGuest* guest) { |
void BrowserPluginEmbedder::StartDrag(BrowserPluginGuest* guest) { |
guest_started_drag_ = guest->AsWeakPtr(); |
+ seen_system_drag_ended_ = false; |
+ seen_drag_source_ended_at_ = false; |
} |
WebContentsImpl* BrowserPluginEmbedder::GetWebContents() const { |
@@ -65,6 +69,18 @@ BrowserPluginEmbedder::GetBrowserPluginGuestManager() const { |
return GetWebContents()->GetBrowserContext()->GetGuestManager(); |
} |
+void BrowserPluginEmbedder::ClearGuestDragStateIfApplicable() { |
+ // The order at which we observe SystemDragEnded() and DragSourceEndedAt() is |
+ // platform dependent. |
+ // In OSX, we see SystemDragEnded() first, where in aura, we see |
+ // DragSourceEndedAt() first. For this reason, we check if both methods were |
+ // called before resetting |guest_started_drag_|. |
+ if (guest_started_drag_ && seen_drag_source_ended_at_ && |
+ seen_system_drag_ended_) { |
+ guest_started_drag_.reset(); |
+ } |
+} |
+ |
bool BrowserPluginEmbedder::DidSendScreenRectsCallback( |
WebContents* guest_web_contents) { |
static_cast<RenderViewHostImpl*>( |
@@ -93,22 +109,25 @@ bool BrowserPluginEmbedder::OnMessageReceived(const IPC::Message& message) { |
void BrowserPluginEmbedder::DragSourceEndedAt(int client_x, int client_y, |
int screen_x, int screen_y, blink::WebDragOperation operation) { |
- if (guest_started_drag_.get()) { |
+ seen_drag_source_ended_at_ = true; |
+ if (guest_started_drag_) { |
gfx::Point guest_offset = |
guest_started_drag_->GetScreenCoordinates(gfx::Point()); |
guest_started_drag_->DragSourceEndedAt(client_x - guest_offset.x(), |
client_y - guest_offset.y(), screen_x, screen_y, operation); |
} |
+ ClearGuestDragStateIfApplicable(); |
} |
void BrowserPluginEmbedder::SystemDragEnded() { |
// When the embedder's drag/drop operation ends, we need to pass the message |
// to the guest that initiated the drag/drop operation. This will ensure that |
// the guest's RVH state is reset properly. |
- if (guest_started_drag_.get()) |
+ seen_system_drag_ended_ = true; |
+ if (guest_started_drag_) |
guest_started_drag_->EndSystemDrag(); |
- guest_started_drag_.reset(); |
guest_dragging_over_.reset(); |
+ ClearGuestDragStateIfApplicable(); |
} |
void BrowserPluginEmbedder::OnUpdateDragCursor(bool* handled) { |