diff options
author | vitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-29 17:39:47 +0000 |
---|---|---|
committer | vitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-29 17:39:47 +0000 |
commit | 6df7b5a2ccf86cc7134baa1e070d14bc7623d64c (patch) | |
tree | db41a1171c2e33afb5fa3cc798fa5369ebb2954c /chrome | |
parent | 13582f6b5aa6043c1d099ab78b86fe226939f967 (diff) | |
download | chromium_src-6df7b5a2ccf86cc7134baa1e070d14bc7623d64c.zip chromium_src-6df7b5a2ccf86cc7134baa1e070d14bc7623d64c.tar.gz chromium_src-6df7b5a2ccf86cc7134baa1e070d14bc7623d64c.tar.bz2 |
Pass location and description of local printers into print preview.
OSX already uses description as display name for printers, so pass printer model instead.
BUG=256223
NOTRY=true
Review URL: https://codereview.chromium.org/214443007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260383 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/resources/print_preview/data/local_parsers.js | 18 | ||||
-rw-r--r-- | chrome/browser/ui/webui/print_preview/print_preview_handler.cc | 22 |
2 files changed, 33 insertions, 7 deletions
diff --git a/chrome/browser/resources/print_preview/data/local_parsers.js b/chrome/browser/resources/print_preview/data/local_parsers.js index 91d5208..22cfded 100644 --- a/chrome/browser/resources/print_preview/data/local_parsers.js +++ b/chrome/browser/resources/print_preview/data/local_parsers.js @@ -15,13 +15,21 @@ cr.define('print_preview', function() { * @return {!print_preview.Destination} Parsed local print destination. */ LocalDestinationParser.parse = function(destinationInfo) { + var options = {'description': destinationInfo.printerDescription}; + if (destinationInfo.printerOptions) { + // Convert options into cloud print tags format. + options.tags = Object.keys(destinationInfo.printerOptions).map( + function(key) {return '__cp__' + key + '=' + this[key];}, + destinationInfo.printerOptions); + } return new print_preview.Destination( destinationInfo.deviceName, print_preview.Destination.Type.LOCAL, print_preview.Destination.Origin.LOCAL, destinationInfo.printerName, false /*isRecent*/, - print_preview.Destination.ConnectionStatus.ONLINE); + print_preview.Destination.ConnectionStatus.ONLINE, + options); }; /** Namespace that contains a method to parse local print capabilities. */ @@ -37,7 +45,7 @@ cr.define('print_preview', function() { var cdd = { version: '1.0', printer: { - collate: {default: true} + collate: {'default': true} } }; @@ -53,11 +61,11 @@ cr.define('print_preview', function() { is_default: !settingsInfo['setColorAsDefault'] } ] - } + }; } if (!settingsInfo['disableCopiesOption']) { - cdd.printer.copies = {default: 1}; + cdd.printer.copies = {'default': 1}; } if (settingsInfo['printerDefaultDuplexValue'] != @@ -105,7 +113,7 @@ cr.define('print_preview', function() { if (destinationInfo.isUnregistered) { returnedPrinters.push(new print_preview.Destination( - destinationInfo.serviceName, + destinationInfo.serviceName, print_preview.Destination.Type.GOOGLE, print_preview.Destination.Origin.PRIVET, destinationInfo.name, diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc index e087e91..4ee6c2f 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc @@ -62,6 +62,7 @@ #include "content/public/browser/web_ui.h" #include "google_apis/gaia/oauth2_token_service.h" #include "printing/backend/print_backend.h" +#include "printing/backend/print_backend_consts.h" #include "printing/metafile.h" #include "printing/metafile_impl.h" #include "printing/pdf_render_settings.h" @@ -286,19 +287,36 @@ void EnumeratePrintersOnFileThread( for (printing::PrinterList::iterator it = printer_list.begin(); it != printer_list.end(); ++it) { base::DictionaryValue* printer_info = new base::DictionaryValue; + printers->Append(printer_info); std::string printer_name; + std::string printer_description; #if defined(OS_MACOSX) // On Mac, |it->printer_description| specifies the printer name and // |it->printer_name| specifies the device name / printer queue name. printer_name = it->printer_description; + if (!it->options[kDriverNameTagName].empty()) + printer_description = it->options[kDriverNameTagName]; #else printer_name = it->printer_name; + printer_description = it->printer_description; #endif - printer_info->SetString(printing::kSettingPrinterName, printer_name); printer_info->SetString(printing::kSettingDeviceName, it->printer_name); + printer_info->SetString(printing::kSettingPrinterDescription, + printer_description); + printer_info->SetString(printing::kSettingPrinterName, printer_name); VLOG(1) << "Found printer " << printer_name << " with device name " << it->printer_name; - printers->Append(printer_info); + + base::DictionaryValue* options = new base::DictionaryValue; + printer_info->Set(printing::kSettingPrinterOptions, options); + for (std::map<std::string, std::string>::iterator opt = it->options.begin(); + opt != it->options.end(); + ++opt) { + options->SetString(opt->first, opt->second); + } + + VLOG(1) << "Found printer " << printer_name << " with device name " + << it->printer_name; } VLOG(1) << "Enumerate printers finished, found " << printers->GetSize() << " printers"; |