Implemented consumer management unenrollment.
[chromium-blink-merge.git] / chrome / browser / chromeos / dbus / printer_service_provider.h
blob3ab89717f7649de2061586944cfebc75a3e9ae06
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_DBUS_PRINTER_SERVICE_PROVIDER_H_
6 #define CHROME_BROWSER_CHROMEOS_DBUS_PRINTER_SERVICE_PROVIDER_H_
8 #include <string>
10 #include "base/memory/weak_ptr.h"
11 #include "chromeos/dbus/services/cros_dbus_service.h"
12 #include "dbus/exported_object.h"
14 namespace dbus {
15 class MethodCall;
16 class Response;
19 namespace chromeos {
21 // This class provides printer service for CrosDBusService.
22 // It detects attached printers and show user help page.
24 // The following methods are exported.
26 // Interface: org.chromium.LibCrosServiceInterface (kLibCrosServiceInterface)
27 // Method: PrinterAdded (kPrinterAdded)
28 // Parameters: string:vendor Optional, USB vendor ID.
29 // string:product Optional, USB product ID.
31 // Display help page to advice user to use Cloud Print.
33 // The returned signal will contain the three values:
35 // This service can be manually tested dbus-send on ChromeOS.
37 // 1. Open a terminal and run the following:
39 // % dbus-send --system --type=method_call
40 // --dest=org.chromium.LibCrosService /org/chromium/LibCrosService
41 // org.chromium.LibCrosServiceInterface.PrinterAdded
42 // string:123 string:456
44 // 2. Go back to ChromeOS and check if new tab with information is opened.
46 class PrinterServiceProvider
47 : public CrosDBusService::ServiceProviderInterface {
48 public:
49 PrinterServiceProvider();
50 virtual ~PrinterServiceProvider();
52 // CrosDBusService::ServiceProviderInterface override.
53 virtual void Start(
54 scoped_refptr<dbus::ExportedObject> exported_object) override;
56 protected:
57 virtual void ShowCloudPrintHelp(const std::string& vendor,
58 const std::string& product);
60 private:
61 // Called from ExportedObject, when PrinterAdded() is exported as
62 // a D-Bus method, or failed to be exported.
63 void OnExported(const std::string& interface_name,
64 const std::string& method_name,
65 bool success);
67 // Invoked when usb printer is detected.
68 // Called on UI thread from dbus request.
69 void PrinterAdded(dbus::MethodCall* method_call,
70 dbus::ExportedObject::ResponseSender response_sender);
72 scoped_refptr<dbus::ExportedObject> exported_object_;
73 base::WeakPtrFactory<PrinterServiceProvider> weak_ptr_factory_;
75 DISALLOW_COPY_AND_ASSIGN(PrinterServiceProvider);
78 } // namespace chromeos
80 #endif // CHROME_BROWSER_CHROMEOS_DBUS_PRINTER_SERVICE_PROVIDER_H_