diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-29 21:46:39 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-29 21:46:39 +0000 |
commit | 69e92c3cc4993ff6e42b55ae7fc41d43a103e73d (patch) | |
tree | 9a0cbdc5324ea886ea0d83af9a8059d54095d2f9 /ui | |
parent | 31e8a85a3ca9f76d10ddfa6920d89fc2abe47628 (diff) | |
download | chromium_src-69e92c3cc4993ff6e42b55ae7fc41d43a103e73d.zip chromium_src-69e92c3cc4993ff6e42b55ae7fc41d43a103e73d.tar.gz chromium_src-69e92c3cc4993ff6e42b55ae7fc41d43a103e73d.tar.bz2 |
gtk: Remove unused ViewsGtk drag and drop code.
This code should have been deleted when ViewsGtk was deleted.
BUG=none
Review URL: https://chromiumcodereview.appspot.com/13267002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191448 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/dragdrop/drag_drop_types_gtk.cc | 35 | ||||
-rw-r--r-- | ui/base/dragdrop/drag_utils_gtk.cc | 46 | ||||
-rw-r--r-- | ui/base/dragdrop/os_exchange_data_provider_gtk.cc | 246 | ||||
-rw-r--r-- | ui/base/dragdrop/os_exchange_data_provider_gtk.h | 131 | ||||
-rw-r--r-- | ui/ui.gyp | 8 |
5 files changed, 0 insertions, 466 deletions
diff --git a/ui/base/dragdrop/drag_drop_types_gtk.cc b/ui/base/dragdrop/drag_drop_types_gtk.cc deleted file mode 100644 index 2a70d7e..0000000 --- a/ui/base/dragdrop/drag_drop_types_gtk.cc +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2011 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 "ui/base/dragdrop/drag_drop_types.h" - -#include <gtk/gtk.h> - -namespace ui { - -// static -int ui::DragDropTypes::DragOperationToGdkDragAction(int drag_operation) { - int gdk_drag_action = 0; - if (drag_operation & DRAG_MOVE) - gdk_drag_action |= GDK_ACTION_MOVE; - if (drag_operation & DRAG_COPY) - gdk_drag_action |= GDK_ACTION_COPY; - if (drag_operation & DRAG_LINK) - gdk_drag_action |= GDK_ACTION_LINK; - return gdk_drag_action; -} - -// static -int ui::DragDropTypes::GdkDragActionToDragOperation(int gdk_drag_action) { - int drag_operation = DRAG_NONE; - if (gdk_drag_action & GDK_ACTION_COPY) - drag_operation |= DRAG_COPY; - if (gdk_drag_action & GDK_ACTION_MOVE) - drag_operation |= DRAG_MOVE; - if (gdk_drag_action & GDK_ACTION_LINK) - drag_operation |= DRAG_LINK; - return drag_operation; -} - -} // namespace ui diff --git a/ui/base/dragdrop/drag_utils_gtk.cc b/ui/base/dragdrop/drag_utils_gtk.cc deleted file mode 100644 index 7a3517b..0000000 --- a/ui/base/dragdrop/drag_utils_gtk.cc +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2012 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 "ui/base/dragdrop/drag_utils.h" - -#include <gtk/gtk.h> - -#include "base/logging.h" -#include "ui/base/dragdrop/os_exchange_data.h" -#include "ui/base/dragdrop/os_exchange_data_provider_gtk.h" -#include "ui/gfx/canvas.h" -#include "ui/gfx/gtk_util.h" -#include "ui/gfx/image/image_skia.h" -#include "ui/gfx/point.h" -#include "ui/gfx/size.h" - -namespace drag_utils { - -void SetDragImageOnDataObject(const gfx::ImageSkia& image_skia, - const gfx::Size& size, - const gfx::Vector2d& cursor_offset, - ui::OSExchangeData* data_object) { - ui::OSExchangeDataProviderGtk& provider( - static_cast<ui::OSExchangeDataProviderGtk&>(data_object->provider())); - - // Convert the image into a GdkPixbuf. - GdkPixbuf* canvas_pixbuf = gfx::GdkPixbufFromSkBitmap(image_skia.bitmap()); - - // Make a new pixbuf of the requested size and copy it over. - GdkPixbuf* pixbuf = gdk_pixbuf_new( - gdk_pixbuf_get_colorspace(canvas_pixbuf), - gdk_pixbuf_get_has_alpha(canvas_pixbuf), - gdk_pixbuf_get_bits_per_sample(canvas_pixbuf), - size.width(), - size.height()); - gdk_pixbuf_copy_area(canvas_pixbuf, 0, 0, size.width(), size.height(), pixbuf, - 0, 0); - g_object_unref(canvas_pixbuf); - - // Set the drag data on to the provider. - provider.SetDragImage(pixbuf, cursor_offset); - g_object_unref(pixbuf); -} - -} // namespace drag_utils diff --git a/ui/base/dragdrop/os_exchange_data_provider_gtk.cc b/ui/base/dragdrop/os_exchange_data_provider_gtk.cc deleted file mode 100644 index 09bd9cd..0000000 --- a/ui/base/dragdrop/os_exchange_data_provider_gtk.cc +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright (c) 2011 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 "ui/base/dragdrop/os_exchange_data_provider_gtk.h" - -#include <algorithm> - -#include "base/files/file_path.h" -#include "base/utf_string_conversions.h" -#include "net/base/net_util.h" -#include "ui/base/dragdrop/gtk_dnd_util.h" - -namespace ui { - -OSExchangeDataProviderGtk::OSExchangeDataProviderGtk( - int known_formats, - const std::set<GdkAtom>& known_custom_formats) - : known_formats_(known_formats), - known_custom_formats_(known_custom_formats), - formats_(0), - drag_image_(NULL) { -} - -OSExchangeDataProviderGtk::OSExchangeDataProviderGtk() - : known_formats_(0), - formats_(0), - drag_image_(NULL) { -} - -OSExchangeDataProviderGtk::~OSExchangeDataProviderGtk() { - if (drag_image_) - g_object_unref(drag_image_); -} - -bool OSExchangeDataProviderGtk::HasDataForAllFormats( - int formats, - const std::set<GdkAtom>& custom_formats) const { - if ((formats_ & formats) != formats) - return false; - for (std::set<GdkAtom>::iterator i = custom_formats.begin(); - i != custom_formats.end(); ++i) { - if (pickle_data_.find(*i) == pickle_data_.end()) - return false; - } - return true; -} - -GtkTargetList* OSExchangeDataProviderGtk::GetTargetList() const { - GtkTargetList* targets = gtk_target_list_new(NULL, 0); - - if ((formats_ & OSExchangeData::STRING) != 0) - gtk_target_list_add_text_targets(targets, OSExchangeData::STRING); - - if ((formats_ & OSExchangeData::URL) != 0) { - gtk_target_list_add_uri_targets(targets, OSExchangeData::URL); - gtk_target_list_add( - targets, - ui::GetAtomForTarget(ui::CHROME_NAMED_URL), - 0, - OSExchangeData::URL); - } - - if ((formats_ & OSExchangeData::FILE_NAME) != 0) - gtk_target_list_add_uri_targets(targets, OSExchangeData::FILE_NAME); - - for (PickleData::const_iterator i = pickle_data_.begin(); - i != pickle_data_.end(); ++i) { - gtk_target_list_add(targets, i->first, 0, OSExchangeData::PICKLED_DATA); - } - - return targets; -} - -void OSExchangeDataProviderGtk::WriteFormatToSelection( - int format, - GtkSelectionData* selection) const { - if ((format & OSExchangeData::STRING) != 0) { - gtk_selection_data_set_text( - selection, - reinterpret_cast<const gchar*>(string_.c_str()), - -1); - } - - if ((format & OSExchangeData::URL) != 0) { - Pickle pickle; - pickle.WriteString(UTF16ToUTF8(title_)); - pickle.WriteString(url_.spec()); - gtk_selection_data_set( - selection, - ui::GetAtomForTarget(ui::CHROME_NAMED_URL), - 8, - reinterpret_cast<const guchar*>(pickle.data()), - pickle.size()); - - gchar* uri_array[2]; - uri_array[0] = strdup(url_.spec().c_str()); - uri_array[1] = NULL; - gtk_selection_data_set_uris(selection, uri_array); - free(uri_array[0]); - } - - if ((format & OSExchangeData::FILE_NAME) != 0) { - gchar* uri_array[2]; - uri_array[0] = strdup(net::FilePathToFileURL( - base::FilePath(filename_)).spec().c_str()); - uri_array[1] = NULL; - gtk_selection_data_set_uris(selection, uri_array); - free(uri_array[0]); - } - - if ((format & OSExchangeData::PICKLED_DATA) != 0) { - for (PickleData::const_iterator i = pickle_data_.begin(); - i != pickle_data_.end(); ++i) { - const Pickle& data = i->second; - gtk_selection_data_set( - selection, - i->first, - 8, - reinterpret_cast<const guchar*>(data.data()), - data.size()); - } - } -} - -void OSExchangeDataProviderGtk::SetString(const string16& data) { - string_ = data; - formats_ |= OSExchangeData::STRING; -} - -void OSExchangeDataProviderGtk::SetURL(const GURL& url, const string16& title) { - url_ = url; - title_ = title; - formats_ |= OSExchangeData::URL; -} - -void OSExchangeDataProviderGtk::SetFilename(const base::FilePath& path) { - filename_ = path; - formats_ |= OSExchangeData::FILE_NAME; -} - -void OSExchangeDataProviderGtk::SetPickledData(GdkAtom format, - const Pickle& data) { - pickle_data_[format] = data; - formats_ |= OSExchangeData::PICKLED_DATA; -} - -bool OSExchangeDataProviderGtk::GetString(string16* data) const { - if ((formats_ & OSExchangeData::STRING) == 0) - return false; - *data = string_; - return true; -} - -bool OSExchangeDataProviderGtk::GetURLAndTitle(GURL* url, - string16* title) const { - if ((formats_ & OSExchangeData::URL) == 0) { - title->clear(); - return GetPlainTextURL(url); - } - - if (!url_.is_valid()) - return false; - - *url = url_; - *title = title_; - return true; -} - -bool OSExchangeDataProviderGtk::GetFilename(base::FilePath* path) const { - if ((formats_ & OSExchangeData::FILE_NAME) == 0) - return false; - *path = filename_; - return true; -} - -bool OSExchangeDataProviderGtk::GetPickledData(GdkAtom format, - Pickle* data) const { - PickleData::const_iterator i = pickle_data_.find(format); - if (i == pickle_data_.end()) - return false; - - *data = i->second; - return true; -} - -bool OSExchangeDataProviderGtk::HasString() const { - return (known_formats_ & OSExchangeData::STRING) != 0 || - (formats_ & OSExchangeData::STRING) != 0; -} - -bool OSExchangeDataProviderGtk::HasURL() const { - if ((known_formats_ & OSExchangeData::URL) != 0 || - (formats_ & OSExchangeData::URL) != 0) { - return true; - } - // No URL, see if we have plain text that can be parsed as a URL. - return GetPlainTextURL(NULL); -} - -bool OSExchangeDataProviderGtk::HasFile() const { - return (known_formats_ & OSExchangeData::FILE_NAME) != 0 || - (formats_ & OSExchangeData::FILE_NAME) != 0; - } - -bool OSExchangeDataProviderGtk::HasCustomFormat(GdkAtom format) const { - return known_custom_formats_.find(format) != known_custom_formats_.end() || - pickle_data_.find(format) != pickle_data_.end(); -} - -bool OSExchangeDataProviderGtk::GetPlainTextURL(GURL* url) const { - if ((formats_ & OSExchangeData::STRING) == 0) - return false; - - GURL test_url(string_); - if (!test_url.is_valid()) - return false; - - if (url) - *url = test_url; - return true; -} - -void OSExchangeDataProviderGtk::SetDragImage( - GdkPixbuf* drag_image, - const gfx::Vector2d& cursor_offset) { - if (drag_image_) - g_object_unref(drag_image_); - g_object_ref(drag_image); - drag_image_ = drag_image; - cursor_offset_ = cursor_offset; -} - -/////////////////////////////////////////////////////////////////////////////// -// OSExchangeData, public: - -// static -OSExchangeData::Provider* OSExchangeData::CreateProvider() { - return new OSExchangeDataProviderGtk(); -} - -GdkAtom OSExchangeData::RegisterCustomFormat(const std::string& type) { - return gdk_atom_intern(type.c_str(), false); -} - -} // namespace ui diff --git a/ui/base/dragdrop/os_exchange_data_provider_gtk.h b/ui/base/dragdrop/os_exchange_data_provider_gtk.h deleted file mode 100644 index 1856053..0000000 --- a/ui/base/dragdrop/os_exchange_data_provider_gtk.h +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) 2012 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 UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_GTK_H_ -#define UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_GTK_H_ - -#include <gtk/gtk.h> -#include <map> -#include <set> -#include <string> - -#include "base/compiler_specific.h" -#include "base/files/file_path.h" -#include "base/pickle.h" -#include "base/string16.h" -#include "googleurl/src/gurl.h" -#include "ui/base/dragdrop/os_exchange_data.h" -#include "ui/gfx/vector2d.h" - -namespace ui { - -// OSExchangeData::Provider implementation for Gtk. OSExchangeDataProviderGtk -// is created with a set of known data types. In addition specific data -// types can be set on OSExchangeDataProviderGtk by way of the various setters. -// The various has methods return true if the format was supplied to the -// constructor, or explicitly set. -class UI_EXPORT OSExchangeDataProviderGtk : public OSExchangeData::Provider { - public: - OSExchangeDataProviderGtk(int known_formats, - const std::set<GdkAtom>& known_custom_formats_); - OSExchangeDataProviderGtk(); - - virtual ~OSExchangeDataProviderGtk(); - - int known_formats() const { return known_formats_; } - const std::set<GdkAtom>& known_custom_formats() const { - return known_custom_formats_; - } - - // Returns true if all the formats and custom formats identified by |formats| - // and |custom_formats| have been set in this provider. - // - // NOTE: this is NOT the same as whether a format may be provided (as is - // returned by the various HasXXX methods), but rather if the data for the - // formats has been set on this provider by way of the various Setter - // methods. - bool HasDataForAllFormats(int formats, - const std::set<GdkAtom>& custom_formats) const; - - // Returns the set of formats available as a GtkTargetList. It is up to the - // caller to free (gtk_target_list_unref) the returned list. - GtkTargetList* GetTargetList() const; - - // Writes the data to |selection|. |format| is any combination of - // OSExchangeData::Formats. - void WriteFormatToSelection(int format, - GtkSelectionData* selection) const; - - // Provider methods. - virtual void SetString(const string16& data) OVERRIDE; - virtual void SetURL(const GURL& url, const string16& title) OVERRIDE; - virtual void SetFilename(const base::FilePath& path) OVERRIDE; - virtual void SetFilenames( - const std::vector<OSExchangeData::FileInfo>& filenames) OVERRIDE { - NOTREACHED(); - } - virtual void SetPickledData(OSExchangeData::CustomFormat format, - const Pickle& data) OVERRIDE; - virtual bool GetString(string16* data) const OVERRIDE; - virtual bool GetURLAndTitle(GURL* url, string16* title) const OVERRIDE; - virtual bool GetFilename(base::FilePath* path) const OVERRIDE; - virtual bool GetFilenames( - std::vector<OSExchangeData::FileInfo>* filenames) const OVERRIDE { - NOTREACHED(); - return false; - } - virtual bool GetPickledData(OSExchangeData::CustomFormat format, - Pickle* data) const OVERRIDE; - virtual bool HasString() const OVERRIDE; - virtual bool HasURL() const OVERRIDE; - virtual bool HasFile() const OVERRIDE; - virtual bool HasCustomFormat( - OSExchangeData::CustomFormat format) const OVERRIDE; - - // Set the image and cursor offset data for this drag. Will - // increment the ref count of pixbuf. - void SetDragImage(GdkPixbuf* pixbuf, const gfx::Vector2d& cursor_offset); - GdkPixbuf* drag_image() const { return drag_image_; } - gfx::Vector2d cursor_offset() const { return cursor_offset_; } - - private: - typedef std::map<OSExchangeData::CustomFormat, Pickle> PickleData; - - // Returns true if |formats_| contains a string format and the string can be - // parsed as a URL. - bool GetPlainTextURL(GURL* url) const; - - // These are the possible formats the OSExchangeData may contain. Don't - // confuse this with the actual formats that have been set, which are - // |formats_| and |custom_formats_|. - const int known_formats_; - const std::set<GdkAtom> known_custom_formats_; - - // Actual formats that have been set. See comment above |known_formats_| - // for details. - int formats_; - - // String contents. - string16 string_; - - // URL contents. - GURL url_; - string16 title_; - - // File name. - base::FilePath filename_; - - // PICKLED_DATA contents. - PickleData pickle_data_; - - // Drag image and offset data. - GdkPixbuf* drag_image_; - gfx::Vector2d cursor_offset_; - - DISALLOW_COPY_AND_ASSIGN(OSExchangeDataProviderGtk); -}; - -} // namespace ui - -#endif // UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_GTK_H_ @@ -126,14 +126,12 @@ 'base/dragdrop/cocoa_dnd_util.h', 'base/dragdrop/cocoa_dnd_util.mm', 'base/dragdrop/drag_drop_types.h', - 'base/dragdrop/drag_drop_types_gtk.cc', 'base/dragdrop/drag_drop_types_win.cc', 'base/dragdrop/drag_source_win.cc', 'base/dragdrop/drag_source_win.h', 'base/dragdrop/drag_utils.cc', 'base/dragdrop/drag_utils.h', 'base/dragdrop/drag_utils_aura.cc', - 'base/dragdrop/drag_utils_gtk.cc', 'base/dragdrop/drag_utils_win.cc', 'base/dragdrop/drop_target_win.cc', 'base/dragdrop/drop_target_win.h', @@ -143,8 +141,6 @@ 'base/dragdrop/os_exchange_data.h', 'base/dragdrop/os_exchange_data_provider_aura.cc', 'base/dragdrop/os_exchange_data_provider_aura.h', - 'base/dragdrop/os_exchange_data_provider_gtk.cc', - 'base/dragdrop/os_exchange_data_provider_gtk.h', 'base/dragdrop/os_exchange_data_provider_win.cc', 'base/dragdrop/os_exchange_data_provider_win.h', 'base/events/event.cc', @@ -634,14 +630,10 @@ # Note: because of gyp predence rules this has to be defined as # 'sources/' rather than 'sources!'. 'sources/': [ - ['exclude', '^base/dragdrop/drag_drop_types_gtk.cc'], - ['exclude', '^base/dragdrop/drag_utils_gtk.cc'], ['exclude', '^base/dragdrop/drag_utils.cc'], ['exclude', '^base/dragdrop/drag_utils.h'], ['exclude', '^base/dragdrop/os_exchange_data.cc'], ['exclude', '^base/dragdrop/os_exchange_data.h'], - ['exclude', '^base/dragdrop/os_exchange_data_provider_gtk.cc'], - ['exclude', '^base/dragdrop/os_exchange_data_provider_gtk.h'], ], }, { # Note: because of gyp predence rules this has to be defined as |