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

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: present display name as mac does 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
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..0fd483030dc8bafd48c86d9d12e01d4e7d505ad2
--- /dev/null
+++ b/chrome/browser/ui/webui/print_preview/printer_backend_proxy_chromeos.cc
@@ -0,0 +1,67 @@
+// 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
Lei Zhang 2016/11/03 22:12:29 |printer_name|
skau 2016/11/03 22:30:08 Done.
+// as the system_driverinfo option value, and the Printer#display_name in
+// the description field. This will match how 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 "";
+}
+
+PrinterList EnumeratePrintersOnBlockingPoolThread(Profile* profile) {
+ DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
+
+ 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));
+ }
+ }
+
+ return printer_list;
+}
+
+} // namespace printing

Powered by Google App Engine
This is Rietveld 408576698