| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Many of these functions are based on those found in | 5 // Many of these functions are based on those found in |
| 6 // webkit/port/platform/PasteboardWin.cpp | 6 // webkit/port/platform/PasteboardWin.cpp |
| 7 | 7 |
| 8 #include "ui/base/clipboard/clipboard.h" | 8 #include "ui/base/clipboard/clipboard.h" |
| 9 | 9 |
| 10 #include <shlobj.h> | 10 #include <shlobj.h> |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 return; | 345 return; |
| 346 } | 346 } |
| 347 | 347 |
| 348 const FORMATETC* textFormat = ClipboardUtil::GetPlainTextFormat(); | 348 const FORMATETC* textFormat = ClipboardUtil::GetPlainTextFormat(); |
| 349 const FORMATETC* htmlFormat = ClipboardUtil::GetHtmlFormat(); | 349 const FORMATETC* htmlFormat = ClipboardUtil::GetHtmlFormat(); |
| 350 types->clear(); | 350 types->clear(); |
| 351 if (::IsClipboardFormatAvailable(textFormat->cfFormat)) | 351 if (::IsClipboardFormatAvailable(textFormat->cfFormat)) |
| 352 types->push_back(UTF8ToUTF16(kMimeTypeText)); | 352 types->push_back(UTF8ToUTF16(kMimeTypeText)); |
| 353 if (::IsClipboardFormatAvailable(htmlFormat->cfFormat)) | 353 if (::IsClipboardFormatAvailable(htmlFormat->cfFormat)) |
| 354 types->push_back(UTF8ToUTF16(kMimeTypeHTML)); | 354 types->push_back(UTF8ToUTF16(kMimeTypeHTML)); |
| 355 if (::IsClipboardFormatAvailable(CF_BITMAP)) | 355 if (::IsClipboardFormatAvailable(CF_DIB)) |
| 356 types->push_back(UTF8ToUTF16(kMimeTypePNG)); | 356 types->push_back(UTF8ToUTF16(kMimeTypePNG)); |
| 357 *contains_filenames = false; | 357 *contains_filenames = false; |
| 358 } | 358 } |
| 359 | 359 |
| 360 void Clipboard::ReadText(Clipboard::Buffer buffer, string16* result) const { | 360 void Clipboard::ReadText(Clipboard::Buffer buffer, string16* result) const { |
| 361 DCHECK_EQ(buffer, BUFFER_STANDARD); | 361 DCHECK_EQ(buffer, BUFFER_STANDARD); |
| 362 if (!result) { | 362 if (!result) { |
| 363 NOTREACHED(); | 363 NOTREACHED(); |
| 364 return; | 364 return; |
| 365 } | 365 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 | 435 |
| 436 // Acquire the clipboard. | 436 // Acquire the clipboard. |
| 437 ScopedClipboard clipboard; | 437 ScopedClipboard clipboard; |
| 438 if (!clipboard.Acquire(GetClipboardWindow())) | 438 if (!clipboard.Acquire(GetClipboardWindow())) |
| 439 return SkBitmap(); | 439 return SkBitmap(); |
| 440 | 440 |
| 441 // We use a DIB rather than a DDB here since ::GetObject() with the | 441 // We use a DIB rather than a DDB here since ::GetObject() with the |
| 442 // HBITMAP returned from ::GetClipboardData(CF_BITMAP) always reports a color | 442 // HBITMAP returned from ::GetClipboardData(CF_BITMAP) always reports a color |
| 443 // depth of 32bpp. | 443 // depth of 32bpp. |
| 444 BITMAPINFO* bitmap = static_cast<BITMAPINFO*>(::GetClipboardData(CF_DIB)); | 444 BITMAPINFO* bitmap = static_cast<BITMAPINFO*>(::GetClipboardData(CF_DIB)); |
| 445 if (!bitmap) |
| 446 return SkBitmap(); |
| 445 int color_table_length = 0; | 447 int color_table_length = 0; |
| 446 switch (bitmap->bmiHeader.biBitCount) { | 448 switch (bitmap->bmiHeader.biBitCount) { |
| 447 case 1: | 449 case 1: |
| 448 case 4: | 450 case 4: |
| 449 case 8: | 451 case 8: |
| 450 color_table_length = bitmap->bmiHeader.biClrUsed | 452 color_table_length = bitmap->bmiHeader.biClrUsed |
| 451 ? bitmap->bmiHeader.biClrUsed | 453 ? bitmap->bmiHeader.biClrUsed |
| 452 : 1 << bitmap->bmiHeader.biBitCount; | 454 : 1 << bitmap->bmiHeader.biBitCount; |
| 453 break; | 455 break; |
| 454 case 16: | 456 case 16: |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 clipboard_owner_ = ::CreateWindow(L"ClipboardOwnerWindowClass", | 688 clipboard_owner_ = ::CreateWindow(L"ClipboardOwnerWindowClass", |
| 687 L"ClipboardOwnerWindow", | 689 L"ClipboardOwnerWindow", |
| 688 0, 0, 0, 0, 0, | 690 0, 0, 0, 0, 0, |
| 689 HWND_MESSAGE, | 691 HWND_MESSAGE, |
| 690 0, 0, 0); | 692 0, 0, 0); |
| 691 } | 693 } |
| 692 return clipboard_owner_; | 694 return clipboard_owner_; |
| 693 } | 695 } |
| 694 | 696 |
| 695 } // namespace ui | 697 } // namespace ui |
| OLD | NEW |