| Index: content/browser/renderer_host/clipboard_message_filter.cc
|
| diff --git a/content/browser/renderer_host/clipboard_message_filter.cc b/content/browser/renderer_host/clipboard_message_filter.cc
|
| index dc08dd5f8f6f2cf572c33a2583e97b6c11a15ccb..640e8364f7e91952b346cf8da0ebab4406b66838 100644
|
| --- a/content/browser/renderer_host/clipboard_message_filter.cc
|
| +++ b/content/browser/renderer_host/clipboard_message_filter.cc
|
| @@ -8,6 +8,9 @@
|
| #include "base/bind_helpers.h"
|
| #include "base/stl_util.h"
|
| #include "content/common/clipboard_messages.h"
|
| +#include "content/public/browser/content_browser_client.h"
|
| +#include "content/public/browser/incognito_marker.h"
|
| +#include "content/public/common/content_client.h"
|
| #include "googleurl/src/gurl.h"
|
| #include "ipc/ipc_message_macros.h"
|
| #include "third_party/skia/include/core/SkBitmap.h"
|
| @@ -17,6 +20,16 @@
|
|
|
| namespace content {
|
|
|
| +namespace {
|
| + // Notifies ContentBrowserClient and writes objects to the clipborad.
|
| + void WriteObjectsWrapper(ui::Clipboard* clipboard,
|
| + ui::Clipboard::ObjectMap* objects,
|
| + BrowserContext* browser_context) {
|
| + AddIncognitoMarkerForOffTheRecordProfile(browser_context, objects);
|
| + clipboard->WriteObjects(ui::Clipboard::BUFFER_STANDARD, *objects);
|
| + }
|
| +}
|
| +
|
| #if defined(OS_WIN)
|
|
|
| namespace {
|
| @@ -24,17 +37,19 @@ namespace {
|
| // 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 WriteObjectsHelper(const ui::Clipboard::ObjectMap* objects) {
|
| +void WriteObjectsHelper(ui::Clipboard::ObjectMap* objects,
|
| + BrowserContext* browser_context) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| static ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
|
| - clipboard->WriteObjects(ui::Clipboard::BUFFER_STANDARD, *objects);
|
| + WriteObjectsWrapper(clipboard, objects, browser_context);
|
| }
|
|
|
| } // namespace
|
|
|
| #endif
|
|
|
| -ClipboardMessageFilter::ClipboardMessageFilter() {
|
| +ClipboardMessageFilter::ClipboardMessageFilter(BrowserContext* browser_context)
|
| + : browser_context_(browser_context) {
|
| }
|
|
|
| void ClipboardMessageFilter::OverrideThreadForMessage(
|
| @@ -90,7 +105,7 @@ ClipboardMessageFilter::~ClipboardMessageFilter() {
|
| }
|
|
|
| void ClipboardMessageFilter::OnWriteObjectsSync(
|
| - const ui::Clipboard::ObjectMap& objects,
|
| + ui::Clipboard::ObjectMap objects,
|
| base::SharedMemoryHandle bitmap_handle) {
|
| DCHECK(base::SharedMemory::IsHandleValid(bitmap_handle))
|
| << "Bad bitmap handle";
|
| @@ -99,8 +114,8 @@ void ClipboardMessageFilter::OnWriteObjectsSync(
|
| // 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(objects);
|
| + ui::Clipboard::ObjectMap* long_living_objects = new ui::Clipboard::ObjectMap;
|
| + long_living_objects->swap(objects);
|
|
|
| // Splice the shared memory handle into the clipboard data.
|
| ui::Clipboard::ReplaceSharedMemHandle(long_living_objects, bitmap_handle,
|
| @@ -109,24 +124,23 @@ void ClipboardMessageFilter::OnWriteObjectsSync(
|
| BrowserThread::PostTask(
|
| BrowserThread::UI,
|
| FROM_HERE,
|
| - base::Bind(&WriteObjectsHelper, base::Owned(long_living_objects)));
|
| + base::Bind(&WriteObjectsHelper, base::Owned(long_living_objects),
|
| + browser_context_));
|
| #else
|
| // 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);
|
| + ui::Clipboard::ReplaceSharedMemHandle(&objects, bitmap_handle, peer_handle());
|
| + WriteObjectsWrapper(GetClipboard(), &objects, browser_context_);
|
| #endif
|
| }
|
|
|
| void ClipboardMessageFilter::OnWriteObjectsAsync(
|
| - const ui::Clipboard::ObjectMap& objects) {
|
| + ui::Clipboard::ObjectMap objects) {
|
| #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 post a task to preform
|
| // the write on the UI thread.
|
| - ui::Clipboard::ObjectMap* long_living_objects =
|
| - new ui::Clipboard::ObjectMap(objects);
|
| + ui::Clipboard::ObjectMap* long_living_objects = new ui::Clipboard::ObjectMap;
|
| + long_living_objects->swap(objects);
|
|
|
| // This async message doesn't support shared-memory based bitmaps; they must
|
| // be removed otherwise we might dereference a rubbish pointer.
|
| @@ -135,9 +149,10 @@ void ClipboardMessageFilter::OnWriteObjectsAsync(
|
| BrowserThread::PostTask(
|
| BrowserThread::UI,
|
| FROM_HERE,
|
| - base::Bind(&WriteObjectsHelper, base::Owned(long_living_objects)));
|
| + base::Bind(&WriteObjectsHelper, base::Owned(long_living_objects),
|
| + browser_context_));
|
| #else
|
| - GetClipboard()->WriteObjects(ui::Clipboard::BUFFER_STANDARD, objects);
|
| + WriteObjectsWrapper(GetClipboard(), &objects, browser_context_);
|
| #endif
|
| }
|
|
|
|
|