user_notes_ui.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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_INTERFACES_USER_NOTES_UI_H_
  5. #define COMPONENTS_USER_NOTES_INTERFACES_USER_NOTES_UI_H_
  6. #include "base/supports_user_data.h"
  7. #include "base/unguessable_token.h"
  8. #include "ui/gfx/geometry/rect.h"
  9. namespace user_notes {
  10. class UserNoteInstance;
  11. // Interface that the UI layer of User Notes must implement. Used by the
  12. // business logic in the service to send commands to the UI.
  13. class UserNotesUI : public base::SupportsUserData::Data {
  14. public:
  15. static const void* UserDataKey() { return &kUserDataKey; }
  16. UserNotesUI() = default;
  17. UserNotesUI(const UserNotesUI&) = delete;
  18. UserNotesUI& operator=(const UserNotesUI&) = delete;
  19. ~UserNotesUI() override = default;
  20. // Called when a note in the UI should be scrolled to / brought to the
  21. // foreground, and focused.
  22. virtual void FocusNote(const base::UnguessableToken& guid) = 0;
  23. // Called when the note creation UX should be shown in the UI layer. |bounds|
  24. // corresponds to the location in the webpage where the associated highlight
  25. // is, and should be compared with existing notes in the UI to determine where
  26. // the new note should be inserted.
  27. virtual void StartNoteCreation(UserNoteInstance* instance) = 0;
  28. // Called when the model has changed and the UI should consequently refresh
  29. // the notes it is displaying. The new model must be polled from the active
  30. // tab's primary page.
  31. virtual void Invalidate() = 0;
  32. // Called by the UserNoteService when the user triggers one of the feature's
  33. // entry points, indicating the Notes UI should show itself.
  34. virtual void Show() = 0;
  35. private:
  36. static const int kUserDataKey = 0;
  37. };
  38. } // namespace user_notes
  39. #endif // COMPONENTS_USER_NOTES_INTERFACES_USER_NOTES_UI_H_