OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "extensions/browser/api/printer_provider_internal/printer_provider_inte
rnal_api.h" | 5 #include "extensions/browser/api/printer_provider_internal/printer_provider_inte
rnal_api.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 } | 216 } |
217 return RespondLater(); | 217 return RespondLater(); |
218 } | 218 } |
219 | 219 |
220 void PrinterProviderInternalGetPrintDataFunction::OnBlob( | 220 void PrinterProviderInternalGetPrintDataFunction::OnBlob( |
221 const std::string& type, | 221 const std::string& type, |
222 int size, | 222 int size, |
223 const scoped_refptr<base::RefCountedMemory>& data, | 223 const scoped_refptr<base::RefCountedMemory>& data, |
224 std::unique_ptr<content::BlobHandle> blob) { | 224 std::unique_ptr<content::BlobHandle> blob) { |
225 if (!blob) { | 225 if (!blob) { |
226 SetError("Unable to create the blob."); | 226 Respond(Error("Unable to create the blob.")); |
227 SendResponse(false); | |
228 return; | 227 return; |
229 } | 228 } |
230 | 229 |
231 internal_api::BlobInfo info; | 230 internal_api::BlobInfo info; |
232 info.blob_uuid = blob->GetUUID(); | 231 info.blob_uuid = blob->GetUUID(); |
233 info.type = type; | 232 info.type = type; |
234 info.size = size; | 233 info.size = size; |
235 | 234 |
236 std::vector<std::string> uuids; | 235 std::vector<std::string> uuids; |
237 uuids.push_back(blob->GetUUID()); | 236 uuids.push_back(blob->GetUUID()); |
238 | 237 |
239 extensions::BlobHolder* holder = | 238 extensions::BlobHolder* holder = |
240 extensions::BlobHolder::FromRenderProcessHost( | 239 extensions::BlobHolder::FromRenderProcessHost( |
241 render_frame_host()->GetProcess()); | 240 render_frame_host()->GetProcess()); |
242 holder->HoldBlobReference(std::move(blob)); | 241 holder->HoldBlobReference(std::move(blob)); |
243 | 242 |
244 results_ = internal_api::GetPrintData::Results::Create(info); | |
245 SetTransferredBlobUUIDs(uuids); | 243 SetTransferredBlobUUIDs(uuids); |
246 SendResponse(true); | 244 Respond(ArgumentList(internal_api::GetPrintData::Results::Create(info))); |
247 } | 245 } |
248 | 246 |
249 PrinterProviderInternalReportUsbPrinterInfoFunction:: | 247 PrinterProviderInternalReportUsbPrinterInfoFunction:: |
250 PrinterProviderInternalReportUsbPrinterInfoFunction() { | 248 PrinterProviderInternalReportUsbPrinterInfoFunction() { |
251 } | 249 } |
252 | 250 |
253 PrinterProviderInternalReportUsbPrinterInfoFunction:: | 251 PrinterProviderInternalReportUsbPrinterInfoFunction:: |
254 ~PrinterProviderInternalReportUsbPrinterInfoFunction() { | 252 ~PrinterProviderInternalReportUsbPrinterInfoFunction() { |
255 } | 253 } |
256 | 254 |
257 ExtensionFunction::ResponseAction | 255 ExtensionFunction::ResponseAction |
258 PrinterProviderInternalReportUsbPrinterInfoFunction::Run() { | 256 PrinterProviderInternalReportUsbPrinterInfoFunction::Run() { |
259 std::unique_ptr<internal_api::ReportUsbPrinterInfo::Params> params( | 257 std::unique_ptr<internal_api::ReportUsbPrinterInfo::Params> params( |
260 internal_api::ReportUsbPrinterInfo::Params::Create(*args_)); | 258 internal_api::ReportUsbPrinterInfo::Params::Create(*args_)); |
261 EXTENSION_FUNCTION_VALIDATE(params.get()); | 259 EXTENSION_FUNCTION_VALIDATE(params.get()); |
262 | 260 |
263 PrinterProviderInternalAPI::GetFactoryInstance() | 261 PrinterProviderInternalAPI::GetFactoryInstance() |
264 ->Get(browser_context()) | 262 ->Get(browser_context()) |
265 ->NotifyGetUsbPrinterInfoResult(extension(), params->request_id, | 263 ->NotifyGetUsbPrinterInfoResult(extension(), params->request_id, |
266 params->printer_info.get()); | 264 params->printer_info.get()); |
267 return RespondNow(NoArguments()); | 265 return RespondNow(NoArguments()); |
268 } | 266 } |
269 | 267 |
270 } // namespace extensions | 268 } // namespace extensions |
OLD | NEW |