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

Unified Diff: base/clipboard_win.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, 10 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 | « base/clipboard_unittest.cc ('k') | base/scoped_clipboard_writer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/clipboard_win.cc
===================================================================
--- base/clipboard_win.cc (revision 10774)
+++ base/clipboard_win.cc (working copy)
@@ -11,6 +11,7 @@
#include <shellapi.h>
#include "base/clipboard_util.h"
+#include "base/lock.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/shared_memory.h"
@@ -169,8 +170,8 @@
}
void Clipboard::WriteText(const char* text_data, size_t text_len) {
- std::wstring text;
- UTF8ToWide(text_data, text_len, &text);
+ string16 text;
+ UTF8ToUTF16(text_data, text_len, &text);
HGLOBAL glob = CreateGlobalData(text);
WriteToClipboard(CF_UNICODETEXT, glob);
@@ -200,7 +201,7 @@
bookmark.append(1, L'\n');
bookmark.append(url_data, url_len);
- std::wstring wide_bookmark = UTF8ToWide(bookmark);
+ string16 wide_bookmark = UTF8ToWide(bookmark);
HGLOBAL glob = CreateGlobalData(wide_bookmark);
WriteToClipboard(GetUrlWFormatType(), glob);
@@ -350,10 +351,9 @@
// invokes a paste command (in a Windows explorer shell, for example), the files
// will be copied to the paste location.
void Clipboard::WriteFiles(const char* file_data, size_t file_len) {
- std::wstring filenames(UTF8ToWide(std::string(file_data, file_len)));
// Calculate the amount of space we'll need store the strings and
// a DROPFILES struct.
- size_t bytes = sizeof(DROPFILES) + filenames.length() * sizeof(wchar_t);
+ size_t bytes = sizeof(DROPFILES) + file_len;
HANDLE hdata = ::GlobalAlloc(GMEM_MOVEABLE, bytes);
if (!hdata)
@@ -364,8 +364,7 @@
drop_files->pFiles = sizeof(DROPFILES);
drop_files->fWide = TRUE;
- memcpy(data + sizeof DROPFILES, filenames.c_str(),
- filenames.length() * sizeof(wchar_t));
+ memcpy(data + sizeof(DROPFILES), file_data, file_len);
::GlobalUnlock(hdata);
WriteToClipboard(CF_HDROP, hdata);
@@ -383,7 +382,7 @@
return ::IsClipboardFormatAvailable(format) != FALSE;
}
-void Clipboard::ReadText(std::wstring* result) const {
+void Clipboard::ReadText(string16* result) const {
if (!result) {
NOTREACHED();
return;
@@ -400,7 +399,7 @@
if (!data)
return;
- result->assign(static_cast<const wchar_t*>(::GlobalLock(data)));
+ result->assign(static_cast<const char16*>(::GlobalLock(data)));
::GlobalUnlock(data);
}
@@ -425,7 +424,7 @@
::GlobalUnlock(data);
}
-void Clipboard::ReadHTML(std::wstring* markup, std::string* src_url) const {
+void Clipboard::ReadHTML(string16* markup, std::string* src_url) const {
if (markup)
markup->clear();
@@ -449,7 +448,7 @@
markup->assign(UTF8ToWide(markup_utf8));
}
-void Clipboard::ReadBookmark(std::wstring* title, std::string* url) const {
+void Clipboard::ReadBookmark(string16* title, std::string* url) const {
if (title)
title->clear();
@@ -465,21 +464,21 @@
if (!data)
return;
- std::wstring bookmark(static_cast<const wchar_t*>(::GlobalLock(data)));
+ string16 bookmark(static_cast<const char16*>(::GlobalLock(data)));
::GlobalUnlock(data);
ParseBookmarkClipboardFormat(bookmark, title, url);
}
// Read a file in HDROP format from the clipboard.
-void Clipboard::ReadFile(std::wstring* file) const {
+void Clipboard::ReadFile(FilePath* file) const {
if (!file) {
NOTREACHED();
return;
}
file->clear();
- std::vector<std::wstring> files;
+ std::vector<FilePath> files;
ReadFiles(&files);
// Take the first file, if available.
@@ -488,7 +487,7 @@
}
// Read a set of files in HDROP format from the clipboard.
-void Clipboard::ReadFiles(std::vector<std::wstring>* files) const {
+void Clipboard::ReadFiles(std::vector<FilePath>* files) const {
if (!files) {
NOTREACHED();
return;
@@ -510,7 +509,7 @@
if (count) {
for (int i = 0; i < count; ++i) {
int size = ::DragQueryFile(drop, i, NULL, 0) + 1;
- std::wstring file;
+ string16 file;
::DragQueryFile(drop, i, WriteInto(&file, size), size);
files->push_back(file);
}
@@ -518,10 +517,10 @@
}
// static
-void Clipboard::ParseBookmarkClipboardFormat(const std::wstring& bookmark,
- std::wstring* title,
- std::string* url) {
- const wchar_t* const kDelim = L"\r\n";
+void Clipboard::ParseBookmarkClipboardFormat(const string16& bookmark,
+ string16* title,
+ string16* url) {
+ const string16 kDelim = ASCIIToUTF16("\r\n");
const size_t title_end = bookmark.find_first_of(kDelim);
if (title)
@@ -529,8 +528,8 @@
if (url) {
const size_t url_start = bookmark.find_first_not_of(kDelim, title_end);
- if (url_start != std::wstring::npos)
- *url = WideToUTF8(bookmark.substr(url_start, std::wstring::npos));
+ if (url_start != string16::npos)
+ *url = UTF16ToUTF8(bookmark.substr(url_start, string16::npos));
}
}
« no previous file with comments | « base/clipboard_unittest.cc ('k') | base/scoped_clipboard_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698