user_note_target.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2022 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_USER_NOTES_MODEL_USER_NOTE_TARGET_H_
  5. #define COMPONENTS_USER_NOTES_MODEL_USER_NOTE_TARGET_H_
  6. #include <string>
  7. #include "url/gurl.h"
  8. namespace user_notes {
  9. // Model class for a note target.
  10. class UserNoteTarget {
  11. public:
  12. enum TargetType { kPage = 0, kPageText };
  13. explicit UserNoteTarget(TargetType type,
  14. const std::u16string& original_text,
  15. GURL target_page,
  16. const std::string& selector);
  17. ~UserNoteTarget();
  18. UserNoteTarget(const UserNoteTarget&) = delete;
  19. UserNoteTarget& operator=(const UserNoteTarget&) = delete;
  20. TargetType type() const { return type_; }
  21. const std::u16string& original_text() const { return original_text_; }
  22. const GURL& target_page() const { return target_page_; }
  23. const std::string& selector() const { return selector_; }
  24. private:
  25. // The type of target. Currently only page and page text is supported.
  26. TargetType type_;
  27. // The original text to which the note was attached. Useful if the page
  28. // changes. Empty for `TargetType::PAGE`.
  29. std::u16string original_text_;
  30. // The URL of the page the note is attached to.
  31. GURL target_page_;
  32. // The text fragment selector that identifies the `original_text_`.
  33. // Empty for `TargetType::PAGE`.
  34. std::string selector_;
  35. };
  36. } // namespace user_notes
  37. #endif // COMPONENTS_USER_NOTES_MODEL_USER_NOTE_TARGET_H_