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

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

Issue 2463473002: Present the printer list from preferences for Chrome OS. (Closed)
Patch Set: tidy Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/print_preview/printer_backend_proxy.cc
diff --git a/chrome/browser/ui/webui/print_preview/printer_backend_proxy.cc b/chrome/browser/ui/webui/print_preview/printer_backend_proxy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9f42b5cfbb7c737a7958d7c6887b35796c1b8ebf
--- /dev/null
+++ b/chrome/browser/ui/webui/print_preview/printer_backend_proxy.cc
@@ -0,0 +1,39 @@
+// 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 <string>
+
+#include "base/logging.h"
+#include "base/memory/ref_counted.h"
+#include "content/public/browser/browser_thread.h"
+#include "printing/backend/print_backend.h"
+
+namespace printing {
+
+std::string GetDefaultPrinterOnBlockingPoolThread() {
+ DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
+
+ scoped_refptr<printing::PrintBackend> print_backend(
+ printing::PrintBackend::CreateInstance(nullptr));
Lei Zhang 2016/10/28 21:55:51 nit: you can omit printing:: in namespace printing
skau 2016/11/02 22:00:03 Done.
+
+ std::string default_printer = print_backend->GetDefaultPrinterName();
+ VLOG(1) << "Default Printer: " << default_printer;
+ return default_printer;
+}
+
+PrinterList EnumeratePrintersOnBlockingPoolThread(Profile* /* profile */) {
+ DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
+ PrinterList printer_list;
+
+ scoped_refptr<printing::PrintBackend> print_backend(
+ printing::PrintBackend::CreateInstance(nullptr));
+
+ print_backend->EnumeratePrinters(&printer_list);
+
+ return printer_list;
+}
+
+} // namespace printing

Powered by Google App Engine
This is Rietveld 408576698