OLD | NEW |
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 <shlobj.h> | 5 #include <shlobj.h> |
6 | 6 |
7 #include "chrome/common/os_exchange_data.h" | 7 #include "chrome/common/os_exchange_data.h" |
8 | 8 |
9 #include "base/clipboard_util.h" | 9 #include "base/clipboard_util.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 } | 323 } |
324 | 324 |
325 void OSExchangeData::SetFileContents(const std::wstring& filename, | 325 void OSExchangeData::SetFileContents(const std::wstring& filename, |
326 const std::string& file_contents) { | 326 const std::string& file_contents) { |
327 // Add CFSTR_FILEDESCRIPTOR | 327 // Add CFSTR_FILEDESCRIPTOR |
328 STGMEDIUM* storage = GetStorageForFileDescriptor(filename); | 328 STGMEDIUM* storage = GetStorageForFileDescriptor(filename); |
329 contents_.push_back(new StoredDataInfo( | 329 contents_.push_back(new StoredDataInfo( |
330 ClipboardUtil::GetFileDescriptorFormat()->cfFormat, storage)); | 330 ClipboardUtil::GetFileDescriptorFormat()->cfFormat, storage)); |
331 | 331 |
332 // Add CFSTR_FILECONTENTS | 332 // Add CFSTR_FILECONTENTS |
333 storage = GetStorageForString(file_contents); | 333 storage = GetStorageForBytes(file_contents.data(), file_contents.length()); |
334 contents_.push_back(new StoredDataInfo( | 334 contents_.push_back(new StoredDataInfo( |
335 ClipboardUtil::GetFileContentFormatZero()->cfFormat, storage)); | 335 ClipboardUtil::GetFileContentFormatZero()->cfFormat, storage)); |
336 } | 336 } |
337 | 337 |
338 void OSExchangeData::SetCFHtml(const std::wstring& cf_html) { | 338 void OSExchangeData::SetCFHtml(const std::wstring& cf_html) { |
339 std::string utf8 = WideToUTF8(cf_html); | 339 std::string utf8 = WideToUTF8(cf_html); |
340 STGMEDIUM* storage = GetStorageForBytes(utf8.c_str(), utf8.size()); | 340 STGMEDIUM* storage = GetStorageForBytes(utf8.c_str(), utf8.size()); |
341 contents_.push_back(new StoredDataInfo( | 341 contents_.push_back(new StoredDataInfo( |
342 ClipboardUtil::GetHtmlFormat()->cfFormat, storage)); | 342 ClipboardUtil::GetHtmlFormat()->cfFormat, storage)); |
343 } | 343 } |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 | 686 |
687 GlobalUnlock(handle); | 687 GlobalUnlock(handle); |
688 | 688 |
689 STGMEDIUM* storage = new STGMEDIUM; | 689 STGMEDIUM* storage = new STGMEDIUM; |
690 storage->hGlobal = handle; | 690 storage->hGlobal = handle; |
691 storage->tymed = TYMED_HGLOBAL; | 691 storage->tymed = TYMED_HGLOBAL; |
692 storage->pUnkForRelease = NULL; | 692 storage->pUnkForRelease = NULL; |
693 return storage; | 693 return storage; |
694 } | 694 } |
695 | 695 |
OLD | NEW |