OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/clipboard_util.h" | 5 #include "base/clipboard_util.h" |
6 | 6 |
7 #include <shellapi.h> | 7 #include <shellapi.h> |
8 #include <shlwapi.h> | 8 #include <shlwapi.h> |
9 #include <wininet.h> | 9 #include <wininet.h> |
10 | 10 |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 | 349 |
350 if (!has_data) | 350 if (!has_data) |
351 return false; | 351 return false; |
352 | 352 |
353 STGMEDIUM content; | 353 STGMEDIUM content; |
354 // The call to GetData can be very slow depending on what is in | 354 // The call to GetData can be very slow depending on what is in |
355 // |data_object|. | 355 // |data_object|. |
356 if (SUCCEEDED(data_object->GetData(GetFileContentFormatZero(), &content))) { | 356 if (SUCCEEDED(data_object->GetData(GetFileContentFormatZero(), &content))) { |
357 if (TYMED_HGLOBAL == content.tymed) { | 357 if (TYMED_HGLOBAL == content.tymed) { |
358 ScopedHGlobal<char> data(content.hGlobal); | 358 ScopedHGlobal<char> data(content.hGlobal); |
359 // The size includes the trailing NULL byte. We don't want it. | 359 file_contents->assign(data.get(), data.Size()); |
360 file_contents->assign(data.get(), data.Size() - 1); | |
361 } | 360 } |
362 ReleaseStgMedium(&content); | 361 ReleaseStgMedium(&content); |
363 } | 362 } |
364 | 363 |
365 STGMEDIUM description; | 364 STGMEDIUM description; |
366 if (SUCCEEDED(data_object->GetData(GetFileDescriptorFormat(), | 365 if (SUCCEEDED(data_object->GetData(GetFileDescriptorFormat(), |
367 &description))) { | 366 &description))) { |
368 ScopedHGlobal<FILEGROUPDESCRIPTOR> fgd(description.hGlobal); | 367 ScopedHGlobal<FILEGROUPDESCRIPTOR> fgd(description.hGlobal); |
369 // We expect there to be at least one file in here. | 368 // We expect there to be at least one file in here. |
370 DCHECK(fgd->cItems >= 1); | 369 DCHECK(fgd->cItems >= 1); |
371 filename->assign(fgd->fgd[0].cFileName); | 370 filename->assign(fgd->fgd[0].cFileName); |
372 ReleaseStgMedium(&description); | 371 ReleaseStgMedium(&description); |
373 } | 372 } |
374 return true; | 373 return true; |
375 } | 374 } |
376 | 375 |
OLD | NEW |