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

Side by Side Diff: base/clipboard_linux.cc

Issue 28294: Modified clipboard classes to use string16 instead of std::wstring (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/clipboard.h ('k') | base/clipboard_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/clipboard.h" 5 #include "base/clipboard.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 7
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 break; 193 break;
194 } 194 }
195 } 195 }
196 196
197 gtk_selection_data_free(data); 197 gtk_selection_data_free(data);
198 g_free(targets); 198 g_free(targets);
199 199
200 return retval; 200 return retval;
201 } 201 }
202 202
203 void Clipboard::ReadText(std::wstring* result) const { 203 void Clipboard::ReadText(string16* result) const {
204 result->clear(); 204 result->clear();
205 gchar* text = gtk_clipboard_wait_for_text(clipboard_); 205 gchar* text = gtk_clipboard_wait_for_text(clipboard_);
206 206
207 if (text == NULL) 207 if (text == NULL)
208 return; 208 return;
209 209
210 // TODO(estade): do we want to handle the possible error here? 210 // TODO(estade): do we want to handle the possible error here?
211 UTF8ToWide(text, strlen(text), result); 211 UTF8ToUTF16(text, strlen(text), result);
212 g_free(text); 212 g_free(text);
213 } 213 }
214 214
215 void Clipboard::ReadAsciiText(std::string* result) const { 215 void Clipboard::ReadAsciiText(std::string* result) const {
216 result->clear(); 216 result->clear();
217 gchar* text = gtk_clipboard_wait_for_text(clipboard_); 217 gchar* text = gtk_clipboard_wait_for_text(clipboard_);
218 218
219 if (text == NULL) 219 if (text == NULL)
220 return; 220 return;
221 221
222 result->assign(text); 222 result->assign(text);
223 g_free(text); 223 g_free(text);
224 } 224 }
225 225
226 void Clipboard::ReadFile(FilePath* file) const {
227 file->clear();
228 }
229
226 // TODO(estade): handle different charsets. 230 // TODO(estade): handle different charsets.
227 void Clipboard::ReadHTML(std::wstring* markup, std::string* src_url) const { 231 void Clipboard::ReadHTML(string16* markup, std::string* src_url) const {
228 markup->clear(); 232 markup->clear();
229 233
230 GtkSelectionData* data = gtk_clipboard_wait_for_contents(clipboard_, 234 GtkSelectionData* data = gtk_clipboard_wait_for_contents(clipboard_,
231 GetHtmlFormatType()); 235 GetHtmlFormatType());
232 236
233 if (!data) 237 if (!data)
234 return; 238 return;
235 239
236 UTF8ToWide(reinterpret_cast<char*>(data->data), 240 UTF8ToUTF16(reinterpret_cast<char*>(data->data),
237 strlen(reinterpret_cast<char*>(data->data)), 241 strlen(reinterpret_cast<char*>(data->data)),
238 markup); 242 markup);
239 gtk_selection_data_free(data); 243 gtk_selection_data_free(data);
240 } 244 }
241 245
242 // static 246 // static
243 Clipboard::FormatType Clipboard::GetPlainTextFormatType() { 247 Clipboard::FormatType Clipboard::GetPlainTextFormatType() {
244 return GDK_TARGET_STRING; 248 return GDK_TARGET_STRING;
245 } 249 }
246 250
247 // static 251 // static
248 Clipboard::FormatType Clipboard::GetPlainTextWFormatType() { 252 Clipboard::FormatType Clipboard::GetPlainTextWFormatType() {
(...skipping 18 matching lines...) Expand all
267 void Clipboard::InsertMapping(const char* key, 271 void Clipboard::InsertMapping(const char* key,
268 char* data, 272 char* data,
269 size_t data_len) { 273 size_t data_len) {
270 TargetMap::iterator iter = clipboard_data_->find(key); 274 TargetMap::iterator iter = clipboard_data_->find(key);
271 275
272 if (iter != clipboard_data_->end()) 276 if (iter != clipboard_data_->end())
273 delete[] iter->second.first; 277 delete[] iter->second.first;
274 278
275 (*clipboard_data_)[key] = std::make_pair(data, data_len); 279 (*clipboard_data_)[key] = std::make_pair(data, data_len);
276 } 280 }
OLDNEW
« no previous file with comments | « base/clipboard.h ('k') | base/clipboard_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698