| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/printer_backend_proxy.h" | 5 #include "chrome/browser/ui/webui/print_preview/printer_backend_proxy.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 89 } |
| 90 | 90 |
| 91 void OnPrinterAddError(const PrinterSetupCallback& cb) { | 91 void OnPrinterAddError(const PrinterSetupCallback& cb) { |
| 92 // It's expected that debug daemon posts callbacks on the UI thread. | 92 // It's expected that debug daemon posts callbacks on the UI thread. |
| 93 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 93 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 94 | 94 |
| 95 LOG(WARNING) << "Could not contact debugd"; | 95 LOG(WARNING) << "Could not contact debugd"; |
| 96 PostCallbackError(cb); | 96 PostCallbackError(cb); |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool IsIppEverywhere(const chromeos::Printer& printer) { | |
| 100 // TODO(skau): Use uri, effective_make and effective_model to determine if | |
| 101 // we should do an IPP Everywhere configuration. | |
| 102 return false; | |
| 103 } | |
| 104 | |
| 105 std::string GetPPDPath(const chromeos::Printer& printer) { | 99 std::string GetPPDPath(const chromeos::Printer& printer) { |
| 106 // TODO(skau): Consult the PPD Provider for the correct file path. | 100 // TODO(skau): Consult the PPD Provider for the correct file path. |
| 107 return printer.ppd_reference().user_supplied_ppd_url; | 101 return printer.ppd_reference().user_supplied_ppd_url; |
| 108 } | 102 } |
| 109 | 103 |
| 110 } // namespace | 104 } // namespace |
| 111 | 105 |
| 112 std::string GetDefaultPrinterOnBlockingPoolThread() { | 106 std::string GetDefaultPrinterOnBlockingPoolThread() { |
| 113 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | 107 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| 114 // TODO(crbug.com/660898): Add default printers to ChromeOS. | 108 // TODO(crbug.com/660898): Add default printers to ChromeOS. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 139 void ConfigurePrinterAndFetchCapabilities(Profile* profile, | 133 void ConfigurePrinterAndFetchCapabilities(Profile* profile, |
| 140 const std::string& printer_name, | 134 const std::string& printer_name, |
| 141 const PrinterSetupCallback& cb) { | 135 const PrinterSetupCallback& cb) { |
| 142 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 136 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 143 | 137 |
| 144 chromeos::PrinterPrefManager* prefs = | 138 chromeos::PrinterPrefManager* prefs = |
| 145 chromeos::PrinterPrefManagerFactory::GetForBrowserContext(profile); | 139 chromeos::PrinterPrefManagerFactory::GetForBrowserContext(profile); |
| 146 std::unique_ptr<chromeos::Printer> printer = prefs->GetPrinter(printer_name); | 140 std::unique_ptr<chromeos::Printer> printer = prefs->GetPrinter(printer_name); |
| 147 | 141 |
| 148 // Check if configuration is viable. | 142 // Check if configuration is viable. |
| 149 bool ipp_everywhere = IsIppEverywhere(*printer); | 143 bool ipp_everywhere = printer->IsIppEverywhere(); |
| 150 std::string ppd_path = GetPPDPath(*printer); | 144 std::string ppd_path = GetPPDPath(*printer); |
| 151 if (!ipp_everywhere && ppd_path.empty()) { | 145 if (!ipp_everywhere && ppd_path.empty()) { |
| 152 HandlePrinterSetup(std::move(printer), PPD_NOT_FOUND, cb); | 146 HandlePrinterSetup(std::move(printer), PPD_NOT_FOUND, cb); |
| 153 return; | 147 return; |
| 154 } | 148 } |
| 155 | 149 |
| 156 // Always push configuration to CUPS. It may need an update. | 150 // Always push configuration to CUPS. It may need an update. |
| 157 std::string printer_uri = printer->uri(); | 151 std::string printer_uri = printer->uri(); |
| 158 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient()->CupsAddPrinter( | 152 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient()->CupsAddPrinter( |
| 159 printer_name, printer_uri, ppd_path, ipp_everywhere, | 153 printer_name, printer_uri, ppd_path, ipp_everywhere, |
| 160 base::Bind(&OnPrinterAddResult, base::Passed(&printer), cb), | 154 base::Bind(&OnPrinterAddResult, base::Passed(&printer), cb), |
| 161 base::Bind(&OnPrinterAddError, cb)); | 155 base::Bind(&OnPrinterAddError, cb)); |
| 162 } | 156 } |
| 163 | 157 |
| 164 } // namespace printing | 158 } // namespace printing |
| OLD | NEW |