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 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 | 821 |
822 STGMEDIUM* storage = new STGMEDIUM; | 822 STGMEDIUM* storage = new STGMEDIUM; |
823 storage->hGlobal = handle; | 823 storage->hGlobal = handle; |
824 storage->tymed = TYMED_HGLOBAL; | 824 storage->tymed = TYMED_HGLOBAL; |
825 storage->pUnkForRelease = NULL; | 825 storage->pUnkForRelease = NULL; |
826 return storage; | 826 return storage; |
827 } | 827 } |
828 | 828 |
829 template<class T> | 829 template<class T> |
830 static HGLOBAL CopyStringToGlobalHandle(const T& payload) { | 830 static HGLOBAL CopyStringToGlobalHandle(const T& payload) { |
831 int bytes = static_cast<int>(payload.size() + 1) * sizeof(T::value_type); | 831 int bytes = |
| 832 static_cast<int>(payload.size() + 1) * sizeof(typename T::value_type); |
832 HANDLE handle = GlobalAlloc(GPTR, bytes); | 833 HANDLE handle = GlobalAlloc(GPTR, bytes); |
833 void* data = GlobalLock(handle); | 834 void* data = GlobalLock(handle); |
834 size_t allocated = static_cast<size_t>(GlobalSize(handle)); | 835 size_t allocated = static_cast<size_t>(GlobalSize(handle)); |
835 memcpy(data, payload.c_str(), allocated); | 836 memcpy(data, payload.c_str(), allocated); |
836 static_cast<T::value_type*>(data)[payload.size()] = '\0'; | 837 static_cast<typename T::value_type*>(data)[payload.size()] = '\0'; |
837 GlobalUnlock(handle); | 838 GlobalUnlock(handle); |
838 return handle; | 839 return handle; |
839 } | 840 } |
840 | 841 |
841 static STGMEDIUM* GetStorageForString16(const string16& data) { | 842 static STGMEDIUM* GetStorageForString16(const string16& data) { |
842 STGMEDIUM* storage = new STGMEDIUM; | 843 STGMEDIUM* storage = new STGMEDIUM; |
843 storage->hGlobal = CopyStringToGlobalHandle<string16>(data); | 844 storage->hGlobal = CopyStringToGlobalHandle<string16>(data); |
844 storage->tymed = TYMED_HGLOBAL; | 845 storage->tymed = TYMED_HGLOBAL; |
845 storage->pUnkForRelease = NULL; | 846 storage->pUnkForRelease = NULL; |
846 return storage; | 847 return storage; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 return new OSExchangeDataProviderWin(); | 941 return new OSExchangeDataProviderWin(); |
941 } | 942 } |
942 | 943 |
943 // static | 944 // static |
944 OSExchangeData::CustomFormat OSExchangeData::RegisterCustomFormat( | 945 OSExchangeData::CustomFormat OSExchangeData::RegisterCustomFormat( |
945 const std::string& type) { | 946 const std::string& type) { |
946 return RegisterClipboardFormat(ASCIIToUTF16(type).c_str()); | 947 return RegisterClipboardFormat(ASCIIToUTF16(type).c_str()); |
947 } | 948 } |
948 | 949 |
949 } // namespace ui | 950 } // namespace ui |
OLD | NEW |