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

Side by Side Diff: ui/base/clipboard/clipboard.h

Issue 9232075: Have ScopedClipboardWriter and Clipboard::WriteObjects take a buffer parameter. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix build error Created 8 years, 10 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 | Annotate | Revision Log
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 #ifndef UI_BASE_CLIPBOARD_CLIPBOARD_H_ 5 #ifndef UI_BASE_CLIPBOARD_CLIPBOARD_H_
6 #define UI_BASE_CLIPBOARD_CLIPBOARD_H_ 6 #define UI_BASE_CLIPBOARD_CLIPBOARD_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // object containing the bitmap data. 123 // object containing the bitmap data.
124 // size gfx::Size struct 124 // size gfx::Size struct
125 // CBF_DATA format char array 125 // CBF_DATA format char array
126 // data byte array 126 // data byte array
127 typedef std::vector<char> ObjectMapParam; 127 typedef std::vector<char> ObjectMapParam;
128 typedef std::vector<ObjectMapParam> ObjectMapParams; 128 typedef std::vector<ObjectMapParam> ObjectMapParams;
129 typedef std::map<int /* ObjectType */, ObjectMapParams> ObjectMap; 129 typedef std::map<int /* ObjectType */, ObjectMapParams> ObjectMap;
130 130
131 // Buffer designates which clipboard the action should be applied to. 131 // Buffer designates which clipboard the action should be applied to.
132 // Only platforms that use the X Window System support the selection 132 // Only platforms that use the X Window System support the selection
133 // buffer. Furthermore we currently only use a buffer other than the 133 // buffer.
134 // standard buffer when reading from the clipboard so only those
135 // functions accept a buffer parameter.
136 enum Buffer { 134 enum Buffer {
137 BUFFER_STANDARD, 135 BUFFER_STANDARD,
138 BUFFER_SELECTION, 136 BUFFER_SELECTION,
139 }; 137 };
140 138
141 static bool IsValidBuffer(int32 buffer) { 139 static bool IsValidBuffer(int32 buffer) {
142 switch (buffer) { 140 switch (buffer) {
143 case BUFFER_STANDARD: 141 case BUFFER_STANDARD:
144 return true; 142 return true;
145 #if defined(USE_X11) && !defined(USE_AURA) 143 #if defined(USE_X11) && !defined(USE_AURA)
146 case BUFFER_SELECTION: 144 case BUFFER_SELECTION:
147 return true; 145 return true;
148 #endif 146 #endif
149 } 147 }
150 return false; 148 return false;
151 } 149 }
152 150
153 static Buffer FromInt(int32 buffer) { 151 static Buffer FromInt(int32 buffer) {
154 return static_cast<Buffer>(buffer); 152 return static_cast<Buffer>(buffer);
155 } 153 }
156 154
157 Clipboard(); 155 Clipboard();
158 ~Clipboard(); 156 ~Clipboard();
159 157
160 // Write a bunch of objects to the system clipboard. Copies are made of the 158 // Write a bunch of objects to the system clipboard. Copies are made of the
161 // contents of |objects|. On Windows they are copied to the system clipboard. 159 // contents of |objects|. On Windows they are copied to the system clipboard.
162 // On linux they are copied into a structure owned by the Clipboard object and 160 // On linux they are copied into a structure owned by the Clipboard object and
163 // kept until the system clipboard is set again. 161 // kept until the system clipboard is set again.
164 void WriteObjects(const ObjectMap& objects); 162 void WriteObjects(Buffer buffer, const ObjectMap& objects);
165 163
166 // On Linux/BSD, we need to know when the clipboard is set to a URL. Most 164 // On Linux/BSD, we need to know when the clipboard is set to a URL. Most
167 // platforms don't care. 165 // platforms don't care.
168 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(USE_AURA) 166 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(USE_AURA)
169 void DidWriteURL(const std::string& utf8_text) {} 167 void DidWriteURL(Buffer buffer, const std::string& utf8_text) {}
dcheng 2012/02/03 21:53:58 It seems like we don't need the buffer parameter s
peter1 2012/02/04 00:54:46 We need to check in DidWriteURL that the write was
dcheng 2012/02/04 01:11:05 Right, but this is only called from ScopedClipboar
peter1 2012/02/04 02:05:43 I see. Well, I don't think it matters too much wh
170 #else // !defined(OS_WIN) && !defined(OS_MACOSX) 168 #else // !defined(OS_WIN) && !defined(OS_MACOSX)
171 void DidWriteURL(const std::string& utf8_text); 169 void DidWriteURL(Buffer buffer, const std::string& utf8_text);
172 #endif 170 #endif
173 171
174 // Returns a sequence number which uniquely identifies clipboard state. 172 // Returns a sequence number which uniquely identifies clipboard state.
175 // This can be used to version the data on the clipboard and determine 173 // This can be used to version the data on the clipboard and determine
176 // whether it has changed. 174 // whether it has changed.
177 uint64 GetSequenceNumber(Buffer buffer); 175 uint64 GetSequenceNumber(Buffer buffer);
178 176
179 // Tests whether the clipboard contains a certain format 177 // Tests whether the clipboard contains a certain format
180 bool IsFormatAvailable(const FormatType& format, Buffer buffer) const; 178 bool IsFormatAvailable(const FormatType& format, Buffer buffer) const;
181 179
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // of data we intend to put on the clipboard on clipboard_data_ as 302 // of data we intend to put on the clipboard on clipboard_data_ as
305 // WriteObjects is running, and then at the end call SetGtkClipboard 303 // WriteObjects is running, and then at the end call SetGtkClipboard
306 // which replaces whatever is on the system clipboard with the 304 // which replaces whatever is on the system clipboard with the
307 // contents of clipboard_data_. 305 // contents of clipboard_data_.
308 306
309 public: 307 public:
310 typedef std::map<std::string, std::pair<char*, size_t> > TargetMap; 308 typedef std::map<std::string, std::pair<char*, size_t> > TargetMap;
311 309
312 private: 310 private:
313 // Write changes to gtk clipboard. 311 // Write changes to gtk clipboard.
314 void SetGtkClipboard(); 312 void SetGtkClipboard(Buffer buffer);
315 // Insert a mapping into clipboard_data_. 313 // Insert a mapping into clipboard_data_.
316 void InsertMapping(const char* key, char* data, size_t data_len); 314 void InsertMapping(const char* key, char* data, size_t data_len);
317 315
318 // Find the gtk clipboard for the passed buffer enum. 316 // Find the gtk clipboard for the passed buffer enum.
319 GtkClipboard* LookupBackingClipboard(Buffer clipboard) const; 317 GtkClipboard* LookupBackingClipboard(Buffer clipboard) const;
320 318
321 TargetMap* clipboard_data_; 319 TargetMap* clipboard_data_;
322 GtkClipboard* clipboard_; 320 GtkClipboard* clipboard_;
323 GtkClipboard* primary_selection_; 321 GtkClipboard* primary_selection_;
324 #endif 322 #endif
325 323
326 // MIME type constants. 324 // MIME type constants.
327 static const char kMimeTypeText[]; 325 static const char kMimeTypeText[];
328 static const char kMimeTypeHTML[]; 326 static const char kMimeTypeHTML[];
329 static const char kMimeTypePNG[]; 327 static const char kMimeTypePNG[];
330 328
331 DISALLOW_COPY_AND_ASSIGN(Clipboard); 329 DISALLOW_COPY_AND_ASSIGN(Clipboard);
332 }; 330 };
333 331
334 } // namespace ui 332 } // namespace ui
335 333
336 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_H_ 334 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698