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" |
11 #include "base/i18n/file_util_icu.h" | 11 #include "base/i18n/file_util_icu.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/scoped_handle.h" | 13 #include "base/memory/scoped_handle.h" |
14 #include "base/pickle.h" | 14 #include "base/pickle.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/win/scoped_hglobal.h" | 16 #include "base/win/scoped_hglobal.h" |
17 #include "grit/ui_strings.h" | 17 #include "grit/ui_strings.h" |
18 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
19 #include "ui/base/clipboard/clipboard.h" | 19 #include "ui/base/clipboard/clipboard.h" |
20 #include "ui/base/clipboard/clipboard_util_win.h" | 20 #include "ui/base/clipboard/clipboard_util_win.h" |
| 21 #include "ui/base/dragdrop/file_info.h" |
21 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
22 #include "url/gurl.h" | 23 #include "url/gurl.h" |
23 | 24 |
24 namespace ui { | 25 namespace ui { |
25 | 26 |
26 static const OSExchangeData::CustomFormat& GetRendererTaintCustomType() { | 27 static const OSExchangeData::CustomFormat& GetRendererTaintCustomType() { |
27 CR_DEFINE_STATIC_LOCAL( | 28 CR_DEFINE_STATIC_LOCAL( |
28 ui::OSExchangeData::CustomFormat, | 29 ui::OSExchangeData::CustomFormat, |
29 format, | 30 format, |
30 (ui::Clipboard::GetFormatType("chromium/x-renderer-taint"))); | 31 (ui::Clipboard::GetFormatType("chromium/x-renderer-taint"))); |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 346 |
346 storage = GetIDListStorageForFileName(path); | 347 storage = GetIDListStorageForFileName(path); |
347 if (!storage) | 348 if (!storage) |
348 return; | 349 return; |
349 info = new DataObjectImpl::StoredDataInfo( | 350 info = new DataObjectImpl::StoredDataInfo( |
350 Clipboard::GetIDListFormatType().ToFormatEtc(), storage); | 351 Clipboard::GetIDListFormatType().ToFormatEtc(), storage); |
351 data_->contents_.push_back(info); | 352 data_->contents_.push_back(info); |
352 } | 353 } |
353 | 354 |
354 void OSExchangeDataProviderWin::SetFilenames( | 355 void OSExchangeDataProviderWin::SetFilenames( |
355 const std::vector<OSExchangeData::FileInfo>& filenames) { | 356 const std::vector<FileInfo>& filenames) { |
356 for (size_t i = 0; i < filenames.size(); ++i) { | 357 for (size_t i = 0; i < filenames.size(); ++i) { |
357 STGMEDIUM* storage = GetStorageForFileName(filenames[i].path); | 358 STGMEDIUM* storage = GetStorageForFileName(filenames[i].path); |
358 DataObjectImpl::StoredDataInfo* info = new DataObjectImpl::StoredDataInfo( | 359 DataObjectImpl::StoredDataInfo* info = new DataObjectImpl::StoredDataInfo( |
359 Clipboard::GetCFHDropFormatType().ToFormatEtc(), storage); | 360 Clipboard::GetCFHDropFormatType().ToFormatEtc(), storage); |
360 data_->contents_.push_back(info); | 361 data_->contents_.push_back(info); |
361 } | 362 } |
362 } | 363 } |
363 | 364 |
364 void OSExchangeDataProviderWin::SetPickledData( | 365 void OSExchangeDataProviderWin::SetPickledData( |
365 const OSExchangeData::CustomFormat& format, | 366 const OSExchangeData::CustomFormat& format, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 | 433 |
433 bool OSExchangeDataProviderWin::GetFilename(base::FilePath* path) const { | 434 bool OSExchangeDataProviderWin::GetFilename(base::FilePath* path) const { |
434 std::vector<base::string16> filenames; | 435 std::vector<base::string16> filenames; |
435 bool success = ClipboardUtil::GetFilenames(source_object_, &filenames); | 436 bool success = ClipboardUtil::GetFilenames(source_object_, &filenames); |
436 if (success) | 437 if (success) |
437 *path = base::FilePath(filenames[0]); | 438 *path = base::FilePath(filenames[0]); |
438 return success; | 439 return success; |
439 } | 440 } |
440 | 441 |
441 bool OSExchangeDataProviderWin::GetFilenames( | 442 bool OSExchangeDataProviderWin::GetFilenames( |
442 std::vector<OSExchangeData::FileInfo>* filenames) const { | 443 std::vector<FileInfo>* filenames) const { |
443 std::vector<base::string16> filenames_local; | 444 std::vector<base::string16> filenames_local; |
444 bool success = ClipboardUtil::GetFilenames(source_object_, &filenames_local); | 445 bool success = ClipboardUtil::GetFilenames(source_object_, &filenames_local); |
445 if (success) { | 446 if (success) { |
446 for (size_t i = 0; i < filenames_local.size(); ++i) | 447 for (size_t i = 0; i < filenames_local.size(); ++i) |
447 filenames->push_back( | 448 filenames->push_back( |
448 OSExchangeData::FileInfo(base::FilePath(filenames_local[i]), | 449 FileInfo(base::FilePath(filenames_local[i]), base::FilePath())); |
449 base::FilePath())); | |
450 } | 450 } |
451 return success; | 451 return success; |
452 } | 452 } |
453 | 453 |
454 bool OSExchangeDataProviderWin::GetPickledData( | 454 bool OSExchangeDataProviderWin::GetPickledData( |
455 const OSExchangeData::CustomFormat& format, | 455 const OSExchangeData::CustomFormat& format, |
456 Pickle* data) const { | 456 Pickle* data) const { |
457 DCHECK(data); | 457 DCHECK(data); |
458 bool success = false; | 458 bool success = false; |
459 STGMEDIUM medium; | 459 STGMEDIUM medium; |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 | 1055 |
1056 /////////////////////////////////////////////////////////////////////////////// | 1056 /////////////////////////////////////////////////////////////////////////////// |
1057 // OSExchangeData, public: | 1057 // OSExchangeData, public: |
1058 | 1058 |
1059 // static | 1059 // static |
1060 OSExchangeData::Provider* OSExchangeData::CreateProvider() { | 1060 OSExchangeData::Provider* OSExchangeData::CreateProvider() { |
1061 return new OSExchangeDataProviderWin(); | 1061 return new OSExchangeDataProviderWin(); |
1062 } | 1062 } |
1063 | 1063 |
1064 } // namespace ui | 1064 } // namespace ui |
OLD | NEW |