summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/web_contents_drag_source.h
blob: 168ce31a548b757ea1e0c1915fa4c927ae1e707b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_COCOA_WEB_CONTENTS_DRAG_SOURCE_H_
#define CHROME_BROWSER_COCOA_WEB_CONTENTS_DRAG_SOURCE_H_
#pragma once

#import <Cocoa/Cocoa.h>

#include "base/scoped_nsobject.h"
#include "chrome/browser/bookmarks/bookmark_drag_data.h"

@class TabContentsViewCocoa;

// A class that handles tracking and event processing for a drag and drop
// originating from the content area.  Subclasses should implement
// fillClipboard and dragImage.
@interface WebContentsDragSource : NSObject {
 @private
  // Our tab. Weak reference (owns or co-owns us).
  TabContentsViewCocoa* contentsView_;

  // Our pasteboard.
  scoped_nsobject<NSPasteboard> pasteboard_;

  // A mask of the allowed drag operations.
  NSDragOperation dragOperationMask_;
}

// Initialize a DragDataSource object for a drag (originating on the given
// contentsView and with the given dropData and pboard). Fill the pasteboard
// with data types appropriate for dropData.
- (id)initWithContentsView:(TabContentsViewCocoa*)contentsView
                pasteboard:(NSPasteboard*)pboard
         dragOperationMask:(NSDragOperation)dragOperationMask;

// Creates the drag image.  Implemented by the subclass.
- (NSImage*)dragImage;

// Put the data being dragged onto the pasteboard.  Implemented by the
// subclass.
- (void)fillPasteboard;

// Returns a mask of the allowed drag operations.
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal;

// Start the drag (on the originally provided contentsView); can do this right
// after -initWithContentsView:....
- (void)startDrag;

// End the drag and clear the pasteboard; hook up to
// -draggedImage:endedAt:operation:.
- (void)endDragAt:(NSPoint)screenPoint
        operation:(NSDragOperation)operation;

// Drag moved; hook up to -draggedImage:movedTo:.
- (void)moveDragTo:(NSPoint)screenPoint;

@end

#endif  // CHROME_BROWSER_COCOA_WEB_CONTENTS_DRAG_SOURCE_H_