OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/base/dragdrop/os_exchange_data_provider_win.h" | 5 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 for (size_t i = 0; i < filenames.size(); ++i) { | 357 for (size_t i = 0; i < filenames.size(); ++i) { |
358 STGMEDIUM* storage = GetStorageForFileName(filenames[i].path); | 358 STGMEDIUM* storage = GetStorageForFileName(filenames[i].path); |
359 DataObjectImpl::StoredDataInfo* info = new DataObjectImpl::StoredDataInfo( | 359 DataObjectImpl::StoredDataInfo* info = new DataObjectImpl::StoredDataInfo( |
360 Clipboard::GetCFHDropFormatType().ToFormatEtc(), storage); | 360 Clipboard::GetCFHDropFormatType().ToFormatEtc(), storage); |
361 data_->contents_.push_back(info); | 361 data_->contents_.push_back(info); |
362 } | 362 } |
363 } | 363 } |
364 | 364 |
365 void OSExchangeDataProviderWin::SetPickledData( | 365 void OSExchangeDataProviderWin::SetPickledData( |
366 const OSExchangeData::CustomFormat& format, | 366 const OSExchangeData::CustomFormat& format, |
367 const Pickle& data) { | 367 const base::Pickle& data) { |
368 STGMEDIUM* storage = GetStorageForBytes(data.data(), data.size()); | 368 STGMEDIUM* storage = GetStorageForBytes(data.data(), data.size()); |
369 data_->contents_.push_back( | 369 data_->contents_.push_back( |
370 new DataObjectImpl::StoredDataInfo(format.ToFormatEtc(), storage)); | 370 new DataObjectImpl::StoredDataInfo(format.ToFormatEtc(), storage)); |
371 } | 371 } |
372 | 372 |
373 void OSExchangeDataProviderWin::SetFileContents( | 373 void OSExchangeDataProviderWin::SetFileContents( |
374 const base::FilePath& filename, | 374 const base::FilePath& filename, |
375 const std::string& file_contents) { | 375 const std::string& file_contents) { |
376 // Add CFSTR_FILEDESCRIPTOR | 376 // Add CFSTR_FILEDESCRIPTOR |
377 STGMEDIUM* storage = GetStorageForFileDescriptor(filename); | 377 STGMEDIUM* storage = GetStorageForFileDescriptor(filename); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 if (success) { | 442 if (success) { |
443 for (size_t i = 0; i < filenames_local.size(); ++i) | 443 for (size_t i = 0; i < filenames_local.size(); ++i) |
444 filenames->push_back( | 444 filenames->push_back( |
445 FileInfo(base::FilePath(filenames_local[i]), base::FilePath())); | 445 FileInfo(base::FilePath(filenames_local[i]), base::FilePath())); |
446 } | 446 } |
447 return success; | 447 return success; |
448 } | 448 } |
449 | 449 |
450 bool OSExchangeDataProviderWin::GetPickledData( | 450 bool OSExchangeDataProviderWin::GetPickledData( |
451 const OSExchangeData::CustomFormat& format, | 451 const OSExchangeData::CustomFormat& format, |
452 Pickle* data) const { | 452 base::Pickle* data) const { |
453 DCHECK(data); | 453 DCHECK(data); |
454 bool success = false; | 454 bool success = false; |
455 STGMEDIUM medium; | 455 STGMEDIUM medium; |
456 FORMATETC format_etc = format.ToFormatEtc(); | 456 FORMATETC format_etc = format.ToFormatEtc(); |
457 if (SUCCEEDED(source_object_->GetData(&format_etc, &medium))) { | 457 if (SUCCEEDED(source_object_->GetData(&format_etc, &medium))) { |
458 if (medium.tymed & TYMED_HGLOBAL) { | 458 if (medium.tymed & TYMED_HGLOBAL) { |
459 base::win::ScopedHGlobal<char*> c_data(medium.hGlobal); | 459 base::win::ScopedHGlobal<char*> c_data(medium.hGlobal); |
460 DCHECK_GT(c_data.Size(), 0u); | 460 DCHECK_GT(c_data.Size(), 0u); |
461 *data = Pickle(c_data.get(), static_cast<int>(c_data.Size())); | 461 *data = base::Pickle(c_data.get(), static_cast<int>(c_data.Size())); |
462 success = true; | 462 success = true; |
463 } | 463 } |
464 ReleaseStgMedium(&medium); | 464 ReleaseStgMedium(&medium); |
465 } | 465 } |
466 return success; | 466 return success; |
467 } | 467 } |
468 | 468 |
469 bool OSExchangeDataProviderWin::GetFileContents( | 469 bool OSExchangeDataProviderWin::GetFileContents( |
470 base::FilePath* filename, | 470 base::FilePath* filename, |
471 std::string* file_contents) const { | 471 std::string* file_contents) const { |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 | 1065 |
1066 /////////////////////////////////////////////////////////////////////////////// | 1066 /////////////////////////////////////////////////////////////////////////////// |
1067 // OSExchangeData, public: | 1067 // OSExchangeData, public: |
1068 | 1068 |
1069 // static | 1069 // static |
1070 OSExchangeData::Provider* OSExchangeData::CreateProvider() { | 1070 OSExchangeData::Provider* OSExchangeData::CreateProvider() { |
1071 return new OSExchangeDataProviderWin(); | 1071 return new OSExchangeDataProviderWin(); |
1072 } | 1072 } |
1073 | 1073 |
1074 } // namespace ui | 1074 } // namespace ui |
OLD | NEW |