1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/download/drag_download_item.h"
7 #include "chrome/browser/ui/cocoa/download/download_util_mac.h"
8 #include "content/public/browser/download_item.h"
9 #include "ui/gfx/image/image.h"
11 void DragDownloadItem(const content::DownloadItem* download,
13 gfx::NativeView view) {
14 DCHECK_EQ(content::DownloadItem::COMPLETE, download->GetState());
15 NSPasteboard* pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
16 download_util::AddFileToPasteboard(pasteboard, download->GetTargetFilePath());
18 // Synthesize a drag event, since we don't have access to the actual event
19 // that initiated a drag (possibly consumed by the Web UI, for example).
20 NSPoint position = [[view window] mouseLocationOutsideOfEventStream];
21 NSTimeInterval eventTime = [[NSApp currentEvent] timestamp];
22 NSEvent* dragEvent = [NSEvent mouseEventWithType:NSLeftMouseDragged
24 modifierFlags:NSLeftMouseDraggedMask
26 windowNumber:[[view window] windowNumber]
32 // Run the drag operation.
33 [[view window] dragImage:icon->ToNSImage()