| 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/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/nix/mime_util_xdg.h" | 10 #include "base/nix/mime_util_xdg.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 const gfx::Point& image_offset) { | 78 const gfx::Point& image_offset) { |
| 79 // Guard against re-starting before previous drag completed. | 79 // Guard against re-starting before previous drag completed. |
| 80 if (drag_context_) { | 80 if (drag_context_) { |
| 81 NOTREACHED(); | 81 NOTREACHED(); |
| 82 web_contents_->SystemDragEnded(); | 82 web_contents_->SystemDragEnded(); |
| 83 return; | 83 return; |
| 84 } | 84 } |
| 85 | 85 |
| 86 int targets_mask = 0; | 86 int targets_mask = 0; |
| 87 | 87 |
| 88 if (!drop_data.plain_text.empty()) | 88 if (!drop_data.text.string().empty()) |
| 89 targets_mask |= ui::TEXT_PLAIN; | 89 targets_mask |= ui::TEXT_PLAIN; |
| 90 if (drop_data.url.is_valid()) { | 90 if (drop_data.url.is_valid()) { |
| 91 targets_mask |= ui::TEXT_URI_LIST; | 91 targets_mask |= ui::TEXT_URI_LIST; |
| 92 targets_mask |= ui::CHROME_NAMED_URL; | 92 targets_mask |= ui::CHROME_NAMED_URL; |
| 93 targets_mask |= ui::NETSCAPE_URL; | 93 targets_mask |= ui::NETSCAPE_URL; |
| 94 } | 94 } |
| 95 if (!drop_data.text_html.empty()) | 95 if (!drop_data.html.string().empty()) |
| 96 targets_mask |= ui::TEXT_HTML; | 96 targets_mask |= ui::TEXT_HTML; |
| 97 if (!drop_data.file_contents.empty()) | 97 if (!drop_data.file_contents.empty()) |
| 98 targets_mask |= ui::CHROME_WEBDROP_FILE_CONTENTS; | 98 targets_mask |= ui::CHROME_WEBDROP_FILE_CONTENTS; |
| 99 if (!drop_data.download_metadata.empty() && | 99 if (!drop_data.download_metadata.empty() && |
| 100 drag_download_util::ParseDownloadMetadata(drop_data.download_metadata, | 100 drag_download_util::ParseDownloadMetadata(drop_data.download_metadata, |
| 101 &wide_download_mime_type_, | 101 &wide_download_mime_type_, |
| 102 &download_file_name_, | 102 &download_file_name_, |
| 103 &download_url_)) { | 103 &download_url_)) { |
| 104 targets_mask |= ui::DIRECT_SAVE_FILE; | 104 targets_mask |= ui::DIRECT_SAVE_FILE; |
| 105 } | 105 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 176 |
| 177 void WebDragSourceGtk::OnDragDataGet(GtkWidget* sender, | 177 void WebDragSourceGtk::OnDragDataGet(GtkWidget* sender, |
| 178 GdkDragContext* context, | 178 GdkDragContext* context, |
| 179 GtkSelectionData* selection_data, | 179 GtkSelectionData* selection_data, |
| 180 guint target_type, | 180 guint target_type, |
| 181 guint time) { | 181 guint time) { |
| 182 const int kBitsPerByte = 8; | 182 const int kBitsPerByte = 8; |
| 183 | 183 |
| 184 switch (target_type) { | 184 switch (target_type) { |
| 185 case ui::TEXT_PLAIN: { | 185 case ui::TEXT_PLAIN: { |
| 186 std::string utf8_text = UTF16ToUTF8(drop_data_->plain_text); | 186 std::string utf8_text = UTF16ToUTF8(drop_data_->text.string()); |
| 187 gtk_selection_data_set_text(selection_data, utf8_text.c_str(), | 187 gtk_selection_data_set_text(selection_data, utf8_text.c_str(), |
| 188 utf8_text.length()); | 188 utf8_text.length()); |
| 189 break; | 189 break; |
| 190 } | 190 } |
| 191 | 191 |
| 192 case ui::TEXT_HTML: { | 192 case ui::TEXT_HTML: { |
| 193 // TODO(estade): change relative links to be absolute using | 193 // TODO(estade): change relative links to be absolute using |
| 194 // |html_base_url|. | 194 // |html_base_url|. |
| 195 std::string utf8_text = UTF16ToUTF8(drop_data_->text_html); | 195 std::string utf8_text = UTF16ToUTF8(drop_data_->html.string()); |
| 196 gtk_selection_data_set(selection_data, | 196 gtk_selection_data_set(selection_data, |
| 197 ui::GetAtomForTarget(ui::TEXT_HTML), | 197 ui::GetAtomForTarget(ui::TEXT_HTML), |
| 198 kBitsPerByte, | 198 kBitsPerByte, |
| 199 reinterpret_cast<const guchar*>(utf8_text.c_str()), | 199 reinterpret_cast<const guchar*>(utf8_text.c_str()), |
| 200 utf8_text.length()); | 200 utf8_text.length()); |
| 201 break; | 201 break; |
| 202 } | 202 } |
| 203 | 203 |
| 204 case ui::TEXT_URI_LIST: | 204 case ui::TEXT_URI_LIST: |
| 205 case ui::CHROME_NAMED_URL: | 205 case ui::CHROME_NAMED_URL: |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 cairo_clip(cr); | 403 cairo_clip(cr); |
| 404 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); | 404 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
| 405 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); | 405 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); |
| 406 cairo_paint(cr); | 406 cairo_paint(cr); |
| 407 cairo_destroy(cr); | 407 cairo_destroy(cr); |
| 408 | 408 |
| 409 return TRUE; | 409 return TRUE; |
| 410 } | 410 } |
| 411 | 411 |
| 412 } // namespace content | 412 } // namespace content |
| OLD | NEW |