| OLD | NEW |
| 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/process.h" | 13 #include "base/process.h" |
| 14 #include "base/string16.h" |
| 13 #include "base/gfx/size.h" | 15 #include "base/gfx/size.h" |
| 14 | 16 |
| 15 #if defined(OS_MACOSX) | 17 #if defined(OS_MACOSX) |
| 16 #if defined(__OBJC__) | 18 #if defined(__OBJC__) |
| 17 @class NSString; | 19 @class NSString; |
| 18 #else | 20 #else |
| 19 class NSString; | 21 class NSString; |
| 20 #endif | 22 #endif |
| 21 #endif | 23 #endif |
| 22 | 24 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 // * indicates an optional argument. | 57 // * indicates an optional argument. |
| 56 // | 58 // |
| 57 // Key Arguments Type | 59 // Key Arguments Type |
| 58 // ------------------------------------- | 60 // ------------------------------------- |
| 59 // CBF_TEXT text char array | 61 // CBF_TEXT text char array |
| 60 // CBF_HTML html char array | 62 // CBF_HTML html char array |
| 61 // url* char array | 63 // url* char array |
| 62 // CBF_BOOKMARK html char array | 64 // CBF_BOOKMARK html char array |
| 63 // url char array | 65 // url char array |
| 64 // CBF_LINK html char array | 66 // CBF_LINK html char array |
| 65 // url char array | 67 // url char array |
| 66 // CBF_FILES files char array representing multiple files. | 68 // CBF_FILES files char array representing multiple files. |
| 67 // Filenames are separated by null characters and | 69 // Filenames are separated by null characters and |
| 68 // the final filename is double null terminated. | 70 // the final filename is double null terminated. |
| 71 // The filenames are encoded in platform-specific |
| 72 // encoding. |
| 69 // CBF_WEBKIT none empty vector | 73 // CBF_WEBKIT none empty vector |
| 70 // CBF_BITMAP pixels byte array | 74 // CBF_BITMAP pixels byte array |
| 71 // size gfx::Size struct | 75 // size gfx::Size struct |
| 72 // CBF_SMBITMAP shared_mem shared memory handle | 76 // CBF_SMBITMAP shared_mem shared memory handle |
| 73 // size gfx::Size struct | 77 // size gfx::Size struct |
| 74 typedef std::vector<char> ObjectMapParam; | 78 typedef std::vector<char> ObjectMapParam; |
| 75 typedef std::vector<ObjectMapParam> ObjectMapParams; | 79 typedef std::vector<ObjectMapParam> ObjectMapParams; |
| 76 typedef std::map<int /* ObjectType */, ObjectMapParams> ObjectMap; | 80 typedef std::map<int /* ObjectType */, ObjectMapParams> ObjectMap; |
| 77 | 81 |
| 78 Clipboard(); | 82 Clipboard(); |
| 79 ~Clipboard(); | 83 ~Clipboard(); |
| 80 | 84 |
| 81 // Write a bunch of objects to the system clipboard. Copies are made of the | 85 // Write a bunch of objects to the system clipboard. Copies are made of the |
| 82 // contents of |objects|. On Windows they are copied to the system clipboard. | 86 // contents of |objects|. On Windows they are copied to the system clipboard. |
| 83 // On linux they are copied into a structure owned by the Clipboard object and | 87 // On linux they are copied into a structure owned by the Clipboard object and |
| 84 // kept until the system clipboard is set again. | 88 // kept until the system clipboard is set again. |
| 85 void WriteObjects(const ObjectMap& objects); | 89 void WriteObjects(const ObjectMap& objects); |
| 86 | 90 |
| 87 // Behaves as above. If there is some shared memory handle passed as one of | 91 // Behaves as above. If there is some shared memory handle passed as one of |
| 88 // the objects, it came from the process designated by |process|. This will | 92 // the objects, it came from the process designated by |process|. This will |
| 89 // assist in turning it into a shared memory region that the current process | 93 // assist in turning it into a shared memory region that the current process |
| 90 // can use. | 94 // can use. |
| 91 void WriteObjects(const ObjectMap& objects, base::ProcessHandle process); | 95 void WriteObjects(const ObjectMap& objects, base::ProcessHandle process); |
| 92 | 96 |
| 93 // Tests whether the clipboard contains a certain format | 97 // Tests whether the clipboard contains a certain format |
| 94 bool IsFormatAvailable(FormatType format) const; | 98 bool IsFormatAvailable(FormatType format) const; |
| 95 | 99 |
| 96 // Reads UNICODE text from the clipboard, if available. | 100 // Reads UNICODE text from the clipboard, if available. |
| 97 void ReadText(std::wstring* result) const; | 101 void ReadText(string16* result) const; |
| 98 | 102 |
| 99 // Reads ASCII text from the clipboard, if available. | 103 // Reads ASCII text from the clipboard, if available. |
| 100 void ReadAsciiText(std::string* result) const; | 104 void ReadAsciiText(std::string* result) const; |
| 101 | 105 |
| 102 // Reads HTML from the clipboard, if available. | 106 // Reads HTML from the clipboard, if available. |
| 103 void ReadHTML(std::wstring* markup, std::string* src_url) const; | 107 void ReadHTML(string16* markup, std::string* src_url) const; |
| 104 | 108 |
| 105 // Reads a bookmark from the clipboard, if available. | 109 // Reads a bookmark from the clipboard, if available. |
| 106 void ReadBookmark(std::wstring* title, std::string* url) const; | 110 void ReadBookmark(string16* title, std::string* url) const; |
| 107 | 111 |
| 108 // Reads a file or group of files from the clipboard, if available, into the | 112 // Reads a file or group of files from the clipboard, if available, into the |
| 109 // out parameter. | 113 // out parameter. |
| 110 void ReadFile(std::wstring* file) const; | 114 void ReadFile(FilePath* file) const; |
| 111 void ReadFiles(std::vector<std::wstring>* files) const; | 115 void ReadFiles(std::vector<FilePath>* files) const; |
| 112 | 116 |
| 113 // Get format Identifiers for various types. | 117 // Get format Identifiers for various types. |
| 114 static FormatType GetUrlFormatType(); | 118 static FormatType GetUrlFormatType(); |
| 115 static FormatType GetUrlWFormatType(); | 119 static FormatType GetUrlWFormatType(); |
| 116 static FormatType GetMozUrlFormatType(); | 120 static FormatType GetMozUrlFormatType(); |
| 117 static FormatType GetPlainTextFormatType(); | 121 static FormatType GetPlainTextFormatType(); |
| 118 static FormatType GetPlainTextWFormatType(); | 122 static FormatType GetPlainTextWFormatType(); |
| 119 static FormatType GetFilenameFormatType(); | 123 static FormatType GetFilenameFormatType(); |
| 120 static FormatType GetFilenameWFormatType(); | 124 static FormatType GetFilenameWFormatType(); |
| 121 static FormatType GetWebKitSmartPasteFormatType(); | 125 static FormatType GetWebKitSmartPasteFormatType(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 void WriteBitmapFromSharedMemory(const char* bitmap_data, | 168 void WriteBitmapFromSharedMemory(const char* bitmap_data, |
| 165 const char* size_data, | 169 const char* size_data, |
| 166 base::ProcessHandle handle); | 170 base::ProcessHandle handle); |
| 167 | 171 |
| 168 void WriteBitmapFromHandle(HBITMAP source_hbitmap, | 172 void WriteBitmapFromHandle(HBITMAP source_hbitmap, |
| 169 const gfx::Size& size); | 173 const gfx::Size& size); |
| 170 | 174 |
| 171 // Safely write to system clipboard. Free |handle| on failure. | 175 // Safely write to system clipboard. Free |handle| on failure. |
| 172 void WriteToClipboard(FormatType format, HANDLE handle); | 176 void WriteToClipboard(FormatType format, HANDLE handle); |
| 173 | 177 |
| 174 static void ParseBookmarkClipboardFormat(const std::wstring& bookmark, | 178 static void ParseBookmarkClipboardFormat(const string16& bookmark, |
| 175 std::wstring* title, | 179 string16* title, |
| 176 std::string* url); | 180 std::string* url); |
| 177 | 181 |
| 178 // Free a handle depending on its type (as intuited from format) | 182 // Free a handle depending on its type (as intuited from format) |
| 179 static void FreeData(FormatType format, HANDLE data); | 183 static void FreeData(FormatType format, HANDLE data); |
| 180 | 184 |
| 181 // Return the window that should be the clipboard owner, creating it | 185 // Return the window that should be the clipboard owner, creating it |
| 182 // if neccessary. Marked const for lazily initialization by const methods. | 186 // if neccessary. Marked const for lazily initialization by const methods. |
| 183 HWND GetClipboardWindow() const; | 187 HWND GetClipboardWindow() const; |
| 184 | 188 |
| 185 // Mark this as mutable so const methods can still do lazy initialization. | 189 // Mark this as mutable so const methods can still do lazy initialization. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 203 void InsertMapping(const char* key, char* data, size_t data_len); | 207 void InsertMapping(const char* key, char* data, size_t data_len); |
| 204 | 208 |
| 205 TargetMap* clipboard_data_; | 209 TargetMap* clipboard_data_; |
| 206 GtkClipboard* clipboard_; | 210 GtkClipboard* clipboard_; |
| 207 #endif | 211 #endif |
| 208 | 212 |
| 209 DISALLOW_EVIL_CONSTRUCTORS(Clipboard); | 213 DISALLOW_EVIL_CONSTRUCTORS(Clipboard); |
| 210 }; | 214 }; |
| 211 | 215 |
| 212 #endif // BASE_CLIPBOARD_H_ | 216 #endif // BASE_CLIPBOARD_H_ |
| OLD | NEW |