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 #ifndef CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_MESSAGE_FILTER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_MESSAGE_FILTER_H_
11 #include "base/basictypes.h"
12 #include "content/public/browser/browser_message_filter.h"
13 #include "ui/base/clipboard/clipboard.h"
19 class ClipboardMessageFilter : public BrowserMessageFilter {
21 ClipboardMessageFilter();
23 virtual void OverrideThreadForMessage(
24 const IPC::Message& message,
25 BrowserThread::ID* thread) OVERRIDE;
26 virtual bool OnMessageReceived(const IPC::Message& message,
27 bool* message_was_ok) OVERRIDE;
29 virtual ~ClipboardMessageFilter();
31 void OnWriteObjectsAsync(const ui::Clipboard::ObjectMap& objects);
32 void OnWriteObjectsSync(ui::Clipboard::ObjectMap objects,
33 base::SharedMemoryHandle bitmap_handle);
35 void OnGetSequenceNumber(const ui::ClipboardType type,
36 uint64* sequence_number);
37 void OnIsFormatAvailable(const ui::Clipboard::FormatType& format,
38 ui::ClipboardType type,
40 void OnClear(ui::ClipboardType type);
41 void OnReadAvailableTypes(ui::ClipboardType type,
42 std::vector<string16>* types,
43 bool* contains_filenames);
44 void OnReadText(ui::ClipboardType type, string16* result);
45 void OnReadAsciiText(ui::ClipboardType type, std::string* result);
46 void OnReadHTML(ui::ClipboardType type,
49 uint32* fragment_start,
50 uint32* fragment_end);
51 void OnReadRTF(ui::ClipboardType type, std::string* result);
52 void OnReadImage(ui::ClipboardType type, IPC::Message* reply_msg);
53 void OnReadImageReply(const SkBitmap& bitmap, IPC::Message* reply_msg);
54 void OnReadCustomData(ui::ClipboardType clipboard_type,
57 void OnReadData(const ui::Clipboard::FormatType& format,
60 #if defined(OS_MACOSX)
61 void OnFindPboardWriteString(const string16& text);
64 // We have our own clipboard because we want to access the clipboard on the
65 // IO thread instead of forwarding (possibly synchronous) messages to the UI
66 // thread. This instance of the clipboard should be accessed only on the IO
68 static ui::Clipboard* GetClipboard();
70 DISALLOW_COPY_AND_ASSIGN(ClipboardMessageFilter);
73 } // namespace content
75 #endif // CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_MESSAGE_FILTER_H_