| 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 // This file provides the embedder's side of random webkit glue functions. | 5 // This file provides the embedder's side of random webkit glue functions. |
| 6 | 6 |
| 7 #include "content/renderer/renderer_clipboard_client.h" | 7 #include "content/renderer/renderer_clipboard_client.h" |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 class RendererClipboardWriteContext : | 25 class RendererClipboardWriteContext : |
| 26 public webkit_glue::ClipboardClient::WriteContext { | 26 public webkit_glue::ClipboardClient::WriteContext { |
| 27 public: | 27 public: |
| 28 RendererClipboardWriteContext(); | 28 RendererClipboardWriteContext(); |
| 29 virtual ~RendererClipboardWriteContext(); | 29 virtual ~RendererClipboardWriteContext(); |
| 30 virtual void WriteBitmapFromPixels(ui::Clipboard::ObjectMap* objects, | 30 virtual void WriteBitmapFromPixels(ui::Clipboard::ObjectMap* objects, |
| 31 const void* pixels, | 31 const void* pixels, |
| 32 const gfx::Size& size); | 32 const gfx::Size& size); |
| 33 virtual void FlushAndDestroy(const ui::Clipboard::ObjectMap& objects); | 33 virtual void Flush(const ui::Clipboard::ObjectMap& objects); |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 scoped_ptr<base::SharedMemory> shared_buf_; | 36 scoped_ptr<base::SharedMemory> shared_buf_; |
| 37 DISALLOW_COPY_AND_ASSIGN(RendererClipboardWriteContext); | 37 DISALLOW_COPY_AND_ASSIGN(RendererClipboardWriteContext); |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 RendererClipboardWriteContext::RendererClipboardWriteContext() { | 40 RendererClipboardWriteContext::RendererClipboardWriteContext() { |
| 41 } | 41 } |
| 42 | 42 |
| 43 RendererClipboardWriteContext::~RendererClipboardWriteContext() { | 43 RendererClipboardWriteContext::~RendererClipboardWriteContext() { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 73 ui::Clipboard::ObjectMapParams params; | 73 ui::Clipboard::ObjectMapParams params; |
| 74 | 74 |
| 75 // The first parameter is replaced on the receiving end with a pointer to | 75 // The first parameter is replaced on the receiving end with a pointer to |
| 76 // a shared memory object containing the bitmap. We reserve space for it here. | 76 // a shared memory object containing the bitmap. We reserve space for it here. |
| 77 ui::Clipboard::ObjectMapParam place_holder_param; | 77 ui::Clipboard::ObjectMapParam place_holder_param; |
| 78 params.push_back(place_holder_param); | 78 params.push_back(place_holder_param); |
| 79 params.push_back(size_param); | 79 params.push_back(size_param); |
| 80 (*objects)[ui::Clipboard::CBF_SMBITMAP] = params; | 80 (*objects)[ui::Clipboard::CBF_SMBITMAP] = params; |
| 81 } | 81 } |
| 82 | 82 |
| 83 // Define a destructor that makes IPCs to flush the contents to the | 83 // Flushes the objects to the clipboard with an IPC. |
| 84 // system clipboard. | 84 void RendererClipboardWriteContext::Flush( |
| 85 void RendererClipboardWriteContext::FlushAndDestroy( | |
| 86 const ui::Clipboard::ObjectMap& objects) { | 85 const ui::Clipboard::ObjectMap& objects) { |
| 87 scoped_ptr<RendererClipboardWriteContext> delete_on_return(this); | |
| 88 | |
| 89 if (shared_buf_.get()) { | 86 if (shared_buf_.get()) { |
| 90 RenderThreadImpl::current()->Send( | 87 RenderThreadImpl::current()->Send( |
| 91 new ClipboardHostMsg_WriteObjectsSync(objects, shared_buf_->handle())); | 88 new ClipboardHostMsg_WriteObjectsSync(objects, shared_buf_->handle())); |
| 92 } else { | 89 } else { |
| 93 RenderThreadImpl::current()->Send( | 90 RenderThreadImpl::current()->Send( |
| 94 new ClipboardHostMsg_WriteObjectsAsync(objects)); | 91 new ClipboardHostMsg_WriteObjectsAsync(objects)); |
| 95 } | 92 } |
| 96 } | 93 } |
| 97 | 94 |
| 98 } // anonymous namespace | 95 } // anonymous namespace |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 const string16& type, | 178 const string16& type, |
| 182 string16* data) { | 179 string16* data) { |
| 183 RenderThreadImpl::current()->Send( | 180 RenderThreadImpl::current()->Send( |
| 184 new ClipboardHostMsg_ReadCustomData(buffer, type, data)); | 181 new ClipboardHostMsg_ReadCustomData(buffer, type, data)); |
| 185 } | 182 } |
| 186 | 183 |
| 187 webkit_glue::ClipboardClient::WriteContext* | 184 webkit_glue::ClipboardClient::WriteContext* |
| 188 RendererClipboardClient::CreateWriteContext() { | 185 RendererClipboardClient::CreateWriteContext() { |
| 189 return new RendererClipboardWriteContext; | 186 return new RendererClipboardWriteContext; |
| 190 } | 187 } |
| OLD | NEW |