1 // Copyright 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.
5 #include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h"
9 #include "base/compiler_specific.h"
10 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h"
11 #include "chrome/browser/ui/gtk/custom_drag.h"
15 const GdkDragAction kBookmarkDragAction
=
16 static_cast<GdkDragAction
>(GDK_ACTION_COPY
| GDK_ACTION_MOVE
);
18 // Encapsulates functionality for drags of one or more bookmarks.
19 class BookmarkDrag
: public CustomDrag
{
21 BookmarkDrag(Profile
* profile
, const std::vector
<const BookmarkNode
*>& nodes
);
24 virtual ~BookmarkDrag() {}
26 virtual void OnDragDataGet(GtkWidget
* widget
,
27 GdkDragContext
* context
,
28 GtkSelectionData
* selection_data
,
30 guint time
) OVERRIDE
{
31 WriteBookmarksToSelection(nodes_
, selection_data
, target_type
, profile_
);
35 std::vector
<const BookmarkNode
*> nodes_
;
37 DISALLOW_COPY_AND_ASSIGN(BookmarkDrag
);
40 BookmarkDrag::BookmarkDrag(Profile
* profile
,
41 const std::vector
<const BookmarkNode
*>& nodes
)
42 : CustomDrag(NULL
, GetCodeMask(false), kBookmarkDragAction
),
50 void DragBookmarks(Profile
* profile
,
51 const std::vector
<const BookmarkNode
*>& nodes
,
52 gfx::NativeView view
) {
53 DCHECK(!nodes
.empty());
55 // This starts the drag process, the lifetime of this object is tied to the
57 new BookmarkDrag(profile
, nodes
);