| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "chromeos/dbus/debug_daemon_client.h" | 30 #include "chromeos/dbus/debug_daemon_client.h" |
| 31 #include "chromeos/printing/ppd_provider.h" | 31 #include "chromeos/printing/ppd_provider.h" |
| 32 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
| 33 #include "device/base/device_client.h" | 33 #include "device/base/device_client.h" |
| 34 #include "device/usb/usb_device.h" | 34 #include "device/usb/usb_device.h" |
| 35 #include "device/usb/usb_service.h" | 35 #include "device/usb/usb_service.h" |
| 36 | 36 |
| 37 namespace chromeos { | 37 namespace chromeos { |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 using printing::PpdProvider; | |
| 41 | |
| 42 // Aggregates the information needed for printer setup so it's easier to pass it | 40 // Aggregates the information needed for printer setup so it's easier to pass it |
| 43 // around. | 41 // around. |
| 44 struct SetUpPrinterData { | 42 struct SetUpPrinterData { |
| 45 // The configurer running the SetUpPrinter call. | 43 // The configurer running the SetUpPrinter call. |
| 46 std::unique_ptr<PrinterConfigurer> configurer; | 44 std::unique_ptr<PrinterConfigurer> configurer; |
| 47 | 45 |
| 48 // The printer being set up. | 46 // The printer being set up. |
| 49 std::unique_ptr<Printer> printer; | 47 std::unique_ptr<Printer> printer; |
| 50 | 48 |
| 51 // The usb device causing this setup flow. | 49 // The usb device causing this setup flow. |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 return; | 202 return; |
| 205 } | 203 } |
| 206 | 204 |
| 207 // It's not a device we have configured previously. | 205 // It's not a device we have configured previously. |
| 208 // | 206 // |
| 209 // TODO(justincarlson): Add a notification that we are attempting to set up | 207 // TODO(justincarlson): Add a notification that we are attempting to set up |
| 210 // this printer at this point. | 208 // this printer at this point. |
| 211 data->is_new = true; | 209 data->is_new = true; |
| 212 | 210 |
| 213 // Look for an exact match based on USB ids. | 211 // Look for an exact match based on USB ids. |
| 214 scoped_refptr<PpdProvider> ppd_provider = | 212 scoped_refptr<PpdProvider> ppd_provider = CreatePpdProvider(profile_); |
| 215 printing::CreateProvider(profile_); | |
| 216 ppd_provider->ResolveUsbIds( | 213 ppd_provider->ResolveUsbIds( |
| 217 device->vendor_id(), device->product_id(), | 214 device->vendor_id(), device->product_id(), |
| 218 base::Bind(&UsbPrinterDetectorImpl::ResolveUsbIdsDone, | 215 base::Bind(&UsbPrinterDetectorImpl::ResolveUsbIdsDone, |
| 219 weak_ptr_factory_.GetWeakPtr(), ppd_provider, | 216 weak_ptr_factory_.GetWeakPtr(), ppd_provider, |
| 220 base::Passed(std::move(data)))); | 217 base::Passed(std::move(data)))); |
| 221 } | 218 } |
| 222 | 219 |
| 223 void OnPrinterResolved(std::unique_ptr<SetUpPrinterData> data) { | 220 void OnPrinterResolved(std::unique_ptr<SetUpPrinterData> data) { |
| 224 // |data| will be invalidated by the move below, so we have to latch it | 221 // |data| will be invalidated by the move below, so we have to latch it |
| 225 // before the call. | 222 // before the call. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 | 312 |
| 316 } // namespace | 313 } // namespace |
| 317 | 314 |
| 318 // static | 315 // static |
| 319 std::unique_ptr<UsbPrinterDetector> UsbPrinterDetector::Create( | 316 std::unique_ptr<UsbPrinterDetector> UsbPrinterDetector::Create( |
| 320 Profile* profile) { | 317 Profile* profile) { |
| 321 return base::MakeUnique<UsbPrinterDetectorImpl>(profile); | 318 return base::MakeUnique<UsbPrinterDetectorImpl>(profile); |
| 322 } | 319 } |
| 323 | 320 |
| 324 } // namespace chromeos | 321 } // namespace chromeos |
| OLD | NEW |