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

Side by Side Diff: ui/base/clipboard/clipboard_gtk.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_chromeos.cc ('k') | ui/base/clipboard/clipboard_mac.mm » ('j') | 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 #include "ui/base/clipboard/clipboard.h" 5 #include "ui/base/clipboard/clipboard.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 #include <X11/extensions/Xfixes.h> 8 #include <X11/extensions/Xfixes.h>
9 #include <X11/Xatom.h> 9 #include <X11/Xatom.h>
10 #include <map> 10 #include <map>
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 return; 456 return;
457 ReadCustomDataTypes(gtk_selection_data_get_data(data), 457 ReadCustomDataTypes(gtk_selection_data_get_data(data),
458 gtk_selection_data_get_length(data), 458 gtk_selection_data_get_length(data),
459 types); 459 types);
460 gtk_selection_data_free(data); 460 gtk_selection_data_free(data);
461 } 461 }
462 462
463 463
464 void Clipboard::ReadText(Clipboard::Buffer buffer, string16* result) const { 464 void Clipboard::ReadText(Clipboard::Buffer buffer, string16* result) const {
465 DCHECK(CalledOnValidThread()); 465 DCHECK(CalledOnValidThread());
466 ReportAction(buffer, READ_TEXT);
466 GtkClipboard* clipboard = LookupBackingClipboard(buffer); 467 GtkClipboard* clipboard = LookupBackingClipboard(buffer);
467 if (clipboard == NULL) 468 if (clipboard == NULL)
468 return; 469 return;
469 470
470 result->clear(); 471 result->clear();
471 gchar* text = gtk_clipboard_wait_for_text(clipboard); 472 gchar* text = gtk_clipboard_wait_for_text(clipboard);
472 473
473 if (text == NULL) 474 if (text == NULL)
474 return; 475 return;
475 476
476 // TODO(estade): do we want to handle the possible error here? 477 // TODO(estade): do we want to handle the possible error here?
477 UTF8ToUTF16(text, strlen(text), result); 478 UTF8ToUTF16(text, strlen(text), result);
478 g_free(text); 479 g_free(text);
479 } 480 }
480 481
481 void Clipboard::ReadAsciiText(Clipboard::Buffer buffer, 482 void Clipboard::ReadAsciiText(Clipboard::Buffer buffer,
482 std::string* result) const { 483 std::string* result) const {
483 DCHECK(CalledOnValidThread()); 484 DCHECK(CalledOnValidThread());
485 ReportAction(buffer, READ_TEXT);
484 GtkClipboard* clipboard = LookupBackingClipboard(buffer); 486 GtkClipboard* clipboard = LookupBackingClipboard(buffer);
485 if (clipboard == NULL) 487 if (clipboard == NULL)
486 return; 488 return;
487 489
488 result->clear(); 490 result->clear();
489 gchar* text = gtk_clipboard_wait_for_text(clipboard); 491 gchar* text = gtk_clipboard_wait_for_text(clipboard);
490 492
491 if (text == NULL) 493 if (text == NULL)
492 return; 494 return;
493 495
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 537
536 *fragment_start = 0; 538 *fragment_start = 0;
537 DCHECK(markup->length() <= kuint32max); 539 DCHECK(markup->length() <= kuint32max);
538 *fragment_end = static_cast<uint32>(markup->length()); 540 *fragment_end = static_cast<uint32>(markup->length());
539 541
540 gtk_selection_data_free(data); 542 gtk_selection_data_free(data);
541 } 543 }
542 544
543 void Clipboard::ReadRTF(Buffer buffer, std::string* result) const { 545 void Clipboard::ReadRTF(Buffer buffer, std::string* result) const {
544 DCHECK(CalledOnValidThread()); 546 DCHECK(CalledOnValidThread());
547 ReportAction(buffer, READ_TEXT);
545 ReadData(GetRtfFormatType(), result); 548 ReadData(GetRtfFormatType(), result);
546 } 549 }
547 550
548 SkBitmap Clipboard::ReadImage(Buffer buffer) const { 551 SkBitmap Clipboard::ReadImage(Buffer buffer) const {
549 DCHECK(CalledOnValidThread()); 552 DCHECK(CalledOnValidThread());
550 ScopedGObject<GdkPixbuf>::Type pixbuf( 553 ScopedGObject<GdkPixbuf>::Type pixbuf(
551 gtk_clipboard_wait_for_image(clipboard_)); 554 gtk_clipboard_wait_for_image(clipboard_));
552 if (!pixbuf.get()) 555 if (!pixbuf.get())
553 return SkBitmap(); 556 return SkBitmap();
554 557
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 return clipboard_; 708 return clipboard_;
706 case BUFFER_SELECTION: 709 case BUFFER_SELECTION:
707 return primary_selection_; 710 return primary_selection_;
708 default: 711 default:
709 NOTREACHED(); 712 NOTREACHED();
710 return NULL; 713 return NULL;
711 } 714 }
712 } 715 }
713 716
714 } // namespace ui 717 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_chromeos.cc ('k') | ui/base/clipboard/clipboard_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698