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

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

Issue 1934013002: Enable the cups backend when --enable-native-cups is specified. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cupsFlag
Patch Set: Unbreak other platforms Created 4 years, 5 months 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
« no previous file with comments | « no previous file | printing/BUILD.gn » ('j') | printing/backend/print_backend.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 printing_context->settings().device_units_per_inch(); 337 printing_context->settings().device_units_per_inch();
338 return gfx::Size(pdf_media_size.width() * deviceMicronsPerDeviceUnit, 338 return gfx::Size(pdf_media_size.width() * deviceMicronsPerDeviceUnit,
339 pdf_media_size.height() * deviceMicronsPerDeviceUnit); 339 pdf_media_size.height() * deviceMicronsPerDeviceUnit);
340 } 340 }
341 341
342 std::unique_ptr<base::DictionaryValue> GetPdfCapabilities( 342 std::unique_ptr<base::DictionaryValue> GetPdfCapabilities(
343 const std::string& locale) { 343 const std::string& locale) {
344 DCHECK_CURRENTLY_ON(BrowserThread::UI); 344 DCHECK_CURRENTLY_ON(BrowserThread::UI);
345 345
346 cloud_devices::CloudDeviceDescription description; 346 cloud_devices::CloudDeviceDescription description;
347 using namespace cloud_devices::printer; 347
348 using cloud_devices::printer::OrientationCapability;
349 using cloud_devices::printer::PORTRAIT;
350 using cloud_devices::printer::LANDSCAPE;
351 using cloud_devices::printer::AUTO_ORIENTATION;
348 352
349 OrientationCapability orientation; 353 OrientationCapability orientation;
350 orientation.AddOption(cloud_devices::printer::PORTRAIT); 354 orientation.AddOption(PORTRAIT);
351 orientation.AddOption(cloud_devices::printer::LANDSCAPE); 355 orientation.AddOption(LANDSCAPE);
352 orientation.AddDefaultOption(AUTO_ORIENTATION, true); 356 orientation.AddDefaultOption(AUTO_ORIENTATION, true);
353 orientation.SaveTo(&description); 357 orientation.SaveTo(&description);
354 358
359 using cloud_devices::printer::ColorCapability;
360 using cloud_devices::printer::Color;
361 using cloud_devices::printer::STANDARD_COLOR;
362
355 ColorCapability color; 363 ColorCapability color;
356 { 364 {
357 Color standard_color(STANDARD_COLOR); 365 Color standard_color(STANDARD_COLOR);
358 standard_color.vendor_id = base::IntToString(printing::COLOR); 366 standard_color.vendor_id = base::IntToString(printing::COLOR);
359 color.AddDefaultOption(standard_color, true); 367 color.AddDefaultOption(standard_color, true);
360 } 368 }
361 color.SaveTo(&description); 369 color.SaveTo(&description);
362 370
363 static const cloud_devices::printer::MediaType kPdfMedia[] = { 371 using cloud_devices::printer::MediaType;
364 ISO_A0, 372 using cloud_devices::printer::ISO_A0;
365 ISO_A1, 373 using cloud_devices::printer::ISO_A1;
366 ISO_A2, 374 using cloud_devices::printer::ISO_A2;
367 ISO_A3, 375 using cloud_devices::printer::ISO_A3;
368 ISO_A4, 376 using cloud_devices::printer::ISO_A4;
369 ISO_A5, 377 using cloud_devices::printer::ISO_A5;
370 NA_LEGAL, 378 using cloud_devices::printer::NA_LEGAL;
371 NA_LETTER, 379 using cloud_devices::printer::NA_LETTER;
372 NA_LEDGER 380 using cloud_devices::printer::NA_LEDGER;
373 }; 381
382 static const MediaType kPdfMedia[] = {ISO_A0, ISO_A1, ISO_A2,
383 ISO_A3, ISO_A4, ISO_A5,
384 NA_LEGAL, NA_LETTER, NA_LEDGER};
385
374 const gfx::Size default_media_size = GetDefaultPdfMediaSizeMicrons(); 386 const gfx::Size default_media_size = GetDefaultPdfMediaSizeMicrons();
387
388 using cloud_devices::printer::Media;
389 using cloud_devices::printer::MediaCapability;
390
375 Media default_media( 391 Media default_media(
376 "", "", default_media_size.width(), default_media_size.height()); 392 "", "", default_media_size.width(), default_media_size.height());
377 if (!default_media.MatchBySize() || 393 if (!default_media.MatchBySize() ||
378 std::find(kPdfMedia, 394 std::find(kPdfMedia,
379 kPdfMedia + arraysize(kPdfMedia), 395 kPdfMedia + arraysize(kPdfMedia),
380 default_media.type) == kPdfMedia + arraysize(kPdfMedia)) { 396 default_media.type) == kPdfMedia + arraysize(kPdfMedia)) {
381 default_media = Media(locale == "en-US" ? NA_LETTER : ISO_A4); 397 default_media = Media(locale == "en-US" ? NA_LETTER : ISO_A4);
382 } 398 }
383 MediaCapability media; 399 MediaCapability media;
384 for (size_t i = 0; i < arraysize(kPdfMedia); ++i) { 400 for (size_t i = 0; i < arraysize(kPdfMedia); ++i) {
(...skipping 18 matching lines...) Expand all
403 real_description = it->second; 419 real_description = it->second;
404 return std::make_pair(real_name, real_description); 420 return std::make_pair(real_name, real_description);
405 #else 421 #else
406 return std::make_pair(printer.printer_name, printer.printer_description); 422 return std::make_pair(printer.printer_name, printer.printer_description);
407 #endif 423 #endif
408 } 424 }
409 425
410 void EnumeratePrintersOnBlockingPoolThread(base::ListValue* printers) { 426 void EnumeratePrintersOnBlockingPoolThread(base::ListValue* printers) {
411 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); 427 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
412 428
429 #if defined(OS_CHROMEOS)
430 printing::PrintBackend::SetNativeCupsEnabled(
Lei Zhang 2016/06/28 22:27:35 We probably don't need to set the same value every
skau 2016/06/28 23:58:19 I've moved it to ChromeBrowserMainChromeos since t
431 base::CommandLine::ForCurrentProcess()->HasSwitch(
432 switches::kEnableNativeCups));
433 #endif // defined(OS_CHROMEOS)
434
413 scoped_refptr<printing::PrintBackend> print_backend( 435 scoped_refptr<printing::PrintBackend> print_backend(
414 printing::PrintBackend::CreateInstance(nullptr)); 436 printing::PrintBackend::CreateInstance(nullptr));
415 437
416 VLOG(1) << "Enumerate printers start"; 438 VLOG(1) << "Enumerate printers start";
417 printing::PrinterList printer_list; 439 printing::PrinterList printer_list;
418 print_backend->EnumeratePrinters(&printer_list); 440 print_backend->EnumeratePrinters(&printer_list);
419 441
420 for (const printing::PrinterBasicInfo& printer : printer_list) { 442 for (const printing::PrinterBasicInfo& printer : printer_list) {
421 std::unique_ptr<base::DictionaryValue> printer_info( 443 std::unique_ptr<base::DictionaryValue> printer_info(
422 new base::DictionaryValue); 444 new base::DictionaryValue);
(...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 1816
1795 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { 1817 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() {
1796 if (gaia_cookie_manager_service_) 1818 if (gaia_cookie_manager_service_)
1797 gaia_cookie_manager_service_->RemoveObserver(this); 1819 gaia_cookie_manager_service_->RemoveObserver(this);
1798 } 1820 }
1799 1821
1800 void PrintPreviewHandler::SetPdfSavedClosureForTesting( 1822 void PrintPreviewHandler::SetPdfSavedClosureForTesting(
1801 const base::Closure& closure) { 1823 const base::Closure& closure) {
1802 pdf_file_saved_closure_ = closure; 1824 pdf_file_saved_closure_ = closure;
1803 } 1825 }
OLDNEW
« no previous file with comments | « no previous file | printing/BUILD.gn » ('j') | printing/backend/print_backend.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698