OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_MESSAGE_FILTER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_MESSAGE_FILTER_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_MESSAGE_FILTER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_MESSAGE_FILTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/shared_memory.h" |
12 #include "content/common/clipboard_format.h" | 13 #include "content/common/clipboard_format.h" |
13 #include "content/public/browser/browser_message_filter.h" | 14 #include "content/public/browser/browser_message_filter.h" |
14 #include "ui/base/clipboard/clipboard.h" | 15 #include "ui/base/clipboard/clipboard.h" |
15 | 16 |
16 class GURL; | 17 class GURL; |
17 | 18 |
| 19 namespace ui { |
| 20 class ScopedClipboardWriter; |
| 21 } // namespace ui |
| 22 |
18 namespace content { | 23 namespace content { |
19 | 24 |
20 class ClipboardMessageFilter : public BrowserMessageFilter { | 25 class ClipboardMessageFilter : public BrowserMessageFilter { |
21 public: | 26 public: |
22 ClipboardMessageFilter(); | 27 ClipboardMessageFilter(); |
23 | 28 |
24 virtual void OverrideThreadForMessage( | 29 virtual void OverrideThreadForMessage( |
25 const IPC::Message& message, | 30 const IPC::Message& message, |
26 BrowserThread::ID* thread) OVERRIDE; | 31 BrowserThread::ID* thread) OVERRIDE; |
27 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
28 private: | 33 private: |
29 virtual ~ClipboardMessageFilter(); | 34 virtual ~ClipboardMessageFilter(); |
30 | 35 |
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); | |
35 | |
36 void OnGetSequenceNumber(const ui::ClipboardType type, | 36 void OnGetSequenceNumber(const ui::ClipboardType type, |
37 uint64* sequence_number); | 37 uint64* sequence_number); |
38 void OnIsFormatAvailable(ClipboardFormat format, | 38 void OnIsFormatAvailable(ClipboardFormat format, |
39 ui::ClipboardType type, | 39 ui::ClipboardType type, |
40 bool* result); | 40 bool* result); |
41 void OnClear(ui::ClipboardType type); | 41 void OnClear(ui::ClipboardType type); |
42 void OnReadAvailableTypes(ui::ClipboardType type, | 42 void OnReadAvailableTypes(ui::ClipboardType type, |
43 std::vector<base::string16>* types, | 43 std::vector<base::string16>* types, |
44 bool* contains_filenames); | 44 bool* contains_filenames); |
45 void OnReadText(ui::ClipboardType type, base::string16* result); | 45 void OnReadText(ui::ClipboardType type, base::string16* result); |
46 void OnReadHTML(ui::ClipboardType type, | 46 void OnReadHTML(ui::ClipboardType type, |
47 base::string16* markup, | 47 base::string16* markup, |
48 GURL* url, | 48 GURL* url, |
49 uint32* fragment_start, | 49 uint32* fragment_start, |
50 uint32* fragment_end); | 50 uint32* fragment_end); |
51 void OnReadRTF(ui::ClipboardType type, std::string* result); | 51 void OnReadRTF(ui::ClipboardType type, std::string* result); |
52 void OnReadImage(ui::ClipboardType type, IPC::Message* reply_msg); | 52 void OnReadImage(ui::ClipboardType type, IPC::Message* reply_msg); |
53 void OnReadImageReply(const SkBitmap& bitmap, IPC::Message* reply_msg); | 53 void OnReadImageReply(const SkBitmap& bitmap, IPC::Message* reply_msg); |
54 void OnReadCustomData(ui::ClipboardType clipboard_type, | 54 void OnReadCustomData(ui::ClipboardType clipboard_type, |
55 const base::string16& type, | 55 const base::string16& type, |
56 base::string16* result); | 56 base::string16* result); |
57 void OnReadData(const ui::Clipboard::FormatType& format, | 57 void OnReadData(const ui::Clipboard::FormatType& format, |
58 std::string* data); | 58 std::string* data); |
59 | 59 |
| 60 void OnWriteText(ui::ClipboardType clipboard_type, |
| 61 const base::string16& text); |
| 62 void OnWriteHTML(ui::ClipboardType clipboard_type, |
| 63 const base::string16& markup, |
| 64 const GURL& url); |
| 65 void OnWriteSmartPasteMarker(ui::ClipboardType clipboard_type); |
| 66 void OnWriteCustomData(ui::ClipboardType clipboard_type, |
| 67 const std::map<base::string16, base::string16>& data); |
| 68 void OnWriteBookmark(ui::ClipboardType clipboard_type, |
| 69 const GURL& url, |
| 70 const base::string16& title); |
| 71 void OnWriteImage(ui::ClipboardType clipboard_type, |
| 72 const gfx::Size& size, |
| 73 base::SharedMemoryHandle handle); |
| 74 void OnCommitWrite(ui::ClipboardType clipboard_type); |
| 75 |
60 #if defined(OS_MACOSX) | 76 #if defined(OS_MACOSX) |
61 void OnFindPboardWriteString(const base::string16& text); | 77 void OnFindPboardWriteString(const base::string16& text); |
62 #endif | 78 #endif |
63 | 79 |
64 // We have our own clipboard because we want to access the clipboard on the | 80 // 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 | 81 // 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 | 82 // thread. This instance of the clipboard should be accessed only on the IO |
67 // thread. | 83 // thread. |
68 static ui::Clipboard* GetClipboard(); | 84 static ui::Clipboard* GetClipboard(); |
69 | 85 |
| 86 scoped_ptr<ui::ScopedClipboardWriter> clipboard_writer_; |
| 87 |
70 DISALLOW_COPY_AND_ASSIGN(ClipboardMessageFilter); | 88 DISALLOW_COPY_AND_ASSIGN(ClipboardMessageFilter); |
71 }; | 89 }; |
72 | 90 |
73 } // namespace content | 91 } // namespace content |
74 | 92 |
75 #endif // CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_MESSAGE_FILTER_H_ | 93 #endif // CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_MESSAGE_FILTER_H_ |
OLD | NEW |