gesture_properties_service_provider.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Copyright 2019 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.
  4. #ifndef ASH_DBUS_GESTURE_PROPERTIES_SERVICE_PROVIDER_H_
  5. #define ASH_DBUS_GESTURE_PROPERTIES_SERVICE_PROVIDER_H_
  6. #include "ash/ash_export.h"
  7. #include "base/memory/ref_counted.h"
  8. #include "base/memory/weak_ptr.h"
  9. #include "chromeos/ash/components/dbus/services/cros_dbus_service.h"
  10. #include "dbus/exported_object.h"
  11. #include "dbus/message.h"
  12. #include "mojo/public/cpp/bindings/remote.h"
  13. #include "ui/ozone/public/mojom/gesture_properties_service.mojom.h"
  14. namespace dbus {
  15. class MethodCall;
  16. }
  17. namespace ash {
  18. /**
  19. * Provides a D-Bus bridge to the Mojo GesturePropertiesService, allowing
  20. * gesture properties to be easily modified. See the Google-internal design doc
  21. * at go/cros-gesture-properties-dbus-design for more details.
  22. */
  23. class ASH_EXPORT GesturePropertiesServiceProvider
  24. : public CrosDBusService::ServiceProviderInterface {
  25. public:
  26. GesturePropertiesServiceProvider();
  27. GesturePropertiesServiceProvider(const GesturePropertiesServiceProvider&) =
  28. delete;
  29. GesturePropertiesServiceProvider& operator=(
  30. const GesturePropertiesServiceProvider&) = delete;
  31. ~GesturePropertiesServiceProvider() override;
  32. void set_service_for_test(
  33. ui::ozone::mojom::GesturePropertiesService* service) {
  34. service_for_test_ = service;
  35. }
  36. // CrosDBusService::ServiceProviderInterface
  37. void Start(scoped_refptr<dbus::ExportedObject> exported_object) override;
  38. private:
  39. // Called from ExportedObject when CheckLiveness() is exported as a D-Bus
  40. // method or failed to be exported.
  41. void OnExported(const std::string& interface_name,
  42. const std::string& method_name,
  43. bool success);
  44. // Called on UI thread in response to a D-Bus request.
  45. void ListDevices(dbus::MethodCall* method_call,
  46. dbus::ExportedObject::ResponseSender response_sender);
  47. // Called on UI thread in response to a D-Bus request.
  48. void ListProperties(dbus::MethodCall* method_call,
  49. dbus::ExportedObject::ResponseSender response_sender);
  50. // Called on UI thread in response to a D-Bus request.
  51. void GetProperty(dbus::MethodCall* method_call,
  52. dbus::ExportedObject::ResponseSender response_sender);
  53. // Called on UI thread in response to a D-Bus request.
  54. void SetProperty(dbus::MethodCall* method_call,
  55. dbus::ExportedObject::ResponseSender response_sender);
  56. ui::ozone::mojom::GesturePropertiesService* GetService();
  57. mojo::Remote<ui::ozone::mojom::GesturePropertiesService> service_;
  58. ui::ozone::mojom::GesturePropertiesService* service_for_test_ = nullptr;
  59. base::WeakPtrFactory<GesturePropertiesServiceProvider> weak_ptr_factory_;
  60. };
  61. } // namespace ash
  62. #endif // ASH_DBUS_GESTURE_PROPERTIES_SERVICE_PROVIDER_H_