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
3 // found in the LICENSE file.
5 // Some helper functions for working with the clipboard and IDataObjects.
7 #ifndef UI_BASE_CLIPBOARD_CLIPBOARD_UTIL_WIN_H_
8 #define UI_BASE_CLIPBOARD_CLIPBOARD_UTIL_WIN_H_
15 #include "base/strings/string16.h"
16 #include "ui/base/ui_export.h"
20 class UI_EXPORT ClipboardUtil {
22 /////////////////////////////////////////////////////////////////////////////
23 // These methods check to see if |data_object| has the requested type.
24 // Returns true if it does.
25 static bool HasUrl(IDataObject* data_object);
26 static bool HasFilenames(IDataObject* data_object);
27 static bool HasPlainText(IDataObject* data_object);
28 static bool HasFileContents(IDataObject* data_object);
29 static bool HasHtml(IDataObject* data_object);
31 /////////////////////////////////////////////////////////////////////////////
32 // Helper methods to extract information from an IDataObject. These methods
33 // return true if the requested data type is found in |data_object|.
34 static bool GetUrl(IDataObject* data_object,
37 bool convert_filenames);
38 static bool GetFilenames(IDataObject* data_object,
39 std::vector<string16>* filenames);
40 static bool GetPlainText(IDataObject* data_object, string16* plain_text);
41 static bool GetHtml(IDataObject* data_object,
43 std::string* base_url);
44 static bool GetFileContents(IDataObject* data_object,
46 std::string* file_contents);
47 // This represents custom MIME types a web page might set to transport its
48 // own types of data for drag and drop. It is sandboxed in its own CLIPFORMAT
49 // to avoid polluting the ::RegisterClipboardFormat() namespace with random
50 // strings from web content.
51 static bool GetWebCustomData(IDataObject* data_object,
52 std::map<string16, string16>* custom_data);
54 // Helper method for converting between MS CF_HTML format and plain
56 static std::string HtmlToCFHtml(const std::string& html,
57 const std::string& base_url);
58 static void CFHtmlToHtml(const std::string& cf_html,
60 std::string* base_url);
61 static void CFHtmlExtractMetadata(const std::string& cf_html,
62 std::string* base_url,
64 size_t* fragment_start,
65 size_t* fragment_end);
70 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_UTIL_WIN_H_