| 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_discoverer.h" | 5 #include "chrome/browser/chromeos/printing/printer_discoverer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // object. | 68 // object. |
| 69 void WrappedOnPrintersFound(PrinterDiscoverer::Observer* observer, | 69 void WrappedOnPrintersFound(PrinterDiscoverer::Observer* observer, |
| 70 const std::vector<Printer>& printers) { | 70 const std::vector<Printer>& printers) { |
| 71 if (observer_list_.HasObserver(observer)) { | 71 if (observer_list_.HasObserver(observer)) { |
| 72 observer->OnPrintersFound(printers); | 72 observer->OnPrintersFound(printers); |
| 73 // Since USB is the only thing we're worried about at the moment, and we | 73 // Since USB is the only thing we're worried about at the moment, and we |
| 74 // don't have to wait for those printers to be scanned, we can just tell | 74 // don't have to wait for those printers to be scanned, we can just tell |
| 75 // the observer the initial scan is done now. This will change when we're | 75 // the observer the initial scan is done now. This will change when we're |
| 76 // also doing network discovery -- we'll hold off on issuing this callback | 76 // also doing network discovery -- we'll hold off on issuing this callback |
| 77 // until the network discovery is done as well. | 77 // until the network discovery is done as well. |
| 78 observer->OnDiscoveryInitialScanDone(); | 78 observer->OnDiscoveryInitialScanDone(printers.size()); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 // Get the current set of discovered printers that are not already known | 82 // Get the current set of discovered printers that are not already known |
| 83 // to the user's PrintersManager. | 83 // to the user's PrintersManager. |
| 84 std::vector<Printer> GetAvailablePrinters() { | 84 std::vector<Printer> GetAvailablePrinters() { |
| 85 // Only know about usb printers for now. Eventually we'll add discovered | 85 // Only know about usb printers for now. Eventually we'll add discovered |
| 86 // network printers as well. | 86 // network printers as well. |
| 87 std::vector<Printer> ret; | 87 std::vector<Printer> ret; |
| 88 PrintersManager* printers_manager = | 88 PrintersManager* printers_manager = |
| (...skipping 21 matching lines...) Expand all Loading... |
| 110 | 110 |
| 111 } // namespace | 111 } // namespace |
| 112 | 112 |
| 113 // static | 113 // static |
| 114 std::unique_ptr<PrinterDiscoverer> PrinterDiscoverer::CreateForProfile( | 114 std::unique_ptr<PrinterDiscoverer> PrinterDiscoverer::CreateForProfile( |
| 115 Profile* profile) { | 115 Profile* profile) { |
| 116 return base::MakeUnique<PrinterDiscovererImpl>(profile); | 116 return base::MakeUnique<PrinterDiscovererImpl>(profile); |
| 117 } | 117 } |
| 118 | 118 |
| 119 } // namespace chromeos | 119 } // namespace chromeos |
| OLD | NEW |