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

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

Issue 1492403002: Remove kuint32max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: http security header file Created 5 years 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_aura.cc ('k') | ui/base/clipboard/clipboard_mac.h » ('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_aurax11.h" 5 #include "ui/base/clipboard/clipboard_aurax11.h"
6 6
7 #include <stdint.h>
7 #include <X11/extensions/Xfixes.h> 8 #include <X11/extensions/Xfixes.h>
8 #include <X11/Xatom.h> 9 #include <X11/Xatom.h>
10
11 #include <limits>
9 #include <list> 12 #include <list>
10 #include <set> 13 #include <set>
11 14
12 #include "base/basictypes.h"
13 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
14 #include "base/logging.h" 16 #include "base/logging.h"
15 #include "base/memory/ref_counted_memory.h" 17 #include "base/memory/ref_counted_memory.h"
16 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/singleton.h" 19 #include "base/memory/singleton.h"
18 #include "base/metrics/histogram.h" 20 #include "base/metrics/histogram.h"
19 #include "base/stl_util.h" 21 #include "base/stl_util.h"
20 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
21 #include "third_party/skia/include/core/SkBitmap.h" 23 #include "third_party/skia/include/core/SkBitmap.h"
22 #include "ui/base/clipboard/custom_data_helper.h" 24 #include "ui/base/clipboard/custom_data_helper.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 NULL 60 NULL
59 }; 61 };
60 62
61 /////////////////////////////////////////////////////////////////////////////// 63 ///////////////////////////////////////////////////////////////////////////////
62 64
63 // Uses the XFixes API to provide sequence numbers for GetSequenceNumber(). 65 // Uses the XFixes API to provide sequence numbers for GetSequenceNumber().
64 class SelectionChangeObserver : public ui::PlatformEventObserver { 66 class SelectionChangeObserver : public ui::PlatformEventObserver {
65 public: 67 public:
66 static SelectionChangeObserver* GetInstance(); 68 static SelectionChangeObserver* GetInstance();
67 69
68 uint64 clipboard_sequence_number() const { 70 uint64_t clipboard_sequence_number() const {
69 return clipboard_sequence_number_; 71 return clipboard_sequence_number_;
70 } 72 }
71 uint64 primary_sequence_number() const { return primary_sequence_number_; } 73 uint64_t primary_sequence_number() const { return primary_sequence_number_; }
72 74
73 private: 75 private:
74 friend struct base::DefaultSingletonTraits<SelectionChangeObserver>; 76 friend struct base::DefaultSingletonTraits<SelectionChangeObserver>;
75 77
76 SelectionChangeObserver(); 78 SelectionChangeObserver();
77 ~SelectionChangeObserver() override; 79 ~SelectionChangeObserver() override;
78 80
79 // ui::PlatformEventObserver: 81 // ui::PlatformEventObserver:
80 void WillProcessEvent(const ui::PlatformEvent& event) override; 82 void WillProcessEvent(const ui::PlatformEvent& event) override;
81 void DidProcessEvent(const ui::PlatformEvent& event) override {} 83 void DidProcessEvent(const ui::PlatformEvent& event) override {}
82 84
83 int event_base_; 85 int event_base_;
84 Atom clipboard_atom_; 86 Atom clipboard_atom_;
85 uint64 clipboard_sequence_number_; 87 uint64_t clipboard_sequence_number_;
86 uint64 primary_sequence_number_; 88 uint64_t primary_sequence_number_;
87 89
88 DISALLOW_COPY_AND_ASSIGN(SelectionChangeObserver); 90 DISALLOW_COPY_AND_ASSIGN(SelectionChangeObserver);
89 }; 91 };
90 92
91 SelectionChangeObserver::SelectionChangeObserver() 93 SelectionChangeObserver::SelectionChangeObserver()
92 : event_base_(-1), 94 : event_base_(-1),
93 clipboard_atom_(None), 95 clipboard_atom_(None),
94 clipboard_sequence_number_(0), 96 clipboard_sequence_number_(0),
95 primary_sequence_number_(0) { 97 primary_sequence_number_(0) {
96 int ignored; 98 int ignored;
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 ClipboardAuraX11::ClipboardAuraX11() : aurax11_details_(new AuraX11Details) { 665 ClipboardAuraX11::ClipboardAuraX11() : aurax11_details_(new AuraX11Details) {
664 DCHECK(CalledOnValidThread()); 666 DCHECK(CalledOnValidThread());
665 } 667 }
666 668
667 ClipboardAuraX11::~ClipboardAuraX11() { 669 ClipboardAuraX11::~ClipboardAuraX11() {
668 DCHECK(CalledOnValidThread()); 670 DCHECK(CalledOnValidThread());
669 671
670 aurax11_details_->StoreCopyPasteDataAndWait(); 672 aurax11_details_->StoreCopyPasteDataAndWait();
671 } 673 }
672 674
673 uint64 ClipboardAuraX11::GetSequenceNumber(ClipboardType type) const { 675 uint64_t ClipboardAuraX11::GetSequenceNumber(ClipboardType type) const {
674 DCHECK(CalledOnValidThread()); 676 DCHECK(CalledOnValidThread());
675 if (type == CLIPBOARD_TYPE_COPY_PASTE) 677 if (type == CLIPBOARD_TYPE_COPY_PASTE)
676 return SelectionChangeObserver::GetInstance()->clipboard_sequence_number(); 678 return SelectionChangeObserver::GetInstance()->clipboard_sequence_number();
677 else 679 else
678 return SelectionChangeObserver::GetInstance()->primary_sequence_number(); 680 return SelectionChangeObserver::GetInstance()->primary_sequence_number();
679 } 681 }
680 682
681 bool ClipboardAuraX11::IsFormatAvailable(const FormatType& format, 683 bool ClipboardAuraX11::IsFormatAvailable(const FormatType& format,
682 ClipboardType type) const { 684 ClipboardType type) const {
683 DCHECK(CalledOnValidThread()); 685 DCHECK(CalledOnValidThread());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 type, aurax11_details_->GetTextAtoms())); 748 type, aurax11_details_->GetTextAtoms()));
747 if (data.IsValid()) 749 if (data.IsValid())
748 result->assign(data.GetText()); 750 result->assign(data.GetText());
749 } 751 }
750 752
751 // TODO(estade): handle different charsets. 753 // TODO(estade): handle different charsets.
752 // TODO(port): set *src_url. 754 // TODO(port): set *src_url.
753 void ClipboardAuraX11::ReadHTML(ClipboardType type, 755 void ClipboardAuraX11::ReadHTML(ClipboardType type,
754 base::string16* markup, 756 base::string16* markup,
755 std::string* src_url, 757 std::string* src_url,
756 uint32* fragment_start, 758 uint32_t* fragment_start,
757 uint32* fragment_end) const { 759 uint32_t* fragment_end) const {
758 DCHECK(CalledOnValidThread()); 760 DCHECK(CalledOnValidThread());
759 markup->clear(); 761 markup->clear();
760 if (src_url) 762 if (src_url)
761 src_url->clear(); 763 src_url->clear();
762 *fragment_start = 0; 764 *fragment_start = 0;
763 *fragment_end = 0; 765 *fragment_end = 0;
764 766
765 SelectionData data(aurax11_details_->RequestAndWaitForTypes( 767 SelectionData data(aurax11_details_->RequestAndWaitForTypes(
766 type, aurax11_details_->GetAtomsForFormat(GetHtmlFormatType()))); 768 type, aurax11_details_->GetAtomsForFormat(GetHtmlFormatType())));
767 if (data.IsValid()) { 769 if (data.IsValid()) {
768 *markup = data.GetHtml(); 770 *markup = data.GetHtml();
769 771
770 *fragment_start = 0; 772 *fragment_start = 0;
771 DCHECK(markup->length() <= kuint32max); 773 DCHECK(markup->length() <= std::numeric_limits<uint32_t>::max());
772 *fragment_end = static_cast<uint32>(markup->length()); 774 *fragment_end = static_cast<uint32_t>(markup->length());
773 } 775 }
774 } 776 }
775 777
776 void ClipboardAuraX11::ReadRTF(ClipboardType type, std::string* result) const { 778 void ClipboardAuraX11::ReadRTF(ClipboardType type, std::string* result) const {
777 DCHECK(CalledOnValidThread()); 779 DCHECK(CalledOnValidThread());
778 780
779 SelectionData data(aurax11_details_->RequestAndWaitForTypes( 781 SelectionData data(aurax11_details_->RequestAndWaitForTypes(
780 type, aurax11_details_->GetAtomsForFormat(GetRtfFormatType()))); 782 type, aurax11_details_->GetAtomsForFormat(GetRtfFormatType())));
781 if (data.IsValid()) 783 if (data.IsValid())
782 data.AssignTo(result); 784 data.AssignTo(result);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 if (format.Equals(GetBitmapFormatType())) 932 if (format.Equals(GetBitmapFormatType()))
931 return; 933 return;
932 934
933 std::vector<unsigned char> bytes(data_data, data_data + data_len); 935 std::vector<unsigned char> bytes(data_data, data_data + data_len);
934 scoped_refptr<base::RefCountedMemory> mem( 936 scoped_refptr<base::RefCountedMemory> mem(
935 base::RefCountedBytes::TakeVector(&bytes)); 937 base::RefCountedBytes::TakeVector(&bytes));
936 aurax11_details_->InsertMapping(format.ToString(), mem); 938 aurax11_details_->InsertMapping(format.ToString(), mem);
937 } 939 }
938 940
939 } // namespace ui 941 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_aura.cc ('k') | ui/base/clipboard/clipboard_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698