1 // Copyright 2014 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.
5 #ifndef COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_OBSERVER_H_
6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_OBSERVER_H_
16 // Observer for the BookmarkModel.
17 class BookmarkModelObserver
{
19 // Invoked when the model has finished loading. |ids_reassigned| mirrors
20 // that of BookmarkLoadDetails::ids_reassigned. See it for details.
21 virtual void BookmarkModelLoaded(BookmarkModel
* model
,
22 bool ids_reassigned
) = 0;
24 // Invoked from the destructor of the BookmarkModel.
25 virtual void BookmarkModelBeingDeleted(BookmarkModel
* model
) {}
27 // Invoked when a node has moved.
28 virtual void BookmarkNodeMoved(BookmarkModel
* model
,
29 const BookmarkNode
* old_parent
,
31 const BookmarkNode
* new_parent
,
34 // Invoked when a node has been added.
35 virtual void BookmarkNodeAdded(BookmarkModel
* model
,
36 const BookmarkNode
* parent
,
39 // Invoked prior to removing a node from the model. When a node is removed
40 // it's descendants are implicitly removed from the model as
41 // well. Notification is only sent for the node itself, not any
42 // descendants. For example, if folder 'A' has the children 'A1' and 'A2',
43 // model->Remove('A') generates a single notification for 'A'; no notification
44 // is sent for 'A1' or 'A2'.
46 // |parent| the parent of the node that will be removed.
47 // |old_index| the index of the node about to be removed in |parent|.
48 // |node| is the node to be removed.
49 virtual void OnWillRemoveBookmarks(BookmarkModel
* model
,
50 const BookmarkNode
* parent
,
52 const BookmarkNode
* node
) {}
54 // Invoked after a node has been removed from the model. Removing a node
55 // implicitly removes all descendants. Notification is only sent for the node
56 // that BookmarkModel::Remove() is invoked on. See description of
57 // OnWillRemoveBookmarks() for details.
59 // |parent| the parent of the node that was removed.
60 // |old_index| the index of the removed node in |parent| before it was
62 // |node| the node that was removed.
63 // |no_longer_bookmarked| contains the urls of any nodes that are no longer
64 // bookmarked as a result of the removal.
65 virtual void BookmarkNodeRemoved(
67 const BookmarkNode
* parent
,
69 const BookmarkNode
* node
,
70 const std::set
<GURL
>& no_longer_bookmarked
) = 0;
72 // Invoked before the title or url of a node is changed.
73 virtual void OnWillChangeBookmarkNode(BookmarkModel
* model
,
74 const BookmarkNode
* node
) {}
76 // Invoked when the title or url of a node changes.
77 virtual void BookmarkNodeChanged(BookmarkModel
* model
,
78 const BookmarkNode
* node
) = 0;
80 // Invoked before the metainfo of a node is changed.
81 virtual void OnWillChangeBookmarkMetaInfo(BookmarkModel
* model
,
82 const BookmarkNode
* node
) {}
84 // Invoked when the metainfo on a node changes.
85 virtual void BookmarkMetaInfoChanged(BookmarkModel
* model
,
86 const BookmarkNode
* node
) {}
88 // Invoked when a favicon has been loaded or changed.
89 virtual void BookmarkNodeFaviconChanged(BookmarkModel
* model
,
90 const BookmarkNode
* node
) = 0;
92 // Invoked before the direct children of |node| have been reordered in some
93 // way, such as sorted.
94 virtual void OnWillReorderBookmarkNode(BookmarkModel
* model
,
95 const BookmarkNode
* node
) {}
97 // Invoked when the children (just direct children, not descendants) of
98 // |node| have been reordered in some way, such as sorted.
99 virtual void BookmarkNodeChildrenReordered(BookmarkModel
* model
,
100 const BookmarkNode
* node
) = 0;
102 // Invoked before an extensive set of model changes is about to begin.
103 // This tells UI intensive observers to wait until the updates finish to
104 // update themselves.
105 // These methods should only be used for imports and sync.
106 // Observers should still respond to BookmarkNodeRemoved immediately,
107 // to avoid holding onto stale node pointers.
108 virtual void ExtensiveBookmarkChangesBeginning(BookmarkModel
* model
) {}
110 // Invoked after an extensive set of model changes has ended.
111 // This tells observers to update themselves if they were waiting for the
113 virtual void ExtensiveBookmarkChangesEnded(BookmarkModel
* model
) {}
115 // Invoked before all non-permanent bookmark nodes that are editable by
116 // the user are removed.
117 virtual void OnWillRemoveAllUserBookmarks(BookmarkModel
* model
) {}
119 // Invoked when all non-permanent bookmark nodes that are editable by the
120 // user have been removed.
121 // |removed_urls| is populated with the urls which no longer have any
122 // bookmarks associated with them.
123 virtual void BookmarkAllUserNodesRemoved(
124 BookmarkModel
* model
,
125 const std::set
<GURL
>& removed_urls
) = 0;
127 // Invoked before a set of model changes that is initiated by a single user
128 // action. For example, this is called a single time when pasting from the
129 // clipboard before each pasted bookmark is added to the bookmark model.
130 virtual void GroupedBookmarkChangesBeginning(BookmarkModel
* model
) {}
132 // Invoked after a set of model changes triggered by a single user action has
134 virtual void GroupedBookmarkChangesEnded(BookmarkModel
* model
) {}
137 virtual ~BookmarkModelObserver() {}
140 } // namespace bookmarks
142 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_OBSERVER_H_