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_
14 // Observer for the BookmarkModel.
15 class BookmarkModelObserver {
17 // Invoked when the model has finished loading. |ids_reassigned| mirrors
18 // that of BookmarkLoadDetails::ids_reassigned. See it for details.
19 virtual void BookmarkModelLoaded(BookmarkModel* model,
20 bool ids_reassigned) = 0;
22 // Invoked from the destructor of the BookmarkModel.
23 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) {}
25 // Invoked when a node has moved.
26 virtual void BookmarkNodeMoved(BookmarkModel* model,
27 const BookmarkNode* old_parent,
29 const BookmarkNode* new_parent,
32 // Invoked when a node has been added.
33 virtual void BookmarkNodeAdded(BookmarkModel* model,
34 const BookmarkNode* parent,
37 // Invoked before a node is removed.
38 // |parent| the parent of the node that will be removed.
39 // |old_index| the index of the node about to be removed in |parent|.
40 // |node| is the node to be removed.
41 virtual void OnWillRemoveBookmarks(BookmarkModel* model,
42 const BookmarkNode* parent,
44 const BookmarkNode* node) {}
46 // Invoked when a node has been removed, the item may still be starred though.
47 // |parent| the parent of the node that was removed.
48 // |old_index| the index of the removed node in |parent| before it was
50 // |node| is the node that was removed.
51 // |removed_urls| is populated with the urls which no longer have any
52 // bookmarks associated with them.
53 virtual void BookmarkNodeRemoved(BookmarkModel* model,
54 const BookmarkNode* parent,
56 const BookmarkNode* node,
57 const std::set<GURL>& removed_urls) = 0;
59 // Invoked before the title or url of a node is changed.
60 virtual void OnWillChangeBookmarkNode(BookmarkModel* model,
61 const BookmarkNode* node) {}
63 // Invoked when the title or url of a node changes.
64 virtual void BookmarkNodeChanged(BookmarkModel* model,
65 const BookmarkNode* node) = 0;
67 // Invoked before the metainfo of a node is changed.
68 virtual void OnWillChangeBookmarkMetaInfo(BookmarkModel* model,
69 const BookmarkNode* node) {}
71 // Invoked when the metainfo on a node changes.
72 virtual void BookmarkMetaInfoChanged(BookmarkModel* model,
73 const BookmarkNode* node) {}
75 // Invoked when a favicon has been loaded or changed.
76 virtual void BookmarkNodeFaviconChanged(BookmarkModel* model,
77 const BookmarkNode* node) = 0;
79 // Invoked before the direct children of |node| have been reordered in some
80 // way, such as sorted.
81 virtual void OnWillReorderBookmarkNode(BookmarkModel* model,
82 const BookmarkNode* node) {}
84 // Invoked when the children (just direct children, not descendants) of
85 // |node| have been reordered in some way, such as sorted.
86 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model,
87 const BookmarkNode* node) = 0;
89 // Invoked before an extensive set of model changes is about to begin.
90 // This tells UI intensive observers to wait until the updates finish to
92 // These methods should only be used for imports and sync.
93 // Observers should still respond to BookmarkNodeRemoved immediately,
94 // to avoid holding onto stale node pointers.
95 virtual void ExtensiveBookmarkChangesBeginning(BookmarkModel* model) {}
97 // Invoked after an extensive set of model changes has ended.
98 // This tells observers to update themselves if they were waiting for the
100 virtual void ExtensiveBookmarkChangesEnded(BookmarkModel* model) {}
102 // Invoked before all non-permanent bookmark nodes that are editable by
103 // the user are removed.
104 virtual void OnWillRemoveAllUserBookmarks(BookmarkModel* model) {}
106 // Invoked when all non-permanent bookmark nodes that are editable by the
107 // user have been removed.
108 // |removed_urls| is populated with the urls which no longer have any
109 // bookmarks associated with them.
110 virtual void BookmarkAllUserNodesRemoved(
111 BookmarkModel* model,
112 const std::set<GURL>& removed_urls) = 0;
114 // Invoked before a set of model changes that is initiated by a single user
115 // action. For example, this is called a single time when pasting from the
116 // clipboard before each pasted bookmark is added to the bookmark model.
117 virtual void GroupedBookmarkChangesBeginning(BookmarkModel* model) {}
119 // Invoked after a set of model changes triggered by a single user action has
121 virtual void GroupedBookmarkChangesEnded(BookmarkModel* model) {}
124 virtual ~BookmarkModelObserver() {}
127 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_OBSERVER_H_