<webview> fix drag and drop issues.

This CL makes sure following scenarios work properly on mac/linux/cros/win:
1. Dragging and dropping within a <webview> works
2. Dragging from one <webview> to another <webview> works.
3. Dragging from one <webview> and cancelling it by releasing mouse
  on non-droppable target works where there can be 3 cases:
    a. the release is done within the same <webview>
    b. the release is done within a different <webview>
    c. the release is done outside of any <webview>, i.e. the embedder.

The key fix here is to call guest RVH->DragSourceSystemDragEnded() correctly
on the guest where the drag was initiated. Calling DragSourceSystemDragEnded()
correctly means we call it in all cases and also make sure we only call it once.
This ensures that the input state of the guest stays correct, otherwise it will go
stale and won't accept any further input events.

The strategy I've used to call DragSourceSystemDragEnded() on a guest RVH when
the following conditions are met:
a. Embedder has seen SystemDragEnded()
b. Embedder has seen DragSourceEndedAt()
c. The guest has seen some drag status update other than WebDragStatusUnknown.

Note that c) should ideally be done differently: The guest has seen at least one of
{WebDragStatusOver, WebDragStatusDrop}. However, if a user drags a source
quickly outside of <webview> bounds, then the BrowserPluginGuest never sees
any of these drag status updates.

BUG=450175
Test=
1) On webview based signin page, try dragging some text from the signin page to user name field, it should now work.
2) Load a chrome app with two <webview>s
e.g. https://github.com/lazyboy/chromium/tree/master/tests/chrome-apps/webview_input
Now see there are two <webview>s, one red and one blue, perform following and expect things to work correctly:

a. select and drag text from red webview, e.g. "this is guest", to an tex box within the same webview, expect it to insert that text to the <input> box.
b. now do the same as a), but drag it to the text box within the second/blue <webview>, expect that text to be inserted.
c. select and drag text from red <webview>, drag it but stay within the red <webview> and release it somewhere where there's no text box, expect the drag operation to be cancelled properly, make sure you can still type in the text box of that <webview>.
d. do the same as c) but release it somewhere in the blue <webview> where there's no input box, expect the same, make sure you can type in both <webview>'s input box.
e. do the same as c), but release it somewhere in the app where there's no input box (white background), expect the same and make sure you can type in both <webview>'s input box.

Review URL: https://codereview.chromium.org/885803002

Cr-Commit-Position: refs/heads/master@{#314356}
diff --git a/content/browser/browser_plugin/browser_plugin_guest.h b/content/browser/browser_plugin/browser_plugin_guest.h
index 0941782..874e6ce3 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.h
+++ b/content/browser/browser_plugin/browser_plugin_guest.h
@@ -198,7 +198,8 @@
       int screen_y, blink::WebDragOperation operation);
 
   // Called when the drag started by this guest ends at an OS-level.
-  void EndSystemDrag();
+  void EmbedderSystemDragEnded();
+  void EndSystemDragIfApplicable();
 
   void RespondToPermissionRequest(int request_id,
                                   bool should_allow,
@@ -387,6 +388,12 @@
   // The is the routing ID for a swapped out RenderView for the guest
   // WebContents in the embedder's process.
   int guest_proxy_routing_id_;
+  // Last seen state of drag status update.
+  blink::WebDragStatus last_drag_status_;
+  // Whether or not our embedder has seen a SystemDragEnded() call.
+  bool seen_embedder_system_drag_ended_;
+  // Whether or not our embedder has seen a DragSourceEndedAt() call.
+  bool seen_embedder_drag_source_ended_at_;
 
   // Guests generate frames and send a CompositorFrameSwapped (CFS) message
   // indicating the next frame is ready to be positioned and composited.