clipboard_recent_content_ios.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2015 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_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IOS_H_
  5. #define COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IOS_H_
  6. #include <string>
  7. #include "base/time/time.h"
  8. #include "components/open_from_clipboard/clipboard_recent_content.h"
  9. #include "url/gurl.h"
  10. @class NSArray;
  11. @class NSDate;
  12. @class NSUserDefaults;
  13. @class ClipboardRecentContentImplIOS;
  14. // IOS implementation of ClipboardRecentContent.
  15. // A large part of the implementation is in clipboard_recent_content_impl_ios,
  16. // a GURL-free class that is used by some of the iOS extensions. Not using GURL
  17. // in extensions is preferable as GURL requires depending on ICU which makes the
  18. // extensions much larger.
  19. class ClipboardRecentContentIOS : public ClipboardRecentContent {
  20. public:
  21. // |application_scheme| is the URL scheme that can be used to open the
  22. // current application, may be empty if no such scheme exists. Used to
  23. // determine whether or not the clipboard contains a relevant URL.
  24. // |group_user_defaults| is the NSUserDefaults used to store information on
  25. // pasteboard entry expiration. This information will be shared with other
  26. // application in the application group.
  27. ClipboardRecentContentIOS(const std::string& application_scheme,
  28. NSUserDefaults* group_user_defaults);
  29. // Constructor that directly takes an |implementation|. For use in tests.
  30. explicit ClipboardRecentContentIOS(
  31. ClipboardRecentContentImplIOS* implementation);
  32. ClipboardRecentContentIOS(const ClipboardRecentContentIOS&) = delete;
  33. ClipboardRecentContentIOS& operator=(const ClipboardRecentContentIOS&) =
  34. delete;
  35. ~ClipboardRecentContentIOS() override;
  36. // ClipboardRecentContent implementation.
  37. absl::optional<GURL> GetRecentURLFromClipboard() override;
  38. absl::optional<std::u16string> GetRecentTextFromClipboard() override;
  39. absl::optional<std::set<ClipboardContentType>>
  40. GetCachedClipboardContentTypes() override;
  41. void GetRecentImageFromClipboard(GetRecentImageCallback callback) override;
  42. bool HasRecentImageFromClipboard() override;
  43. void HasRecentContentFromClipboard(std::set<ClipboardContentType> types,
  44. HasDataCallback callback) override;
  45. void GetRecentURLFromClipboard(GetRecentURLCallback callback) override;
  46. void GetRecentTextFromClipboard(GetRecentTextCallback callback) override;
  47. base::TimeDelta GetClipboardContentAge() const override;
  48. void SuppressClipboardContent() override;
  49. void ClearClipboardContent() override;
  50. private:
  51. absl::optional<gfx::Image> GetRecentImageFromClipboardInternal();
  52. void OnGetRecentImageFromClipboard(GetRecentImageCallback callback,
  53. const SkBitmap& sk_bitmap);
  54. // The implementation instance.
  55. __strong ClipboardRecentContentImplIOS* implementation_;
  56. };
  57. #endif // COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IOS_H_