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 "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 gchar* uri_array[2]; | 96 gchar* uri_array[2]; |
97 uri_array[0] = strdup(url_.spec().c_str()); | 97 uri_array[0] = strdup(url_.spec().c_str()); |
98 uri_array[1] = NULL; | 98 uri_array[1] = NULL; |
99 gtk_selection_data_set_uris(selection, uri_array); | 99 gtk_selection_data_set_uris(selection, uri_array); |
100 free(uri_array[0]); | 100 free(uri_array[0]); |
101 } | 101 } |
102 | 102 |
103 if ((format & OSExchangeData::FILE_NAME) != 0) { | 103 if ((format & OSExchangeData::FILE_NAME) != 0) { |
104 gchar* uri_array[2]; | 104 gchar* uri_array[2]; |
105 uri_array[0] = | 105 uri_array[0] = strdup(net::FilePathToFileURL( |
106 strdup(net::FilePathToFileURL(FilePath(filename_)).spec().c_str()); | 106 base::FilePath(filename_)).spec().c_str()); |
107 uri_array[1] = NULL; | 107 uri_array[1] = NULL; |
108 gtk_selection_data_set_uris(selection, uri_array); | 108 gtk_selection_data_set_uris(selection, uri_array); |
109 free(uri_array[0]); | 109 free(uri_array[0]); |
110 } | 110 } |
111 | 111 |
112 if ((format & OSExchangeData::PICKLED_DATA) != 0) { | 112 if ((format & OSExchangeData::PICKLED_DATA) != 0) { |
113 for (PickleData::const_iterator i = pickle_data_.begin(); | 113 for (PickleData::const_iterator i = pickle_data_.begin(); |
114 i != pickle_data_.end(); ++i) { | 114 i != pickle_data_.end(); ++i) { |
115 const Pickle& data = i->second; | 115 const Pickle& data = i->second; |
116 gtk_selection_data_set( | 116 gtk_selection_data_set( |
(...skipping 10 matching lines...) Expand all Loading... |
127 string_ = data; | 127 string_ = data; |
128 formats_ |= OSExchangeData::STRING; | 128 formats_ |= OSExchangeData::STRING; |
129 } | 129 } |
130 | 130 |
131 void OSExchangeDataProviderGtk::SetURL(const GURL& url, const string16& title) { | 131 void OSExchangeDataProviderGtk::SetURL(const GURL& url, const string16& title) { |
132 url_ = url; | 132 url_ = url; |
133 title_ = title; | 133 title_ = title; |
134 formats_ |= OSExchangeData::URL; | 134 formats_ |= OSExchangeData::URL; |
135 } | 135 } |
136 | 136 |
137 void OSExchangeDataProviderGtk::SetFilename(const FilePath& path) { | 137 void OSExchangeDataProviderGtk::SetFilename(const base::FilePath& path) { |
138 filename_ = path; | 138 filename_ = path; |
139 formats_ |= OSExchangeData::FILE_NAME; | 139 formats_ |= OSExchangeData::FILE_NAME; |
140 } | 140 } |
141 | 141 |
142 void OSExchangeDataProviderGtk::SetPickledData(GdkAtom format, | 142 void OSExchangeDataProviderGtk::SetPickledData(GdkAtom format, |
143 const Pickle& data) { | 143 const Pickle& data) { |
144 pickle_data_[format] = data; | 144 pickle_data_[format] = data; |
145 formats_ |= OSExchangeData::PICKLED_DATA; | 145 formats_ |= OSExchangeData::PICKLED_DATA; |
146 } | 146 } |
147 | 147 |
(...skipping 12 matching lines...) Expand all Loading... |
160 } | 160 } |
161 | 161 |
162 if (!url_.is_valid()) | 162 if (!url_.is_valid()) |
163 return false; | 163 return false; |
164 | 164 |
165 *url = url_; | 165 *url = url_; |
166 *title = title_; | 166 *title = title_; |
167 return true; | 167 return true; |
168 } | 168 } |
169 | 169 |
170 bool OSExchangeDataProviderGtk::GetFilename(FilePath* path) const { | 170 bool OSExchangeDataProviderGtk::GetFilename(base::FilePath* path) const { |
171 if ((formats_ & OSExchangeData::FILE_NAME) == 0) | 171 if ((formats_ & OSExchangeData::FILE_NAME) == 0) |
172 return false; | 172 return false; |
173 *path = filename_; | 173 *path = filename_; |
174 return true; | 174 return true; |
175 } | 175 } |
176 | 176 |
177 bool OSExchangeDataProviderGtk::GetPickledData(GdkAtom format, | 177 bool OSExchangeDataProviderGtk::GetPickledData(GdkAtom format, |
178 Pickle* data) const { | 178 Pickle* data) const { |
179 PickleData::const_iterator i = pickle_data_.find(format); | 179 PickleData::const_iterator i = pickle_data_.find(format); |
180 if (i == pickle_data_.end()) | 180 if (i == pickle_data_.end()) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 // static | 237 // static |
238 OSExchangeData::Provider* OSExchangeData::CreateProvider() { | 238 OSExchangeData::Provider* OSExchangeData::CreateProvider() { |
239 return new OSExchangeDataProviderGtk(); | 239 return new OSExchangeDataProviderGtk(); |
240 } | 240 } |
241 | 241 |
242 GdkAtom OSExchangeData::RegisterCustomFormat(const std::string& type) { | 242 GdkAtom OSExchangeData::RegisterCustomFormat(const std::string& type) { |
243 return gdk_atom_intern(type.c_str(), false); | 243 return gdk_atom_intern(type.c_str(), false); |
244 } | 244 } |
245 | 245 |
246 } // namespace ui | 246 } // namespace ui |
OLD | NEW |