From 417e0ced4be60b082087bd1e0edd695608d10b5c Mon Sep 17 00:00:00 2001 From: "tfarina@chromium.org" Date: Sun, 8 Sep 2013 23:46:12 +0000 Subject: [PATCH] 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 --- .../browser/ui/gtk/bookmarks/bookmark_drag.cc | 36 --------------- .../browser/ui/gtk/bookmarks/bookmark_drag.h | 41 ----------------- .../gtk/bookmarks/bookmark_drag_drop_gtk.cc | 45 ++++++++++++++++++- .../ui/gtk/download/download_item_drag.cc | 9 ++-- .../ui/gtk/download/download_item_drag.h | 7 +-- chrome/chrome_browser_ui.gypi | 2 - 6 files changed, 48 insertions(+), 92 deletions(-) delete mode 100644 chrome/browser/ui/gtk/bookmarks/bookmark_drag.cc delete mode 100644 chrome/browser/ui/gtk/bookmarks/bookmark_drag.h diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_drag.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_drag.cc deleted file mode 100644 index 44f806da40d1b5..00000000000000 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_drag.cc +++ /dev/null @@ -1,36 +0,0 @@ -// 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(GDK_ACTION_COPY | GDK_ACTION_MOVE); - -} // namespace - -// static -void BookmarkDrag::BeginDrag(Profile* profile, - const std::vector& nodes) { - new BookmarkDrag(profile, nodes); -} - -BookmarkDrag::BookmarkDrag(Profile* profile, - const std::vector& 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_); -} diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_drag.h b/chrome/browser/ui/gtk/bookmarks/bookmark_drag.h deleted file mode 100644 index 0ca1f848713af5..00000000000000 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_drag.h +++ /dev/null @@ -1,41 +0,0 @@ -// 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 - -#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& nodes); - - private: - BookmarkDrag(Profile* profile, const std::vector& nodes); - virtual ~BookmarkDrag(); - - virtual void OnDragDataGet(GtkWidget* widget, - GdkDragContext* context, - GtkSelectionData* selection_data, - guint target_type, - guint time) OVERRIDE; - - Profile* profile_; - std::vector nodes_; - - DISALLOW_COPY_AND_ASSIGN(BookmarkDrag); -}; - -#endif // CHROME_BROWSER_UI_GTK_BOOKMARKS_BOOKMARK_DRAG_H_ diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_drag_drop_gtk.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_drag_drop_gtk.cc index 03b769dfebae9a..926fad29bde182 100644 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_drag_drop_gtk.cc +++ b/chrome/browser/ui/gtk/bookmarks/bookmark_drag_drop_gtk.cc @@ -4,7 +4,46 @@ #include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h" -#include "chrome/browser/ui/gtk/bookmarks/bookmark_drag.h" +#include + +#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(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& 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 nodes_; + + DISALLOW_COPY_AND_ASSIGN(BookmarkDrag); +}; + +BookmarkDrag::BookmarkDrag(Profile* profile, + const std::vector& nodes) + : CustomDrag(NULL, GetCodeMask(false), kBookmarkDragAction), + profile_(profile), + nodes_(nodes) {} + +} // namespace namespace chrome { @@ -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 diff --git a/chrome/browser/ui/gtk/download/download_item_drag.cc b/chrome/browser/ui/gtk/download/download_item_drag.cc index 1e5575f0ba462e..74ddd42c331ae4 100644 --- a/chrome/browser/ui/gtk/download/download_item_drag.cc +++ b/chrome/browser/ui/gtk/download/download_item_drag.cc @@ -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)) {} @@ -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); } diff --git a/chrome/browser/ui/gtk/download/download_item_drag.h b/chrome/browser/ui/gtk/download/download_item_drag.h index 9e626c70e418e7..703088c123c296 100644 --- a/chrome/browser/ui/gtk/download/download_item_drag.h +++ b/chrome/browser/ui/gtk/download/download_item_drag.h @@ -17,6 +17,8 @@ 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|. @@ -24,14 +26,9 @@ class DownloadItemDrag : public CustomDrag { 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, diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index 4807e0884a9d7b..98c24f985e877b 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -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',