Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / components / bookmarks / browser / bookmark_model_observer.h
blobd5c20a1a0a379b2970c73ab12ede202b2aeb73da
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_
8 #include <set>
10 class BookmarkModel;
11 class BookmarkNode;
12 class GURL;
14 // Observer for the BookmarkModel.
15 class BookmarkModelObserver {
16 public:
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,
28 int old_index,
29 const BookmarkNode* new_parent,
30 int new_index) = 0;
32 // Invoked prior to adding a bookmark node, and in particular, prior to adding
33 // it to the parent. This function can be used to alter the contents of the
34 // node before BookmarkNodeAdded listeners know about it.
35 virtual void OnWillAddBookmarkNode(BookmarkModel* model,
36 BookmarkNode* node) {}
38 // Invoked when a node has been added.
39 virtual void BookmarkNodeAdded(BookmarkModel* model,
40 const BookmarkNode* parent,
41 int index) = 0;
43 // Invoked before a node is removed.
44 // |parent| the parent of the node that will be removed.
45 // |old_index| the index of the node about to be removed in |parent|.
46 // |node| is the node to be removed.
47 virtual void OnWillRemoveBookmarks(BookmarkModel* model,
48 const BookmarkNode* parent,
49 int old_index,
50 const BookmarkNode* node) {}
52 // Invoked when a node has been removed, the item may still be starred though.
53 // |parent| the parent of the node that was removed.
54 // |old_index| the index of the removed node in |parent| before it was
55 // removed.
56 // |node| is the node that was removed.
57 // |removed_urls| is populated with the urls which no longer have any
58 // bookmarks associated with them.
59 virtual void BookmarkNodeRemoved(BookmarkModel* model,
60 const BookmarkNode* parent,
61 int old_index,
62 const BookmarkNode* node,
63 const std::set<GURL>& removed_urls) = 0;
65 // Invoked before the title or url of a node is changed.
66 virtual void OnWillChangeBookmarkNode(BookmarkModel* model,
67 const BookmarkNode* node) {}
69 // Invoked when the title or url of a node changes.
70 virtual void BookmarkNodeChanged(BookmarkModel* model,
71 const BookmarkNode* node) = 0;
73 // Invoked before the metainfo of a node is changed.
74 virtual void OnWillChangeBookmarkMetaInfo(BookmarkModel* model,
75 const BookmarkNode* node) {}
77 // Invoked when the metainfo on a node changes.
78 virtual void BookmarkMetaInfoChanged(BookmarkModel* model,
79 const BookmarkNode* node) {}
81 // Invoked when a favicon has been loaded or changed.
82 virtual void BookmarkNodeFaviconChanged(BookmarkModel* model,
83 const BookmarkNode* node) = 0;
85 // Invoked before the direct children of |node| have been reordered in some
86 // way, such as sorted.
87 virtual void OnWillReorderBookmarkNode(BookmarkModel* model,
88 const BookmarkNode* node) {}
90 // Invoked when the children (just direct children, not descendants) of
91 // |node| have been reordered in some way, such as sorted.
92 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model,
93 const BookmarkNode* node) = 0;
95 // Invoked before an extensive set of model changes is about to begin.
96 // This tells UI intensive observers to wait until the updates finish to
97 // update themselves.
98 // These methods should only be used for imports and sync.
99 // Observers should still respond to BookmarkNodeRemoved immediately,
100 // to avoid holding onto stale node pointers.
101 virtual void ExtensiveBookmarkChangesBeginning(BookmarkModel* model) {}
103 // Invoked after an extensive set of model changes has ended.
104 // This tells observers to update themselves if they were waiting for the
105 // update to finish.
106 virtual void ExtensiveBookmarkChangesEnded(BookmarkModel* model) {}
108 // Invoked before all non-permanent bookmark nodes that are editable by
109 // the user are removed.
110 virtual void OnWillRemoveAllUserBookmarks(BookmarkModel* model) {}
112 // Invoked when all non-permanent bookmark nodes that are editable by the
113 // user have been removed.
114 // |removed_urls| is populated with the urls which no longer have any
115 // bookmarks associated with them.
116 virtual void BookmarkAllUserNodesRemoved(
117 BookmarkModel* model,
118 const std::set<GURL>& removed_urls) = 0;
120 // Invoked before a set of model changes that is initiated by a single user
121 // action. For example, this is called a single time when pasting from the
122 // clipboard before each pasted bookmark is added to the bookmark model.
123 virtual void GroupedBookmarkChangesBeginning(BookmarkModel* model) {}
125 // Invoked after a set of model changes triggered by a single user action has
126 // ended.
127 virtual void GroupedBookmarkChangesEnded(BookmarkModel* model) {}
129 protected:
130 virtual ~BookmarkModelObserver() {}
133 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_OBSERVER_H_