| Index: chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
|
| diff --git a/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc b/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
|
| index 28a1781f5cad216bd1123cd274008f7d44ca2c0e..c6e28eca3d8fbdf1ce327cfa726d3ae2d032758d 100644
|
| --- a/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
|
| +++ b/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
|
| @@ -11,6 +11,7 @@
|
| #include "base/files/file_util.h"
|
| #include "base/json/json_string_value_serializer.h"
|
| #include "base/memory/ptr_util.h"
|
| +#include "base/metrics/histogram_macros.h"
|
| #include "base/path_service.h"
|
| #include "base/strings/string_util.h"
|
| #include "base/threading/sequenced_task_runner_handle.h"
|
| @@ -44,7 +45,12 @@ namespace settings {
|
|
|
| namespace {
|
|
|
| -void OnRemovedPrinter(bool success) {}
|
| +void OnRemovedPrinter(const Printer::PrinterProtocol& protocol, bool success) {
|
| + if (success) {
|
| + UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.PrinterRemoved", protocol,
|
| + Printer::PrinterProtocol::PROTOCOL_MAX);
|
| + }
|
| +}
|
|
|
| std::unique_ptr<base::DictionaryValue> GetPrinterInfo(const Printer& printer) {
|
| std::unique_ptr<base::DictionaryValue> printer_info =
|
| @@ -175,12 +181,22 @@ void CupsPrintersHandler::HandleRemoveCupsPrinter(const base::ListValue* args) {
|
| std::string printer_name;
|
| CHECK(args->GetString(0, &printer_id));
|
| CHECK(args->GetString(1, &printer_name));
|
| - PrintersManagerFactory::GetForBrowserContext(profile_)->RemovePrinter(
|
| - printer_id);
|
| + PrintersManager* prefs =
|
| + PrintersManagerFactory::GetForBrowserContext(profile_);
|
| + auto printer = prefs->GetPrinter(printer_id);
|
| +
|
| + if (!printer) {
|
| + LOG(WARNING) << "Tried to remove non-existant printer";
|
| + return;
|
| + }
|
| + Printer::PrinterProtocol protocol = printer->GetProtocol();
|
| +
|
| + prefs->RemovePrinter(printer_id);
|
|
|
| chromeos::DebugDaemonClient* client =
|
| chromeos::DBusThreadManager::Get()->GetDebugDaemonClient();
|
| - client->CupsRemovePrinter(printer_name, base::Bind(&OnRemovedPrinter),
|
| + client->CupsRemovePrinter(printer_name,
|
| + base::Bind(&OnRemovedPrinter, protocol),
|
| base::Bind(&base::DoNothing));
|
| }
|
|
|
| @@ -257,6 +273,8 @@ void CupsPrintersHandler::OnAddedPrinter(
|
| std::string printer_name = printer->display_name();
|
| switch (result_code) {
|
| case chromeos::PrinterSetupResult::SUCCESS: {
|
| + UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.PrinterAdded",
|
| + printer->GetProtocol(), Printer::PROTOCOL_MAX);
|
| auto* manager = PrintersManagerFactory::GetForBrowserContext(profile_);
|
| manager->PrinterInstalled(*printer);
|
| manager->RegisterPrinter(std::move(printer));
|
|
|