diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-19 20:22:00 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-19 20:22:00 +0000 |
commit | 02bae0f37e6b09992f3b81792735010f28b9542e (patch) | |
tree | b33485cba2d3f3049d7e801957759b268aa9257e /chrome/browser/ui | |
parent | cfe1d619ca7f651c509ce4a4b52540fd573fbcd3 (diff) | |
download | chromium_src-02bae0f37e6b09992f3b81792735010f28b9542e.zip chromium_src-02bae0f37e6b09992f3b81792735010f28b9542e.tar.gz chromium_src-02bae0f37e6b09992f3b81792735010f28b9542e.tar.bz2 |
Move more dnd related files to ui/base
BUG=none
TEST=none
TBR=brettw
Review URL: http://codereview.chromium.org/6250014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71828 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
17 files changed, 125 insertions, 136 deletions
diff --git a/chrome/browser/ui/gtk/bookmark_bar_gtk.cc b/chrome/browser/ui/gtk/bookmark_bar_gtk.cc index 237b009..e74a873 100644 --- a/chrome/browser/ui/gtk/bookmark_bar_gtk.cc +++ b/chrome/browser/ui/gtk/bookmark_bar_gtk.cc @@ -6,7 +6,6 @@ #include <vector> -#include "app/gtk_dnd_util.h" #include "app/resource_bundle.h" #include "base/utf_string_conversions.h" #include "chrome/browser/bookmarks/bookmark_node_data.h" @@ -46,6 +45,7 @@ #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "ui/base/animation/slide_animation.h" +#include "ui/base/dragdrop/gtk_dnd_util.h" namespace { @@ -76,11 +76,11 @@ const int kOtherBookmarksPaddingHorizontal = 2; const int kOtherBookmarksPaddingVertical = 1; // The targets accepted by the toolbar and folder buttons for DnD. -const int kDestTargetList[] = { gtk_dnd_util::CHROME_BOOKMARK_ITEM, - gtk_dnd_util::CHROME_NAMED_URL, - gtk_dnd_util::TEXT_URI_LIST, - gtk_dnd_util::NETSCAPE_URL, - gtk_dnd_util::TEXT_PLAIN, -1 }; +const int kDestTargetList[] = { ui::CHROME_BOOKMARK_ITEM, + ui::CHROME_NAMED_URL, + ui::TEXT_URI_LIST, + ui::NETSCAPE_URL, + ui::TEXT_PLAIN, -1 }; // Acceptable drag actions for the bookmark bar drag destinations. const GdkDragAction kDragAction = @@ -212,7 +212,7 @@ void BookmarkBarGtk::Init(Profile* profile) { gtk_drag_dest_set(instructions_, GtkDestDefaults(GTK_DEST_DEFAULT_DROP | GTK_DEST_DEFAULT_MOTION), NULL, 0, kDragAction); - gtk_dnd_util::SetDestTargetList(instructions_, kDestTargetList); + ui::SetDestTargetList(instructions_, kDestTargetList); g_signal_connect(instructions_, "drag-data-received", G_CALLBACK(&OnDragReceivedThunk), this); @@ -239,7 +239,7 @@ void BookmarkBarGtk::Init(Profile* profile) { gtk_drag_dest_set(bookmark_toolbar_.get(), GTK_DEST_DEFAULT_DROP, NULL, 0, kDragAction); - gtk_dnd_util::SetDestTargetList(bookmark_toolbar_.get(), kDestTargetList); + ui::SetDestTargetList(bookmark_toolbar_.get(), kDestTargetList); g_signal_connect(bookmark_toolbar_.get(), "drag-motion", G_CALLBACK(&OnToolbarDragMotionThunk), this); g_signal_connect(bookmark_toolbar_.get(), "drag-leave", @@ -840,7 +840,7 @@ GtkWidget* BookmarkBarGtk::CreateBookmarkButton(const BookmarkNode* node) { gtk_drag_source_set(button, GDK_BUTTON1_MASK, NULL, 0, static_cast<GdkDragAction>(GDK_ACTION_MOVE | GDK_ACTION_COPY)); int target_mask = bookmark_utils::GetCodeMask(node->is_folder()); - gtk_dnd_util::SetSourceTargetListFromCodeMask(button, target_mask); + ui::SetSourceTargetListFromCodeMask(button, target_mask); g_signal_connect(button, "drag-begin", G_CALLBACK(&OnButtonDragBeginThunk), this); g_signal_connect(button, "drag-end", @@ -889,7 +889,7 @@ void BookmarkBarGtk::ConnectFolderButtonEvents(GtkWidget* widget, NULL, 0, kDragAction); - gtk_dnd_util::SetDestTargetList(widget, kDestTargetList); + ui::SetDestTargetList(widget, kDestTargetList); g_signal_connect(widget, "drag-data-received", G_CALLBACK(&OnDragReceivedThunk), this); if (is_tool_item) { @@ -1116,8 +1116,7 @@ gboolean BookmarkBarGtk::ItemDraggedOverToolbar(GdkDragContext* context, gtk_toolbar_set_drop_highlight_item(GTK_TOOLBAR(bookmark_toolbar_.get()), GTK_TOOL_ITEM(toolbar_drop_item_), index); - if (target_type == - gtk_dnd_util::GetAtomForTarget(gtk_dnd_util::CHROME_BOOKMARK_ITEM)) { + if (target_type == ui::GetAtomForTarget(ui::CHROME_BOOKMARK_ITEM)) { gdk_drag_status(context, GDK_ACTION_MOVE, time); } else { gdk_drag_status(context, GDK_ACTION_COPY, time); @@ -1163,8 +1162,7 @@ gboolean BookmarkBarGtk::OnFolderDragMotion(GtkWidget* button, // Drag is over middle of folder. gtk_drag_highlight(button); - if (target_type == - gtk_dnd_util::GetAtomForTarget(gtk_dnd_util::CHROME_BOOKMARK_ITEM)) { + if (target_type == ui::GetAtomForTarget(ui::CHROME_BOOKMARK_ITEM)) { gdk_drag_status(context, GDK_ACTION_MOVE, time); } else { gdk_drag_status(context, GDK_ACTION_COPY, time); @@ -1237,7 +1235,7 @@ void BookmarkBarGtk::OnDragReceived(GtkWidget* widget, } switch (target_type) { - case gtk_dnd_util::CHROME_BOOKMARK_ITEM: { + case ui::CHROME_BOOKMARK_ITEM: { std::vector<const BookmarkNode*> nodes = bookmark_utils::GetNodesFromSelection(context, selection_data, target_type, @@ -1253,25 +1251,25 @@ void BookmarkBarGtk::OnDragReceived(GtkWidget* widget, break; } - case gtk_dnd_util::CHROME_NAMED_URL: { + case ui::CHROME_NAMED_URL: { dnd_success = bookmark_utils::CreateNewBookmarkFromNamedUrl( selection_data, model_, dest_node, index); break; } - case gtk_dnd_util::TEXT_URI_LIST: { + case ui::TEXT_URI_LIST: { dnd_success = bookmark_utils::CreateNewBookmarksFromURIList( selection_data, model_, dest_node, index); break; } - case gtk_dnd_util::NETSCAPE_URL: { + case ui::NETSCAPE_URL: { dnd_success = bookmark_utils::CreateNewBookmarkFromNetscapeURL( selection_data, model_, dest_node, index); break; } - case gtk_dnd_util::TEXT_PLAIN: { + case ui::TEXT_PLAIN: { guchar* text = gtk_selection_data_get_text(selection_data); if (!text) break; diff --git a/chrome/browser/ui/gtk/bookmark_menu_controller_gtk.cc b/chrome/browser/ui/gtk/bookmark_menu_controller_gtk.cc index 6b5b687..b90cd17 100644 --- a/chrome/browser/ui/gtk/bookmark_menu_controller_gtk.cc +++ b/chrome/browser/ui/gtk/bookmark_menu_controller_gtk.cc @@ -6,7 +6,6 @@ #include <gtk/gtk.h> -#include "app/gtk_dnd_util.h" #include "app/l10n_util.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" @@ -23,6 +22,7 @@ #include "grit/app_resources.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" +#include "ui/base/dragdrop/gtk_dnd_util.h" #include "webkit/glue/window_open_disposition.h" namespace { @@ -178,10 +178,10 @@ void BookmarkMenuController::BuildMenu(const BookmarkNode* parent, gtk_drag_source_set(menu_item, GDK_BUTTON1_MASK, NULL, 0, static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_LINK)); - int target_mask = gtk_dnd_util::CHROME_BOOKMARK_ITEM; + int target_mask = ui::CHROME_BOOKMARK_ITEM; if (node->is_url()) - target_mask |= gtk_dnd_util::TEXT_URI_LIST | gtk_dnd_util::NETSCAPE_URL; - gtk_dnd_util::SetSourceTargetListFromCodeMask(menu_item, target_mask); + target_mask |= ui::TEXT_URI_LIST | ui::NETSCAPE_URL; + ui::SetSourceTargetListFromCodeMask(menu_item, target_mask); signals_.Connect(menu_item, "drag-begin", G_CALLBACK(OnMenuItemDragBeginThunk), this); signals_.Connect(menu_item, "drag-end", diff --git a/chrome/browser/ui/gtk/bookmark_utils_gtk.cc b/chrome/browser/ui/gtk/bookmark_utils_gtk.cc index 15ad4ad..1c2bc1c 100644 --- a/chrome/browser/ui/gtk/bookmark_utils_gtk.cc +++ b/chrome/browser/ui/gtk/bookmark_utils_gtk.cc @@ -4,7 +4,6 @@ #include "chrome/browser/ui/gtk/bookmark_utils_gtk.h" -#include "app/gtk_dnd_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/pickle.h" @@ -21,6 +20,7 @@ #include "gfx/canvas_skia_paint.h" #include "gfx/font.h" #include "gfx/gtk_util.h" +#include "ui/base/dragdrop/gtk_dnd_util.h" namespace { @@ -294,11 +294,11 @@ void SetButtonTextColors(GtkWidget* label, GtkThemeProvider* provider) { // DnD-related ----------------------------------------------------------------- int GetCodeMask(bool folder) { - int rv = gtk_dnd_util::CHROME_BOOKMARK_ITEM; + int rv = ui::CHROME_BOOKMARK_ITEM; if (!folder) { - rv |= gtk_dnd_util::TEXT_URI_LIST | - gtk_dnd_util::TEXT_PLAIN | - gtk_dnd_util::NETSCAPE_URL; + rv |= ui::TEXT_URI_LIST | + ui::TEXT_PLAIN | + ui::NETSCAPE_URL; } return rv; } @@ -318,7 +318,7 @@ void WriteBookmarksToSelection(const std::vector<const BookmarkNode*>& nodes, guint target_type, Profile* profile) { switch (target_type) { - case gtk_dnd_util::CHROME_BOOKMARK_ITEM: { + case ui::CHROME_BOOKMARK_ITEM: { BookmarkNodeData data(nodes); Pickle pickle; data.WriteToPickle(profile, &pickle); @@ -329,7 +329,7 @@ void WriteBookmarksToSelection(const std::vector<const BookmarkNode*>& nodes, pickle.size()); break; } - case gtk_dnd_util::NETSCAPE_URL: { + case ui::NETSCAPE_URL: { // _NETSCAPE_URL format is URL + \n + title. std::string utf8_text = nodes[0]->GetURL().spec() + "\n" + UTF16ToUTF8(nodes[0]->GetTitle()); @@ -340,7 +340,7 @@ void WriteBookmarksToSelection(const std::vector<const BookmarkNode*>& nodes, utf8_text.length()); break; } - case gtk_dnd_util::TEXT_URI_LIST: { + case ui::TEXT_URI_LIST: { gchar** uris = reinterpret_cast<gchar**>(malloc(sizeof(gchar*) * (nodes.size() + 1))); for (size_t i = 0; i < nodes.size(); ++i) { @@ -358,7 +358,7 @@ void WriteBookmarksToSelection(const std::vector<const BookmarkNode*>& nodes, free(uris); break; } - case gtk_dnd_util::TEXT_PLAIN: { + case ui::TEXT_PLAIN: { gtk_selection_data_set_text(selection_data, nodes[0]->GetURL().spec().c_str(), -1); break; @@ -386,7 +386,7 @@ std::vector<const BookmarkNode*> GetNodesFromSelection( *delete_selection_data = TRUE; switch (target_type) { - case gtk_dnd_util::CHROME_BOOKMARK_ITEM: { + case ui::CHROME_BOOKMARK_ITEM: { if (dnd_success) *dnd_success = TRUE; Pickle pickle(reinterpret_cast<char*>(selection_data->data), @@ -408,7 +408,7 @@ bool CreateNewBookmarkFromNamedUrl(GtkSelectionData* selection_data, BookmarkModel* model, const BookmarkNode* parent, int idx) { GURL url; string16 title; - if (!gtk_dnd_util::ExtractNamedURL(selection_data, &url, &title)) + if (!ui::ExtractNamedURL(selection_data, &url, &title)) return false; model->AddURL(parent, idx, title, url); @@ -418,7 +418,7 @@ bool CreateNewBookmarkFromNamedUrl(GtkSelectionData* selection_data, bool CreateNewBookmarksFromURIList(GtkSelectionData* selection_data, BookmarkModel* model, const BookmarkNode* parent, int idx) { std::vector<GURL> urls; - gtk_dnd_util::ExtractURIList(selection_data, &urls); + ui::ExtractURIList(selection_data, &urls); for (size_t i = 0; i < urls.size(); ++i) { std::string title = GetNameForURL(urls[i]); model->AddURL(parent, idx++, UTF8ToUTF16(title), urls[i]); @@ -430,7 +430,7 @@ bool CreateNewBookmarkFromNetscapeURL(GtkSelectionData* selection_data, BookmarkModel* model, const BookmarkNode* parent, int idx) { GURL url; string16 title; - if (!gtk_dnd_util::ExtractNetscapeURL(selection_data, &url, &title)) + if (!ui::ExtractNetscapeURL(selection_data, &url, &title)) return false; model->AddURL(parent, idx, title, url); diff --git a/chrome/browser/ui/gtk/bookmark_utils_gtk_unittest.cc b/chrome/browser/ui/gtk/bookmark_utils_gtk_unittest.cc index a5f0f17..ffef87c 100644 --- a/chrome/browser/ui/gtk/bookmark_utils_gtk_unittest.cc +++ b/chrome/browser/ui/gtk/bookmark_utils_gtk_unittest.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "app/gtk_dnd_util.h" #include "chrome/browser/ui/gtk/bookmark_utils_gtk.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/base/dragdrop/gtk_dnd_util.h" TEST(BookmarkUtilsGtkTest, GetNodesFromSelectionInvalid) { std::vector<const BookmarkNode*> nodes; @@ -20,19 +20,19 @@ TEST(BookmarkUtilsGtkTest, GetNodesFromSelectionInvalid) { EXPECT_EQ(0u, nodes.size()); nodes = bookmark_utils::GetNodesFromSelection(NULL, NULL, - gtk_dnd_util::CHROME_BOOKMARK_ITEM, NULL, NULL, NULL); + ui::CHROME_BOOKMARK_ITEM, NULL, NULL, NULL); EXPECT_EQ(0u, nodes.size()); data.data = NULL; data.length = 0; nodes = bookmark_utils::GetNodesFromSelection(NULL, &data, - gtk_dnd_util::CHROME_BOOKMARK_ITEM, NULL, NULL, NULL); + ui::CHROME_BOOKMARK_ITEM, NULL, NULL, NULL); EXPECT_EQ(0u, nodes.size()); guchar test_data[] = ""; data.data = test_data; data.length = 0; nodes = bookmark_utils::GetNodesFromSelection(NULL, &data, - gtk_dnd_util::CHROME_BOOKMARK_ITEM, NULL, NULL, NULL); + ui::CHROME_BOOKMARK_ITEM, NULL, NULL, NULL); EXPECT_EQ(0u, nodes.size()); } diff --git a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc index 4943f84..49d8d3d 100644 --- a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc +++ b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc @@ -8,7 +8,6 @@ #include <gdk/gdkkeysyms.h> #include <gtk/gtk.h> -#include "app/gtk_dnd_util.h" #include "app/l10n_util.h" #include "base/base_paths.h" #include "base/command_line.h" @@ -52,6 +51,7 @@ #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" +#include "ui/base/dragdrop/gtk_dnd_util.h" #include "ui/base/models/accelerator_gtk.h" namespace { @@ -421,9 +421,8 @@ void BrowserToolbarGtk::SetUpDragForHomeButton(bool enable) { if (enable) { gtk_drag_dest_set(home_->widget(), GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY); - static const int targets[] = { gtk_dnd_util::TEXT_PLAIN, - gtk_dnd_util::TEXT_URI_LIST, -1 }; - gtk_dnd_util::SetDestTargetList(home_->widget(), targets); + static const int targets[] = { ui::TEXT_PLAIN, ui::TEXT_URI_LIST, -1 }; + ui::SetDestTargetList(home_->widget(), targets); drop_handler_.reset(new GtkSignalRegistrar()); drop_handler_->Connect(home_->widget(), "drag-data-received", @@ -599,7 +598,7 @@ gboolean BrowserToolbarGtk::OnMenuButtonPressEvent(GtkWidget* button, void BrowserToolbarGtk::OnDragDataReceived(GtkWidget* widget, GdkDragContext* drag_context, gint x, gint y, GtkSelectionData* data, guint info, guint time) { - if (info != gtk_dnd_util::TEXT_PLAIN) { + if (info != ui::TEXT_PLAIN) { NOTIMPLEMENTED() << "Only support plain text drops for now, sorry!"; return; } diff --git a/chrome/browser/ui/gtk/custom_drag.cc b/chrome/browser/ui/gtk/custom_drag.cc index ea1aa80..eb786b3 100644 --- a/chrome/browser/ui/gtk/custom_drag.cc +++ b/chrome/browser/ui/gtk/custom_drag.cc @@ -4,7 +4,6 @@ #include "chrome/browser/ui/gtk/custom_drag.h" -#include "app/gtk_dnd_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/download/download_item.h" #include "chrome/browser/ui/gtk/bookmark_utils_gtk.h" @@ -12,11 +11,11 @@ #include "googleurl/src/gurl.h" #include "net/base/net_util.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "ui/base/dragdrop/gtk_dnd_util.h" namespace { -const int kDownloadItemCodeMask = gtk_dnd_util::TEXT_URI_LIST | - gtk_dnd_util::CHROME_NAMED_URL; +const int kDownloadItemCodeMask = ui::TEXT_URI_LIST | ui::CHROME_NAMED_URL; const GdkDragAction kDownloadItemDragAction = GDK_ACTION_COPY; const GdkDragAction kBookmarkDragAction = static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE); @@ -25,7 +24,7 @@ void OnDragDataGetForDownloadItem(GtkSelectionData* selection_data, guint target_type, const DownloadItem* download_item) { GURL url = net::FilePathToFileURL(download_item->full_path()); - gtk_dnd_util::WriteURLWithName(selection_data, url, + ui::WriteURLWithName(selection_data, url, UTF8ToUTF16(download_item->GetFileNameToReportUser().value()), target_type); } @@ -51,7 +50,7 @@ CustomDrag::CustomDrag(SkBitmap* icon, int code_mask, GdkDragAction action) g_signal_connect(drag_widget_, "drag-end", G_CALLBACK(OnDragEndThunk), this); - GtkTargetList* list = gtk_dnd_util::GetTargetListFromCodeMask(code_mask); + GtkTargetList* list = ui::GetTargetListFromCodeMask(code_mask); GdkEvent* event = gtk_get_current_event(); gtk_drag_begin(drag_widget_, list, action, 1, event); if (event) @@ -98,7 +97,7 @@ void DownloadItemDrag::SetSource(GtkWidget* widget, SkBitmap* icon) { gtk_drag_source_set(widget, GDK_BUTTON1_MASK, NULL, 0, kDownloadItemDragAction); - gtk_dnd_util::SetSourceTargetListFromCodeMask(widget, kDownloadItemCodeMask); + ui::SetSourceTargetListFromCodeMask(widget, kDownloadItemCodeMask); // Disconnect previous signal handlers, if any. g_signal_handlers_disconnect_by_func( diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc index 84be94e..4489a5f 100644 --- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc +++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc @@ -8,7 +8,6 @@ #include <string> #include <vector> -#include "app/gtk_dnd_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/basictypes.h" @@ -61,6 +60,7 @@ #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "net/base/net_util.h" +#include "ui/base/dragdrop/gtk_dnd_util.h" #include "webkit/glue/window_open_disposition.h" namespace { @@ -370,10 +370,10 @@ void LocationBarViewGtk::SetSiteTypeDragSource() { gtk_drag_source_set(site_type_event_box_, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY); - gtk_dnd_util::SetSourceTargetListFromCodeMask(site_type_event_box_, - gtk_dnd_util::TEXT_PLAIN | - gtk_dnd_util::TEXT_URI_LIST | - gtk_dnd_util::CHROME_NAMED_URL); + ui::SetSourceTargetListFromCodeMask(site_type_event_box_, + ui::TEXT_PLAIN | + ui::TEXT_URI_LIST | + ui::CHROME_NAMED_URL); } void LocationBarViewGtk::SetProfile(Profile* profile) { @@ -1124,7 +1124,7 @@ void LocationBarViewGtk::OnIconDragData(GtkWidget* sender, TabContents* tab = GetTabContents(); if (!tab) return; - gtk_dnd_util::WriteURLWithName(data, tab->GetURL(), tab->GetTitle(), info); + ui::WriteURLWithName(data, tab->GetURL(), tab->GetTitle(), info); } void LocationBarViewGtk::OnIconDragBegin(GtkWidget* sender, diff --git a/chrome/browser/ui/gtk/tab_contents_drag_source.cc b/chrome/browser/ui/gtk/tab_contents_drag_source.cc index 6413565..0739d34 100644 --- a/chrome/browser/ui/gtk/tab_contents_drag_source.cc +++ b/chrome/browser/ui/gtk/tab_contents_drag_source.cc @@ -6,7 +6,6 @@ #include <string> -#include "app/gtk_dnd_util.h" #include "base/file_util.h" #include "base/mime_util.h" #include "base/utf_string_conversions.h" @@ -21,6 +20,7 @@ #include "gfx/gtk_util.h" #include "net/base/file_stream.h" #include "net/base/net_util.h" +#include "ui/base/dragdrop/gtk_dnd_util.h" #include "webkit/glue/webdropdata.h" using WebKit::WebDragOperation; @@ -82,22 +82,22 @@ void TabContentsDragSource::StartDragging(const WebDropData& drop_data, int targets_mask = 0; if (!drop_data.plain_text.empty()) - targets_mask |= gtk_dnd_util::TEXT_PLAIN; + targets_mask |= ui::TEXT_PLAIN; if (drop_data.url.is_valid()) { - targets_mask |= gtk_dnd_util::TEXT_URI_LIST; - targets_mask |= gtk_dnd_util::CHROME_NAMED_URL; - targets_mask |= gtk_dnd_util::NETSCAPE_URL; + targets_mask |= ui::TEXT_URI_LIST; + targets_mask |= ui::CHROME_NAMED_URL; + targets_mask |= ui::NETSCAPE_URL; } if (!drop_data.text_html.empty()) - targets_mask |= gtk_dnd_util::TEXT_HTML; + targets_mask |= ui::TEXT_HTML; if (!drop_data.file_contents.empty()) - targets_mask |= gtk_dnd_util::CHROME_WEBDROP_FILE_CONTENTS; + targets_mask |= ui::CHROME_WEBDROP_FILE_CONTENTS; if (!drop_data.download_metadata.empty() && drag_download_util::ParseDownloadMetadata(drop_data.download_metadata, &wide_download_mime_type_, &download_file_name_, &download_url_)) { - targets_mask |= gtk_dnd_util::DIRECT_SAVE_FILE; + targets_mask |= ui::DIRECT_SAVE_FILE; } // NOTE: Begin a drag even if no targets present. Otherwise, things like @@ -111,12 +111,12 @@ void TabContentsDragSource::StartDragging(const WebDropData& drop_data, drag_pixbuf_ = gfx::GdkPixbufFromSkBitmap(&image); image_offset_ = image_offset; - GtkTargetList* list = gtk_dnd_util::GetTargetListFromCodeMask(targets_mask); - if (targets_mask & gtk_dnd_util::CHROME_WEBDROP_FILE_CONTENTS) { + GtkTargetList* list = ui::GetTargetListFromCodeMask(targets_mask); + if (targets_mask & ui::CHROME_WEBDROP_FILE_CONTENTS) { drag_file_mime_type_ = gdk_atom_intern( mime_util::GetDataMimeType(drop_data.file_contents).c_str(), FALSE); gtk_target_list_add(list, drag_file_mime_type_, - 0, gtk_dnd_util::CHROME_WEBDROP_FILE_CONTENTS); + 0, ui::CHROME_WEBDROP_FILE_CONTENTS); } drag_failed_ = false; @@ -173,35 +173,34 @@ void TabContentsDragSource::OnDragDataGet(GtkWidget* sender, const int kBitsPerByte = 8; switch (target_type) { - case gtk_dnd_util::TEXT_PLAIN: { + case ui::TEXT_PLAIN: { std::string utf8_text = UTF16ToUTF8(drop_data_->plain_text); gtk_selection_data_set_text(selection_data, utf8_text.c_str(), utf8_text.length()); break; } - case gtk_dnd_util::TEXT_HTML: { + case ui::TEXT_HTML: { // TODO(estade): change relative links to be absolute using // |html_base_url|. std::string utf8_text = UTF16ToUTF8(drop_data_->text_html); gtk_selection_data_set(selection_data, - gtk_dnd_util::GetAtomForTarget( - gtk_dnd_util::TEXT_HTML), + ui::GetAtomForTarget(ui::TEXT_HTML), kBitsPerByte, reinterpret_cast<const guchar*>(utf8_text.c_str()), utf8_text.length()); break; } - case gtk_dnd_util::TEXT_URI_LIST: - case gtk_dnd_util::CHROME_NAMED_URL: - case gtk_dnd_util::NETSCAPE_URL: { - gtk_dnd_util::WriteURLWithName(selection_data, drop_data_->url, - drop_data_->url_title, target_type); + case ui::TEXT_URI_LIST: + case ui::CHROME_NAMED_URL: + case ui::NETSCAPE_URL: { + ui::WriteURLWithName(selection_data, drop_data_->url, + drop_data_->url_title, target_type); break; } - case gtk_dnd_util::CHROME_WEBDROP_FILE_CONTENTS: { + case ui::CHROME_WEBDROP_FILE_CONTENTS: { gtk_selection_data_set( selection_data, drag_file_mime_type_, kBitsPerByte, @@ -210,7 +209,7 @@ void TabContentsDragSource::OnDragDataGet(GtkWidget* sender, break; } - case gtk_dnd_util::DIRECT_SAVE_FILE: { + case ui::DIRECT_SAVE_FILE: { char status_code = 'E'; // Retrieves the full file path (in file URL format) provided by the @@ -219,10 +218,8 @@ void TabContentsDragSource::OnDragDataGet(GtkWidget* sender, gint file_url_len = 0; guchar* file_url_value = NULL; if (gdk_property_get(context->source_window, - gtk_dnd_util::GetAtomForTarget( - gtk_dnd_util::DIRECT_SAVE_FILE), - gtk_dnd_util::GetAtomForTarget( - gtk_dnd_util::TEXT_PLAIN_NO_CHARSET), + ui::GetAtomForTarget(ui::DIRECT_SAVE_FILE), + ui::GetAtomForTarget(ui::TEXT_PLAIN_NO_CHARSET), 0, 1024, FALSE, @@ -309,10 +306,8 @@ void TabContentsDragSource::OnDragBegin(GtkWidget* sender, // Pass the file name to the drop target by setting the source window's // XdndDirectSave0 property. gdk_property_change(drag_context->source_window, - gtk_dnd_util::GetAtomForTarget( - gtk_dnd_util::DIRECT_SAVE_FILE), - gtk_dnd_util::GetAtomForTarget( - gtk_dnd_util::TEXT_PLAIN_NO_CHARSET), + ui::GetAtomForTarget(ui::DIRECT_SAVE_FILE), + ui::GetAtomForTarget(ui::TEXT_PLAIN_NO_CHARSET), 8, GDK_PROP_MODE_REPLACE, reinterpret_cast<const guchar*>( @@ -349,8 +344,7 @@ void TabContentsDragSource::OnDragEnd(GtkWidget* sender, if (!download_url_.is_empty()) { gdk_property_delete(drag_context->source_window, - gtk_dnd_util::GetAtomForTarget( - gtk_dnd_util::DIRECT_SAVE_FILE)); + ui::GetAtomForTarget(ui::DIRECT_SAVE_FILE)); } if (!drag_failed_) { diff --git a/chrome/browser/ui/gtk/tabs/tab_gtk.cc b/chrome/browser/ui/gtk/tabs/tab_gtk.cc index 13f788c..b87c753 100644 --- a/chrome/browser/ui/gtk/tabs/tab_gtk.cc +++ b/chrome/browser/ui/gtk/tabs/tab_gtk.cc @@ -6,7 +6,6 @@ #include <gdk/gdkkeysyms.h> -#include "app/gtk_dnd_util.h" #include "base/singleton.h" #include "base/utf_string_conversions.h" #include "chrome/app/chrome_command_ids.h" @@ -16,6 +15,7 @@ #include "gfx/path.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" +#include "ui/base/dragdrop/gtk_dnd_util.h" #include "ui/base/models/accelerator_gtk.h" namespace { @@ -365,8 +365,7 @@ void TabGtk::DestroyDragWidget() { void TabGtk::StartDragging(gfx::Point drag_offset) { CreateDragWidget(); - GtkTargetList* list = gtk_dnd_util::GetTargetListFromCodeMask( - gtk_dnd_util::CHROME_TAB); + GtkTargetList* list = ui::GetTargetListFromCodeMask(ui::CHROME_TAB); gtk_drag_begin(drag_widget_, list, GDK_ACTION_MOVE, 1, // Drags are always initiated by the left button. last_mouse_down_); diff --git a/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc index b366334..00e2f2c 100644 --- a/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc +++ b/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc @@ -6,7 +6,6 @@ #include <algorithm> -#include "app/gtk_dnd_util.h" #include "app/resource_bundle.h" #include "base/i18n/rtl.h" #include "base/string_util.h" @@ -34,6 +33,7 @@ #include "grit/theme_resources.h" #include "ui/base/animation/animation_delegate.h" #include "ui/base/animation/slide_animation.h" +#include "ui/base/dragdrop/gtk_dnd_util.h" namespace { @@ -738,11 +738,11 @@ void TabStripGtk::Init() { NULL, 0, static_cast<GdkDragAction>( GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK)); - static const int targets[] = { gtk_dnd_util::TEXT_URI_LIST, - gtk_dnd_util::NETSCAPE_URL, - gtk_dnd_util::TEXT_PLAIN, + static const int targets[] = { ui::TEXT_URI_LIST, + ui::NETSCAPE_URL, + ui::TEXT_PLAIN, -1 }; - gtk_dnd_util::SetDestTargetList(tabstrip_.get(), targets); + ui::SetDestTargetList(tabstrip_.get(), targets); g_signal_connect(tabstrip_.get(), "expose-event", G_CALLBACK(OnExposeThunk), this); @@ -1976,10 +1976,10 @@ gboolean TabStripGtk::OnDragDataReceived(GtkWidget* widget, guint info, guint time) { bool success = false; - if (info == gtk_dnd_util::TEXT_URI_LIST || - info == gtk_dnd_util::NETSCAPE_URL || - info == gtk_dnd_util::TEXT_PLAIN) { - success = CompleteDrop(data->data, info == gtk_dnd_util::TEXT_PLAIN); + if (info == ui::TEXT_URI_LIST || + info == ui::NETSCAPE_URL || + info == ui::TEXT_PLAIN) { + success = CompleteDrop(data->data, info == ui::TEXT_PLAIN); } gtk_drag_finish(context, success, success, time); diff --git a/chrome/browser/ui/views/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmark_bar_view.cc index f672ceb..61a5971 100644 --- a/chrome/browser/ui/views/bookmark_bar_view.cc +++ b/chrome/browser/ui/views/bookmark_bar_view.cc @@ -674,7 +674,7 @@ int BookmarkBarView::OnPerformDrop(const DropTargetEvent& event) { bookmark_drop_menu_->Cancel(); if (!drop_info_.get() || !drop_info_->drag_operation) - return DragDropTypes::DRAG_NONE; + return ui::DragDropTypes::DRAG_NONE; const BookmarkNode* root = drop_info_->is_over_other ? model_->other_node() : @@ -1134,7 +1134,7 @@ int BookmarkBarView::GetDragOperations(View* sender, const gfx::Point& p) { // the new tab page, on the new tab page size_animation_ is always 0). This // typically is only hit if the user does something to inadvertanty trigger // dnd, such as pressing the mouse and hitting control-b. - return DragDropTypes::DRAG_NONE; + return ui::DragDropTypes::DRAG_NONE; } for (int i = 0; i < GetBookmarkButtonCount(); ++i) { @@ -1144,7 +1144,7 @@ int BookmarkBarView::GetDragOperations(View* sender, const gfx::Point& p) { } } NOTREACHED(); - return DragDropTypes::DRAG_NONE; + return ui::DragDropTypes::DRAG_NONE; } bool BookmarkBarView::CanStartDrag(views::View* sender, @@ -1426,7 +1426,7 @@ int BookmarkBarView::CalculateDropOperation(const DropTargetEvent& event, event.y() >= other_bookmarked_button_->y() + other_bookmarked_button_->height()) { // Mouse isn't over a button. - return DragDropTypes::DRAG_NONE; + return ui::DragDropTypes::DRAG_NONE; } bool found = false; @@ -1441,8 +1441,8 @@ int BookmarkBarView::CalculateDropOperation(const DropTargetEvent& event, // No bookmarks, accept the drop. *index = 0; int ops = data.GetFirstNode(profile_) - ? DragDropTypes::DRAG_MOVE - : DragDropTypes::DRAG_COPY | DragDropTypes::DRAG_LINK; + ? ui::DragDropTypes::DRAG_MOVE + : ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK; return bookmark_utils::PreferredDropOperation(event.GetSourceOperations(), ops); @@ -1488,14 +1488,14 @@ int BookmarkBarView::CalculateDropOperation(const DropTargetEvent& event, // use the last visible index. *index = GetFirstHiddenNodeIndex(); } else { - return DragDropTypes::DRAG_NONE; + return ui::DragDropTypes::DRAG_NONE; } } else if (mirrored_x < other_bookmarked_button_->x()) { // Mouse is after the last visible button but before more recently // bookmarked; use the last visible index. *index = GetFirstHiddenNodeIndex(); } else { - return DragDropTypes::DRAG_NONE; + return ui::DragDropTypes::DRAG_NONE; } } diff --git a/chrome/browser/ui/views/bookmark_bar_view.h b/chrome/browser/ui/views/bookmark_bar_view.h index 49cec21..c02ed48 100644 --- a/chrome/browser/ui/views/bookmark_bar_view.h +++ b/chrome/browser/ui/views/bookmark_bar_view.h @@ -409,7 +409,7 @@ class BookmarkBarView : public DetachableToolbarView, void StartShowFolderDropMenuTimer(const BookmarkNode* node); // Returns the drop operation and index for the drop based on the event - // and data. Returns DragDropTypes::DRAG_NONE if not a valid location. + // and data. Returns ui::DragDropTypes::DRAG_NONE if not a valid location. int CalculateDropOperation(const views::DropTargetEvent& event, const BookmarkNodeData& data, int* index, diff --git a/chrome/browser/ui/views/browser_actions_container.cc b/chrome/browser/ui/views/browser_actions_container.cc index 0e3f14c..7e3726d 100644 --- a/chrome/browser/ui/views/browser_actions_container.cc +++ b/chrome/browser/ui/views/browser_actions_container.cc @@ -634,7 +634,7 @@ int BrowserActionsContainer::OnDragUpdated( if (GetViewForPoint(event.location()) == chevron_) { if (show_menu_task_factory_.empty() && !overflow_menu_) StartShowFolderDropMenuTimer(); - return DragDropTypes::DRAG_MOVE; + return ui::DragDropTypes::DRAG_MOVE; } StopShowFolderDropMenuTimer(); @@ -684,7 +684,7 @@ int BrowserActionsContainer::OnDragUpdated( SetDropIndicator(width_before_icons + (before_icon * IconWidth(true)) - (kItemSpacing / 2)); - return DragDropTypes::DRAG_MOVE; + return ui::DragDropTypes::DRAG_MOVE; } void BrowserActionsContainer::OnDragExited() { @@ -697,7 +697,7 @@ int BrowserActionsContainer::OnPerformDrop( const views::DropTargetEvent& event) { BrowserActionDragData data; if (!data.Read(event.GetData())) - return DragDropTypes::DRAG_NONE; + return ui::DragDropTypes::DRAG_NONE; // Make sure we have the same view as we started with. DCHECK_EQ(browser_action_views_[data.index()]->button()->extension()->id(), @@ -732,7 +732,7 @@ int BrowserActionsContainer::OnPerformDrop( browser_action_views_[data.index()]->button()->extension(), i); OnDragExited(); // Perform clean up after dragging. - return DragDropTypes::DRAG_MOVE; + return ui::DragDropTypes::DRAG_MOVE; } void BrowserActionsContainer::OnThemeChanged() { @@ -777,7 +777,7 @@ void BrowserActionsContainer::WriteDragData(View* sender, int BrowserActionsContainer::GetDragOperations(View* sender, const gfx::Point& p) { - return DragDropTypes::DRAG_MOVE; + return ui::DragDropTypes::DRAG_MOVE; } bool BrowserActionsContainer::CanStartDrag(View* sender, diff --git a/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc b/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc index 29edcc0a..7972aa1 100644 --- a/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc +++ b/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc @@ -145,13 +145,13 @@ int BrowserActionOverflowMenuController::GetDropOperation( if ((item->GetCommand() == 0) && (*position == DROP_BEFORE)) { BrowserActionDragData drop_data; if (!drop_data.Read(event.GetData())) - return DragDropTypes::DRAG_NONE; + return ui::DragDropTypes::DRAG_NONE; if (drop_data.index() < owner_->VisibleBrowserActions()) - return DragDropTypes::DRAG_NONE; + return ui::DragDropTypes::DRAG_NONE; } - return DragDropTypes::DRAG_MOVE; + return ui::DragDropTypes::DRAG_MOVE; } int BrowserActionOverflowMenuController::OnPerformDrop( @@ -160,7 +160,7 @@ int BrowserActionOverflowMenuController::OnPerformDrop( const views::DropTargetEvent& event) { BrowserActionDragData drop_data; if (!drop_data.Read(event.GetData())) - return DragDropTypes::DRAG_NONE; + return ui::DragDropTypes::DRAG_NONE; size_t drop_index; ViewForId(menu->GetCommand(), &drop_index); @@ -175,7 +175,7 @@ int BrowserActionOverflowMenuController::OnPerformDrop( if (for_drop_) delete this; - return DragDropTypes::DRAG_MOVE; + return ui::DragDropTypes::DRAG_MOVE; } bool BrowserActionOverflowMenuController::CanDrag(views::MenuItemView* menu) { @@ -194,7 +194,7 @@ void BrowserActionOverflowMenuController::WriteDragData( int BrowserActionOverflowMenuController::GetDragOperations( views::MenuItemView* sender) { - return DragDropTypes::DRAG_MOVE; + return ui::DragDropTypes::DRAG_MOVE; } BrowserActionView* BrowserActionOverflowMenuController::ViewForId( diff --git a/chrome/browser/ui/views/frame/browser_root_view.cc b/chrome/browser/ui/views/frame/browser_root_view.cc index 32ed64b..720ca3b 100644 --- a/chrome/browser/ui/views/frame/browser_root_view.cc +++ b/chrome/browser/ui/views/frame/browser_root_view.cc @@ -4,7 +4,6 @@ #include "chrome/browser/ui/views/frame/browser_root_view.h" -#include "app/drag_drop_types.h" #include "app/l10n_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/autocomplete/autocomplete.h" @@ -16,6 +15,7 @@ #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/tabs/tab_strip.h" #include "grit/chromium_strings.h" +#include "ui/base/dragdrop/drag_drop_types.h" #include "ui/base/dragdrop/os_exchange_data.h" BrowserRootView::BrowserRootView(BrowserView* browser_view, @@ -74,7 +74,7 @@ int BrowserRootView::OnDragUpdated(const views::DropTargetEvent& event) { forwarding_to_tab_strip_ = false; tabstrip()->OnDragExited(); } - return DragDropTypes::DRAG_NONE; + return ui::DragDropTypes::DRAG_NONE; } void BrowserRootView::OnDragExited() { @@ -86,7 +86,7 @@ void BrowserRootView::OnDragExited() { int BrowserRootView::OnPerformDrop(const views::DropTargetEvent& event) { if (!forwarding_to_tab_strip_) - return DragDropTypes::DRAG_NONE; + return ui::DragDropTypes::DRAG_NONE; // Extract the URL and create a new ui::OSExchangeData containing the URL. We // do this as the TabStrip doesn't know about the autocomplete edit and needs diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc index 4d2723b..ff40ad8 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc @@ -8,7 +8,6 @@ #include <gtk/gtk.h> #endif -#include "app/drag_drop_types.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "app/theme_provider.h" @@ -44,6 +43,7 @@ #include "gfx/skia_util.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" +#include "ui/base/dragdrop/drag_drop_types.h" #include "views/controls/label.h" #include "views/drag_utils.h" @@ -1085,7 +1085,7 @@ AccessibilityTypes::Role LocationBarView::GetAccessibleRole() { void LocationBarView::WriteDragData(views::View* sender, const gfx::Point& press_pt, OSExchangeData* data) { - DCHECK(GetDragOperations(sender, press_pt) != DragDropTypes::DRAG_NONE); + DCHECK(GetDragOperations(sender, press_pt) != ui::DragDropTypes::DRAG_NONE); TabContents* tab_contents = GetTabContentsFromDelegate(delegate_); DCHECK(tab_contents); @@ -1100,8 +1100,8 @@ int LocationBarView::GetDragOperations(views::View* sender, TabContents* tab_contents = GetTabContentsFromDelegate(delegate_); return (tab_contents && tab_contents->GetURL().is_valid() && !location_entry()->IsEditingOrEmpty()) ? - (DragDropTypes::DRAG_COPY | DragDropTypes::DRAG_LINK) : - DragDropTypes::DRAG_NONE; + (ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK) : + ui::DragDropTypes::DRAG_NONE; } bool LocationBarView::CanStartDrag(View* sender, diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc index 7bc49de..7145017 100644 --- a/chrome/browser/ui/views/tabs/tab_strip.cc +++ b/chrome/browser/ui/views/tabs/tab_strip.cc @@ -6,7 +6,6 @@ #include <algorithm> -#include "app/drag_drop_types.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/compiler_specific.h" @@ -23,6 +22,7 @@ #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "ui/base/animation/animation_container.h" +#include "ui/base/dragdrop/drag_drop_types.h" #include "views/controls/image_view.h" #include "views/widget/default_theme_provider.h" #include "views/window/non_client_view.h" @@ -349,7 +349,7 @@ void TabStrip::OnDragExited() { int TabStrip::OnPerformDrop(const DropTargetEvent& event) { if (!drop_info_.get()) - return DragDropTypes::DRAG_NONE; + return ui::DragDropTypes::DRAG_NONE; const int drop_index = drop_info_->drop_index; const bool drop_before = drop_info_->drop_before; @@ -360,7 +360,7 @@ int TabStrip::OnPerformDrop(const DropTargetEvent& event) { GURL url; std::wstring title; if (!event.GetData().GetURLAndTitle(&url, &title) || !url.is_valid()) - return DragDropTypes::DRAG_NONE; + return ui::DragDropTypes::DRAG_NONE; controller()->PerformDrop(drop_before, drop_index, url); @@ -770,11 +770,11 @@ void TabStrip::SetDropIndex(int tab_data_index, bool drop_before) { int TabStrip::GetDropEffect(const views::DropTargetEvent& event) { const int source_ops = event.GetSourceOperations(); - if (source_ops & DragDropTypes::DRAG_COPY) - return DragDropTypes::DRAG_COPY; - if (source_ops & DragDropTypes::DRAG_LINK) - return DragDropTypes::DRAG_LINK; - return DragDropTypes::DRAG_MOVE; + if (source_ops & ui::DragDropTypes::DRAG_COPY) + return ui::DragDropTypes::DRAG_COPY; + if (source_ops & ui::DragDropTypes::DRAG_LINK) + return ui::DragDropTypes::DRAG_LINK; + return ui::DragDropTypes::DRAG_MOVE; } // static |