1 // Copyright (c) 2013 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 #ifndef CONTENT_RENDERER_CLIPBOARD_CLIENT_H_
6 #define CONTENT_RENDERER_CLIPBOARD_CLIENT_H_
8 #include "content/common/clipboard_format.h"
9 #include "ui/base/clipboard/clipboard.h"
15 // Interface for the content embedder to implement to support clipboard.
16 class ClipboardClient
{
20 virtual ~WriteContext() { }
22 // Writes bitmap data into the context, updating the ObjectMap.
23 virtual void WriteBitmapFromPixels(ui::Clipboard::ObjectMap
* objects
,
25 const gfx::Size
& size
) = 0;
27 // Flushes all gathered data.
28 virtual void Flush(const ui::Clipboard::ObjectMap
& objects
) = 0;
31 virtual ~ClipboardClient() { }
33 // Get a clipboard that can be used to construct a ScopedClipboardWriterGlue.
34 virtual ui::Clipboard
* GetClipboard() = 0;
36 // Get a sequence number which uniquely identifies clipboard state.
37 virtual uint64
GetSequenceNumber(ui::ClipboardType type
) = 0;
39 // Tests whether the clipboard contains a certain format
40 virtual bool IsFormatAvailable(ClipboardFormat format
,
41 ui::ClipboardType type
) = 0;
43 // Clear the contents of the clipboard.
44 virtual void Clear(ui::ClipboardType type
) = 0;
46 // Reads the available types from the clipboard, if available.
47 virtual void ReadAvailableTypes(ui::ClipboardType type
,
48 std::vector
<base::string16
>* types
,
49 bool* contains_filenames
) = 0;
51 // Reads text from the clipboard, trying UNICODE first, then falling back to
53 virtual void ReadText(ui::ClipboardType type
,
54 base::string16
* result
) = 0;
56 // Reads HTML from the clipboard, if available.
57 virtual void ReadHTML(ui::ClipboardType type
,
58 base::string16
* markup
,
60 uint32
* fragment_start
,
61 uint32
* fragment_end
) = 0;
63 // Reads RTF from the clipboard, if available.
64 virtual void ReadRTF(ui::ClipboardType type
, std::string
* result
) = 0;
66 // Reads and image from the clipboard, if available.
67 virtual void ReadImage(ui::ClipboardType type
, std::string
* data
) = 0;
69 // Reads a custom data type from the clipboard, if available.
70 virtual void ReadCustomData(ui::ClipboardType clipboard_type
,
71 const base::string16
& type
,
72 base::string16
* data
) = 0;
74 // Creates a context to write clipboard data. May return NULL.
75 virtual WriteContext
* CreateWriteContext() = 0;
78 } // namespace content
80 #endif // CONTENT_RENDERER_CLIPBOARD_CLIENT_H_