Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: content/browser/renderer_host/clipboard_message_filter.h

Issue 574273002: Rewrite clipboard write IPC handling to be easier to understand. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Document Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
14 #include "content/common/content_export.h"
13 #include "content/public/browser/browser_message_filter.h" 15 #include "content/public/browser/browser_message_filter.h"
14 #include "ui/base/clipboard/clipboard.h" 16 #include "ui/base/clipboard/clipboard.h"
15 17
16 class GURL; 18 class GURL;
17 19
20 namespace ui {
21 class ScopedClipboardWriter;
22 } // namespace ui
23
18 namespace content { 24 namespace content {
19 25
20 class ClipboardMessageFilter : public BrowserMessageFilter { 26 class ClipboardMessageFilterTest;
27
28 class CONTENT_EXPORT ClipboardMessageFilter : public BrowserMessageFilter {
21 public: 29 public:
22 ClipboardMessageFilter(); 30 ClipboardMessageFilter();
23 31
24 void OverrideThreadForMessage(const IPC::Message& message, 32 void OverrideThreadForMessage(const IPC::Message& message,
25 BrowserThread::ID* thread) override; 33 BrowserThread::ID* thread) override;
26 bool OnMessageReceived(const IPC::Message& message) override; 34 bool OnMessageReceived(const IPC::Message& message) override;
27 35
28 private: 36 private:
37 friend class ClipboardMessageFilterTest;
38
29 ~ClipboardMessageFilter() override; 39 ~ClipboardMessageFilter() override;
30 40
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, 41 void OnGetSequenceNumber(const ui::ClipboardType type,
37 uint64* sequence_number); 42 uint64* sequence_number);
38 void OnIsFormatAvailable(ClipboardFormat format, 43 void OnIsFormatAvailable(ClipboardFormat format,
39 ui::ClipboardType type, 44 ui::ClipboardType type,
40 bool* result); 45 bool* result);
41 void OnClear(ui::ClipboardType type); 46 void OnClear(ui::ClipboardType type);
42 void OnReadAvailableTypes(ui::ClipboardType type, 47 void OnReadAvailableTypes(ui::ClipboardType type,
43 std::vector<base::string16>* types, 48 std::vector<base::string16>* types,
44 bool* contains_filenames); 49 bool* contains_filenames);
45 void OnReadText(ui::ClipboardType type, base::string16* result); 50 void OnReadText(ui::ClipboardType type, base::string16* result);
46 void OnReadHTML(ui::ClipboardType type, 51 void OnReadHTML(ui::ClipboardType type,
47 base::string16* markup, 52 base::string16* markup,
48 GURL* url, 53 GURL* url,
49 uint32* fragment_start, 54 uint32* fragment_start,
50 uint32* fragment_end); 55 uint32* fragment_end);
51 void OnReadRTF(ui::ClipboardType type, std::string* result); 56 void OnReadRTF(ui::ClipboardType type, std::string* result);
52 void OnReadImage(ui::ClipboardType type, IPC::Message* reply_msg); 57 void OnReadImage(ui::ClipboardType type, IPC::Message* reply_msg);
53 void OnReadImageReply(const SkBitmap& bitmap, IPC::Message* reply_msg); 58 void OnReadImageReply(const SkBitmap& bitmap, IPC::Message* reply_msg);
54 void OnReadCustomData(ui::ClipboardType clipboard_type, 59 void OnReadCustomData(ui::ClipboardType clipboard_type,
55 const base::string16& type, 60 const base::string16& type,
56 base::string16* result); 61 base::string16* result);
57 void OnReadData(const ui::Clipboard::FormatType& format, 62 void OnReadData(const ui::Clipboard::FormatType& format,
58 std::string* data); 63 std::string* data);
59 64
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
60 #if defined(OS_MACOSX) 81 #if defined(OS_MACOSX)
61 void OnFindPboardWriteString(const base::string16& text); 82 void OnFindPboardWriteString(const base::string16& text);
62 #endif 83 #endif
63 84
64 // We have our own clipboard because we want to access the clipboard on the 85 // 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 86 // 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 87 // thread. This instance of the clipboard should be accessed only on the IO
67 // thread. 88 // thread.
68 static ui::Clipboard* GetClipboard(); 89 static ui::Clipboard* GetClipboard();
69 90
91 scoped_ptr<ui::ScopedClipboardWriter> clipboard_writer_;
92
70 DISALLOW_COPY_AND_ASSIGN(ClipboardMessageFilter); 93 DISALLOW_COPY_AND_ASSIGN(ClipboardMessageFilter);
71 }; 94 };
72 95
73 } // namespace content 96 } // namespace content
74 97
75 #endif // CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_MESSAGE_FILTER_H_ 98 #endif // CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_MESSAGE_FILTER_H_
OLDNEW
« no previous file with comments | « components/bookmarks/browser/BUILD.gn ('k') | content/browser/renderer_host/clipboard_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698