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 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 static STGMEDIUM* GetStorageForFileDescriptor( | 957 static STGMEDIUM* GetStorageForFileDescriptor( |
958 const FilePath& path) { | 958 const FilePath& path) { |
959 string16 file_name = path.value(); | 959 string16 file_name = path.value(); |
960 DCHECK(!file_name.empty()); | 960 DCHECK(!file_name.empty()); |
961 HANDLE hdata = GlobalAlloc(GPTR, sizeof(FILEGROUPDESCRIPTOR)); | 961 HANDLE hdata = GlobalAlloc(GPTR, sizeof(FILEGROUPDESCRIPTOR)); |
962 base::win::ScopedHGlobal<FILEGROUPDESCRIPTOR> locked_mem(hdata); | 962 base::win::ScopedHGlobal<FILEGROUPDESCRIPTOR> locked_mem(hdata); |
963 | 963 |
964 FILEGROUPDESCRIPTOR* descriptor = locked_mem.get(); | 964 FILEGROUPDESCRIPTOR* descriptor = locked_mem.get(); |
965 descriptor->cItems = 1; | 965 descriptor->cItems = 1; |
966 descriptor->fgd[0].dwFlags = FD_LINKUI; | 966 descriptor->fgd[0].dwFlags = FD_LINKUI; |
967 wcsncpy_s(descriptor->fgd[0].cFileName, | 967 wcsncpy_s(descriptor->fgd[0].cFileName, MAX_PATH, file_name.c_str(), |
968 MAX_PATH, | 968 std::min(file_name.size(), static_cast<size_t>(MAX_PATH - 1u))); |
969 file_name.c_str(), | |
970 std::min(file_name.size(), MAX_PATH - 1u)); | |
971 | 969 |
972 STGMEDIUM* storage = new STGMEDIUM; | 970 STGMEDIUM* storage = new STGMEDIUM; |
973 storage->tymed = TYMED_HGLOBAL; | 971 storage->tymed = TYMED_HGLOBAL; |
974 storage->hGlobal = hdata; | 972 storage->hGlobal = hdata; |
975 storage->pUnkForRelease = NULL; | 973 storage->pUnkForRelease = NULL; |
976 return storage; | 974 return storage; |
977 } | 975 } |
978 | 976 |
979 /////////////////////////////////////////////////////////////////////////////// | 977 /////////////////////////////////////////////////////////////////////////////// |
980 // OSExchangeData, public: | 978 // OSExchangeData, public: |
981 | 979 |
982 // static | 980 // static |
983 OSExchangeData::Provider* OSExchangeData::CreateProvider() { | 981 OSExchangeData::Provider* OSExchangeData::CreateProvider() { |
984 return new OSExchangeDataProviderWin(); | 982 return new OSExchangeDataProviderWin(); |
985 } | 983 } |
986 | 984 |
987 // static | 985 // static |
988 OSExchangeData::CustomFormat OSExchangeData::RegisterCustomFormat( | 986 OSExchangeData::CustomFormat OSExchangeData::RegisterCustomFormat( |
989 const std::string& type) { | 987 const std::string& type) { |
990 return RegisterClipboardFormat(ASCIIToUTF16(type).c_str()); | 988 return RegisterClipboardFormat(ASCIIToUTF16(type).c_str()); |
991 } | 989 } |
992 | 990 |
993 } // namespace ui | 991 } // namespace ui |
OLD | NEW |