data_source_delegate.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2017 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 COMPONENTS_EXO_DATA_SOURCE_DELEGATE_H_
  5. #define COMPONENTS_EXO_DATA_SOURCE_DELEGATE_H_
  6. #include <string>
  7. #include "base/files/scoped_file.h"
  8. #include "components/exo/data_device.h"
  9. #include "third_party/abseil-cpp/absl/types/optional.h"
  10. namespace exo {
  11. class DataSource;
  12. // Handles events on data devices in context-specific ways.
  13. class DataSourceDelegate {
  14. public:
  15. // Called at the top of the data device's destructor, to give observers a
  16. // chance to remove themselves.
  17. virtual void OnDataSourceDestroying(DataSource* source) = 0;
  18. // Called when a client accepts a |mime_type|.
  19. virtual void OnTarget(const absl::optional<std::string>& mime_type) = 0;
  20. // Called when the data is requested.
  21. virtual void OnSend(const std::string& mime_type, base::ScopedFD fd) = 0;
  22. // Called when selection or drag and drop operation was cancelled.
  23. virtual void OnCancelled() = 0;
  24. // Called when a user performes drop operation.
  25. virtual void OnDndDropPerformed() = 0;
  26. // Called when the drag and drop operation completes and compositor stop using
  27. // the data source.
  28. virtual void OnDndFinished() = 0;
  29. // Called when the compositor selects one drag and drop action.
  30. virtual void OnAction(DndAction dnd_action) = 0;
  31. // This should return true if |surface| is the source of this data source.
  32. // E.g. the surface is owned by the same client as the data source.
  33. virtual bool CanAcceptDataEventsForSurface(Surface* surface) const = 0;
  34. protected:
  35. virtual ~DataSourceDelegate() {}
  36. };
  37. } // namespace exo
  38. #endif // COMPONENTS_EXO_DATA_SOURCE_DELEGATE_H_