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/settings/chromeos/cups_printers_handler.h" | 5 #include "chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
12 #include "base/json/json_string_value_serializer.h" | 12 #include "base/json/json_string_value_serializer.h" |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/metrics/histogram_macros.h" | |
14 #include "base/path_service.h" | 15 #include "base/path_service.h" |
15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
16 #include "base/threading/sequenced_task_runner_handle.h" | 17 #include "base/threading/sequenced_task_runner_handle.h" |
17 #include "base/values.h" | 18 #include "base/values.h" |
18 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/chromeos/printing/ppd_provider_factory.h" | 20 #include "chrome/browser/chromeos/printing/ppd_provider_factory.h" |
20 #include "chrome/browser/chromeos/printing/printer_configurer.h" | 21 #include "chrome/browser/chromeos/printing/printer_configurer.h" |
21 #include "chrome/browser/chromeos/printing/printer_discoverer.h" | 22 #include "chrome/browser/chromeos/printing/printer_discoverer.h" |
22 #include "chrome/browser/chromeos/printing/printers_manager_factory.h" | 23 #include "chrome/browser/chromeos/printing/printers_manager_factory.h" |
23 #include "chrome/browser/download/download_prefs.h" | 24 #include "chrome/browser/download/download_prefs.h" |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
393 } | 394 } |
394 | 395 |
395 printer_discoverer_->AddObserver(this); | 396 printer_discoverer_->AddObserver(this); |
396 } | 397 } |
397 | 398 |
398 void CupsPrintersHandler::HandleStopDiscovery(const base::ListValue* args) { | 399 void CupsPrintersHandler::HandleStopDiscovery(const base::ListValue* args) { |
399 printer_discoverer_.reset(); | 400 printer_discoverer_.reset(); |
400 } | 401 } |
401 | 402 |
402 void CupsPrintersHandler::OnPrintersFound( | 403 void CupsPrintersHandler::OnPrintersFound( |
404 bool scan_done, | |
403 const std::vector<Printer>& printers) { | 405 const std::vector<Printer>& printers) { |
404 std::unique_ptr<base::ListValue> printers_list = | 406 std::unique_ptr<base::ListValue> printers_list = |
405 base::MakeUnique<base::ListValue>(); | 407 base::MakeUnique<base::ListValue>(); |
406 for (const auto& printer : printers) { | 408 for (const auto& printer : printers) { |
407 printers_list->Append(GetPrinterInfo(printer)); | 409 printers_list->Append(GetPrinterInfo(printer)); |
408 } | 410 } |
409 | 411 |
410 FireWebUIListener("on-printer-discovered", *printers_list); | 412 FireWebUIListener("on-printer-discovered", *printers_list); |
411 } | |
412 | 413 |
413 void CupsPrintersHandler::OnDiscoveryInitialScanDone() { | 414 if (scan_done) { |
dpapad
2017/05/26 21:02:03
Is it necessary to merge OnDiscoveryInitialScanDon
skau
2017/05/26 21:20:10
Justin and I have been considering whether the cur
| |
414 FireWebUIListener("on-printer-discovery-done"); | 415 UMA_HISTOGRAM_COUNTS_100("Printing.CUPS.PrintersDiscovered", |
416 printers_list->GetSize()); | |
417 FireWebUIListener("on-printer-discovery-done"); | |
418 } | |
415 } | 419 } |
416 | 420 |
417 } // namespace settings | 421 } // namespace settings |
418 } // namespace chromeos | 422 } // namespace chromeos |
OLD | NEW |