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

Unified Diff: chrome/browser/ui/webui/print_preview/printer_backend_proxy_chromeos.cc

Issue 2463473002: Present the printer list from preferences for Chrome OS. (Closed)
Patch Set: done 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/print_preview/printer_backend_proxy.cc ('k') | printing/backend/print_backend.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/print_preview/printer_backend_proxy_chromeos.cc
diff --git a/chrome/browser/ui/webui/print_preview/printer_backend_proxy_chromeos.cc b/chrome/browser/ui/webui/print_preview/printer_backend_proxy_chromeos.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b2e98d3216862d977f0118b77bf8fc835ab9fd8f
--- /dev/null
+++ b/chrome/browser/ui/webui/print_preview/printer_backend_proxy_chromeos.cc
@@ -0,0 +1,69 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/print_preview/printer_backend_proxy.h"
+
+#include <memory>
+#include <vector>
+
+#include "base/command_line.h"
+#include "base/values.h"
+#include "chrome/browser/chromeos/printing/printer_pref_manager.h"
+#include "chrome/browser/chromeos/printing/printer_pref_manager_factory.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/chrome_switches.h"
+#include "chromeos/printing/printer_configuration.h"
+#include "content/public/browser/browser_thread.h"
+#include "printing/backend/print_backend.h"
+#include "printing/backend/print_backend_consts.h"
+
+namespace printing {
+
+namespace {
+
+// Store the name used in CUPS, Printer#id in |printer_name|, the description
+// as the system_driverinfo option value, and the Printer#display_name in
+// the |printer_description| field. This will match how Mac OS X presents
+// printer information.
+printing::PrinterBasicInfo ToBasicInfo(const chromeos::Printer& printer) {
+ PrinterBasicInfo basic_info;
+
+ // TODO(skau): Unify Mac with the other platforms for display name
+ // presentation so I can remove this strange code.
+ basic_info.options[kDriverInfoTagName] = printer.description();
+ basic_info.printer_name = printer.id();
+ basic_info.printer_description = printer.display_name();
+ return basic_info;
+}
+
+} // namespace
+
+std::string GetDefaultPrinterOnBlockingPoolThread() {
+ DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
+ // TODO(crbug.com/660898): Add default printers to ChromeOS.
+ return "";
+}
+
+void EnumeratePrinters(Profile* profile, const EnumeratePrintersCallback& cb) {
+ // PrinterPrefManager is not thread safe and must be called from the UI
+ // thread.
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ PrinterList printer_list;
+
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableNativeCups)) {
+ chromeos::PrinterPrefManager* prefs =
+ chromeos::PrinterPrefManagerFactory::GetForBrowserContext(profile);
+ std::vector<std::unique_ptr<chromeos::Printer>> printers =
+ prefs->GetPrinters();
+ for (const std::unique_ptr<chromeos::Printer>& printer : printers) {
+ printer_list.push_back(ToBasicInfo(*printer));
+ }
+ }
+
+ cb.Run(printer_list);
+}
+
+} // namespace printing
« no previous file with comments | « chrome/browser/ui/webui/print_preview/printer_backend_proxy.cc ('k') | printing/backend/print_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698