Skip to content

Commit

Permalink
gtk: Fold bookmark_drag.* into bookmark_drag_drop_gtk.cc
Browse files Browse the repository at this point in the history
BUG=None
TEST=none, no functional changes.
R=erg@chromium.org
TBR=thestig # for gyp change.

Review URL: https://chromiumcodereview.appspot.com/23743003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221962 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
tfarina@chromium.org committed Sep 8, 2013
1 parent d4b3878 commit 417e0ce
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 92 deletions.
36 changes: 0 additions & 36 deletions chrome/browser/ui/gtk/bookmarks/bookmark_drag.cc

This file was deleted.

41 changes: 0 additions & 41 deletions chrome/browser/ui/gtk/bookmarks/bookmark_drag.h

This file was deleted.

45 changes: 43 additions & 2 deletions chrome/browser/ui/gtk/bookmarks/bookmark_drag_drop_gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,46 @@

#include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h"

#include "chrome/browser/ui/gtk/bookmarks/bookmark_drag.h"
#include <vector>

#include "base/compiler_specific.h"
#include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h"
#include "chrome/browser/ui/gtk/custom_drag.h"

namespace {

const GdkDragAction kBookmarkDragAction =
static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE);

// Encapsulates functionality for drags of one or more bookmarks.
class BookmarkDrag : public CustomDrag {
public:
BookmarkDrag(Profile* profile, const std::vector<const BookmarkNode*>& nodes);

private:
virtual ~BookmarkDrag() {}

virtual void OnDragDataGet(GtkWidget* widget,
GdkDragContext* context,
GtkSelectionData* selection_data,
guint target_type,
guint time) OVERRIDE {
WriteBookmarksToSelection(nodes_, selection_data, target_type, profile_);
}

Profile* profile_;
std::vector<const BookmarkNode*> nodes_;

DISALLOW_COPY_AND_ASSIGN(BookmarkDrag);
};

BookmarkDrag::BookmarkDrag(Profile* profile,
const std::vector<const BookmarkNode*>& nodes)
: CustomDrag(NULL, GetCodeMask(false), kBookmarkDragAction),
profile_(profile),
nodes_(nodes) {}

} // namespace

namespace chrome {

Expand All @@ -13,7 +52,9 @@ void DragBookmarks(Profile* profile,
gfx::NativeView view) {
DCHECK(!nodes.empty());

BookmarkDrag::BeginDrag(profile, nodes);
// This starts the drag process, the lifetime of this object is tied to the
// system drag.
new BookmarkDrag(profile, nodes);
}

} // namespace chrome
9 changes: 3 additions & 6 deletions chrome/browser/ui/gtk/download/download_item_drag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ void DownloadItemDrag::SetSource(GtkWidget* widget,
DragData::AttachToWidget(drag_data.Pass(), widget, icon);
}

// static
void DownloadItemDrag::BeginDrag(const DownloadItem* item, gfx::Image* icon) {
new DownloadItemDrag(item, icon);
}

DownloadItemDrag::DownloadItemDrag(const DownloadItem* item, gfx::Image* icon)
: CustomDrag(icon, kDownloadItemCodeMask, kDownloadItemDragAction),
drag_data_(new DragData(item)) {}
Expand All @@ -131,5 +126,7 @@ void DownloadItemDrag::OnDragDataGet(GtkWidget* widget,
void DragDownloadItem(const content::DownloadItem* download,
gfx::Image* icon,
gfx::NativeView view) {
DownloadItemDrag::BeginDrag(download, icon);
// This starts the drag process, the lifetime of this object is tied to the
// system drag.
new DownloadItemDrag(download, icon);
}
7 changes: 2 additions & 5 deletions chrome/browser/ui/gtk/download/download_item_drag.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,18 @@ class DownloadItem;
// Encapsulates functionality for drags of download items.
class DownloadItemDrag : public CustomDrag {
public:
DownloadItemDrag(const content::DownloadItem* item, gfx::Image* icon);

// Sets |widget| as a source for drags pertaining to |item|. No
// DownloadItemDrag object is created.
// It is safe to call this multiple times with different values of |icon|.
static void SetSource(GtkWidget* widget,
const content::DownloadItem* item,
gfx::Image* icon);

// Creates a new DownloadItemDrag, the lifetime of which is tied to the
// system drag.
static void BeginDrag(const content::DownloadItem* item, gfx::Image* icon);

private:
class DragData;

DownloadItemDrag(const content::DownloadItem* item, gfx::Image* icon);
virtual ~DownloadItemDrag();

virtual void OnDragDataGet(GtkWidget* widget,
Expand Down
2 changes: 0 additions & 2 deletions chrome/chrome_browser_ui.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -1053,8 +1053,6 @@
'browser/ui/gtk/bookmarks/bookmark_bar_instructions_gtk.h',
'browser/ui/gtk/bookmarks/bookmark_bubble_gtk.cc',
'browser/ui/gtk/bookmarks/bookmark_bubble_gtk.h',
'browser/ui/gtk/bookmarks/bookmark_drag.cc',
'browser/ui/gtk/bookmarks/bookmark_drag.h',
'browser/ui/gtk/bookmarks/bookmark_drag_drop_gtk.cc',
'browser/ui/gtk/bookmarks/bookmark_editor_gtk.cc',
'browser/ui/gtk/bookmarks/bookmark_editor_gtk.h',
Expand Down

0 comments on commit 417e0ce

Please sign in to comment.