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

Unified Diff: content/browser/renderer_host/clipboard_message_filter.cc

Issue 12298037: Revert 183123 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1417/src/
Patch Set: Created 7 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/clipboard_message_filter.cc
===================================================================
--- content/browser/renderer_host/clipboard_message_filter.cc (revision 183210)
+++ content/browser/renderer_host/clipboard_message_filter.cc (working copy)
@@ -8,7 +8,6 @@
#include "base/bind_helpers.h"
#include "base/stl_util.h"
#include "content/common/clipboard_messages.h"
-#include "content/public/browser/browser_context.h"
#include "googleurl/src/gurl.h"
#include "ipc/ipc_message_macros.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -18,22 +17,6 @@
namespace content {
-namespace {
-
-// Writes objects to the clipboard with a SourceTag corresponding to
-// |browser_context|.
-void WriteObjectsWrapper(ui::Clipboard* clipboard,
- const ui::Clipboard::ObjectMap& objects,
- BrowserContext* browser_context) {
- ui::Clipboard::SourceTag source_tag =
- BrowserContext::GetMarkerForOffTheRecordContext(browser_context);
- clipboard->WriteObjects(ui::Clipboard::BUFFER_STANDARD,
- objects,
- source_tag);
-}
-
-} // namespace
-
#if defined(OS_WIN)
namespace {
@@ -41,19 +24,17 @@
// The write must be performed on the UI thread because the clipboard object
// from the IO thread cannot create windows so it cannot be the "owner" of the
// clipboard's contents. // See http://crbug.com/5823.
-void WriteObjectsOnUIThread(ui::Clipboard::ObjectMap* objects,
- BrowserContext* browser_context) {
+void WriteObjectsHelper(const ui::Clipboard::ObjectMap* objects) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
static ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
- WriteObjectsWrapper(clipboard, *objects, browser_context);
+ clipboard->WriteObjects(ui::Clipboard::BUFFER_STANDARD, *objects);
}
} // namespace
#endif
-ClipboardMessageFilter::ClipboardMessageFilter(BrowserContext* browser_context)
- : browser_context_(browser_context) {
+ClipboardMessageFilter::ClipboardMessageFilter() {
}
void ClipboardMessageFilter::OverrideThreadForMessage(
@@ -109,27 +90,32 @@
}
void ClipboardMessageFilter::OnWriteObjectsSync(
- ui::Clipboard::ObjectMap objects,
+ const ui::Clipboard::ObjectMap& objects,
base::SharedMemoryHandle bitmap_handle) {
DCHECK(base::SharedMemory::IsHandleValid(bitmap_handle))
<< "Bad bitmap handle";
- // Splice the shared memory handle into the clipboard data.
- ui::Clipboard::ReplaceSharedMemHandle(&objects, bitmap_handle, peer_handle());
#if defined(OS_WIN)
// We cannot write directly from the IO thread, and cannot service the IPC
// on the UI thread. We'll copy the relevant data and get a handle to any
// shared memory so it doesn't go away when we resume the renderer, and post
// a task to perform the write on the UI thread.
- ui::Clipboard::ObjectMap* long_living_objects = new ui::Clipboard::ObjectMap;
- long_living_objects->swap(objects);
+ ui::Clipboard::ObjectMap* long_living_objects =
+ new ui::Clipboard::ObjectMap(objects);
+ // Splice the shared memory handle into the clipboard data.
+ ui::Clipboard::ReplaceSharedMemHandle(long_living_objects, bitmap_handle,
+ peer_handle());
+
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
- base::Bind(&WriteObjectsOnUIThread, base::Owned(long_living_objects),
- browser_context_));
+ base::Bind(&WriteObjectsHelper, base::Owned(long_living_objects)));
#else
- WriteObjectsWrapper(GetClipboard(), objects, browser_context_);
+ // Splice the shared memory handle into the clipboard data.
+ ui::Clipboard::ObjectMap objects_copy(objects);
+ ui::Clipboard::ReplaceSharedMemHandle(&objects_copy,
+ bitmap_handle, peer_handle());
+ GetClipboard()->WriteObjects(ui::Clipboard::BUFFER_STANDARD, objects_copy);
#endif
}
@@ -149,10 +135,9 @@
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
- base::Bind(&WriteObjectsOnUIThread, base::Owned(long_living_objects),
- browser_context_));
+ base::Bind(&WriteObjectsHelper, base::Owned(long_living_objects)));
#else
- WriteObjectsWrapper(GetClipboard(), objects, browser_context_);
+ GetClipboard()->WriteObjects(ui::Clipboard::BUFFER_STANDARD, objects);
#endif
}
« no previous file with comments | « content/browser/renderer_host/clipboard_message_filter.h ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698