Chromium Code Reviews| 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( |
| 968 MAX_PATH, | 968 descriptor->fgd[0].cFileName, MAX_PATH, file_name.c_str(), |
| 969 file_name.c_str(), | 969 std::min(static_cast<unsigned int>(file_name.size()), MAX_PATH - 1u)); |
|
jschuh
2013/01/14 21:31:39
This should be:
std::min(file_name.size(), static
scottmg
2013/01/14 21:45:00
duh, done.
| |
| 970 std::min(file_name.size(), MAX_PATH - 1u)); | |
| 971 | 970 |
| 972 STGMEDIUM* storage = new STGMEDIUM; | 971 STGMEDIUM* storage = new STGMEDIUM; |
| 973 storage->tymed = TYMED_HGLOBAL; | 972 storage->tymed = TYMED_HGLOBAL; |
| 974 storage->hGlobal = hdata; | 973 storage->hGlobal = hdata; |
| 975 storage->pUnkForRelease = NULL; | 974 storage->pUnkForRelease = NULL; |
| 976 return storage; | 975 return storage; |
| 977 } | 976 } |
| 978 | 977 |
| 979 /////////////////////////////////////////////////////////////////////////////// | 978 /////////////////////////////////////////////////////////////////////////////// |
| 980 // OSExchangeData, public: | 979 // OSExchangeData, public: |
| 981 | 980 |
| 982 // static | 981 // static |
| 983 OSExchangeData::Provider* OSExchangeData::CreateProvider() { | 982 OSExchangeData::Provider* OSExchangeData::CreateProvider() { |
| 984 return new OSExchangeDataProviderWin(); | 983 return new OSExchangeDataProviderWin(); |
| 985 } | 984 } |
| 986 | 985 |
| 987 // static | 986 // static |
| 988 OSExchangeData::CustomFormat OSExchangeData::RegisterCustomFormat( | 987 OSExchangeData::CustomFormat OSExchangeData::RegisterCustomFormat( |
| 989 const std::string& type) { | 988 const std::string& type) { |
| 990 return RegisterClipboardFormat(ASCIIToUTF16(type).c_str()); | 989 return RegisterClipboardFormat(ASCIIToUTF16(type).c_str()); |
| 991 } | 990 } |
| 992 | 991 |
| 993 } // namespace ui | 992 } // namespace ui |
| OLD | NEW |