OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/base/dragdrop/os_exchange_data_provider_gtk.h" | 5 #include "ui/base/dragdrop/os_exchange_data_provider_gtk.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/gtk_dnd_util.h" | |
10 #include "base/file_path.h" | 9 #include "base/file_path.h" |
11 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
12 #include "net/base/net_util.h" | 11 #include "net/base/net_util.h" |
| 12 #include "ui/base/dragdrop/gtk_dnd_util.h" |
13 | 13 |
14 namespace ui { | 14 namespace ui { |
15 | 15 |
16 OSExchangeDataProviderGtk::OSExchangeDataProviderGtk( | 16 OSExchangeDataProviderGtk::OSExchangeDataProviderGtk( |
17 int known_formats, | 17 int known_formats, |
18 const std::set<GdkAtom>& known_custom_formats) | 18 const std::set<GdkAtom>& known_custom_formats) |
19 : known_formats_(known_formats), | 19 : known_formats_(known_formats), |
20 known_custom_formats_(known_custom_formats), | 20 known_custom_formats_(known_custom_formats), |
21 formats_(0), | 21 formats_(0), |
22 drag_image_(NULL) { | 22 drag_image_(NULL) { |
(...skipping 26 matching lines...) Expand all Loading... |
49 GtkTargetList* OSExchangeDataProviderGtk::GetTargetList() const { | 49 GtkTargetList* OSExchangeDataProviderGtk::GetTargetList() const { |
50 GtkTargetList* targets = gtk_target_list_new(NULL, 0); | 50 GtkTargetList* targets = gtk_target_list_new(NULL, 0); |
51 | 51 |
52 if ((formats_ & OSExchangeData::STRING) != 0) | 52 if ((formats_ & OSExchangeData::STRING) != 0) |
53 gtk_target_list_add_text_targets(targets, OSExchangeData::STRING); | 53 gtk_target_list_add_text_targets(targets, OSExchangeData::STRING); |
54 | 54 |
55 if ((formats_ & OSExchangeData::URL) != 0) { | 55 if ((formats_ & OSExchangeData::URL) != 0) { |
56 gtk_target_list_add_uri_targets(targets, OSExchangeData::URL); | 56 gtk_target_list_add_uri_targets(targets, OSExchangeData::URL); |
57 gtk_target_list_add( | 57 gtk_target_list_add( |
58 targets, | 58 targets, |
59 gtk_dnd_util::GetAtomForTarget(gtk_dnd_util::CHROME_NAMED_URL), | 59 ui::GetAtomForTarget(ui::CHROME_NAMED_URL), |
60 0, | 60 0, |
61 OSExchangeData::URL); | 61 OSExchangeData::URL); |
62 } | 62 } |
63 | 63 |
64 if ((formats_ & OSExchangeData::FILE_NAME) != 0) | 64 if ((formats_ & OSExchangeData::FILE_NAME) != 0) |
65 gtk_target_list_add_uri_targets(targets, OSExchangeData::FILE_NAME); | 65 gtk_target_list_add_uri_targets(targets, OSExchangeData::FILE_NAME); |
66 | 66 |
67 for (PickleData::const_iterator i = pickle_data_.begin(); | 67 for (PickleData::const_iterator i = pickle_data_.begin(); |
68 i != pickle_data_.end(); ++i) { | 68 i != pickle_data_.end(); ++i) { |
69 gtk_target_list_add(targets, i->first, 0, OSExchangeData::PICKLED_DATA); | 69 gtk_target_list_add(targets, i->first, 0, OSExchangeData::PICKLED_DATA); |
(...skipping 13 matching lines...) Expand all Loading... |
83 } | 83 } |
84 | 84 |
85 if ((format & OSExchangeData::URL) != 0) { | 85 if ((format & OSExchangeData::URL) != 0) { |
86 // TODO: this should be pulled out of TabContentsDragSource into a common | 86 // TODO: this should be pulled out of TabContentsDragSource into a common |
87 // place. | 87 // place. |
88 Pickle pickle; | 88 Pickle pickle; |
89 pickle.WriteString(UTF16ToUTF8(title_)); | 89 pickle.WriteString(UTF16ToUTF8(title_)); |
90 pickle.WriteString(url_.spec()); | 90 pickle.WriteString(url_.spec()); |
91 gtk_selection_data_set( | 91 gtk_selection_data_set( |
92 selection, | 92 selection, |
93 gtk_dnd_util::GetAtomForTarget(gtk_dnd_util::CHROME_NAMED_URL), | 93 ui::GetAtomForTarget(ui::CHROME_NAMED_URL), |
94 8, | 94 8, |
95 reinterpret_cast<const guchar*>(pickle.data()), | 95 reinterpret_cast<const guchar*>(pickle.data()), |
96 pickle.size()); | 96 pickle.size()); |
97 | 97 |
98 gchar* uri_array[2]; | 98 gchar* uri_array[2]; |
99 uri_array[0] = strdup(url_.spec().c_str()); | 99 uri_array[0] = strdup(url_.spec().c_str()); |
100 uri_array[1] = NULL; | 100 uri_array[1] = NULL; |
101 gtk_selection_data_set_uris(selection, uri_array); | 101 gtk_selection_data_set_uris(selection, uri_array); |
102 free(uri_array[0]); | 102 free(uri_array[0]); |
103 } | 103 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // static | 239 // static |
240 OSExchangeData::Provider* OSExchangeData::CreateProvider() { | 240 OSExchangeData::Provider* OSExchangeData::CreateProvider() { |
241 return new OSExchangeDataProviderGtk(); | 241 return new OSExchangeDataProviderGtk(); |
242 } | 242 } |
243 | 243 |
244 GdkAtom OSExchangeData::RegisterCustomFormat(const std::string& type) { | 244 GdkAtom OSExchangeData::RegisterCustomFormat(const std::string& type) { |
245 return gdk_atom_intern(type.c_str(), false); | 245 return gdk_atom_intern(type.c_str(), false); |
246 } | 246 } |
247 | 247 |
248 } // namespace ui | 248 } // namespace ui |
OLD | NEW |