Index: content/browser/tab_contents/web_drag_dest_gtk.cc |
diff --git a/content/browser/tab_contents/web_drag_dest_gtk.cc b/content/browser/tab_contents/web_drag_dest_gtk.cc |
index 3ba700c5de1773b2aafd3ad97235fc02bbc00b1b..5dc5cc5b3dc3e43a04385f0dc15d71b68dcdbc8d 100644 |
--- a/content/browser/tab_contents/web_drag_dest_gtk.cc |
+++ b/content/browser/tab_contents/web_drag_dest_gtk.cc |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
@@ -143,14 +143,16 @@ void WebDragDestGtk::OnDragDataReceived( |
data_requests_--; |
// Decode the data. |
- if (data->data && data->length > 0) { |
+ gint data_length = gtk_selection_data_get_length(data); |
+ const guchar* raw_data = gtk_selection_data_get_data(data); |
+ if (raw_data && data_length > 0) { |
// If the source can't provide us with valid data for a requested target, |
- // data->data will be NULL. |
+ // raw_data will be NULL. |
if (data->target == ui::GetAtomForTarget(ui::TEXT_PLAIN)) { |
guchar* text = gtk_selection_data_get_text(data); |
if (text) { |
drop_data_->plain_text = |
- UTF8ToUTF16(std::string(reinterpret_cast<char*>(text))); |
+ UTF8ToUTF16(std::string(reinterpret_cast<const char*>(text))); |
g_free(text); |
} |
} else if (data->target == ui::GetAtomForTarget(ui::TEXT_URI_LIST)) { |
@@ -181,12 +183,12 @@ void WebDragDestGtk::OnDragDataReceived( |
} else if (data->target == ui::GetAtomForTarget(ui::TEXT_HTML)) { |
// TODO(estade): Can the html have a non-UTF8 encoding? |
drop_data_->text_html = |
- UTF8ToUTF16(std::string(reinterpret_cast<char*>(data->data), |
- data->length)); |
+ UTF8ToUTF16(std::string(reinterpret_cast<const char*>(raw_data), |
+ data_length)); |
// We leave the base URL empty. |
} else if (data->target == ui::GetAtomForTarget(ui::NETSCAPE_URL)) { |
- std::string netscape_url(reinterpret_cast<char*>(data->data), |
- data->length); |
+ std::string netscape_url(reinterpret_cast<const char*>(raw_data), |
+ data_length); |
size_t split = netscape_url.find_first_of('\n'); |
if (split != std::string::npos) { |
drop_data_->url = GURL(netscape_url.substr(0, split)); |
@@ -197,7 +199,7 @@ void WebDragDestGtk::OnDragDataReceived( |
ui::ExtractNamedURL(data, &drop_data_->url, &drop_data_->url_title); |
} else if (data->target == ui::GetAtomForTarget(ui::CUSTOM_DATA)) { |
ui::ReadCustomDataIntoMap( |
- data->data, data->length, &drop_data_->custom_data); |
+ raw_data, data_length, &drop_data_->custom_data); |
} |
} |
@@ -207,7 +209,7 @@ void WebDragDestGtk::OnDragDataReceived( |
// Note that bookmark drag data is encoded in the same format for both |
// GTK and Views, hence we can share the same logic here. |
if (delegate() && data->target == delegate()->GetBookmarkTargetAtom()) { |
- if (data->data && data->length > 0) { |
+ if (raw_data && data_length > 0) { |
delegate()->OnReceiveDataFromGtk(data); |
} else { |
delegate()->OnReceiveProcessedData(drop_data_->url, |