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_client.h" | 7 #include "content/renderer/renderer_clipboard_client.h" |
8 | 8 |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 bool result; | 113 bool result; |
114 RenderThreadImpl::current()->Send( | 114 RenderThreadImpl::current()->Send( |
115 new ClipboardHostMsg_IsFormatAvailable(format, type, &result)); | 115 new ClipboardHostMsg_IsFormatAvailable(format, type, &result)); |
116 return result; | 116 return result; |
117 } | 117 } |
118 | 118 |
119 void RendererClipboardClient::Clear(ui::ClipboardType type) { | 119 void RendererClipboardClient::Clear(ui::ClipboardType type) { |
120 RenderThreadImpl::current()->Send(new ClipboardHostMsg_Clear(type)); | 120 RenderThreadImpl::current()->Send(new ClipboardHostMsg_Clear(type)); |
121 } | 121 } |
122 | 122 |
123 void RendererClipboardClient::ReadAvailableTypes(ui::ClipboardType type, | 123 void RendererClipboardClient::ReadAvailableTypes( |
124 std::vector<string16>* types, | 124 ui::ClipboardType type, |
125 bool* contains_filenames) { | 125 std::vector<base::string16>* types, |
| 126 bool* contains_filenames) { |
126 RenderThreadImpl::current()->Send(new ClipboardHostMsg_ReadAvailableTypes( | 127 RenderThreadImpl::current()->Send(new ClipboardHostMsg_ReadAvailableTypes( |
127 type, types, contains_filenames)); | 128 type, types, contains_filenames)); |
128 } | 129 } |
129 | 130 |
130 void RendererClipboardClient::ReadText(ui::ClipboardType type, | 131 void RendererClipboardClient::ReadText(ui::ClipboardType type, |
131 string16* result) { | 132 base::string16* result) { |
132 RenderThreadImpl::current()->Send( | 133 RenderThreadImpl::current()->Send( |
133 new ClipboardHostMsg_ReadText(type, result)); | 134 new ClipboardHostMsg_ReadText(type, result)); |
134 } | 135 } |
135 | 136 |
136 void RendererClipboardClient::ReadAsciiText(ui::ClipboardType type, | 137 void RendererClipboardClient::ReadAsciiText(ui::ClipboardType type, |
137 std::string* result) { | 138 std::string* result) { |
138 RenderThreadImpl::current()->Send( | 139 RenderThreadImpl::current()->Send( |
139 new ClipboardHostMsg_ReadAsciiText(type, result)); | 140 new ClipboardHostMsg_ReadAsciiText(type, result)); |
140 } | 141 } |
141 | 142 |
142 void RendererClipboardClient::ReadHTML(ui::ClipboardType type, | 143 void RendererClipboardClient::ReadHTML(ui::ClipboardType type, |
143 string16* markup, | 144 base::string16* markup, |
144 GURL* url, uint32* fragment_start, | 145 GURL* url, uint32* fragment_start, |
145 uint32* fragment_end) { | 146 uint32* fragment_end) { |
146 RenderThreadImpl::current()->Send(new ClipboardHostMsg_ReadHTML( | 147 RenderThreadImpl::current()->Send(new ClipboardHostMsg_ReadHTML( |
147 type, markup, url, fragment_start, fragment_end)); | 148 type, markup, url, fragment_start, fragment_end)); |
148 } | 149 } |
149 | 150 |
150 void RendererClipboardClient::ReadRTF(ui::ClipboardType type, | 151 void RendererClipboardClient::ReadRTF(ui::ClipboardType type, |
151 std::string* result) { | 152 std::string* result) { |
152 RenderThreadImpl::current()->Send(new ClipboardHostMsg_ReadRTF(type, result)); | 153 RenderThreadImpl::current()->Send(new ClipboardHostMsg_ReadRTF(type, result)); |
153 } | 154 } |
154 | 155 |
155 void RendererClipboardClient::ReadImage(ui::ClipboardType type, | 156 void RendererClipboardClient::ReadImage(ui::ClipboardType type, |
156 std::string* data) { | 157 std::string* data) { |
157 base::SharedMemoryHandle image_handle; | 158 base::SharedMemoryHandle image_handle; |
158 uint32 image_size; | 159 uint32 image_size; |
159 RenderThreadImpl::current()->Send( | 160 RenderThreadImpl::current()->Send( |
160 new ClipboardHostMsg_ReadImage(type, &image_handle, &image_size)); | 161 new ClipboardHostMsg_ReadImage(type, &image_handle, &image_size)); |
161 if (base::SharedMemory::IsHandleValid(image_handle)) { | 162 if (base::SharedMemory::IsHandleValid(image_handle)) { |
162 base::SharedMemory buffer(image_handle, true); | 163 base::SharedMemory buffer(image_handle, true); |
163 buffer.Map(image_size); | 164 buffer.Map(image_size); |
164 data->append(static_cast<char*>(buffer.memory()), image_size); | 165 data->append(static_cast<char*>(buffer.memory()), image_size); |
165 } | 166 } |
166 } | 167 } |
167 | 168 |
168 void RendererClipboardClient::ReadCustomData(ui::ClipboardType clipboard_type, | 169 void RendererClipboardClient::ReadCustomData(ui::ClipboardType clipboard_type, |
169 const string16& type, | 170 const base::string16& type, |
170 string16* data) { | 171 base::string16* data) { |
171 RenderThreadImpl::current()->Send( | 172 RenderThreadImpl::current()->Send( |
172 new ClipboardHostMsg_ReadCustomData(clipboard_type, type, data)); | 173 new ClipboardHostMsg_ReadCustomData(clipboard_type, type, data)); |
173 } | 174 } |
174 | 175 |
175 void RendererClipboardClient::ReadData(const ui::Clipboard::FormatType& format, | 176 void RendererClipboardClient::ReadData(const ui::Clipboard::FormatType& format, |
176 std::string* data) { | 177 std::string* data) { |
177 RenderThreadImpl::current()->Send( | 178 RenderThreadImpl::current()->Send( |
178 new ClipboardHostMsg_ReadData(format, data)); | 179 new ClipboardHostMsg_ReadData(format, data)); |
179 } | 180 } |
180 | 181 |
181 ClipboardClient::WriteContext* RendererClipboardClient::CreateWriteContext() { | 182 ClipboardClient::WriteContext* RendererClipboardClient::CreateWriteContext() { |
182 return new RendererClipboardWriteContext; | 183 return new RendererClipboardWriteContext; |
183 } | 184 } |
184 | 185 |
185 } // namespace content | 186 } // namespace content |
OLD | NEW |