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 #include "content/browser/renderer_host/clipboard_message_filter.h" | 5 #include "content/browser/renderer_host/clipboard_message_filter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 // the "owner" of the clipboard's contents. See http://crbug.com/5823. | 27 // the "owner" of the clipboard's contents. See http://crbug.com/5823. |
28 void WriteObjectsOnUIThread(ui::Clipboard::ObjectMap* objects) { | 28 void WriteObjectsOnUIThread(ui::Clipboard::ObjectMap* objects) { |
29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
30 static ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); | 30 static ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); |
31 clipboard->WriteObjects(ui::CLIPBOARD_TYPE_COPY_PASTE, *objects); | 31 clipboard->WriteObjects(ui::CLIPBOARD_TYPE_COPY_PASTE, *objects); |
32 } | 32 } |
33 | 33 |
34 } // namespace | 34 } // namespace |
35 | 35 |
36 | 36 |
37 ClipboardMessageFilter::ClipboardMessageFilter() | 37 ClipboardMessageFilter::ClipboardMessageFilter() {} |
38 : BrowserMessageFilter(ClipboardMsgStart) {} | |
39 | 38 |
40 void ClipboardMessageFilter::OverrideThreadForMessage( | 39 void ClipboardMessageFilter::OverrideThreadForMessage( |
41 const IPC::Message& message, BrowserThread::ID* thread) { | 40 const IPC::Message& message, BrowserThread::ID* thread) { |
42 // Clipboard writes should always occur on the UI thread due the restrictions | 41 // Clipboard writes should always occur on the UI thread due the restrictions |
43 // of various platform APIs. In general, the clipboard is not thread-safe, so | 42 // of various platform APIs. In general, the clipboard is not thread-safe, so |
44 // all clipboard calls should be serviced from the UI thread. | 43 // all clipboard calls should be serviced from the UI thread. |
45 // | 44 // |
46 // Windows needs clipboard reads to be serviced from the IO thread because | 45 // Windows needs clipboard reads to be serviced from the IO thread because |
47 // these are sync IPCs which can result in deadlocks with NPAPI plugins if | 46 // these are sync IPCs which can result in deadlocks with NPAPI plugins if |
48 // serviced from the UI thread. Note that Windows clipboard calls ARE | 47 // serviced from the UI thread. Note that Windows clipboard calls ARE |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 237 |
239 // static | 238 // static |
240 ui::Clipboard* ClipboardMessageFilter::GetClipboard() { | 239 ui::Clipboard* ClipboardMessageFilter::GetClipboard() { |
241 // We have a static instance of the clipboard service for use by all message | 240 // We have a static instance of the clipboard service for use by all message |
242 // filters. This instance lives for the life of the browser processes. | 241 // filters. This instance lives for the life of the browser processes. |
243 static ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); | 242 static ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); |
244 return clipboard; | 243 return clipboard; |
245 } | 244 } |
246 | 245 |
247 } // namespace content | 246 } // namespace content |
OLD | NEW |