Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: ui/base/clipboard/clipboard_gtk.cc

Issue 9151007: GTK: Seal up GSEALs, focusing on GtkSelectionData. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add gtk_widget_style_attach to make minimal version 2.18 Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/tab_contents/web_drag_source_gtk.cc ('k') | ui/base/dragdrop/gtk_dnd_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/clipboard/clipboard_gtk.cc
diff --git a/ui/base/clipboard/clipboard_gtk.cc b/ui/base/clipboard/clipboard_gtk.cc
index 5b6a1a902db0e884dc34f6a2029cd846c66b7bd0..b1ea51b229c12a5e863ad10d16951037707062ac 100644
--- a/ui/base/clipboard/clipboard_gtk.cc
+++ b/ui/base/clipboard/clipboard_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.
@@ -129,7 +129,8 @@ void GetData(GtkClipboard* clipboard,
Clipboard::TargetMap* data_map =
reinterpret_cast<Clipboard::TargetMap*>(user_data);
- std::string target_string = GdkAtomToString(selection_data->target);
+ std::string target_string = GdkAtomToString(
+ gtk_selection_data_get_target(selection_data));
Clipboard::TargetMap::iterator iter = data_map->find(target_string);
if (iter == data_map->end())
@@ -139,7 +140,8 @@ void GetData(GtkClipboard* clipboard,
gtk_selection_data_set_pixbuf(selection_data,
reinterpret_cast<GdkPixbuf*>(iter->second.first));
} else {
- gtk_selection_data_set(selection_data, selection_data->target, 8,
+ gtk_selection_data_set(selection_data,
+ gtk_selection_data_get_target(selection_data), 8,
reinterpret_cast<guchar*>(iter->second.first),
iter->second.second);
}
@@ -421,7 +423,9 @@ void Clipboard::ReadAvailableTypes(Clipboard::Buffer buffer,
clipboard, GetWebCustomDataFormatType().ToGdkAtom());
if (!data)
return;
- ReadCustomDataTypes(data->data, data->length, types);
+ ReadCustomDataTypes(gtk_selection_data_get_data(data),
+ gtk_selection_data_get_length(data),
+ types);
gtk_selection_data_free(data);
}
@@ -484,12 +488,15 @@ void Clipboard::ReadHTML(Clipboard::Buffer buffer, string16* markup,
// If the data starts with 0xFEFF, i.e., Byte Order Mark, assume it is
// UTF-16, otherwise assume UTF-8.
- if (data->length >= 2 &&
- reinterpret_cast<uint16_t*>(data->data)[0] == 0xFEFF) {
- markup->assign(reinterpret_cast<uint16_t*>(data->data) + 1,
- (data->length / 2) - 1);
+ gint data_length = gtk_selection_data_get_length(data);
+ const guchar* raw_data = gtk_selection_data_get_data(data);
+
+ if (data_length >= 2 &&
+ reinterpret_cast<const uint16_t*>(raw_data)[0] == 0xFEFF) {
+ markup->assign(reinterpret_cast<const uint16_t*>(raw_data) + 1,
+ (data_length / 2) - 1);
} else {
- UTF8ToUTF16(reinterpret_cast<char*>(data->data), data->length, markup);
+ UTF8ToUTF16(reinterpret_cast<const char*>(raw_data), data_length, markup);
}
// If there is a terminating NULL, drop it.
@@ -532,7 +539,9 @@ void Clipboard::ReadCustomData(Buffer buffer,
clipboard, GetWebCustomDataFormatType().ToGdkAtom());
if (!data)
return;
- ReadCustomDataForType(data->data, data->length, type, result);
+ ReadCustomDataForType(gtk_selection_data_get_data(data),
+ gtk_selection_data_get_length(data),
+ type, result);
gtk_selection_data_free(data);
}
@@ -546,7 +555,9 @@ void Clipboard::ReadData(const FormatType& format, std::string* result) const {
gtk_clipboard_wait_for_contents(clipboard_, format.ToGdkAtom());
if (!data)
return;
- result->assign(reinterpret_cast<char*>(data->data), data->length);
+ result->assign(reinterpret_cast<const char*>(
+ gtk_selection_data_get_data(data)),
+ gtk_selection_data_get_length(data));
gtk_selection_data_free(data);
}
« no previous file with comments | « content/browser/tab_contents/web_drag_source_gtk.cc ('k') | ui/base/dragdrop/gtk_dnd_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698