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

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

Issue 2501213002: Drag-and-drop: dragSourceEndedAt, dragSourceSystemDragEnded (Closed)
Patch Set: Rebased. Added check for !GetWebWidget(). Created 4 years, 1 month 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_guest.h" 5 #include "content/browser/browser_plugin/browser_plugin_guest.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 // do not load external resources and so they load prior to attachment. 502 // do not load external resources and so they load prior to attachment.
503 // As a result, we must save all these IPCs until attachment and then 503 // As a result, we must save all these IPCs until attachment and then
504 // forward them so that the embedder gets a chance to see and process 504 // forward them so that the embedder gets a chance to see and process
505 // the load events. 505 // the load events.
506 pending_messages_.push_back(std::move(msg)); 506 pending_messages_.push_back(std::move(msg));
507 return; 507 return;
508 } 508 }
509 owner_web_contents_->Send(msg.release()); 509 owner_web_contents_->Send(msg.release());
510 } 510 }
511 511
512 void BrowserPluginGuest::DragSourceEndedAt(int client_x, int client_y, 512 void BrowserPluginGuest::DragSourceEndedAt(int client_x,
513 int screen_x, int screen_y, blink::WebDragOperation operation) { 513 int client_y,
514 web_contents()->GetRenderViewHost()->DragSourceEndedAt(client_x, client_y, 514 int screen_x,
515 screen_x, screen_y, operation); 515 int screen_y,
516 blink::WebDragOperation operation) {
517 // TODO(paulmeyer): This will need to target the correct specific
518 // RenderWidgetHost to work with OOPIFs. See crbug.com/647249.
519 web_contents()->GetRenderViewHost()->GetWidget()->DragSourceEndedAt(
520 client_x, client_y, screen_x, screen_y, operation);
516 seen_embedder_drag_source_ended_at_ = true; 521 seen_embedder_drag_source_ended_at_ = true;
517 EndSystemDragIfApplicable(); 522 EndSystemDragIfApplicable();
518 } 523 }
519 524
520 void BrowserPluginGuest::EndSystemDragIfApplicable() { 525 void BrowserPluginGuest::EndSystemDragIfApplicable() {
521 // Ideally we'd want either WebDragStatusDrop or WebDragStatusLeave... 526 // Ideally we'd want either WebDragStatusDrop or WebDragStatusLeave...
522 // Call guest RVH->DragSourceSystemDragEnded() correctly on the guest where 527 // Call guest RVH->DragSourceSystemDragEnded() correctly on the guest where
523 // the drag was initiated. Calling DragSourceSystemDragEnded() correctly 528 // the drag was initiated. Calling DragSourceSystemDragEnded() correctly
524 // means we call it in all cases and also make sure we only call it once. 529 // means we call it in all cases and also make sure we only call it once.
525 // This ensures that the input state of the guest stays correct, otherwise 530 // This ensures that the input state of the guest stays correct, otherwise
526 // it will go stale and won't accept any further input events. 531 // it will go stale and won't accept any further input events.
527 // 532 //
528 // The strategy used here to call DragSourceSystemDragEnded() on the RVH 533 // The strategy used here to call DragSourceSystemDragEnded() on the RVH
529 // is when the following conditions are met: 534 // is when the following conditions are met:
530 // a. Embedder has seen SystemDragEnded() 535 // a. Embedder has seen SystemDragEnded()
531 // b. Embedder has seen DragSourceEndedAt() 536 // b. Embedder has seen DragSourceEndedAt()
532 // c. The guest has seen some drag status update other than 537 // c. The guest has seen some drag status update other than
533 // WebDragStatusUnknown. Note that this step should ideally be done 538 // WebDragStatusUnknown. Note that this step should ideally be done
534 // differently: The guest has seen at least one of 539 // differently: The guest has seen at least one of
535 // {WebDragStatusOver, WebDragStatusDrop}. However, if a user drags 540 // {WebDragStatusOver, WebDragStatusDrop}. However, if a user drags
536 // a source quickly outside of <webview> bounds, then the 541 // a source quickly outside of <webview> bounds, then the
537 // BrowserPluginGuest never sees any of these drag status updates, 542 // BrowserPluginGuest never sees any of these drag status updates,
538 // there we just check whether we've seen any drag status update or 543 // there we just check whether we've seen any drag status update or
539 // not. 544 // not.
540 if (last_drag_status_ != blink::WebDragStatusOver && 545 if (last_drag_status_ != blink::WebDragStatusOver &&
541 seen_embedder_drag_source_ended_at_ && seen_embedder_system_drag_ended_) { 546 seen_embedder_drag_source_ended_at_ && seen_embedder_system_drag_ended_) {
542 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( 547 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>(
543 GetWebContents()->GetRenderViewHost()); 548 GetWebContents()->GetRenderViewHost());
544 guest_rvh->DragSourceSystemDragEnded(); 549 guest_rvh->GetWidget()->DragSourceSystemDragEnded();
545 last_drag_status_ = blink::WebDragStatusUnknown; 550 last_drag_status_ = blink::WebDragStatusUnknown;
546 seen_embedder_system_drag_ended_ = false; 551 seen_embedder_system_drag_ended_ = false;
547 seen_embedder_drag_source_ended_at_ = false; 552 seen_embedder_drag_source_ended_at_ = false;
548 ignore_dragged_url_ = true; 553 ignore_dragged_url_ = true;
549 } 554 }
550 } 555 }
551 556
552 void BrowserPluginGuest::EmbedderSystemDragEnded() { 557 void BrowserPluginGuest::EmbedderSystemDragEnded() {
553 seen_embedder_system_drag_ended_ = true; 558 seen_embedder_system_drag_ended_ = true;
554 EndSystemDragIfApplicable(); 559 EndSystemDragIfApplicable();
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 range, character_bounds); 1043 range, character_bounds);
1039 } 1044 }
1040 #endif 1045 #endif
1041 1046
1042 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { 1047 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) {
1043 if (delegate_) 1048 if (delegate_)
1044 delegate_->SetContextMenuPosition(position); 1049 delegate_->SetContextMenuPosition(position);
1045 } 1050 }
1046 1051
1047 } // namespace content 1052 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698