| 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" | |
| 13 #include "content/common/clipboard_format.h" | 12 #include "content/common/clipboard_format.h" |
| 14 #include "content/common/content_export.h" | |
| 15 #include "content/public/browser/browser_message_filter.h" | 13 #include "content/public/browser/browser_message_filter.h" |
| 16 #include "ui/base/clipboard/clipboard.h" | 14 #include "ui/base/clipboard/clipboard.h" |
| 17 | 15 |
| 18 class GURL; | 16 class GURL; |
| 19 | 17 |
| 20 namespace ui { | |
| 21 class ScopedClipboardWriter; | |
| 22 } // namespace ui | |
| 23 | |
| 24 namespace content { | 18 namespace content { |
| 25 | 19 |
| 26 class ClipboardMessageFilterTest; | 20 class ClipboardMessageFilter : public BrowserMessageFilter { |
| 27 | |
| 28 class CONTENT_EXPORT ClipboardMessageFilter : public BrowserMessageFilter { | |
| 29 public: | 21 public: |
| 30 ClipboardMessageFilter(); | 22 ClipboardMessageFilter(); |
| 31 | 23 |
| 32 void OverrideThreadForMessage(const IPC::Message& message, | 24 void OverrideThreadForMessage(const IPC::Message& message, |
| 33 BrowserThread::ID* thread) override; | 25 BrowserThread::ID* thread) override; |
| 34 bool OnMessageReceived(const IPC::Message& message) override; | 26 bool OnMessageReceived(const IPC::Message& message) override; |
| 35 | 27 |
| 36 private: | 28 private: |
| 37 friend class ClipboardMessageFilterTest; | 29 ~ClipboardMessageFilter() override; |
| 38 | 30 |
| 39 ~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); |
| 40 | 35 |
| 41 void OnGetSequenceNumber(const ui::ClipboardType type, | 36 void OnGetSequenceNumber(const ui::ClipboardType type, |
| 42 uint64* sequence_number); | 37 uint64* sequence_number); |
| 43 void OnIsFormatAvailable(ClipboardFormat format, | 38 void OnIsFormatAvailable(ClipboardFormat format, |
| 44 ui::ClipboardType type, | 39 ui::ClipboardType type, |
| 45 bool* result); | 40 bool* result); |
| 46 void OnClear(ui::ClipboardType type); | 41 void OnClear(ui::ClipboardType type); |
| 47 void OnReadAvailableTypes(ui::ClipboardType type, | 42 void OnReadAvailableTypes(ui::ClipboardType type, |
| 48 std::vector<base::string16>* types, | 43 std::vector<base::string16>* types, |
| 49 bool* contains_filenames); | 44 bool* contains_filenames); |
| 50 void OnReadText(ui::ClipboardType type, base::string16* result); | 45 void OnReadText(ui::ClipboardType type, base::string16* result); |
| 51 void OnReadHTML(ui::ClipboardType type, | 46 void OnReadHTML(ui::ClipboardType type, |
| 52 base::string16* markup, | 47 base::string16* markup, |
| 53 GURL* url, | 48 GURL* url, |
| 54 uint32* fragment_start, | 49 uint32* fragment_start, |
| 55 uint32* fragment_end); | 50 uint32* fragment_end); |
| 56 void OnReadRTF(ui::ClipboardType type, std::string* result); | 51 void OnReadRTF(ui::ClipboardType type, std::string* result); |
| 57 void OnReadImage(ui::ClipboardType type, IPC::Message* reply_msg); | 52 void OnReadImage(ui::ClipboardType type, IPC::Message* reply_msg); |
| 58 void OnReadImageReply(const SkBitmap& bitmap, IPC::Message* reply_msg); | 53 void OnReadImageReply(const SkBitmap& bitmap, IPC::Message* reply_msg); |
| 59 void OnReadCustomData(ui::ClipboardType clipboard_type, | 54 void OnReadCustomData(ui::ClipboardType clipboard_type, |
| 60 const base::string16& type, | 55 const base::string16& type, |
| 61 base::string16* result); | 56 base::string16* result); |
| 62 void OnReadData(const ui::Clipboard::FormatType& format, | 57 void OnReadData(const ui::Clipboard::FormatType& format, |
| 63 std::string* data); | 58 std::string* data); |
| 64 | 59 |
| 65 void OnWriteText(ui::ClipboardType clipboard_type, | |
| 66 const base::string16& text); | |
| 67 void OnWriteHTML(ui::ClipboardType clipboard_type, | |
| 68 const base::string16& markup, | |
| 69 const GURL& url); | |
| 70 void OnWriteSmartPasteMarker(ui::ClipboardType clipboard_type); | |
| 71 void OnWriteCustomData(ui::ClipboardType clipboard_type, | |
| 72 const std::map<base::string16, base::string16>& data); | |
| 73 void OnWriteBookmark(ui::ClipboardType clipboard_type, | |
| 74 const GURL& url, | |
| 75 const base::string16& title); | |
| 76 void OnWriteImage(ui::ClipboardType clipboard_type, | |
| 77 const gfx::Size& size, | |
| 78 base::SharedMemoryHandle handle); | |
| 79 void OnCommitWrite(ui::ClipboardType clipboard_type); | |
| 80 | |
| 81 #if defined(OS_MACOSX) | 60 #if defined(OS_MACOSX) |
| 82 void OnFindPboardWriteString(const base::string16& text); | 61 void OnFindPboardWriteString(const base::string16& text); |
| 83 #endif | 62 #endif |
| 84 | 63 |
| 85 // We have our own clipboard because we want to access the clipboard on the | 64 // We have our own clipboard because we want to access the clipboard on the |
| 86 // IO thread instead of forwarding (possibly synchronous) messages to the UI | 65 // IO thread instead of forwarding (possibly synchronous) messages to the UI |
| 87 // thread. This instance of the clipboard should be accessed only on the IO | 66 // thread. This instance of the clipboard should be accessed only on the IO |
| 88 // thread. | 67 // thread. |
| 89 static ui::Clipboard* GetClipboard(); | 68 static ui::Clipboard* GetClipboard(); |
| 90 | 69 |
| 91 scoped_ptr<ui::ScopedClipboardWriter> clipboard_writer_; | |
| 92 | |
| 93 DISALLOW_COPY_AND_ASSIGN(ClipboardMessageFilter); | 70 DISALLOW_COPY_AND_ASSIGN(ClipboardMessageFilter); |
| 94 }; | 71 }; |
| 95 | 72 |
| 96 } // namespace content | 73 } // namespace content |
| 97 | 74 |
| 98 #endif // CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_MESSAGE_FILTER_H_ | 75 #endif // CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_MESSAGE_FILTER_H_ |
| OLD | NEW |