Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Side by Side Diff: components/html_viewer/web_clipboard_impl.cc

Issue 1157843002: Update mojo sdk to rev 1dc8a9a5db73d3718d99917fadf31f5fb2ebad4f (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/filesystem/files_test_base.cc ('k') | components/html_viewer/web_cookie_jar_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/html_viewer/web_clipboard_impl.h" 5 #include "components/html_viewer/web_clipboard_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "components/html_viewer/blink_basic_type_converters.h" 8 #include "components/html_viewer/blink_basic_type_converters.h"
9 9
10 using mojo::Array; 10 using mojo::Array;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 62 }
63 63
64 uint64_t WebClipboardImpl::sequenceNumber(Buffer buffer) { 64 uint64_t WebClipboardImpl::sequenceNumber(Buffer buffer) {
65 mojo::Clipboard::Type clipboard_type = ConvertBufferType(buffer); 65 mojo::Clipboard::Type clipboard_type = ConvertBufferType(buffer);
66 66
67 uint64_t number = 0; 67 uint64_t number = 0;
68 clipboard_->GetSequenceNumber(clipboard_type, 68 clipboard_->GetSequenceNumber(clipboard_type,
69 base::Bind(&CopyUint64, &number)); 69 base::Bind(&CopyUint64, &number));
70 70
71 // Force this to be synchronous. 71 // Force this to be synchronous.
72 clipboard_.WaitForIncomingMethodCall(); 72 clipboard_.WaitForIncomingResponse();
73 return number; 73 return number;
74 } 74 }
75 75
76 bool WebClipboardImpl::isFormatAvailable(Format format, Buffer buffer) { 76 bool WebClipboardImpl::isFormatAvailable(Format format, Buffer buffer) {
77 Clipboard::Type clipboard_type = ConvertBufferType(buffer); 77 Clipboard::Type clipboard_type = ConvertBufferType(buffer);
78 78
79 std::vector<std::string> types; 79 std::vector<std::string> types;
80 clipboard_->GetAvailableMimeTypes( 80 clipboard_->GetAvailableMimeTypes(
81 clipboard_type, base::Bind(&CopyVectorString, &types)); 81 clipboard_type, base::Bind(&CopyVectorString, &types));
82 82
83 // Force this to be synchronous. 83 // Force this to be synchronous.
84 clipboard_.WaitForIncomingMethodCall(); 84 clipboard_.WaitForIncomingResponse();
85 85
86 switch (format) { 86 switch (format) {
87 case FormatPlainText: 87 case FormatPlainText:
88 return Contains(types, Clipboard::MIME_TYPE_TEXT); 88 return Contains(types, Clipboard::MIME_TYPE_TEXT);
89 case FormatHTML: 89 case FormatHTML:
90 return Contains(types, Clipboard::MIME_TYPE_HTML); 90 return Contains(types, Clipboard::MIME_TYPE_HTML);
91 case FormatSmartPaste: 91 case FormatSmartPaste:
92 return Contains(types, kMimeTypeWebkitSmartPaste); 92 return Contains(types, kMimeTypeWebkitSmartPaste);
93 case FormatBookmark: 93 case FormatBookmark:
94 // This might be difficult. 94 // This might be difficult.
95 return false; 95 return false;
96 } 96 }
97 97
98 return false; 98 return false;
99 } 99 }
100 100
101 blink::WebVector<blink::WebString> WebClipboardImpl::readAvailableTypes( 101 blink::WebVector<blink::WebString> WebClipboardImpl::readAvailableTypes(
102 Buffer buffer, 102 Buffer buffer,
103 bool* contains_filenames) { 103 bool* contains_filenames) {
104 Clipboard::Type clipboard_type = ConvertBufferType(buffer); 104 Clipboard::Type clipboard_type = ConvertBufferType(buffer);
105 105
106 std::vector<std::string> types; 106 std::vector<std::string> types;
107 clipboard_->GetAvailableMimeTypes( 107 clipboard_->GetAvailableMimeTypes(
108 clipboard_type, base::Bind(&CopyVectorString, &types)); 108 clipboard_type, base::Bind(&CopyVectorString, &types));
109 109
110 // Force this to be synchronous. 110 // Force this to be synchronous.
111 clipboard_.WaitForIncomingMethodCall(); 111 clipboard_.WaitForIncomingResponse();
112 112
113 // AFAICT, every instance of setting contains_filenames is false. 113 // AFAICT, every instance of setting contains_filenames is false.
114 *contains_filenames = false; 114 *contains_filenames = false;
115 115
116 blink::WebVector<blink::WebString> output(types.size()); 116 blink::WebVector<blink::WebString> output(types.size());
117 for (size_t i = 0; i < types.size(); ++i) { 117 for (size_t i = 0; i < types.size(); ++i) {
118 output[i] = blink::WebString::fromUTF8(types[i]); 118 output[i] = blink::WebString::fromUTF8(types[i]);
119 } 119 }
120 120
121 return output; 121 return output;
122 } 122 }
123 123
124 blink::WebString WebClipboardImpl::readPlainText(Buffer buffer) { 124 blink::WebString WebClipboardImpl::readPlainText(Buffer buffer) {
125 Clipboard::Type type = ConvertBufferType(buffer); 125 Clipboard::Type type = ConvertBufferType(buffer);
126 126
127 blink::WebString text; 127 blink::WebString text;
128 clipboard_->ReadMimeType(type, Clipboard::MIME_TYPE_TEXT, 128 clipboard_->ReadMimeType(type, Clipboard::MIME_TYPE_TEXT,
129 base::Bind(&CopyWebString, &text)); 129 base::Bind(&CopyWebString, &text));
130 130
131 // Force this to be synchronous. 131 // Force this to be synchronous.
132 clipboard_.WaitForIncomingMethodCall(); 132 clipboard_.WaitForIncomingResponse();
133 133
134 return text; 134 return text;
135 } 135 }
136 136
137 blink::WebString WebClipboardImpl::readHTML(Buffer buffer, 137 blink::WebString WebClipboardImpl::readHTML(Buffer buffer,
138 blink::WebURL* page_url, 138 blink::WebURL* page_url,
139 unsigned* fragment_start, 139 unsigned* fragment_start,
140 unsigned* fragment_end) { 140 unsigned* fragment_end) {
141 Clipboard::Type type = ConvertBufferType(buffer); 141 Clipboard::Type type = ConvertBufferType(buffer);
142 142
143 blink::WebString html; 143 blink::WebString html;
144 clipboard_->ReadMimeType(type, Clipboard::MIME_TYPE_HTML, 144 clipboard_->ReadMimeType(type, Clipboard::MIME_TYPE_HTML,
145 base::Bind(&CopyWebString, &html)); 145 base::Bind(&CopyWebString, &html));
146 clipboard_.WaitForIncomingMethodCall(); 146 clipboard_.WaitForIncomingResponse();
147 147
148 *fragment_start = 0; 148 *fragment_start = 0;
149 *fragment_end = static_cast<unsigned>(html.length()); 149 *fragment_end = static_cast<unsigned>(html.length());
150 150
151 clipboard_->ReadMimeType(type, Clipboard::MIME_TYPE_URL, 151 clipboard_->ReadMimeType(type, Clipboard::MIME_TYPE_URL,
152 base::Bind(&CopyURL, page_url)); 152 base::Bind(&CopyURL, page_url));
153 clipboard_.WaitForIncomingMethodCall(); 153 clipboard_.WaitForIncomingResponse();
154 154
155 return html; 155 return html;
156 } 156 }
157 157
158 blink::WebString WebClipboardImpl::readCustomData( 158 blink::WebString WebClipboardImpl::readCustomData(
159 Buffer buffer, 159 Buffer buffer,
160 const blink::WebString& mime_type) { 160 const blink::WebString& mime_type) {
161 Clipboard::Type clipboard_type = ConvertBufferType(buffer); 161 Clipboard::Type clipboard_type = ConvertBufferType(buffer);
162 162
163 blink::WebString data; 163 blink::WebString data;
164 clipboard_->ReadMimeType( 164 clipboard_->ReadMimeType(
165 clipboard_type, mime_type.utf8(), base::Bind(&CopyWebString, &data)); 165 clipboard_type, mime_type.utf8(), base::Bind(&CopyWebString, &data));
166 166
167 // Force this to be synchronous. 167 // Force this to be synchronous.
168 clipboard_.WaitForIncomingMethodCall(); 168 clipboard_.WaitForIncomingResponse();
169 169
170 return data; 170 return data;
171 } 171 }
172 172
173 void WebClipboardImpl::writePlainText(const blink::WebString& plain_text) { 173 void WebClipboardImpl::writePlainText(const blink::WebString& plain_text) {
174 Map<String, Array<uint8_t>> data; 174 Map<String, Array<uint8_t>> data;
175 data[Clipboard::MIME_TYPE_TEXT] = Array<uint8_t>::From(plain_text); 175 data[Clipboard::MIME_TYPE_TEXT] = Array<uint8_t>::From(plain_text);
176 176
177 clipboard_->WriteClipboardData(Clipboard::TYPE_COPY_PASTE, data.Pass()); 177 clipboard_->WriteClipboardData(Clipboard::TYPE_COPY_PASTE, data.Pass());
178 } 178 }
(...skipping 19 matching lines...) Expand all
198 return Clipboard::TYPE_COPY_PASTE; 198 return Clipboard::TYPE_COPY_PASTE;
199 case BufferSelection: 199 case BufferSelection:
200 return Clipboard::TYPE_SELECTION; 200 return Clipboard::TYPE_SELECTION;
201 } 201 }
202 202
203 NOTREACHED(); 203 NOTREACHED();
204 return Clipboard::TYPE_COPY_PASTE; 204 return Clipboard::TYPE_COPY_PASTE;
205 } 205 }
206 206
207 } // namespace html_viewer 207 } // namespace html_viewer
OLDNEW
« no previous file with comments | « components/filesystem/files_test_base.cc ('k') | components/html_viewer/web_cookie_jar_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698