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