• Christopher Cameron's avatar
    WebContentsViewMac: Mojo-ify dragging part of drag-drop · 02e5964f
    Christopher Cameron authored
    This modifies 3 parts of WebContentsViewMac and its friends.
    
    1: Initiation of a drag from web contents
    This action follows the following path
      * WebContentsViewMac::StartDragging is called, which calls
      * -[WebContentsViewCocoa startDragWithDropData...], which
      * Creates a WebDragSource (to store state for the drag) and calls
      * -[WebDragSource startDrag], which calls
      * -[NSWindow dragImage...]
    This doesn't work across processes because the WebContentsViewMac
    now exists in the browser process and the WebContentsViewCocoa
    exists in the app shim process. Fix this by adding the mojo method
    WebContentsNSViewBridge::StartDrag, which is called by
    WebContentsViewMac::StartDragging in the browser process, and makes
    the -[WebContentsViewCocoa startDragWithDropData...] when it is
    received in the app shim process.
    
    2: Completion of a drag via -[NSDraggingSource draggedImage...]
    This method takes the following path
      * -[WebContentsViewCocoa(NSDraggingSource) draggedImage...] is
        called by the system, which then calls
      * -[WebDragSource endDragAt:], which then calls
      * WebContentsImpl::SystemDragEnded and
        WebContentsImpl::DragSourceEndedAt
    This doesn't work across processes because the WebContentsViewCocoa
    is in the app shim process while the WebContentsImpl is in the browser
    process. Fix this by adding the mojo method
    WebContentsNSViewClient::EndDrag, which is called by WebDragSource
    in the app shim process, and makes the WebContentsImpl calls when
    it is received in the browser process.
    
    3: -[NSDraggingInfo namesOfPromisedFilesDroppedAtDestination] is called
    This method takes the following path
      * -[WebContentsViewCocoa(NSDraggingInfo) namesOfPromised...] calls
      * -[WebDragSource dragPromisedFileTo...], which creates a
      * DragDownloadFile, which uses the WebContentsImpl
    Same as the above, the WebContentsViewCocoa cannot access the
    WebContentsImpl, so we add a mojo method to bridge between the two.
    
    Move tracking of state for the drag (e.g, the source RenderWidgetHost)
    from WebDragSource to WebContentsViewMac.
    
    This eliminates the last need for accessing the WebContentsViewMac
    in WebContentsViewCocoa and WebDragSource, to remove the related
    member variables.
    
    Because the use of base::ThreadRestrictions::ScopedAllowIO is moved
    by this patch, update it to be ScopedAllowBlocking and add
    WebContentsViewMac as a friend of ScopedAllowBlocking.
    
    Bug: 898608
    Change-Id: I4e7f069e96902b7f0ef26e8579444be96b765a20
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1497543Reviewed-by: default avatardanakj <danakj@chromium.org>
    Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
    Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
    Commit-Queue: ccameron <ccameron@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#637841}
    02e5964f
web_contents_view_mac.h 9.07 KB