Commit 1f7193d3 authored by Sean Kau's avatar Sean Kau Committed by Commit Bot

Record USB printers installed automatically.

USB printers are installed automatically if we are sure of the
configuration.  Log these printers with USB attributes and the fact
that they were configured automatically.

Bug: 740270, 725739
Change-Id: I50d4596cbf94fc9de8871cf5c8e02ded75e05681
Reviewed-on: https://chromium-review.googlesource.com/598691Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Sean Kau <skau@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491800}
parent bf7ca7a1
......@@ -54,6 +54,23 @@ void SetNetworkPrinterInfo(metrics::PrinterEventProto* event,
} // namespace
UsbPrinter::UsbPrinter() = default;
UsbPrinter::UsbPrinter(const UsbPrinter& other)
: manufacturer(other.manufacturer),
model(other.model),
vendor_id(other.vendor_id),
model_id(other.model_id),
printer(other.printer) {}
UsbPrinter& UsbPrinter::operator=(const UsbPrinter& other) {
manufacturer = other.manufacturer;
model = other.model;
vendor_id = other.vendor_id;
model_id = other.model_id;
printer = other.printer;
return *this;
}
UsbPrinter::~UsbPrinter() = default;
PrinterEventTracker::PrinterEventTracker() = default;
......
......@@ -14,6 +14,9 @@ namespace chromeos {
struct UsbPrinter {
UsbPrinter();
UsbPrinter(const UsbPrinter& printer);
UsbPrinter& operator=(const UsbPrinter& printer);
~UsbPrinter();
// USB MFG string
......
......@@ -22,6 +22,8 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/printing/ppd_provider_factory.h"
#include "chrome/browser/chromeos/printing/printer_configurer.h"
#include "chrome/browser/chromeos/printing/printer_event_tracker.h"
#include "chrome/browser/chromeos/printing/printer_event_tracker_factory.h"
#include "chrome/browser/chromeos/printing/synced_printers_manager_factory.h"
#include "chrome/browser/chromeos/printing/usb_printer_detector.h"
#include "chrome/browser/chromeos/printing/usb_printer_util.h"
......@@ -65,12 +67,23 @@ struct SetUpPrinterData {
//
// TODO(justincarlson): Possibly go deeper and query the IEEE1284 fields
// for make and model if we determine those are more likely to contain
// what we want.
// what we want. Strings currently come from udev.
std::string GuessEffectiveMakeAndModel(const device::UsbDevice& device) {
return base::UTF16ToUTF8(device.manufacturer_string()) + " " +
base::UTF16ToUTF8(device.product_string());
}
chromeos::UsbPrinter ToUsbPrinter(const SetUpPrinterData& printer_data) {
chromeos::UsbPrinter usb_printer;
usb_printer.vendor_id = printer_data.device->vendor_id();
usb_printer.model_id = printer_data.device->product_id();
usb_printer.manufacturer =
base::UTF16ToUTF8(printer_data.device->manufacturer_string());
usb_printer.model = base::UTF16ToUTF8(printer_data.device->product_string());
usb_printer.printer = *printer_data.printer;
return usb_printer;
}
// The PrinterDetector that drives the flow for setting up a USB printer to use
// CUPS backend.
class UsbPrinterDetectorImpl : public UsbPrinterDetector,
......@@ -270,6 +283,9 @@ class UsbPrinterDetectorImpl : public UsbPrinterDetector,
if (data->is_new) {
SyncedPrintersManagerFactory::GetForBrowserContext(profile_)
->UpdateConfiguredPrinter(*data->printer);
chromeos::PrinterEventTrackerFactory::GetForBrowserContext(profile_)
->RecordUsbPrinterInstalled(
ToUsbPrinter(*data), chromeos::PrinterEventTracker::kAutomatic);
}
// TODO(justincarlson): If the device was hotplugged, pop a timed
// notification that says the printer is now available for printing.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment