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

Side by Side Diff: base/scoped_clipboard_writer.h

Issue 159815: Refactor bookmark clipboard code to be cross platform. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix UMR Created 11 years, 4 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // This file declares the ScopedClipboardWriter class, a wrapper around 5 // This file declares the ScopedClipboardWriter class, a wrapper around
6 // the Clipboard class which simplifies writing data to the system clipboard. 6 // the Clipboard class which simplifies writing data to the system clipboard.
7 // Upon deletion the class atomically writes all data to |clipboard_|, 7 // Upon deletion the class atomically writes all data to |clipboard_|,
8 // avoiding any potential race condition with other processes that are also 8 // avoiding any potential race condition with other processes that are also
9 // writing to the system clipboard. 9 // writing to the system clipboard.
10 #ifndef BASE_SCOPED_CLIPBOARD_WRITER_H_ 10 #ifndef BASE_SCOPED_CLIPBOARD_WRITER_H_
11 #define BASE_SCOPED_CLIPBOARD_WRITER_H_ 11 #define BASE_SCOPED_CLIPBOARD_WRITER_H_
12 12
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/clipboard.h" 16 #include "base/clipboard.h"
17 #include "base/file_path.h" 17 #include "base/file_path.h"
18 #include "base/string16.h" 18 #include "base/string16.h"
19 19
20 class Pickle;
21
20 // This class is a wrapper for |Clipboard| that handles packing data 22 // This class is a wrapper for |Clipboard| that handles packing data
21 // into a Clipboard::ObjectMap. 23 // into a Clipboard::ObjectMap.
22 // NB: You should probably NOT be using this class if you include 24 // NB: You should probably NOT be using this class if you include
23 // webkit_glue.h. Use ScopedClipboardWriterGlue instead. 25 // webkit_glue.h. Use ScopedClipboardWriterGlue instead.
24 class ScopedClipboardWriter { 26 class ScopedClipboardWriter {
25 public: 27 public:
26 // Create an instance that is a simple wrapper around clipboard. 28 // Create an instance that is a simple wrapper around clipboard.
27 ScopedClipboardWriter(Clipboard* clipboard); 29 ScopedClipboardWriter(Clipboard* clipboard);
28 30
29 ~ScopedClipboardWriter(); 31 ~ScopedClipboardWriter();
(...skipping 18 matching lines...) Expand all
48 void WriteFile(const FilePath& file); 50 void WriteFile(const FilePath& file);
49 void WriteFiles(const std::vector<FilePath>& files); 51 void WriteFiles(const std::vector<FilePath>& files);
50 52
51 // Used by WebKit to determine whether WebKit wrote the clipboard last 53 // Used by WebKit to determine whether WebKit wrote the clipboard last
52 void WriteWebSmartPaste(); 54 void WriteWebSmartPaste();
53 55
54 // Adds a bitmap to the clipboard 56 // Adds a bitmap to the clipboard
55 // Pixel format is assumed to be 32-bit BI_RGB. 57 // Pixel format is assumed to be 32-bit BI_RGB.
56 void WriteBitmapFromPixels(const void* pixels, const gfx::Size& size); 58 void WriteBitmapFromPixels(const void* pixels, const gfx::Size& size);
57 59
60 // Adds arbitrary data to clipboard.
61 void WritePickledData(const Pickle& pickle, Clipboard::FormatType format);
62
58 protected: 63 protected:
59 // We accumulate the data passed to the various targets in the |objects_| 64 // We accumulate the data passed to the various targets in the |objects_|
60 // vector, and pass it to Clipboard::WriteObjects() during object destruction. 65 // vector, and pass it to Clipboard::WriteObjects() during object destruction.
61 Clipboard::ObjectMap objects_; 66 Clipboard::ObjectMap objects_;
62 Clipboard* clipboard_; 67 Clipboard* clipboard_;
63 68
64 private: 69 private:
65 DISALLOW_COPY_AND_ASSIGN(ScopedClipboardWriter); 70 DISALLOW_COPY_AND_ASSIGN(ScopedClipboardWriter);
66 }; 71 };
67 72
68 #endif // BASE_SCOPED_CLIPBOARD_WRITER_H_ 73 #endif // BASE_SCOPED_CLIPBOARD_WRITER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698