Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / chromeos / dbus / printer_service_provider.h
blob19163f226ce958ca676938cbf07530a720c9558e
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 ~PrinterServiceProvider() override;
52 // CrosDBusService::ServiceProviderInterface override.
53 void Start(scoped_refptr<dbus::ExportedObject> exported_object) override;
55 protected:
56 virtual void ShowCloudPrintHelp(const std::string& vendor,
57 const std::string& product);
59 private:
60 // Called from ExportedObject, when PrinterAdded() is exported as
61 // a D-Bus method, or failed to be exported.
62 void OnExported(const std::string& interface_name,
63 const std::string& method_name,
64 bool success);
66 // Invoked when usb printer is detected.
67 // Called on UI thread from dbus request.
68 void PrinterAdded(dbus::MethodCall* method_call,
69 dbus::ExportedObject::ResponseSender response_sender);
71 scoped_refptr<dbus::ExportedObject> exported_object_;
72 base::WeakPtrFactory<PrinterServiceProvider> weak_ptr_factory_;
74 DISALLOW_COPY_AND_ASSIGN(PrinterServiceProvider);
77 } // namespace chromeos
79 #endif // CHROME_BROWSER_CHROMEOS_DBUS_PRINTER_SERVICE_PROVIDER_H_