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