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

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: add bug id 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..6869dfcaf202f399691dfcc0cf49a10162d7fa0e
--- /dev/null
+++ b/chrome/browser/ui/webui/print_preview/printer_backend_proxy_chromeos.cc
@@ -0,0 +1,59 @@
+// 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"
+
+namespace printing {
+
+namespace {
+
+printing::PrinterBasicInfo ToBasicInfo(const chromeos::Printer& printer) {
+ PrinterBasicInfo basic_info;
+ basic_info.printer_display_name = printer.display_name();
+ basic_info.printer_name = printer.id();
+ basic_info.printer_description = printer.description();
+ 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