Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: ui/base/clipboard/clipboard_win.cc

Issue 12313009: Add UMA statistics to the clipboard (Closed) Base URL: http://git.chromium.org/chromium/src.git@bug-177140-fix-test
Patch Set: Remove unnecessary READ_* values Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/base/clipboard/clipboard_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // 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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 ClipboardUtil::GetWebCustomDataFormat()->cfFormat); 430 ClipboardUtil::GetWebCustomDataFormat()->cfFormat);
431 if (!hdata) 431 if (!hdata)
432 return; 432 return;
433 433
434 ReadCustomDataTypes(::GlobalLock(hdata), ::GlobalSize(hdata), types); 434 ReadCustomDataTypes(::GlobalLock(hdata), ::GlobalSize(hdata), types);
435 ::GlobalUnlock(hdata); 435 ::GlobalUnlock(hdata);
436 } 436 }
437 437
438 void Clipboard::ReadText(Clipboard::Buffer buffer, string16* result) const { 438 void Clipboard::ReadText(Clipboard::Buffer buffer, string16* result) const {
439 DCHECK_EQ(buffer, BUFFER_STANDARD); 439 DCHECK_EQ(buffer, BUFFER_STANDARD);
440 ReportAction(buffer, READ_TEXT);
440 if (!result) { 441 if (!result) {
441 NOTREACHED(); 442 NOTREACHED();
442 return; 443 return;
443 } 444 }
444 445
445 result->clear(); 446 result->clear();
446 447
447 // Acquire the clipboard. 448 // Acquire the clipboard.
448 ScopedClipboard clipboard; 449 ScopedClipboard clipboard;
449 if (!clipboard.Acquire(GetClipboardWindow())) 450 if (!clipboard.Acquire(GetClipboardWindow()))
450 return; 451 return;
451 452
452 HANDLE data = ::GetClipboardData(CF_UNICODETEXT); 453 HANDLE data = ::GetClipboardData(CF_UNICODETEXT);
453 if (!data) 454 if (!data)
454 return; 455 return;
455 456
456 result->assign(static_cast<const char16*>(::GlobalLock(data))); 457 result->assign(static_cast<const char16*>(::GlobalLock(data)));
457 ::GlobalUnlock(data); 458 ::GlobalUnlock(data);
458 } 459 }
459 460
460 void Clipboard::ReadAsciiText(Clipboard::Buffer buffer, 461 void Clipboard::ReadAsciiText(Clipboard::Buffer buffer,
461 std::string* result) const { 462 std::string* result) const {
462 DCHECK_EQ(buffer, BUFFER_STANDARD); 463 DCHECK_EQ(buffer, BUFFER_STANDARD);
464 ReportAction(buffer, READ_TEXT);
463 if (!result) { 465 if (!result) {
464 NOTREACHED(); 466 NOTREACHED();
465 return; 467 return;
466 } 468 }
467 469
468 result->clear(); 470 result->clear();
469 471
470 // Acquire the clipboard. 472 // Acquire the clipboard.
471 ScopedClipboard clipboard; 473 ScopedClipboard clipboard;
472 if (!clipboard.Acquire(GetClipboardWindow())) 474 if (!clipboard.Acquire(GetClipboardWindow()))
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 offsets.push_back(start_index - html_start); 527 offsets.push_back(start_index - html_start);
526 offsets.push_back(end_index - html_start); 528 offsets.push_back(end_index - html_start);
527 markup->assign(base::UTF8ToUTF16AndAdjustOffsets(cf_html.data() + html_start, 529 markup->assign(base::UTF8ToUTF16AndAdjustOffsets(cf_html.data() + html_start,
528 &offsets)); 530 &offsets));
529 *fragment_start = base::checked_numeric_cast<uint32>(offsets[0]); 531 *fragment_start = base::checked_numeric_cast<uint32>(offsets[0]);
530 *fragment_end = base::checked_numeric_cast<uint32>(offsets[1]); 532 *fragment_end = base::checked_numeric_cast<uint32>(offsets[1]);
531 } 533 }
532 534
533 void Clipboard::ReadRTF(Buffer buffer, std::string* result) const { 535 void Clipboard::ReadRTF(Buffer buffer, std::string* result) const {
534 DCHECK_EQ(buffer, BUFFER_STANDARD); 536 DCHECK_EQ(buffer, BUFFER_STANDARD);
537 ReportAction(buffer, READ_TEXT);
535 538
536 ReadData(GetRtfFormatType(), result); 539 ReadData(GetRtfFormatType(), result);
537 } 540 }
538 541
539 SkBitmap Clipboard::ReadImage(Buffer buffer) const { 542 SkBitmap Clipboard::ReadImage(Buffer buffer) const {
540 DCHECK_EQ(buffer, BUFFER_STANDARD); 543 DCHECK_EQ(buffer, BUFFER_STANDARD);
541 544
542 // Acquire the clipboard. 545 // Acquire the clipboard.
543 ScopedClipboard clipboard; 546 ScopedClipboard clipboard;
544 if (!clipboard.Acquire(GetClipboardWindow())) 547 if (!clipboard.Acquire(GetClipboardWindow()))
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 clipboard_owner_ = ::CreateWindow(L"ClipboardOwnerWindowClass", 876 clipboard_owner_ = ::CreateWindow(L"ClipboardOwnerWindowClass",
874 L"ClipboardOwnerWindow", 877 L"ClipboardOwnerWindow",
875 0, 0, 0, 0, 0, 878 0, 0, 0, 0, 0,
876 HWND_MESSAGE, 879 HWND_MESSAGE,
877 0, 0, 0); 880 0, 0, 0);
878 } 881 }
879 return clipboard_owner_; 882 return clipboard_owner_;
880 } 883 }
881 884
882 } // namespace ui 885 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698