OLD | NEW |
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 <X11/extensions/Xfixes.h> | 7 #include <X11/extensions/Xfixes.h> |
8 #include <X11/Xatom.h> | 8 #include <X11/Xatom.h> |
9 #include <list> | 9 #include <list> |
10 #include <set> | 10 #include <set> |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } | 64 } |
65 uint64 primary_sequence_number() const { return primary_sequence_number_; } | 65 uint64 primary_sequence_number() const { return primary_sequence_number_; } |
66 | 66 |
67 private: | 67 private: |
68 friend struct DefaultSingletonTraits<SelectionChangeObserver>; | 68 friend struct DefaultSingletonTraits<SelectionChangeObserver>; |
69 | 69 |
70 SelectionChangeObserver(); | 70 SelectionChangeObserver(); |
71 virtual ~SelectionChangeObserver(); | 71 virtual ~SelectionChangeObserver(); |
72 | 72 |
73 // Overridden from base::MessagePumpObserver: | 73 // Overridden from base::MessagePumpObserver: |
74 virtual base::EventStatus WillProcessEvent( | 74 virtual void WillProcessEvent(const base::NativeEvent& event) OVERRIDE; |
75 const base::NativeEvent& event) OVERRIDE; | |
76 virtual void DidProcessEvent( | 75 virtual void DidProcessEvent( |
77 const base::NativeEvent& event) OVERRIDE {} | 76 const base::NativeEvent& event) OVERRIDE {} |
78 | 77 |
79 int event_base_; | 78 int event_base_; |
80 Atom clipboard_atom_; | 79 Atom clipboard_atom_; |
81 uint64 clipboard_sequence_number_; | 80 uint64 clipboard_sequence_number_; |
82 uint64 primary_sequence_number_; | 81 uint64 primary_sequence_number_; |
83 | 82 |
84 DISALLOW_COPY_AND_ASSIGN(SelectionChangeObserver); | 83 DISALLOW_COPY_AND_ASSIGN(SelectionChangeObserver); |
85 }; | 84 }; |
(...skipping 25 matching lines...) Expand all Loading... |
111 } | 110 } |
112 | 111 |
113 SelectionChangeObserver::~SelectionChangeObserver() { | 112 SelectionChangeObserver::~SelectionChangeObserver() { |
114 // We are a singleton; we will outlive our message pump. | 113 // We are a singleton; we will outlive our message pump. |
115 } | 114 } |
116 | 115 |
117 SelectionChangeObserver* SelectionChangeObserver::GetInstance() { | 116 SelectionChangeObserver* SelectionChangeObserver::GetInstance() { |
118 return Singleton<SelectionChangeObserver>::get(); | 117 return Singleton<SelectionChangeObserver>::get(); |
119 } | 118 } |
120 | 119 |
121 base::EventStatus SelectionChangeObserver::WillProcessEvent( | 120 void SelectionChangeObserver::WillProcessEvent(const base::NativeEvent& event) { |
122 const base::NativeEvent& event) { | |
123 if (event->type == event_base_ + XFixesSelectionNotify) { | 121 if (event->type == event_base_ + XFixesSelectionNotify) { |
124 XFixesSelectionNotifyEvent* ev = | 122 XFixesSelectionNotifyEvent* ev = |
125 reinterpret_cast<XFixesSelectionNotifyEvent*>(event); | 123 reinterpret_cast<XFixesSelectionNotifyEvent*>(event); |
126 if (ev->selection == clipboard_atom_) { | 124 if (ev->selection == clipboard_atom_) { |
127 clipboard_sequence_number_++; | 125 clipboard_sequence_number_++; |
128 } else if (ev->selection == XA_PRIMARY) { | 126 } else if (ev->selection == XA_PRIMARY) { |
129 primary_sequence_number_++; | 127 primary_sequence_number_++; |
130 } else { | 128 } else { |
131 DLOG(ERROR) << "Unexpected selection atom: " << ev->selection; | 129 DLOG(ERROR) << "Unexpected selection atom: " << ev->selection; |
132 } | 130 } |
133 } | 131 } |
134 return base::EVENT_CONTINUE; | |
135 } | 132 } |
136 | 133 |
137 /////////////////////////////////////////////////////////////////////////////// | 134 /////////////////////////////////////////////////////////////////////////////// |
138 | 135 |
139 // Represents a list of possible return types. Copy constructable. | 136 // Represents a list of possible return types. Copy constructable. |
140 class TargetList { | 137 class TargetList { |
141 public: | 138 public: |
142 typedef std::vector< ::Atom> AtomVector; | 139 typedef std::vector< ::Atom> AtomVector; |
143 | 140 |
144 TargetList(const AtomVector& target_list, X11AtomCache* atom_cache); | 141 TargetList(const AtomVector& target_list, X11AtomCache* atom_cache); |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 return type; | 859 return type; |
863 } | 860 } |
864 | 861 |
865 // static | 862 // static |
866 const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() { | 863 const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() { |
867 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData)); | 864 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData)); |
868 return type; | 865 return type; |
869 } | 866 } |
870 | 867 |
871 } // namespace ui | 868 } // namespace ui |
OLD | NEW |