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 the Clipboard interface. | 5 // This file provides the embedder's side of the Clipboard interface. |
6 | 6 |
7 #include "content/renderer/renderer_clipboard_delegate.h" | 7 #include "content/renderer/renderer_clipboard_delegate.h" |
8 | 8 |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/numerics/safe_math.h" | 10 #include "base/numerics/safe_math.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 RenderThreadImpl::current()->Send( | 120 RenderThreadImpl::current()->Send( |
121 new ClipboardHostMsg_WriteBookmark(clipboard_type, url.spec(), title)); | 121 new ClipboardHostMsg_WriteBookmark(clipboard_type, url.spec(), title)); |
122 } | 122 } |
123 | 123 |
124 bool RendererClipboardDelegate::WriteImage(ui::ClipboardType clipboard_type, | 124 bool RendererClipboardDelegate::WriteImage(ui::ClipboardType clipboard_type, |
125 const SkBitmap& bitmap) { | 125 const SkBitmap& bitmap) { |
126 // Only 32-bit bitmaps are supported. | 126 // Only 32-bit bitmaps are supported. |
127 DCHECK_EQ(bitmap.colorType(), kN32_SkColorType); | 127 DCHECK_EQ(bitmap.colorType(), kN32_SkColorType); |
128 | 128 |
129 const gfx::Size size(bitmap.width(), bitmap.height()); | 129 const gfx::Size size(bitmap.width(), bitmap.height()); |
130 scoped_ptr<base::SharedMemory> shared_buf; | 130 std::unique_ptr<base::SharedMemory> shared_buf; |
131 { | 131 { |
132 SkAutoLockPixels locked(bitmap); | 132 SkAutoLockPixels locked(bitmap); |
133 void* pixels = bitmap.getPixels(); | 133 void* pixels = bitmap.getPixels(); |
134 // TODO(piman): this should not be NULL, but it is. crbug.com/369621 | 134 // TODO(piman): this should not be NULL, but it is. crbug.com/369621 |
135 if (!pixels) | 135 if (!pixels) |
136 return false; | 136 return false; |
137 | 137 |
138 base::CheckedNumeric<uint32_t> checked_buf_size = 4; | 138 base::CheckedNumeric<uint32_t> checked_buf_size = 4; |
139 checked_buf_size *= size.width(); | 139 checked_buf_size *= size.width(); |
140 checked_buf_size *= size.height(); | 140 checked_buf_size *= size.height(); |
(...skipping 17 matching lines...) Expand all Loading... |
158 clipboard_type, size, shared_buf->handle())); | 158 clipboard_type, size, shared_buf->handle())); |
159 return true; | 159 return true; |
160 } | 160 } |
161 | 161 |
162 void RendererClipboardDelegate::CommitWrite(ui::ClipboardType clipboard_type) { | 162 void RendererClipboardDelegate::CommitWrite(ui::ClipboardType clipboard_type) { |
163 RenderThreadImpl::current()->Send( | 163 RenderThreadImpl::current()->Send( |
164 new ClipboardHostMsg_CommitWrite(clipboard_type)); | 164 new ClipboardHostMsg_CommitWrite(clipboard_type)); |
165 } | 165 } |
166 | 166 |
167 } // namespace content | 167 } // namespace content |
OLD | NEW |