Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Side by Side Diff: chrome/browser/ui/webui/print_preview/print_preview_handler.cc

Issue 2459943002: Use printer id to populate CUPS instead of printer name. (Closed)
Patch Set: proof Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/ui/webui/print_preview/print_preview_handler.h" 5 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 const printing::PrinterBasicInfo& printer) { 376 const printing::PrinterBasicInfo& printer) {
377 #if defined(OS_MACOSX) 377 #if defined(OS_MACOSX)
378 // On Mac, |printer.printer_description| specifies the printer name and 378 // On Mac, |printer.printer_description| specifies the printer name and
379 // |printer.printer_name| specifies the device name / printer queue name. 379 // |printer.printer_name| specifies the device name / printer queue name.
380 const std::string& real_name = printer.printer_description; 380 const std::string& real_name = printer.printer_description;
381 std::string real_description; 381 std::string real_description;
382 const auto it = printer.options.find(kDriverNameTagName); 382 const auto it = printer.options.find(kDriverNameTagName);
383 if (it != printer.options.end()) 383 if (it != printer.options.end())
384 real_description = it->second; 384 real_description = it->second;
385 return std::make_pair(real_name, real_description); 385 return std::make_pair(real_name, real_description);
386 #elif defined(OS_CHROMEOS)
387 // Display the display name. printer.printer_name contains the name
388 // registered in CUPS which is not human readable.
389 return std::make_pair(printer.printer_display_name,
xdai1 2016/10/31 18:08:15 Where does printer_display_name come from? Seems t
skau 2016/11/02 22:08:35 printer_display_name is defined in the dependent p
390 printer.printer_description);
386 #else 391 #else
387 return std::make_pair(printer.printer_name, printer.printer_description); 392 return std::make_pair(printer.printer_name, printer.printer_description);
388 #endif 393 #endif
389 } 394 }
390 395
391 void PrintersToValues(const printing::PrinterList& printer_list, 396 void PrintersToValues(const printing::PrinterList& printer_list,
392 base::ListValue* printers) { 397 base::ListValue* printers) {
393 for (const printing::PrinterBasicInfo& printer : printer_list) { 398 for (const printing::PrinterBasicInfo& printer : printer_list) {
394 std::unique_ptr<base::DictionaryValue> printer_info( 399 std::unique_ptr<base::DictionaryValue> printer_info =
395 new base::DictionaryValue); 400 base::MakeUnique<base::DictionaryValue>();
401 printer_info->SetString(printing::kSettingDeviceName, printer.printer_name);
402
396 const auto printer_name_description = GetPrinterNameAndDescription(printer); 403 const auto printer_name_description = GetPrinterNameAndDescription(printer);
397 const std::string& printer_name = printer_name_description.first; 404 const std::string& printer_name = printer_name_description.first;
398 const std::string& printer_description = printer_name_description.second; 405 const std::string& printer_description = printer_name_description.second;
399 printer_info->SetString(printing::kSettingDeviceName, printer.printer_name);
400 printer_info->SetString(printing::kSettingPrinterName, printer_name); 406 printer_info->SetString(printing::kSettingPrinterName, printer_name);
401 printer_info->SetString(printing::kSettingPrinterDescription, 407 printer_info->SetString(printing::kSettingPrinterDescription,
402 printer_description); 408 printer_description);
403 409
404 base::DictionaryValue* options = new base::DictionaryValue; 410 auto options = base::MakeUnique<base::DictionaryValue>();
405 printer_info->Set(printing::kSettingPrinterOptions, options); 411 printer_info->Set(printing::kSettingPrinterOptions, std::move(options));
406 for (const auto opt_it : printer.options) 412 for (const auto opt_it : printer.options)
407 options->SetString(opt_it.first, opt_it.second); 413 options->SetString(opt_it.first, opt_it.second);
408 414
409 printers->Append(std::move(printer_info)); 415 printers->Append(std::move(printer_info));
410 416
411 VLOG(1) << "Found printer " << printer_name << " with device name " 417 VLOG(1) << "Found printer " << printer_name << " with device name "
412 << printer.printer_name; 418 << printer.printer_name;
413 } 419 }
414 } 420 }
415 421
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 1762
1757 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { 1763 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() {
1758 if (gaia_cookie_manager_service_) 1764 if (gaia_cookie_manager_service_)
1759 gaia_cookie_manager_service_->RemoveObserver(this); 1765 gaia_cookie_manager_service_->RemoveObserver(this);
1760 } 1766 }
1761 1767
1762 void PrintPreviewHandler::SetPdfSavedClosureForTesting( 1768 void PrintPreviewHandler::SetPdfSavedClosureForTesting(
1763 const base::Closure& closure) { 1769 const base::Closure& closure) {
1764 pdf_file_saved_closure_ = closure; 1770 pdf_file_saved_closure_ = closure;
1765 } 1771 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698