1 // Copyright (c) 2012 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 CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_OBSERVER_H_
6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_OBSERVER_H_
11 // Observer for the BookmarkModel.
12 class BookmarkModelObserver {
14 // Invoked when the model has finished loading. |ids_reassigned| mirrors
15 // that of BookmarkLoadDetails::ids_reassigned. See it for details.
16 virtual void Loaded(BookmarkModel* model, bool ids_reassigned) = 0;
18 // Invoked from the destructor of the BookmarkModel.
19 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) {}
21 // Invoked when a node has moved.
22 virtual void BookmarkNodeMoved(BookmarkModel* model,
23 const BookmarkNode* old_parent,
25 const BookmarkNode* new_parent,
28 // Invoked when a node has been added.
29 virtual void BookmarkNodeAdded(BookmarkModel* model,
30 const BookmarkNode* parent,
33 // Invoked before a node is removed.
34 // |parent| the parent of the node that will be removed.
35 // |old_index| the index of the node about to be removed in |parent|.
36 // |node| is the node to be removed.
37 virtual void OnWillRemoveBookmarks(BookmarkModel* model,
38 const BookmarkNode* parent,
40 const BookmarkNode* node) {}
42 // Invoked when a node has been removed, the item may still be starred though.
43 // |parent| the parent of the node that was removed.
44 // |old_index| the index of the removed node in |parent| before it was
46 // |node| is the node that was removed.
47 virtual void BookmarkNodeRemoved(BookmarkModel* model,
48 const BookmarkNode* parent,
50 const BookmarkNode* node) = 0;
52 // Invoked before the title or url of a node is changed.
53 virtual void OnWillChangeBookmarkNode(BookmarkModel* model,
54 const BookmarkNode* node) {}
56 // Invoked when the title or url of a node changes.
57 virtual void BookmarkNodeChanged(BookmarkModel* model,
58 const BookmarkNode* node) = 0;
60 // Invoked before the metainfo of a node is changed.
61 virtual void OnWillChangeBookmarkMetaInfo(BookmarkModel* model,
62 const BookmarkNode* node) {}
64 // Invoked when the metainfo on a node changes.
65 virtual void BookmarkMetaInfoChanged(BookmarkModel* model,
66 const BookmarkNode* node) {}
68 // Invoked when a favicon has been loaded or changed.
69 virtual void BookmarkNodeFaviconChanged(BookmarkModel* model,
70 const BookmarkNode* node) = 0;
72 // Invoked before the direct children of |node| have been reordered in some
73 // way, such as sorted.
74 virtual void OnWillReorderBookmarkNode(BookmarkModel* model,
75 const BookmarkNode* node) {}
77 // Invoked when the children (just direct children, not descendants) of
78 // |node| have been reordered in some way, such as sorted.
79 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model,
80 const BookmarkNode* node) = 0;
82 // Invoked before an extensive set of model changes is about to begin.
83 // This tells UI intensive observers to wait until the updates finish to
85 // These methods should only be used for imports and sync.
86 // Observers should still respond to BookmarkNodeRemoved immediately,
87 // to avoid holding onto stale node pointers.
88 virtual void ExtensiveBookmarkChangesBeginning(BookmarkModel* model) {}
90 // Invoked after an extensive set of model changes has ended.
91 // This tells observers to update themselves if they were waiting for the
93 virtual void ExtensiveBookmarkChangesEnded(BookmarkModel* model) {}
95 // Invoked before all non-permanent bookmark nodes are removed.
96 virtual void OnWillRemoveAllBookmarks(BookmarkModel* model) {}
98 // Invoked when all non-permanent bookmark nodes have been removed.
99 virtual void BookmarkAllNodesRemoved(BookmarkModel* model) = 0;
102 virtual ~BookmarkModelObserver() {}
105 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_OBSERVER_H_