OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/chromeos/printing/printer_configurer.h" | 5 #include "chrome/browser/chromeos/printing/printer_configurer.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 weak_factory_.GetWeakPtr(), callback)); | 60 weak_factory_.GetWeakPtr(), callback)); |
61 } | 61 } |
62 | 62 |
63 private: | 63 private: |
64 void OnAddedPrinter(const Printer& printer, | 64 void OnAddedPrinter(const Printer& printer, |
65 const PrinterSetupCallback& cb, | 65 const PrinterSetupCallback& cb, |
66 int32_t result_code) { | 66 int32_t result_code) { |
67 // It's expected that debug daemon posts callbacks on the UI thread. | 67 // It's expected that debug daemon posts callbacks on the UI thread. |
68 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 68 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
69 | 69 |
70 SetupResult result = UNKNOWN; | 70 PrinterSetupResult result = UNKNOWN; |
71 switch (result_code) { | 71 switch (result_code) { |
72 case 0: | 72 case 0: |
73 result = SUCCESS; | 73 result = SUCCESS; |
74 break; | 74 break; |
75 default: | 75 default: |
76 // TODO(skau): Fill out with more granular errors. | 76 // TODO(skau): Fill out with more granular errors. |
77 result = FATAL_ERROR; | 77 result = FATAL_ERROR; |
78 break; | 78 break; |
79 } | 79 } |
80 | 80 |
81 cb.Run(result); | 81 cb.Run(result); |
82 } | 82 } |
83 | 83 |
84 void OnDbusError(const PrinterSetupCallback& cb) { | 84 void OnDbusError(const PrinterSetupCallback& cb) { |
85 // The callback is expected to run on the UI thread. | 85 // The callback is expected to run on the UI thread. |
86 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 86 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
87 LOG(WARNING) << "Could not contact debugd"; | 87 LOG(WARNING) << "Could not contact debugd"; |
88 cb.Run(SetupResult::DBUS_ERROR); | 88 cb.Run(PrinterSetupResult::DBUS_ERROR); |
89 } | 89 } |
90 | 90 |
91 void AddPrinter(const Printer& printer, | 91 void AddPrinter(const Printer& printer, |
92 const std::string& ppd_contents, | 92 const std::string& ppd_contents, |
93 const PrinterSetupCallback& cb) { | 93 const PrinterSetupCallback& cb) { |
94 auto* client = chromeos::DBusThreadManager::Get()->GetDebugDaemonClient(); | 94 auto* client = chromeos::DBusThreadManager::Get()->GetDebugDaemonClient(); |
95 | 95 |
96 client->CupsAddManuallyConfiguredPrinter( | 96 client->CupsAddManuallyConfiguredPrinter( |
97 printer.id(), printer.uri(), ppd_contents, | 97 printer.id(), printer.uri(), ppd_contents, |
98 base::Bind(&PrinterConfigurerImpl::OnAddedPrinter, | 98 base::Bind(&PrinterConfigurerImpl::OnAddedPrinter, |
(...skipping 29 matching lines...) Expand all Loading... |
128 }; | 128 }; |
129 | 129 |
130 } // namespace | 130 } // namespace |
131 | 131 |
132 // static | 132 // static |
133 std::unique_ptr<PrinterConfigurer> PrinterConfigurer::Create(Profile* profile) { | 133 std::unique_ptr<PrinterConfigurer> PrinterConfigurer::Create(Profile* profile) { |
134 return base::MakeUnique<PrinterConfigurerImpl>(profile); | 134 return base::MakeUnique<PrinterConfigurerImpl>(profile); |
135 } | 135 } |
136 | 136 |
137 } // namespace chromeos | 137 } // namespace chromeos |
OLD | NEW |