| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h" | |
| 6 | |
| 7 #include <vector> | |
| 8 | |
| 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" | |
| 12 #include "ui/base/dragdrop/drag_drop_types.h" | |
| 13 | |
| 14 namespace { | |
| 15 | |
| 16 const GdkDragAction kBookmarkDragAction = | |
| 17 static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE); | |
| 18 | |
| 19 // Encapsulates functionality for drags of one or more bookmarks. | |
| 20 class BookmarkDrag : public CustomDrag { | |
| 21 public: | |
| 22 BookmarkDrag(Profile* profile, const std::vector<const BookmarkNode*>& nodes); | |
| 23 | |
| 24 private: | |
| 25 virtual ~BookmarkDrag() {} | |
| 26 | |
| 27 virtual void OnDragDataGet(GtkWidget* widget, | |
| 28 GdkDragContext* context, | |
| 29 GtkSelectionData* selection_data, | |
| 30 guint target_type, | |
| 31 guint time) OVERRIDE { | |
| 32 WriteBookmarksToSelection(nodes_, selection_data, target_type, profile_); | |
| 33 } | |
| 34 | |
| 35 Profile* profile_; | |
| 36 std::vector<const BookmarkNode*> nodes_; | |
| 37 | |
| 38 DISALLOW_COPY_AND_ASSIGN(BookmarkDrag); | |
| 39 }; | |
| 40 | |
| 41 BookmarkDrag::BookmarkDrag(Profile* profile, | |
| 42 const std::vector<const BookmarkNode*>& nodes) | |
| 43 : CustomDrag(NULL, GetCodeMask(false), kBookmarkDragAction), | |
| 44 profile_(profile), | |
| 45 nodes_(nodes) {} | |
| 46 | |
| 47 } // namespace | |
| 48 | |
| 49 namespace chrome { | |
| 50 | |
| 51 void DragBookmarks(Profile* profile, | |
| 52 const std::vector<const BookmarkNode*>& nodes, | |
| 53 gfx::NativeView view, | |
| 54 ui::DragDropTypes::DragEventSource source) { | |
| 55 DCHECK(!nodes.empty()); | |
| 56 | |
| 57 // This starts the drag process, the lifetime of this object is tied to the | |
| 58 // system drag. | |
| 59 new BookmarkDrag(profile, nodes); | |
| 60 } | |
| 61 | |
| 62 } // namespace chrome | |
| OLD | NEW |