Commit 417e0ced authored by tfarina@chromium.org's avatar tfarina@chromium.org

gtk: Fold bookmark_drag.* into bookmark_drag_drop_gtk.cc

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
parent d4b38787
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/gtk/bookmarks/bookmark_drag.h"
#include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h"
namespace {
const GdkDragAction kBookmarkDragAction =
static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE);
} // namespace
// static
void BookmarkDrag::BeginDrag(Profile* profile,
const std::vector<const BookmarkNode*>& nodes) {
new BookmarkDrag(profile, nodes);
}
BookmarkDrag::BookmarkDrag(Profile* profile,
const std::vector<const BookmarkNode*>& nodes)
: CustomDrag(NULL, GetCodeMask(false), kBookmarkDragAction),
profile_(profile),
nodes_(nodes) {}
BookmarkDrag::~BookmarkDrag() {}
void BookmarkDrag::OnDragDataGet(GtkWidget* widget,
GdkDragContext* context,
GtkSelectionData* selection_data,
guint target_type,
guint time) {
WriteBookmarksToSelection(nodes_, selection_data, target_type, profile_);
}
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_GTK_BOOKMARKS_BOOKMARK_DRAG_H_
#define CHROME_BROWSER_UI_GTK_BOOKMARKS_BOOKMARK_DRAG_H_
#include <vector>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "chrome/browser/ui/gtk/custom_drag.h"
class BookmarkNode;
class Profile;
// Encapsulates functionality for drags of one or more bookmarks.
class BookmarkDrag : public CustomDrag {
public:
// Creates a new BookmarkDrag, the lifetime of which is tied to the system
// drag.
static void BeginDrag(Profile* profile,
const std::vector<const BookmarkNode*>& nodes);
private:
BookmarkDrag(Profile* profile, const std::vector<const BookmarkNode*>& nodes);
virtual ~BookmarkDrag();
virtual void OnDragDataGet(GtkWidget* widget,
GdkDragContext* context,
GtkSelectionData* selection_data,
guint target_type,
guint time) OVERRIDE;
Profile* profile_;
std::vector<const BookmarkNode*> nodes_;
DISALLOW_COPY_AND_ASSIGN(BookmarkDrag);
};
#endif // CHROME_BROWSER_UI_GTK_BOOKMARKS_BOOKMARK_DRAG_H_
...@@ -4,7 +4,46 @@ ...@@ -4,7 +4,46 @@
#include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h" #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 { namespace chrome {
...@@ -13,7 +52,9 @@ void DragBookmarks(Profile* profile, ...@@ -13,7 +52,9 @@ void DragBookmarks(Profile* profile,
gfx::NativeView view) { gfx::NativeView view) {
DCHECK(!nodes.empty()); 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 } // namespace chrome
...@@ -109,11 +109,6 @@ void DownloadItemDrag::SetSource(GtkWidget* widget, ...@@ -109,11 +109,6 @@ void DownloadItemDrag::SetSource(GtkWidget* widget,
DragData::AttachToWidget(drag_data.Pass(), widget, icon); 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) DownloadItemDrag::DownloadItemDrag(const DownloadItem* item, gfx::Image* icon)
: CustomDrag(icon, kDownloadItemCodeMask, kDownloadItemDragAction), : CustomDrag(icon, kDownloadItemCodeMask, kDownloadItemDragAction),
drag_data_(new DragData(item)) {} drag_data_(new DragData(item)) {}
...@@ -131,5 +126,7 @@ void DownloadItemDrag::OnDragDataGet(GtkWidget* widget, ...@@ -131,5 +126,7 @@ void DownloadItemDrag::OnDragDataGet(GtkWidget* widget,
void DragDownloadItem(const content::DownloadItem* download, void DragDownloadItem(const content::DownloadItem* download,
gfx::Image* icon, gfx::Image* icon,
gfx::NativeView view) { 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);
} }
...@@ -17,6 +17,8 @@ class DownloadItem; ...@@ -17,6 +17,8 @@ class DownloadItem;
// Encapsulates functionality for drags of download items. // Encapsulates functionality for drags of download items.
class DownloadItemDrag : public CustomDrag { class DownloadItemDrag : public CustomDrag {
public: public:
DownloadItemDrag(const content::DownloadItem* item, gfx::Image* icon);
// Sets |widget| as a source for drags pertaining to |item|. No // Sets |widget| as a source for drags pertaining to |item|. No
// DownloadItemDrag object is created. // DownloadItemDrag object is created.
// It is safe to call this multiple times with different values of |icon|. // It is safe to call this multiple times with different values of |icon|.
...@@ -24,14 +26,9 @@ class DownloadItemDrag : public CustomDrag { ...@@ -24,14 +26,9 @@ class DownloadItemDrag : public CustomDrag {
const content::DownloadItem* item, const content::DownloadItem* item,
gfx::Image* icon); 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: private:
class DragData; class DragData;
DownloadItemDrag(const content::DownloadItem* item, gfx::Image* icon);
virtual ~DownloadItemDrag(); virtual ~DownloadItemDrag();
virtual void OnDragDataGet(GtkWidget* widget, virtual void OnDragDataGet(GtkWidget* widget,
......
...@@ -1053,8 +1053,6 @@ ...@@ -1053,8 +1053,6 @@
'browser/ui/gtk/bookmarks/bookmark_bar_instructions_gtk.h', 'browser/ui/gtk/bookmarks/bookmark_bar_instructions_gtk.h',
'browser/ui/gtk/bookmarks/bookmark_bubble_gtk.cc', 'browser/ui/gtk/bookmarks/bookmark_bubble_gtk.cc',
'browser/ui/gtk/bookmarks/bookmark_bubble_gtk.h', '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_drag_drop_gtk.cc',
'browser/ui/gtk/bookmarks/bookmark_editor_gtk.cc', 'browser/ui/gtk/bookmarks/bookmark_editor_gtk.cc',
'browser/ui/gtk/bookmarks/bookmark_editor_gtk.h', 'browser/ui/gtk/bookmarks/bookmark_editor_gtk.h',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment