OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "content/renderer/webclipboard_impl.h" | 5 #include "content/renderer/webclipboard_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "content/common/clipboard_format.h" | 11 #include "content/common/clipboard_format.h" |
12 #include "content/public/common/drop_data.h" | 12 #include "content/public/common/drop_data.h" |
13 #include "content/renderer/clipboard_utils.h" | 13 #include "content/renderer/clipboard_utils.h" |
14 #include "content/renderer/drop_data_builder.h" | 14 #include "content/renderer/drop_data_builder.h" |
15 #include "content/renderer/renderer_clipboard_delegate.h" | 15 #include "content/renderer/renderer_clipboard_delegate.h" |
16 #include "third_party/WebKit/public/platform/WebData.h" | |
17 #include "third_party/WebKit/public/platform/WebDragData.h" | 16 #include "third_party/WebKit/public/platform/WebDragData.h" |
18 #include "third_party/WebKit/public/platform/WebImage.h" | 17 #include "third_party/WebKit/public/platform/WebImage.h" |
19 #include "third_party/WebKit/public/platform/WebSize.h" | 18 #include "third_party/WebKit/public/platform/WebSize.h" |
20 #include "third_party/WebKit/public/platform/WebString.h" | 19 #include "third_party/WebKit/public/platform/WebString.h" |
21 #include "third_party/WebKit/public/platform/WebURL.h" | 20 #include "third_party/WebKit/public/platform/WebURL.h" |
22 #include "third_party/WebKit/public/platform/WebVector.h" | 21 #include "third_party/WebKit/public/platform/WebVector.h" |
23 #include "url/gurl.h" | 22 #include "url/gurl.h" |
24 | 23 |
| 24 using blink::WebBlobInfo; |
25 using blink::WebClipboard; | 25 using blink::WebClipboard; |
26 using blink::WebData; | |
27 using blink::WebDragData; | 26 using blink::WebDragData; |
28 using blink::WebImage; | 27 using blink::WebImage; |
29 using blink::WebString; | 28 using blink::WebString; |
30 using blink::WebURL; | 29 using blink::WebURL; |
31 using blink::WebVector; | 30 using blink::WebVector; |
32 | 31 |
33 namespace content { | 32 namespace content { |
34 | 33 |
35 WebClipboardImpl::WebClipboardImpl(RendererClipboardDelegate* delegate) | 34 WebClipboardImpl::WebClipboardImpl(RendererClipboardDelegate* delegate) |
36 : delegate_(delegate) { | 35 : delegate_(delegate) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 102 |
104 base::string16 html_stdstr; | 103 base::string16 html_stdstr; |
105 GURL gurl; | 104 GURL gurl; |
106 delegate_->ReadHTML(clipboard_type, &html_stdstr, &gurl, | 105 delegate_->ReadHTML(clipboard_type, &html_stdstr, &gurl, |
107 static_cast<uint32_t*>(fragment_start), | 106 static_cast<uint32_t*>(fragment_start), |
108 static_cast<uint32_t*>(fragment_end)); | 107 static_cast<uint32_t*>(fragment_end)); |
109 *source_url = gurl; | 108 *source_url = gurl; |
110 return html_stdstr; | 109 return html_stdstr; |
111 } | 110 } |
112 | 111 |
113 WebData WebClipboardImpl::readImage(Buffer buffer) { | 112 WebBlobInfo WebClipboardImpl::readImage(Buffer buffer) { |
114 ui::ClipboardType clipboard_type; | 113 ui::ClipboardType clipboard_type; |
115 if (!ConvertBufferType(buffer, &clipboard_type)) | 114 if (!ConvertBufferType(buffer, &clipboard_type)) |
116 return WebData(); | 115 return WebBlobInfo(); |
117 | 116 |
118 std::string png_data; | 117 std::string blob_uuid; |
119 delegate_->ReadImage(clipboard_type, &png_data); | 118 std::string type; |
120 return WebData(png_data); | 119 int64_t size; |
| 120 delegate_->ReadImage(clipboard_type, &blob_uuid, &type, &size); |
| 121 if (size < 0) |
| 122 return WebBlobInfo(); |
| 123 return WebBlobInfo(base::ASCIIToUTF16(blob_uuid), base::UTF8ToUTF16(type), |
| 124 size); |
121 } | 125 } |
122 | 126 |
123 WebString WebClipboardImpl::readCustomData(Buffer buffer, | 127 WebString WebClipboardImpl::readCustomData(Buffer buffer, |
124 const WebString& type) { | 128 const WebString& type) { |
125 ui::ClipboardType clipboard_type; | 129 ui::ClipboardType clipboard_type; |
126 if (!ConvertBufferType(buffer, &clipboard_type)) | 130 if (!ConvertBufferType(buffer, &clipboard_type)) |
127 return WebString(); | 131 return WebString(); |
128 | 132 |
129 base::string16 data; | 133 base::string16 data; |
130 delegate_->ReadCustomData(clipboard_type, type, &data); | 134 delegate_->ReadCustomData(clipboard_type, type, &data); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 return false; | 212 return false; |
209 #endif | 213 #endif |
210 default: | 214 default: |
211 NOTREACHED(); | 215 NOTREACHED(); |
212 return false; | 216 return false; |
213 } | 217 } |
214 return true; | 218 return true; |
215 } | 219 } |
216 | 220 |
217 } // namespace content | 221 } // namespace content |
OLD | NEW |