OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/web_contents/web_drag_source_gtk.h" | 5 #include "content/browser/web_contents/web_drag_source_gtk.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/nix/mime_util_xdg.h" | 9 #include "base/nix/mime_util_xdg.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 void WebDragSourceGtk::OnDragDataGet(GtkWidget* sender, | 173 void WebDragSourceGtk::OnDragDataGet(GtkWidget* sender, |
174 GdkDragContext* context, | 174 GdkDragContext* context, |
175 GtkSelectionData* selection_data, | 175 GtkSelectionData* selection_data, |
176 guint target_type, | 176 guint target_type, |
177 guint time) { | 177 guint time) { |
178 const int kBitsPerByte = 8; | 178 const int kBitsPerByte = 8; |
179 | 179 |
180 switch (target_type) { | 180 switch (target_type) { |
181 case ui::TEXT_PLAIN: { | 181 case ui::TEXT_PLAIN: { |
182 std::string utf8_text = UTF16ToUTF8(drop_data_->text.string()); | 182 std::string utf8_text = base::UTF16ToUTF8(drop_data_->text.string()); |
183 gtk_selection_data_set_text(selection_data, utf8_text.c_str(), | 183 gtk_selection_data_set_text(selection_data, utf8_text.c_str(), |
184 utf8_text.length()); | 184 utf8_text.length()); |
185 break; | 185 break; |
186 } | 186 } |
187 | 187 |
188 case ui::TEXT_HTML: { | 188 case ui::TEXT_HTML: { |
189 // TODO(estade): change relative links to be absolute using | 189 // TODO(estade): change relative links to be absolute using |
190 // |html_base_url|. | 190 // |html_base_url|. |
191 std::string utf8_text = UTF16ToUTF8(drop_data_->html.string()); | 191 std::string utf8_text = base::UTF16ToUTF8(drop_data_->html.string()); |
192 gtk_selection_data_set(selection_data, | 192 gtk_selection_data_set(selection_data, |
193 ui::GetAtomForTarget(ui::TEXT_HTML), | 193 ui::GetAtomForTarget(ui::TEXT_HTML), |
194 kBitsPerByte, | 194 kBitsPerByte, |
195 reinterpret_cast<const guchar*>(utf8_text.c_str()), | 195 reinterpret_cast<const guchar*>(utf8_text.c_str()), |
196 utf8_text.length()); | 196 utf8_text.length()); |
197 break; | 197 break; |
198 } | 198 } |
199 | 199 |
200 case ui::TEXT_URI_LIST: | 200 case ui::TEXT_URI_LIST: |
201 case ui::CHROME_NAMED_URL: | 201 case ui::CHROME_NAMED_URL: |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 GdkDragContext* drag_context) { | 312 GdkDragContext* drag_context) { |
313 if (!download_url_.is_empty()) { | 313 if (!download_url_.is_empty()) { |
314 // Generate the file name based on both mime type and proposed file name. | 314 // Generate the file name based on both mime type and proposed file name. |
315 std::string default_name = | 315 std::string default_name = |
316 GetContentClient()->browser()->GetDefaultDownloadName(); | 316 GetContentClient()->browser()->GetDefaultDownloadName(); |
317 base::FilePath generated_download_file_name = | 317 base::FilePath generated_download_file_name = |
318 net::GenerateFileName(download_url_, | 318 net::GenerateFileName(download_url_, |
319 std::string(), | 319 std::string(), |
320 std::string(), | 320 std::string(), |
321 download_file_name_.value(), | 321 download_file_name_.value(), |
322 UTF16ToUTF8(wide_download_mime_type_), | 322 base::UTF16ToUTF8(wide_download_mime_type_), |
323 default_name); | 323 default_name); |
324 | 324 |
325 // Pass the file name to the drop target by setting the source window's | 325 // Pass the file name to the drop target by setting the source window's |
326 // XdndDirectSave0 property. | 326 // XdndDirectSave0 property. |
327 gdk_property_change(drag_context->source_window, | 327 gdk_property_change(drag_context->source_window, |
328 ui::GetAtomForTarget(ui::DIRECT_SAVE_FILE), | 328 ui::GetAtomForTarget(ui::DIRECT_SAVE_FILE), |
329 ui::GetAtomForTarget(ui::TEXT_PLAIN_NO_CHARSET), | 329 ui::GetAtomForTarget(ui::TEXT_PLAIN_NO_CHARSET), |
330 8, | 330 8, |
331 GDK_PROP_MODE_REPLACE, | 331 GDK_PROP_MODE_REPLACE, |
332 reinterpret_cast<const guchar*>( | 332 reinterpret_cast<const guchar*>( |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 cairo_clip(cr); | 394 cairo_clip(cr); |
395 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); | 395 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
396 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); | 396 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); |
397 cairo_paint(cr); | 397 cairo_paint(cr); |
398 cairo_destroy(cr); | 398 cairo_destroy(cr); |
399 | 399 |
400 return TRUE; | 400 return TRUE; |
401 } | 401 } |
402 | 402 |
403 } // namespace content | 403 } // namespace content |
OLD | NEW |