reading_list_model_observer.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Copyright 2016 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_READING_LIST_CORE_READING_LIST_MODEL_OBSERVER_H_
  5. #define COMPONENTS_READING_LIST_CORE_READING_LIST_MODEL_OBSERVER_H_
  6. #include "components/reading_list/core/reading_list_entry.h"
  7. class GURL;
  8. class ReadingListModel;
  9. // Observer for the Reading List model. In the observer methods care should be
  10. // taken to not modify the model.
  11. class ReadingListModelObserver {
  12. public:
  13. ReadingListModelObserver(const ReadingListModelObserver&) = delete;
  14. ReadingListModelObserver& operator=(const ReadingListModelObserver&) = delete;
  15. // Invoked when the model has finished loading. Until this method is called it
  16. // is unsafe to use the model.
  17. virtual void ReadingListModelLoaded(const ReadingListModel* model) = 0;
  18. // Invoked when the batch updates are about to start. It will only be called
  19. // once before ReadingListModelCompletedBatchUpdates, even if several updates
  20. // are taking place at the same time.
  21. virtual void ReadingListModelBeganBatchUpdates(
  22. const ReadingListModel* model) {}
  23. // Invoked when the batch updates have completed. This is called once all
  24. // batch updates are completed.
  25. virtual void ReadingListModelCompletedBatchUpdates(
  26. const ReadingListModel* model) {}
  27. // Invoked before the destruction of the model.
  28. virtual void ReadingListModelBeingShutdown(const ReadingListModel* model) {}
  29. // Invoked from the destructor of the model. The model is no longer valid
  30. // after this call. There is no need to call RemoveObserver on the model from
  31. // here, as the observers are automatically deleted.
  32. virtual void ReadingListModelBeingDeleted(const ReadingListModel* model) {}
  33. // Invoked when elements are about to be removed from the read or unread list.
  34. virtual void ReadingListWillRemoveEntry(const ReadingListModel* model,
  35. const GURL& url) {}
  36. // Invoked when elements |MarkEntryUpdated| is called on an entry. This means
  37. // that the order of the entry may change and read/unread list may change
  38. // too.
  39. virtual void ReadingListWillMoveEntry(const ReadingListModel* model,
  40. const GURL& url) {}
  41. // Invoked when elements |MarkEntryUpdated| has been called on an entry. This
  42. // means that the order of the entry may have changed and read/unread list may
  43. // have changed too.
  44. virtual void ReadingListDidMoveEntry(const ReadingListModel* model,
  45. const GURL& url) {}
  46. // Invoked when elements are added.
  47. virtual void ReadingListWillAddEntry(const ReadingListModel* model,
  48. const ReadingListEntry& entry) {}
  49. // Invoked when elements have been added. This method is called after the
  50. // the entry has been added to the model and the entry can now be retrieved
  51. // from the model.
  52. // |source| says where the entry came from.
  53. virtual void ReadingListDidAddEntry(const ReadingListModel* model,
  54. const GURL& url,
  55. reading_list::EntrySource source) {}
  56. // Invoked when an entry is about to change.
  57. virtual void ReadingListWillUpdateEntry(const ReadingListModel* model,
  58. const GURL& url) {}
  59. // Called after all the changes signaled by calls to the "Will" methods are
  60. // done. All the "Will" methods are called as necessary, then the changes
  61. // are applied and then this method is called.
  62. virtual void ReadingListDidApplyChanges(ReadingListModel* model) {}
  63. protected:
  64. ReadingListModelObserver() {}
  65. virtual ~ReadingListModelObserver() {}
  66. };
  67. #endif // COMPONENTS_READING_LIST_CORE_READING_LIST_MODEL_OBSERVER_H_