Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / gtk / bookmarks / bookmark_drag_drop_gtk.cc
blob926fad29bde182cd7624ae7a873cd5fde67507d0
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"
7 #include <vector>
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"
13 namespace {
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 {
20 public:
21 BookmarkDrag(Profile* profile, const std::vector<const BookmarkNode*>& nodes);
23 private:
24 virtual ~BookmarkDrag() {}
26 virtual void OnDragDataGet(GtkWidget* widget,
27 GdkDragContext* context,
28 GtkSelectionData* selection_data,
29 guint target_type,
30 guint time) OVERRIDE {
31 WriteBookmarksToSelection(nodes_, selection_data, target_type, profile_);
34 Profile* 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),
43 profile_(profile),
44 nodes_(nodes) {}
46 } // namespace
48 namespace chrome {
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
56 // system drag.
57 new BookmarkDrag(profile, nodes);
60 } // namespace chrome