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

Unified Diff: content/browser/browser_plugin/browser_plugin_embedder.cc

Issue 499493002: dragend fix for mac <webview>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments from Fady Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_embedder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f0769379aeddec6de15d44b80787cdf443dad7e6 100644
--- a/content/browser/browser_plugin/browser_plugin_embedder.cc
+++ b/content/browser/browser_plugin/browser_plugin_embedder.cc
@@ -28,6 +28,7 @@ namespace content {
BrowserPluginEmbedder::BrowserPluginEmbedder(WebContentsImpl* web_contents)
: WebContentsObserver(web_contents),
+ guest_drag_ending_(false),
weak_ptr_factory_(this) {
}
@@ -54,6 +55,7 @@ void BrowserPluginEmbedder::DragLeftGuest(BrowserPluginGuest* guest) {
void BrowserPluginEmbedder::StartDrag(BrowserPluginGuest* guest) {
guest_started_drag_ = guest->AsWeakPtr();
+ guest_drag_ending_ = false;
}
WebContentsImpl* BrowserPluginEmbedder::GetWebContents() const {
@@ -65,6 +67,20 @@ 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_drag_ending_) {
+ if (guest_started_drag_)
+ guest_started_drag_.reset();
+ } else {
+ guest_drag_ending_ = true;
+ }
+}
+
bool BrowserPluginEmbedder::DidSendScreenRectsCallback(
WebContents* guest_web_contents) {
static_cast<RenderViewHostImpl*>(
@@ -93,22 +109,23 @@ 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()) {
+ 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())
+ if (guest_started_drag_)
guest_started_drag_->EndSystemDrag();
- guest_started_drag_.reset();
guest_dragging_over_.reset();
+ ClearGuestDragStateIfApplicable();
}
void BrowserPluginEmbedder::OnUpdateDragCursor(bool* handled) {
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_embedder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698