blob: 89c7b69546376067d0ed430b6a122a131cacbb20 [file] [log] [blame]
license.botf003cfe2008-08-24 09:55:55 +09001// 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.
initial.commit3f4a7322008-07-27 06:49:38 +09004//
5// Some helper functions for working with the clipboard and IDataObjects.
6
7#include <shlobj.h>
8#include <string>
9#include <vector>
10
11class ClipboardUtil {
12 public:
13 /////////////////////////////////////////////////////////////////////////////
14 // Clipboard formats.
15 static FORMATETC* GetUrlFormat();
16 static FORMATETC* GetUrlWFormat();
17 static FORMATETC* GetMozUrlFormat();
18 static FORMATETC* GetPlainTextFormat();
19 static FORMATETC* GetPlainTextWFormat();
20 static FORMATETC* GetFilenameFormat();
21 static FORMATETC* GetFilenameWFormat();
22 // MS HTML Format
23 static FORMATETC* GetHtmlFormat();
24 // Firefox text/html
25 static FORMATETC* GetTextHtmlFormat();
26 static FORMATETC* GetCFHDropFormat();
27 static FORMATETC* GetFileDescriptorFormat();
28 static FORMATETC* GetFileContentFormatZero();
29 static FORMATETC* GetWebKitSmartPasteFormat();
30
31 /////////////////////////////////////////////////////////////////////////////
32 // These methods check to see if |data_object| has the requested type.
33 // Returns true if it does.
34 static bool HasUrl(IDataObject* data_object);
35 static bool HasFilenames(IDataObject* data_object);
36 static bool HasPlainText(IDataObject* data_object);
37
38 /////////////////////////////////////////////////////////////////////////////
39 // Helper methods to extract information from an IDataObject. These methods
40 // return true if the requested data type is found in |data_object|.
41 static bool GetUrl(IDataObject* data_object,
42 std::wstring* url, std::wstring* title);
43 static bool GetFilenames(IDataObject* data_object,
44 std::vector<std::wstring>* filenames);
45 static bool GetPlainText(IDataObject* data_object, std::wstring* plain_text);
46 static bool GetCFHtml(IDataObject* data_object, std::wstring* cf_html);
47 static bool GetTextHtml(IDataObject* data_object, std::wstring* text_html);
48 static bool GetFileContents(IDataObject* data_object,
49 std::wstring* filename,
50 std::string* file_contents);
51};
license.botf003cfe2008-08-24 09:55:55 +090052