Commit e714d4b9 authored by Alan Screen's avatar Alan Screen Committed by Commit Bot

Cleanup: drop settings parameter when creating PrintBackend

Instantiating a PrintBackend class is done through a CreateInstance()
call.  This call has included a parameter to optionally seed the new
instance with some initial values different from the defaults.  This
parameter is never made use of in the existing code.

Cleanup of this parameter will ease the effort to mojoify the
PrintBackend class.

Bug: 809738
Change-Id: I460e3edd14c2fd830d9d8f126b84619ec9e53597
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2354541Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarDaniel Hosseinian <dhoss@chromium.org>
Commit-Queue: Alan Screen <awscreen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798201}
parent 166a2570
...@@ -27,7 +27,7 @@ base::Optional<printing::PrinterSemanticCapsAndDefaults> ...@@ -27,7 +27,7 @@ base::Optional<printing::PrinterSemanticCapsAndDefaults>
FetchCapabilitiesOnBlockingTaskRunner(const std::string& printer_id) { FetchCapabilitiesOnBlockingTaskRunner(const std::string& printer_id) {
scoped_refptr<printing::PrintBackend> backend( scoped_refptr<printing::PrintBackend> backend(
printing::PrintBackend::CreateInstance( printing::PrintBackend::CreateInstance(
nullptr, g_browser_process->GetApplicationLocale())); g_browser_process->GetApplicationLocale()));
printing::PrinterSemanticCapsAndDefaults capabilities; printing::PrinterSemanticCapsAndDefaults capabilities;
if (!backend->GetPrinterSemanticCapsAndDefaults(printer_id, &capabilities)) { if (!backend->GetPrinterSemanticCapsAndDefaults(printer_id, &capabilities)) {
LOG(WARNING) << "Failed to get capabilities for " << printer_id; LOG(WARNING) << "Failed to get capabilities for " << printer_id;
......
...@@ -216,8 +216,8 @@ void PrintJobWorker::UpdatePrintSettings(base::Value new_settings, ...@@ -216,8 +216,8 @@ void PrintJobWorker::UpdatePrintSettings(base::Value new_settings,
// not thread-safe and have to be accessed on the UI thread. // not thread-safe and have to be accessed on the UI thread.
base::ScopedAllowBlocking allow_blocking; base::ScopedAllowBlocking allow_blocking;
#endif #endif
scoped_refptr<PrintBackend> print_backend = PrintBackend::CreateInstance( scoped_refptr<PrintBackend> print_backend =
nullptr, g_browser_process->GetApplicationLocale()); PrintBackend::CreateInstance(g_browser_process->GetApplicationLocale());
std::string printer_name = *new_settings.FindStringKey(kSettingDeviceName); std::string printer_name = *new_settings.FindStringKey(kSettingDeviceName);
crash_key = std::make_unique<crash_keys::ScopedPrinterInfo>( crash_key = std::make_unique<crash_keys::ScopedPrinterInfo>(
print_backend->GetPrinterDriverInfo(printer_name)); print_backend->GetPrinterDriverInfo(printer_name));
......
...@@ -73,7 +73,7 @@ base::Value FetchCapabilitiesAsync(const std::string& device_name, ...@@ -73,7 +73,7 @@ base::Value FetchCapabilitiesAsync(const std::string& device_name,
const PrinterBasicInfo& basic_info, const PrinterBasicInfo& basic_info,
bool has_secure_protocol, bool has_secure_protocol,
const std::string& locale) { const std::string& locale) {
auto print_backend = PrintBackend::CreateInstance(nullptr, locale); auto print_backend = PrintBackend::CreateInstance(locale);
return GetSettingsOnBlockingTaskRunner( return GetSettingsOnBlockingTaskRunner(
device_name, basic_info, PrinterSemanticCapsAndDefaults::Papers(), device_name, basic_info, PrinterSemanticCapsAndDefaults::Papers(),
has_secure_protocol, print_backend); has_secure_protocol, print_backend);
......
...@@ -67,7 +67,7 @@ PrinterList LocalPrinterHandlerDefault::EnumeratePrintersAsync( ...@@ -67,7 +67,7 @@ PrinterList LocalPrinterHandlerDefault::EnumeratePrintersAsync(
#endif #endif
scoped_refptr<PrintBackend> print_backend( scoped_refptr<PrintBackend> print_backend(
PrintBackend::CreateInstance(nullptr, locale)); PrintBackend::CreateInstance(locale));
PrinterList printer_list; PrinterList printer_list;
print_backend->EnumeratePrinters(&printer_list); print_backend->EnumeratePrinters(&printer_list);
...@@ -91,7 +91,7 @@ base::Value LocalPrinterHandlerDefault::FetchCapabilitiesAsync( ...@@ -91,7 +91,7 @@ base::Value LocalPrinterHandlerDefault::FetchCapabilitiesAsync(
#endif #endif
scoped_refptr<PrintBackend> print_backend( scoped_refptr<PrintBackend> print_backend(
PrintBackend::CreateInstance(nullptr, locale)); PrintBackend::CreateInstance(locale));
VLOG(1) << "Get printer capabilities start for " << device_name; VLOG(1) << "Get printer capabilities start for " << device_name;
...@@ -116,7 +116,7 @@ std::string LocalPrinterHandlerDefault::GetDefaultPrinterAsync( ...@@ -116,7 +116,7 @@ std::string LocalPrinterHandlerDefault::GetDefaultPrinterAsync(
#endif #endif
scoped_refptr<PrintBackend> print_backend( scoped_refptr<PrintBackend> print_backend(
PrintBackend::CreateInstance(nullptr, locale)); PrintBackend::CreateInstance(locale));
std::string default_printer = print_backend->GetDefaultPrinterName(); std::string default_printer = print_backend->GetDefaultPrinterName();
VLOG(1) << "Default Printer: " << default_printer; VLOG(1) << "Default Printer: " << default_printer;
......
...@@ -64,8 +64,7 @@ class PrintSystemWatcherWin : public base::win::ObjectWatcher::Delegate { ...@@ -64,8 +64,7 @@ class PrintSystemWatcherWin : public base::win::ObjectWatcher::Delegate {
bool Start(const std::string& printer_name, Delegate* delegate) { bool Start(const std::string& printer_name, Delegate* delegate) {
scoped_refptr<printing::PrintBackend> print_backend( scoped_refptr<printing::PrintBackend> print_backend(
printing::PrintBackend::CreateInstance(nullptr, printing::PrintBackend::CreateInstance(/*locale=*/std::string()));
/*locale=*/std::string()));
printer_info_ = print_backend->GetPrinterDriverInfo(printer_name); printer_info_ = print_backend->GetPrinterDriverInfo(printer_name);
crash_keys::ScopedPrinterInfo crash_key(printer_info_); crash_keys::ScopedPrinterInfo crash_key(printer_info_);
...@@ -240,8 +239,7 @@ class JobSpoolerWin : public PrintSystem::JobSpooler { ...@@ -240,8 +239,7 @@ class JobSpoolerWin : public PrintSystem::JobSpooler {
JobSpooler::Delegate* delegate) override { JobSpooler::Delegate* delegate) override {
// TODO(gene): add tags handling. // TODO(gene): add tags handling.
scoped_refptr<printing::PrintBackend> print_backend( scoped_refptr<printing::PrintBackend> print_backend(
printing::PrintBackend::CreateInstance(nullptr, printing::PrintBackend::CreateInstance(/*locale=*/std::string()));
/*locale=*/std::string()));
crash_keys::ScopedPrinterInfo crash_key( crash_keys::ScopedPrinterInfo crash_key(
print_backend->GetPrinterDriverInfo(printer_name)); print_backend->GetPrinterDriverInfo(printer_name));
return core_->Spool(print_ticket, print_ticket_mime_type, return core_->Spool(print_ticket, print_ticket_mime_type,
...@@ -645,8 +643,7 @@ class PrintSystemWin : public PrintSystem { ...@@ -645,8 +643,7 @@ class PrintSystemWin : public PrintSystem {
PrintSystemWin::PrintSystemWin() PrintSystemWin::PrintSystemWin()
: print_backend_( : print_backend_(
printing::PrintBackend::CreateInstance(nullptr, printing::PrintBackend::CreateInstance(/*locale=*/std::string())) {}
/*locale=*/std::string())) {}
PrintSystem::PrintSystemResult PrintSystemWin::Init() { PrintSystem::PrintSystemResult PrintSystemWin::Init() {
return PrintSystemResult(true, std::string()); return PrintSystemResult(true, std::string());
......
...@@ -45,7 +45,7 @@ bool PrintingHandler::OnMessageReceived(const IPC::Message& message) { ...@@ -45,7 +45,7 @@ bool PrintingHandler::OnMessageReceived(const IPC::Message& message) {
void PrintingHandler::OnGetPrinterCapsAndDefaults( void PrintingHandler::OnGetPrinterCapsAndDefaults(
const std::string& printer_name) { const std::string& printer_name) {
scoped_refptr<PrintBackend> print_backend = scoped_refptr<PrintBackend> print_backend =
PrintBackend::CreateInstance(nullptr, /*locale=*/std::string()); PrintBackend::CreateInstance(/*locale=*/std::string());
PrinterCapsAndDefaults printer_info; PrinterCapsAndDefaults printer_info;
crash_keys::ScopedPrinterInfo crash_key( crash_keys::ScopedPrinterInfo crash_key(
...@@ -64,7 +64,7 @@ void PrintingHandler::OnGetPrinterCapsAndDefaults( ...@@ -64,7 +64,7 @@ void PrintingHandler::OnGetPrinterCapsAndDefaults(
void PrintingHandler::OnGetPrinterSemanticCapsAndDefaults( void PrintingHandler::OnGetPrinterSemanticCapsAndDefaults(
const std::string& printer_name) { const std::string& printer_name) {
scoped_refptr<PrintBackend> print_backend = scoped_refptr<PrintBackend> print_backend =
PrintBackend::CreateInstance(nullptr, /*locale=*/std::string()); PrintBackend::CreateInstance(/*locale=*/std::string());
PrinterSemanticCapsAndDefaults printer_info; PrinterSemanticCapsAndDefaults printer_info;
crash_keys::ScopedPrinterInfo crash_key( crash_keys::ScopedPrinterInfo crash_key(
......
...@@ -57,11 +57,11 @@ PrintBackend::~PrintBackend() = default; ...@@ -57,11 +57,11 @@ PrintBackend::~PrintBackend() = default;
// static // static
scoped_refptr<PrintBackend> PrintBackend::CreateInstance( scoped_refptr<PrintBackend> PrintBackend::CreateInstance(
const base::DictionaryValue* print_backend_settings,
const std::string& locale) { const std::string& locale) {
return g_print_backend_for_test return g_print_backend_for_test
? g_print_backend_for_test ? g_print_backend_for_test
: PrintBackend::CreateInstanceImpl(print_backend_settings, locale, : PrintBackend::CreateInstanceImpl(
/*print_backend_settings=*/nullptr, locale,
/*for_cloud_print=*/false); /*for_cloud_print=*/false);
} }
......
...@@ -179,11 +179,8 @@ class PRINTING_EXPORT PrintBackend ...@@ -179,11 +179,8 @@ class PRINTING_EXPORT PrintBackend
// Returns true if printer_name points to a valid printer. // Returns true if printer_name points to a valid printer.
virtual bool IsValidPrinter(const std::string& printer_name) = 0; virtual bool IsValidPrinter(const std::string& printer_name) = 0;
// Allocates a print backend. If |print_backend_settings| is nullptr, default // Allocates a print backend.
// settings will be used. static scoped_refptr<PrintBackend> CreateInstance(const std::string& locale);
static scoped_refptr<PrintBackend> CreateInstance(
const base::DictionaryValue* print_backend_settings,
const std::string& locale);
#if defined(USE_CUPS) #if defined(USE_CUPS)
// TODO(crbug.com/1062136): Remove this static function when Cloud Print is // TODO(crbug.com/1062136): Remove this static function when Cloud Print is
......
...@@ -77,7 +77,7 @@ PrintingContext::Result PrintingContextWin::UseDefaultSettings() { ...@@ -77,7 +77,7 @@ PrintingContext::Result PrintingContextWin::UseDefaultSettings() {
DCHECK(!in_print_job_); DCHECK(!in_print_job_);
scoped_refptr<PrintBackend> backend = scoped_refptr<PrintBackend> backend =
PrintBackend::CreateInstance(nullptr, delegate_->GetAppLocale()); PrintBackend::CreateInstance(delegate_->GetAppLocale());
base::string16 default_printer = base::string16 default_printer =
base::UTF8ToWide(backend->GetDefaultPrinterName()); base::UTF8ToWide(backend->GetDefaultPrinterName());
if (!default_printer.empty()) { if (!default_printer.empty()) {
......
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