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

Side by Side Diff: base/clipboard.h

Issue 41012: This changes the base clipboard class. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/clipboard_linux.cc » ('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) 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 #ifndef BASE_CLIPBOARD_H_ 5 #ifndef BASE_CLIPBOARD_H_
6 #define BASE_CLIPBOARD_H_ 6 #define BASE_CLIPBOARD_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/process.h" 13 #include "base/process.h"
14 #include "base/string16.h" 14 #include "base/string16.h"
15 #include "base/gfx/size.h" 15 #include "base/gfx/size.h"
16 16
17 #if defined(OS_MACOSX)
18 #if defined(__OBJC__)
19 @class NSString;
20 #else
21 class NSString;
22 #endif
23 #endif
24
25 class Clipboard { 17 class Clipboard {
26 public: 18 public:
27 #if defined(OS_WIN) 19 typedef std::string FormatType;
28 typedef unsigned int FormatType; 20 #if defined(OS_LINUX)
29 #elif defined(OS_MACOSX)
30 typedef NSString *FormatType;
31 #elif defined(OS_LINUX)
32 typedef struct _GdkAtom* FormatType;
33 typedef struct _GtkClipboard GtkClipboard; 21 typedef struct _GtkClipboard GtkClipboard;
34 typedef std::map<std::string, std::pair<char*, size_t> > TargetMap; 22 typedef std::map<FormatType, std::pair<char*, size_t> > TargetMap;
35 #endif 23 #endif
36 24
37 // ObjectType designates the type of data to be stored in the clipboard. This 25 // ObjectType designates the type of data to be stored in the clipboard. This
38 // designation is shared across all OSes. The system-specific designation 26 // designation is shared across all OSes. The system-specific designation
39 // is defined by FormatType. A single ObjectType might be represented by 27 // is defined by FormatType. A single ObjectType might be represented by
40 // several system-specific FormatTypes. For example, on Linux the CBF_TEXT 28 // several system-specific FormatTypes. For example, on Linux the CBF_TEXT
41 // ObjectType maps to "text/plain", "STRING", and several other formats. On 29 // ObjectType maps to "text/plain", "STRING", and several other formats. On
42 // windows it maps to CF_UNICODETEXT. 30 // windows it maps to CF_UNICODETEXT.
43 enum ObjectType { 31 enum ObjectType {
44 CBF_TEXT, 32 CBF_TEXT,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // kept until the system clipboard is set again. 76 // kept until the system clipboard is set again.
89 void WriteObjects(const ObjectMap& objects); 77 void WriteObjects(const ObjectMap& objects);
90 78
91 // Behaves as above. If there is some shared memory handle passed as one of 79 // Behaves as above. If there is some shared memory handle passed as one of
92 // the objects, it came from the process designated by |process|. This will 80 // the objects, it came from the process designated by |process|. This will
93 // assist in turning it into a shared memory region that the current process 81 // assist in turning it into a shared memory region that the current process
94 // can use. 82 // can use.
95 void WriteObjects(const ObjectMap& objects, base::ProcessHandle process); 83 void WriteObjects(const ObjectMap& objects, base::ProcessHandle process);
96 84
97 // Tests whether the clipboard contains a certain format 85 // Tests whether the clipboard contains a certain format
98 bool IsFormatAvailable(FormatType format) const; 86 bool IsFormatAvailable(const FormatType& format) const;
99 87
100 // Reads UNICODE text from the clipboard, if available. 88 // Reads UNICODE text from the clipboard, if available.
101 void ReadText(string16* result) const; 89 void ReadText(string16* result) const;
102 90
103 // Reads ASCII text from the clipboard, if available. 91 // Reads ASCII text from the clipboard, if available.
104 void ReadAsciiText(std::string* result) const; 92 void ReadAsciiText(std::string* result) const;
105 93
106 // Reads HTML from the clipboard, if available. 94 // Reads HTML from the clipboard, if available.
107 void ReadHTML(string16* markup, std::string* src_url) const; 95 void ReadHTML(string16* markup, std::string* src_url) const;
108 96
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 void WriteBitmap(const char* pixel_data, const char* size_data); 154 void WriteBitmap(const char* pixel_data, const char* size_data);
167 #if defined(OS_WIN) 155 #if defined(OS_WIN)
168 void WriteBitmapFromSharedMemory(const char* bitmap_data, 156 void WriteBitmapFromSharedMemory(const char* bitmap_data,
169 const char* size_data, 157 const char* size_data,
170 base::ProcessHandle handle); 158 base::ProcessHandle handle);
171 159
172 void WriteBitmapFromHandle(HBITMAP source_hbitmap, 160 void WriteBitmapFromHandle(HBITMAP source_hbitmap,
173 const gfx::Size& size); 161 const gfx::Size& size);
174 162
175 // Safely write to system clipboard. Free |handle| on failure. 163 // Safely write to system clipboard. Free |handle| on failure.
176 void WriteToClipboard(FormatType format, HANDLE handle); 164 void WriteToClipboard(unsigned int format, HANDLE handle);
177 165
178 static void ParseBookmarkClipboardFormat(const string16& bookmark, 166 static void ParseBookmarkClipboardFormat(const string16& bookmark,
179 string16* title, 167 string16* title,
180 std::string* url); 168 std::string* url);
181 169
182 // Free a handle depending on its type (as intuited from format) 170 // Free a handle depending on its type (as intuited from format)
183 static void FreeData(FormatType format, HANDLE data); 171 static void FreeData(unsigned int format, HANDLE data);
184 172
185 // Return the window that should be the clipboard owner, creating it 173 // Return the window that should be the clipboard owner, creating it
186 // if neccessary. Marked const for lazily initialization by const methods. 174 // if neccessary. Marked const for lazily initialization by const methods.
187 HWND GetClipboardWindow() const; 175 HWND GetClipboardWindow() const;
188 176
189 // Mark this as mutable so const methods can still do lazy initialization. 177 // Mark this as mutable so const methods can still do lazy initialization.
190 mutable HWND clipboard_owner_; 178 mutable HWND clipboard_owner_;
191 179
192 // True if we can create a window. 180 // True if we can create a window.
193 bool create_window_; 181 bool create_window_;
(...skipping 13 matching lines...) Expand all
207 void InsertMapping(const char* key, char* data, size_t data_len); 195 void InsertMapping(const char* key, char* data, size_t data_len);
208 196
209 TargetMap* clipboard_data_; 197 TargetMap* clipboard_data_;
210 GtkClipboard* clipboard_; 198 GtkClipboard* clipboard_;
211 #endif 199 #endif
212 200
213 DISALLOW_EVIL_CONSTRUCTORS(Clipboard); 201 DISALLOW_EVIL_CONSTRUCTORS(Clipboard);
214 }; 202 };
215 203
216 #endif // BASE_CLIPBOARD_H_ 204 #endif // BASE_CLIPBOARD_H_
OLDNEW
« no previous file with comments | « no previous file | base/clipboard_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698