Commit cc9b3784 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Remove some obsolete TODOs related to ExtensionPrinterHandler.

Simplify some code too.

Change-Id: I94dbf05f1090ee7d3ecd88e8e6ef7edd778494c2
Reviewed-on: https://chromium-review.googlesource.com/1043361Reviewed-by: default avatarToni Barzic <tbarzic@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556104}
parent ca4884b9
...@@ -97,6 +97,11 @@ bool ParseProvisionalUsbPrinterId(const std::string& printer_id, ...@@ -97,6 +97,11 @@ bool ParseProvisionalUsbPrinterId(const std::string& printer_id,
return true; return true;
} }
extensions::PrinterProviderAPI* GetPrinterProviderAPI(Profile* profile) {
return extensions::PrinterProviderAPIFactory::GetInstance()
->GetForBrowserContext(profile);
}
} // namespace } // namespace
ExtensionPrinterHandler::ExtensionPrinterHandler(Profile* profile) ExtensionPrinterHandler::ExtensionPrinterHandler(Profile* profile)
...@@ -138,22 +143,18 @@ void ExtensionPrinterHandler::StartGetPrinters( ...@@ -138,22 +143,18 @@ void ExtensionPrinterHandler::StartGetPrinters(
weak_ptr_factory_.GetWeakPtr(), callback)); weak_ptr_factory_.GetWeakPtr(), callback));
} }
extensions::PrinterProviderAPIFactory::GetInstance() GetPrinterProviderAPI(profile_)->DispatchGetPrintersRequested(
->GetForBrowserContext(profile_) base::BindRepeating(&ExtensionPrinterHandler::WrapGetPrintersCallback,
->DispatchGetPrintersRequested( weak_ptr_factory_.GetWeakPtr(), callback));
base::Bind(&ExtensionPrinterHandler::WrapGetPrintersCallback,
weak_ptr_factory_.GetWeakPtr(), callback));
} }
void ExtensionPrinterHandler::StartGetCapability( void ExtensionPrinterHandler::StartGetCapability(
const std::string& destination_id, const std::string& destination_id,
GetCapabilityCallback callback) { GetCapabilityCallback callback) {
extensions::PrinterProviderAPIFactory::GetInstance() GetPrinterProviderAPI(profile_)->DispatchGetCapabilityRequested(
->GetForBrowserContext(profile_) destination_id,
->DispatchGetCapabilityRequested( base::BindOnce(&ExtensionPrinterHandler::WrapGetCapabilityCallback,
destination_id, weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
base::BindOnce(&ExtensionPrinterHandler::WrapGetCapabilityCallback,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
} }
void ExtensionPrinterHandler::StartPrint( void ExtensionPrinterHandler::StartPrint(
...@@ -175,12 +176,9 @@ void ExtensionPrinterHandler::StartPrint( ...@@ -175,12 +176,9 @@ void ExtensionPrinterHandler::StartPrint(
cloud_devices::printer::ContentTypesCapability content_types; cloud_devices::printer::ContentTypesCapability content_types;
content_types.LoadFrom(printer_description); content_types.LoadFrom(printer_description);
const bool kUsePdf = content_types.Contains(kContentTypePdf) || const bool use_pdf = content_types.Contains(kContentTypePdf) ||
content_types.Contains(kContentTypeAll); content_types.Contains(kContentTypeAll);
if (use_pdf) {
if (kUsePdf) {
// TODO(tbarzic): Consider writing larger PDF to disk and provide the data
// the same way as it's done with PWG raster.
print_job->content_type = kContentTypePdf; print_job->content_type = kContentTypePdf;
print_job->document_bytes = print_data; print_job->document_bytes = print_data;
DispatchPrintJob(std::move(callback), std::move(print_job)); DispatchPrintJob(std::move(callback), std::move(print_job));
...@@ -222,12 +220,10 @@ void ExtensionPrinterHandler::StartGrantPrinterAccess( ...@@ -222,12 +220,10 @@ void ExtensionPrinterHandler::StartGrantPrinterAccess(
DevicePermissionsManager::Get(profile_); DevicePermissionsManager::Get(profile_);
permissions_manager->AllowUsbDevice(extension_id, device); permissions_manager->AllowUsbDevice(extension_id, device);
extensions::PrinterProviderAPIFactory::GetInstance() GetPrinterProviderAPI(profile_)->DispatchGetUsbPrinterInfoRequested(
->GetForBrowserContext(profile_) extension_id, device,
->DispatchGetUsbPrinterInfoRequested( base::BindOnce(&ExtensionPrinterHandler::WrapGetPrinterInfoCallback,
extension_id, device, weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
base::BindOnce(&ExtensionPrinterHandler::WrapGetPrinterInfoCallback,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
} }
void ExtensionPrinterHandler::SetPwgRasterConverterForTesting( void ExtensionPrinterHandler::SetPwgRasterConverterForTesting(
......
...@@ -56,7 +56,6 @@ class ExtensionPrinterHandler : public PrinterHandler { ...@@ -56,7 +56,6 @@ class ExtensionPrinterHandler : public PrinterHandler {
GetPrintersDoneCallback done_callback) override; GetPrintersDoneCallback done_callback) override;
void StartGetCapability(const std::string& destination_id, void StartGetCapability(const std::string& destination_id,
GetCapabilityCallback callback) override; GetCapabilityCallback callback) override;
// TODO(tbarzic): It might make sense to have the strings in a single struct.
void StartPrint(const std::string& destination_id, void StartPrint(const std::string& destination_id,
const std::string& capability, const std::string& capability,
const base::string16& job_title, const base::string16& job_title,
......
...@@ -120,7 +120,6 @@ class PrinterHandler { ...@@ -120,7 +120,6 @@ class PrinterHandler {
// |page_size|: The document page size. // |page_size|: The document page size.
// |print_data|: The document bytes to print. // |print_data|: The document bytes to print.
// |callback| should be called in the response to the request. // |callback| should be called in the response to the request.
// TODO(tbarzic): Page size should be extracted from print data.
virtual void StartPrint( virtual void StartPrint(
const std::string& destination_id, const std::string& destination_id,
const std::string& capability, const std::string& capability,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment