| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "app/os_exchange_data_provider_gtk.h" | 5 #include "app/os_exchange_data_provider_gtk.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/gtk_dnd_util.h" | 9 #include "app/gtk_dnd_util.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "net/base/net_util.h" | 12 #include "net/base/net_util.h" |
| 13 | 13 |
| 14 OSExchangeDataProviderGtk::OSExchangeDataProviderGtk( | 14 OSExchangeDataProviderGtk::OSExchangeDataProviderGtk( |
| 15 int known_formats, | 15 int known_formats, |
| 16 const std::set<GdkAtom>& known_custom_formats) | 16 const std::set<GdkAtom>& known_custom_formats) |
| 17 : known_formats_(known_formats), | 17 : known_formats_(known_formats), |
| 18 known_custom_formats_(known_custom_formats), | 18 known_custom_formats_(known_custom_formats), |
| 19 formats_(0) { | 19 formats_(0), |
| 20 drag_image_(NULL), |
| 21 cursor_offset_x_(0), |
| 22 cursor_offset_y_(0) { |
| 20 } | 23 } |
| 21 | 24 |
| 22 OSExchangeDataProviderGtk::OSExchangeDataProviderGtk() | 25 OSExchangeDataProviderGtk::OSExchangeDataProviderGtk() |
| 23 : known_formats_(0), | 26 : known_formats_(0), |
| 24 formats_(0) { | 27 formats_(0), |
| 28 drag_image_(NULL), |
| 29 cursor_offset_x_(0), |
| 30 cursor_offset_y_(0) { |
| 25 } | 31 } |
| 26 | 32 |
| 27 OSExchangeDataProviderGtk::~OSExchangeDataProviderGtk() { | 33 OSExchangeDataProviderGtk::~OSExchangeDataProviderGtk() { |
| 34 if (drag_image_) |
| 35 g_object_unref(drag_image_); |
| 28 } | 36 } |
| 29 | 37 |
| 30 bool OSExchangeDataProviderGtk::HasDataForAllFormats( | 38 bool OSExchangeDataProviderGtk::HasDataForAllFormats( |
| 31 int formats, | 39 int formats, |
| 32 const std::set<GdkAtom>& custom_formats) const { | 40 const std::set<GdkAtom>& custom_formats) const { |
| 33 if ((formats_ & formats) != formats) | 41 if ((formats_ & formats) != formats) |
| 34 return false; | 42 return false; |
| 35 for (std::set<GdkAtom>::iterator i = custom_formats.begin(); | 43 for (std::set<GdkAtom>::iterator i = custom_formats.begin(); |
| 36 i != custom_formats.end(); ++i) { | 44 i != custom_formats.end(); ++i) { |
| 37 if (pickle_data_.find(*i) == pickle_data_.end()) | 45 if (pickle_data_.find(*i) == pickle_data_.end()) |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 219 |
| 212 GURL test_url(string_); | 220 GURL test_url(string_); |
| 213 if (!test_url.is_valid()) | 221 if (!test_url.is_valid()) |
| 214 return false; | 222 return false; |
| 215 | 223 |
| 216 if (url) | 224 if (url) |
| 217 *url = test_url; | 225 *url = test_url; |
| 218 return true; | 226 return true; |
| 219 } | 227 } |
| 220 | 228 |
| 229 void OSExchangeDataProviderGtk::SetDragImage(GdkPixbuf* drag_image, |
| 230 int cursor_offset_x, |
| 231 int cursor_offset_y) { |
| 232 if (drag_image_) |
| 233 g_object_unref(drag_image_); |
| 234 g_object_ref(drag_image); |
| 235 drag_image_ = drag_image; |
| 236 cursor_offset_x_ = cursor_offset_x; |
| 237 cursor_offset_y_ = cursor_offset_y; |
| 238 } |
| 239 |
| 221 /////////////////////////////////////////////////////////////////////////////// | 240 /////////////////////////////////////////////////////////////////////////////// |
| 222 // OSExchangeData, public: | 241 // OSExchangeData, public: |
| 223 | 242 |
| 224 // static | 243 // static |
| 225 OSExchangeData::Provider* OSExchangeData::CreateProvider() { | 244 OSExchangeData::Provider* OSExchangeData::CreateProvider() { |
| 226 return new OSExchangeDataProviderGtk(); | 245 return new OSExchangeDataProviderGtk(); |
| 227 } | 246 } |
| 228 | 247 |
| 229 GdkAtom OSExchangeData::RegisterCustomFormat(const std::string& type) { | 248 GdkAtom OSExchangeData::RegisterCustomFormat(const std::string& type) { |
| 230 return gdk_atom_intern(type.c_str(), false); | 249 return gdk_atom_intern(type.c_str(), false); |
| 231 } | 250 } |
| OLD | NEW |