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/common/clipboard_format.h"
13 #include "content/public/browser/browser_message_filter.h"
14 #include "ui/base/clipboard/clipboard.h"
20 class ClipboardMessageFilter : public BrowserMessageFilter {
22 ClipboardMessageFilter();
24 void OverrideThreadForMessage(const IPC::Message& message,
25 BrowserThread::ID* thread) override;
26 bool OnMessageReceived(const IPC::Message& message) override;
29 ~ClipboardMessageFilter() override;
31 void OnWriteObjectsAsync(const ui::Clipboard::ObjectMap& objects);
32 void OnWriteObjectsSync(const ui::Clipboard::ObjectMap& objects,
33 base::SharedMemoryHandle bitmap_handle);
34 static void WriteObjectsOnUIThread(const ui::Clipboard::ObjectMap* objects);
36 void OnGetSequenceNumber(const ui::ClipboardType type,
37 uint64* sequence_number);
38 void OnIsFormatAvailable(ClipboardFormat format,
39 ui::ClipboardType type,
41 void OnClear(ui::ClipboardType type);
42 void OnReadAvailableTypes(ui::ClipboardType type,
43 std::vector<base::string16>* types,
44 bool* contains_filenames);
45 void OnReadText(ui::ClipboardType type, base::string16* result);
46 void OnReadHTML(ui::ClipboardType type,
47 base::string16* markup,
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,
55 const base::string16& type,
56 base::string16* result);
57 void OnReadData(const ui::Clipboard::FormatType& format,
60 #if defined(OS_MACOSX)
61 void OnFindPboardWriteString(const base::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_