Drive: Add BatchableRequest subclass.
[chromium-blink-merge.git] / ui / base / clipboard / clipboard_util_win.h
blobc2171da5f16b636663025bf2e3ae06a3ba145ea0
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.
4 //
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_
10 #include <shlobj.h>
11 #include <map>
12 #include <string>
13 #include <vector>
15 #include "base/strings/string16.h"
16 #include "ui/base/ui_base_export.h"
18 class GURL;
20 namespace ui {
22 class UI_BASE_EXPORT ClipboardUtil {
23 public:
24 /////////////////////////////////////////////////////////////////////////////
25 // These methods check to see if |data_object| has the requested type.
26 // Returns true if it does.
27 static bool HasUrl(IDataObject* data_object, bool convert_filenames);
28 static bool HasFilenames(IDataObject* data_object);
29 static bool HasPlainText(IDataObject* data_object);
30 static bool HasFileContents(IDataObject* data_object);
31 static bool HasHtml(IDataObject* data_object);
33 /////////////////////////////////////////////////////////////////////////////
34 // Helper methods to extract information from an IDataObject. These methods
35 // return true if the requested data type is found in |data_object|.
37 // Only returns true if url->is_valid() is true.
38 static bool GetUrl(IDataObject* data_object,
39 GURL* url,
40 base::string16* title,
41 bool convert_filenames);
42 static bool GetFilenames(IDataObject* data_object,
43 std::vector<base::string16>* filenames);
44 static bool GetPlainText(IDataObject* data_object,
45 base::string16* plain_text);
46 static bool GetHtml(IDataObject* data_object,
47 base::string16* text_html,
48 std::string* base_url);
49 static bool GetFileContents(IDataObject* data_object,
50 base::string16* filename,
51 std::string* file_contents);
52 // This represents custom MIME types a web page might set to transport its
53 // own types of data for drag and drop. It is sandboxed in its own CLIPFORMAT
54 // to avoid polluting the ::RegisterClipboardFormat() namespace with random
55 // strings from web content.
56 static bool GetWebCustomData(
57 IDataObject* data_object,
58 std::map<base::string16, base::string16>* custom_data);
60 // Helper method for converting between MS CF_HTML format and plain
61 // text/html.
62 static std::string HtmlToCFHtml(const std::string& html,
63 const std::string& base_url);
64 static void CFHtmlToHtml(const std::string& cf_html,
65 std::string* html,
66 std::string* base_url);
67 static void CFHtmlExtractMetadata(const std::string& cf_html,
68 std::string* base_url,
69 size_t* html_start,
70 size_t* fragment_start,
71 size_t* fragment_end);
76 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_UTIL_WIN_H_