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_
10 #include "base/memory/weak_ptr.h"
11 #include "chromeos/dbus/services/cros_dbus_service.h"
12 #include "dbus/exported_object.h"
14 class NotificationUIManager
;
23 // This class provides printer service for CrosDBusService.
24 // It detects attached printers and show user help page.
26 // The following methods are exported.
28 // Interface: org.chromium.LibCrosServiceInterface (kLibCrosServiceInterface)
29 // Method: PrinterAdded (kPrinterAdded)
30 // Parameters: string:vendor Optional, USB vendor ID.
31 // string:product Optional, USB product ID.
33 // Display help page to advice user to use Cloud Print.
35 // The returned signal will contain the three values:
37 // This service can be manually tested dbus-send on ChromeOS.
39 // 1. Open a terminal and run the following:
41 // % dbus-send --system --type=method_call
42 // --dest=org.chromium.LibCrosService /org/chromium/LibCrosService
43 // org.chromium.LibCrosServiceInterface.PrinterAdded
44 // string:123 string:456
46 // 2. Go back to ChromeOS and check if new tab with information is opened.
48 class PrinterServiceProvider
49 : public CrosDBusService::ServiceProviderInterface
{
51 PrinterServiceProvider();
52 ~PrinterServiceProvider() override
;
54 // CrosDBusService::ServiceProviderInterface override.
55 void Start(scoped_refptr
<dbus::ExportedObject
> exported_object
) override
;
58 virtual void ShowCloudPrintHelp(const std::string
& vendor
,
59 const std::string
& product
);
62 friend class PrinterServiceProviderAppSearchEnabledTest
;
64 void SetNotificationUIManagerForTesting(NotificationUIManager
* manager
);
66 // Called from ExportedObject, when PrinterAdded() is exported as
67 // a D-Bus method, or failed to be exported.
68 void OnExported(const std::string
& interface_name
,
69 const std::string
& method_name
,
72 // Invoked when usb printer is detected.
73 // Called on UI thread from dbus request.
74 void PrinterAdded(dbus::MethodCall
* method_call
,
75 dbus::ExportedObject::ResponseSender response_sender
);
77 NotificationUIManager
* notification_ui_manager_
;
79 scoped_refptr
<dbus::ExportedObject
> exported_object_
;
80 base::WeakPtrFactory
<PrinterServiceProvider
> weak_ptr_factory_
;
82 DISALLOW_COPY_AND_ASSIGN(PrinterServiceProvider
);
85 } // namespace chromeos
87 #endif // CHROME_BROWSER_CHROMEOS_DBUS_PRINTER_SERVICE_PROVIDER_H_