web_drag_dest_delegate.h revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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
3// found in the LICENSE file.
4
5#ifndef CONTENT_PUBLIC_BROWSER_WEB_DRAG_DEST_DELEGATE_H_
6#define CONTENT_PUBLIC_BROWSER_WEB_DRAG_DEST_DELEGATE_H_
7
8#if defined(TOOLKIT_GTK)
9#include <gtk/gtk.h>
10#endif  // TOOLKIT_GTK
11
12#include "base/string16.h"
13
14#if defined(OS_WIN)
15#include "ui/base/dragdrop/drop_target_win.h"
16#endif
17
18class GURL;
19struct WebDropData;
20
21namespace ui {
22class OSExchangeData;
23}
24
25namespace content {
26
27class WebContents;
28
29// An optional delegate that listens for drags of bookmark data.
30class WebDragDestDelegate {
31 public:
32  // Announces that a drag has started. It's valid that a drag starts, along
33  // with over/enter/leave/drop notifications without receiving any bookmark
34  // data.
35  virtual void DragInitialize(WebContents* contents) = 0;
36
37  // Notifications of drag progression.
38#if defined(OS_WIN) && !defined(USE_AURA)
39  virtual void OnDragOver(IDataObject* data_object) = 0;
40  virtual void OnDragEnter(IDataObject* data_object) = 0;
41  virtual void OnDrop(IDataObject* data_object) = 0;
42  virtual void OnDragLeave(IDataObject* data_object) = 0;
43#else
44  virtual void OnDragOver() = 0;
45  virtual void OnDragEnter() = 0;
46  virtual void OnDrop() = 0;
47  // This should also clear any state kept about this drag.
48  virtual void OnDragLeave() = 0;
49#endif
50
51#if defined(TOOLKIT_GTK)
52  // Returns the bookmark atom type. GTK and Views return different values here.
53  virtual GdkAtom GetBookmarkTargetAtom() const = 0;
54
55  // Called when WebDragDestkGtk detects that there's bookmark data in a
56  // drag. Not every drag will trigger these.
57  virtual void OnReceiveDataFromGtk(GtkSelectionData* data) = 0;
58  virtual void OnReceiveProcessedData(const GURL& url,
59                                      const string16& title) = 0;
60#elif defined(USE_AURA)
61  // Called at the start of every drag to supply the data associated with the
62  // drag.
63  virtual void OnReceiveDragData(const ui::OSExchangeData& data) = 0;
64#elif defined(OS_WIN)
65  // Allows the delegate to set data on the drag. If it doesn't want to set
66  // data, it should return false.
67  virtual bool AddDragData(const WebDropData& drop_data,
68                           ui::OSExchangeData* data) = 0;
69#endif  // TOOLKIT_GTK
70
71  virtual ~WebDragDestDelegate() {}
72};
73
74}  // namespace content
75
76#endif  // CONTENT_PUBLIC_BROWSER_WEB_DRAG_DEST_DELEGATE_H_
77