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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/i18n/file_util_icu.h" | 12 #include "base/i18n/file_util_icu.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" |
15 #include "base/pickle.h" | 16 #include "base/pickle.h" |
16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
17 #include "base/win/scoped_hglobal.h" | 18 #include "base/win/scoped_hglobal.h" |
18 #include "net/base/filename_util.h" | 19 #include "net/base/filename_util.h" |
19 #include "ui/base/clipboard/clipboard.h" | 20 #include "ui/base/clipboard/clipboard.h" |
20 #include "ui/base/clipboard/clipboard_util_win.h" | 21 #include "ui/base/clipboard/clipboard_util_win.h" |
21 #include "ui/base/dragdrop/file_info.h" | 22 #include "ui/base/dragdrop/file_info.h" |
22 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
23 #include "ui/strings/grit/ui_strings.h" | 24 #include "ui/strings/grit/ui_strings.h" |
24 #include "url/gurl.h" | 25 #include "url/gurl.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 } | 270 } |
270 | 271 |
271 OSExchangeDataProviderWin::OSExchangeDataProviderWin() | 272 OSExchangeDataProviderWin::OSExchangeDataProviderWin() |
272 : data_(new DataObjectImpl()), | 273 : data_(new DataObjectImpl()), |
273 source_object_(data_.get()) { | 274 source_object_(data_.get()) { |
274 } | 275 } |
275 | 276 |
276 OSExchangeDataProviderWin::~OSExchangeDataProviderWin() { | 277 OSExchangeDataProviderWin::~OSExchangeDataProviderWin() { |
277 } | 278 } |
278 | 279 |
279 OSExchangeData::Provider* OSExchangeDataProviderWin::Clone() const { | 280 std::unique_ptr<OSExchangeData::Provider> |
280 return new OSExchangeDataProviderWin(data_object()); | 281 OSExchangeDataProviderWin::Clone() const { |
| 282 return base::MakeUnique<OSExchangeDataProviderWin>(data_object()); |
281 } | 283 } |
282 | 284 |
283 void OSExchangeDataProviderWin::MarkOriginatedFromRenderer() { | 285 void OSExchangeDataProviderWin::MarkOriginatedFromRenderer() { |
284 STGMEDIUM* storage = GetStorageForString(std::string()); | 286 STGMEDIUM* storage = GetStorageForString(std::string()); |
285 data_->contents_.push_back(new DataObjectImpl::StoredDataInfo( | 287 data_->contents_.push_back(new DataObjectImpl::StoredDataInfo( |
286 GetRendererTaintFormatType().ToFormatEtc(), storage)); | 288 GetRendererTaintFormatType().ToFormatEtc(), storage)); |
287 } | 289 } |
288 | 290 |
289 bool OSExchangeDataProviderWin::DidOriginateFromRenderer() const { | 291 bool OSExchangeDataProviderWin::DidOriginateFromRenderer() const { |
290 return HasCustomFormat(GetRendererTaintFormatType()); | 292 return HasCustomFormat(GetRendererTaintFormatType()); |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 wcsncpy_s(descriptor->fgd[0].cFileName, MAX_PATH, file_name.c_str(), | 1060 wcsncpy_s(descriptor->fgd[0].cFileName, MAX_PATH, file_name.c_str(), |
1059 std::min(file_name.size(), static_cast<size_t>(MAX_PATH - 1u))); | 1061 std::min(file_name.size(), static_cast<size_t>(MAX_PATH - 1u))); |
1060 | 1062 |
1061 STGMEDIUM* storage = new STGMEDIUM; | 1063 STGMEDIUM* storage = new STGMEDIUM; |
1062 storage->tymed = TYMED_HGLOBAL; | 1064 storage->tymed = TYMED_HGLOBAL; |
1063 storage->hGlobal = hdata; | 1065 storage->hGlobal = hdata; |
1064 storage->pUnkForRelease = NULL; | 1066 storage->pUnkForRelease = NULL; |
1065 return storage; | 1067 return storage; |
1066 } | 1068 } |
1067 | 1069 |
1068 /////////////////////////////////////////////////////////////////////////////// | |
1069 // OSExchangeData, public: | |
1070 | |
1071 // static | |
1072 OSExchangeData::Provider* OSExchangeData::CreateProvider() { | |
1073 return new OSExchangeDataProviderWin(); | |
1074 } | |
1075 | |
1076 } // namespace ui | 1070 } // namespace ui |
OLD | NEW |