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 "content/common/clipboard_format.h" | 11 #include "content/common/clipboard_format.h" |
11 #include "content/public/common/drop_data.h" | 12 #include "content/public/common/drop_data.h" |
12 #include "content/renderer/clipboard_utils.h" | 13 #include "content/renderer/clipboard_utils.h" |
13 #include "content/renderer/drop_data_builder.h" | 14 #include "content/renderer/drop_data_builder.h" |
14 #include "content/renderer/renderer_clipboard_delegate.h" | 15 #include "content/renderer/renderer_clipboard_delegate.h" |
15 #include "third_party/WebKit/public/platform/WebData.h" | 16 #include "third_party/WebKit/public/platform/WebData.h" |
16 #include "third_party/WebKit/public/platform/WebDragData.h" | 17 #include "third_party/WebKit/public/platform/WebDragData.h" |
17 #include "third_party/WebKit/public/platform/WebImage.h" | 18 #include "third_party/WebKit/public/platform/WebImage.h" |
18 #include "third_party/WebKit/public/platform/WebSize.h" | 19 #include "third_party/WebKit/public/platform/WebSize.h" |
19 #include "third_party/WebKit/public/platform/WebString.h" | 20 #include "third_party/WebKit/public/platform/WebString.h" |
(...skipping 12 matching lines...) Expand all Loading... |
32 namespace content { | 33 namespace content { |
33 | 34 |
34 WebClipboardImpl::WebClipboardImpl(RendererClipboardDelegate* delegate) | 35 WebClipboardImpl::WebClipboardImpl(RendererClipboardDelegate* delegate) |
35 : delegate_(delegate) { | 36 : delegate_(delegate) { |
36 DCHECK(delegate); | 37 DCHECK(delegate); |
37 } | 38 } |
38 | 39 |
39 WebClipboardImpl::~WebClipboardImpl() { | 40 WebClipboardImpl::~WebClipboardImpl() { |
40 } | 41 } |
41 | 42 |
42 uint64 WebClipboardImpl::sequenceNumber(Buffer buffer) { | 43 uint64_t WebClipboardImpl::sequenceNumber(Buffer buffer) { |
43 ui::ClipboardType clipboard_type; | 44 ui::ClipboardType clipboard_type; |
44 if (!ConvertBufferType(buffer, &clipboard_type)) | 45 if (!ConvertBufferType(buffer, &clipboard_type)) |
45 return 0; | 46 return 0; |
46 | 47 |
47 return delegate_->GetSequenceNumber(clipboard_type); | 48 return delegate_->GetSequenceNumber(clipboard_type); |
48 } | 49 } |
49 | 50 |
50 bool WebClipboardImpl::isFormatAvailable(Format format, Buffer buffer) { | 51 bool WebClipboardImpl::isFormatAvailable(Format format, Buffer buffer) { |
51 ui::ClipboardType clipboard_type = ui::CLIPBOARD_TYPE_COPY_PASTE; | 52 ui::ClipboardType clipboard_type = ui::CLIPBOARD_TYPE_COPY_PASTE; |
52 | 53 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 WebString WebClipboardImpl::readHTML(Buffer buffer, WebURL* source_url, | 97 WebString WebClipboardImpl::readHTML(Buffer buffer, WebURL* source_url, |
97 unsigned* fragment_start, | 98 unsigned* fragment_start, |
98 unsigned* fragment_end) { | 99 unsigned* fragment_end) { |
99 ui::ClipboardType clipboard_type; | 100 ui::ClipboardType clipboard_type; |
100 if (!ConvertBufferType(buffer, &clipboard_type)) | 101 if (!ConvertBufferType(buffer, &clipboard_type)) |
101 return WebString(); | 102 return WebString(); |
102 | 103 |
103 base::string16 html_stdstr; | 104 base::string16 html_stdstr; |
104 GURL gurl; | 105 GURL gurl; |
105 delegate_->ReadHTML(clipboard_type, &html_stdstr, &gurl, | 106 delegate_->ReadHTML(clipboard_type, &html_stdstr, &gurl, |
106 static_cast<uint32*>(fragment_start), | 107 static_cast<uint32_t*>(fragment_start), |
107 static_cast<uint32*>(fragment_end)); | 108 static_cast<uint32_t*>(fragment_end)); |
108 *source_url = gurl; | 109 *source_url = gurl; |
109 return html_stdstr; | 110 return html_stdstr; |
110 } | 111 } |
111 | 112 |
112 WebData WebClipboardImpl::readImage(Buffer buffer) { | 113 WebData WebClipboardImpl::readImage(Buffer buffer) { |
113 ui::ClipboardType clipboard_type; | 114 ui::ClipboardType clipboard_type; |
114 if (!ConvertBufferType(buffer, &clipboard_type)) | 115 if (!ConvertBufferType(buffer, &clipboard_type)) |
115 return WebData(); | 116 return WebData(); |
116 | 117 |
117 std::string png_data; | 118 std::string png_data; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 return false; | 208 return false; |
208 #endif | 209 #endif |
209 default: | 210 default: |
210 NOTREACHED(); | 211 NOTREACHED(); |
211 return false; | 212 return false; |
212 } | 213 } |
213 return true; | 214 return true; |
214 } | 215 } |
215 | 216 |
216 } // namespace content | 217 } // namespace content |
OLD | NEW |