OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 // | |
5 // Some helper functions for working with the clipboard and IDataObjects. | |
6 | |
7 #ifndef BASE_CLIPBOARD_UTIL_H_ | |
8 #define BASE_CLIPBOARD_UTIL_H_ | |
9 | |
10 #include <shlobj.h> | |
11 #include <string> | |
12 #include <vector> | |
13 | |
14 class ClipboardUtil { | |
15 public: | |
16 ///////////////////////////////////////////////////////////////////////////// | |
17 // Clipboard formats. | |
18 static FORMATETC* GetUrlFormat(); | |
19 static FORMATETC* GetUrlWFormat(); | |
20 static FORMATETC* GetMozUrlFormat(); | |
21 static FORMATETC* GetPlainTextFormat(); | |
22 static FORMATETC* GetPlainTextWFormat(); | |
23 static FORMATETC* GetFilenameFormat(); | |
24 static FORMATETC* GetFilenameWFormat(); | |
25 // MS HTML Format | |
26 static FORMATETC* GetHtmlFormat(); | |
27 // Firefox text/html | |
28 static FORMATETC* GetTextHtmlFormat(); | |
29 static FORMATETC* GetCFHDropFormat(); | |
30 static FORMATETC* GetFileDescriptorFormat(); | |
31 static FORMATETC* GetFileContentFormatZero(); | |
32 static FORMATETC* GetWebKitSmartPasteFormat(); | |
33 | |
34 ///////////////////////////////////////////////////////////////////////////// | |
35 // These methods check to see if |data_object| has the requested type. | |
36 // Returns true if it does. | |
37 static bool HasUrl(IDataObject* data_object); | |
38 static bool HasFilenames(IDataObject* data_object); | |
39 static bool HasPlainText(IDataObject* data_object); | |
40 static bool HasFileContents(IDataObject* data_object); | |
41 static bool HasHtml(IDataObject* data_object); | |
42 | |
43 ///////////////////////////////////////////////////////////////////////////// | |
44 // Helper methods to extract information from an IDataObject. These methods | |
45 // return true if the requested data type is found in |data_object|. | |
46 static bool GetUrl(IDataObject* data_object, | |
47 std::wstring* url, std::wstring* title); | |
48 static bool GetFilenames(IDataObject* data_object, | |
49 std::vector<std::wstring>* filenames); | |
50 static bool GetPlainText(IDataObject* data_object, std::wstring* plain_text); | |
51 static bool GetHtml(IDataObject* data_object, std::wstring* text_html, | |
52 std::string* base_url); | |
53 static bool GetFileContents(IDataObject* data_object, | |
54 std::wstring* filename, | |
55 std::string* file_contents); | |
56 | |
57 // A helper method for converting between MS CF_HTML format and plain | |
58 // text/html. | |
59 static std::string HtmlToCFHtml(const std::string& html, | |
60 const std::string& base_url); | |
61 static void CFHtmlToHtml(const std::string& cf_html, std::string* html, | |
62 std::string* base_url); | |
63 }; | |
64 | |
65 #endif // BASE_CLIPBOARD_UTIL_H_ | |
OLD | NEW |