closure: fix compile error by adding missing externs
[chromium-blink-merge.git] / components / bookmarks / browser / bookmark_model_observer.h
bloba946d532ac8cdcf21053944e7d0b9e3d7bbea994
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 GURL;
12 namespace bookmarks {
14 class BookmarkModel;
15 class BookmarkNode;
17 // Observer for the BookmarkModel.
18 class BookmarkModelObserver {
19 public:
20 // Invoked when the model has finished loading. |ids_reassigned| mirrors
21 // that of BookmarkLoadDetails::ids_reassigned. See it for details.
22 virtual void BookmarkModelLoaded(BookmarkModel* model,
23 bool ids_reassigned) = 0;
25 // Invoked from the destructor of the BookmarkModel.
26 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) {}
28 // Invoked when a node has moved.
29 virtual void BookmarkNodeMoved(BookmarkModel* model,
30 const BookmarkNode* old_parent,
31 int old_index,
32 const BookmarkNode* new_parent,
33 int new_index) = 0;
35 // Invoked when a node has been added.
36 virtual void BookmarkNodeAdded(BookmarkModel* model,
37 const BookmarkNode* parent,
38 int index) = 0;
40 // Invoked prior to removing a node from the model. When a node is removed
41 // it's descendants are implicitly removed from the model as
42 // well. Notification is only sent for the node itself, not any
43 // descendants. For example, if folder 'A' has the children 'A1' and 'A2',
44 // model->Remove('A') generates a single notification for 'A'; no notification
45 // is sent for 'A1' or 'A2'.
47 // |parent| the parent of the node that will be removed.
48 // |old_index| the index of the node about to be removed in |parent|.
49 // |node| is the node to be removed.
50 virtual void OnWillRemoveBookmarks(BookmarkModel* model,
51 const BookmarkNode* parent,
52 int old_index,
53 const BookmarkNode* node) {}
55 // Invoked after a node has been removed from the model. Removing a node
56 // implicitly removes all descendants. Notification is only sent for the node
57 // that BookmarkModel::Remove() is invoked on. See description of
58 // OnWillRemoveBookmarks() for details.
60 // |parent| the parent of the node that was removed.
61 // |old_index| the index of the removed node in |parent| before it was
62 // removed.
63 // |node| the node that was removed.
64 // |no_longer_bookmarked| contains the urls of any nodes that are no longer
65 // bookmarked as a result of the removal.
66 virtual void BookmarkNodeRemoved(
67 BookmarkModel* model,
68 const BookmarkNode* parent,
69 int old_index,
70 const BookmarkNode* node,
71 const std::set<GURL>& no_longer_bookmarked) = 0;
73 // Invoked before the title or url of a node is changed.
74 virtual void OnWillChangeBookmarkNode(BookmarkModel* model,
75 const BookmarkNode* node) {}
77 // Invoked when the title or url of a node changes.
78 virtual void BookmarkNodeChanged(BookmarkModel* model,
79 const BookmarkNode* node) = 0;
81 // Invoked before the metainfo of a node is changed.
82 virtual void OnWillChangeBookmarkMetaInfo(BookmarkModel* model,
83 const BookmarkNode* node) {}
85 // Invoked when the metainfo on a node changes.
86 virtual void BookmarkMetaInfoChanged(BookmarkModel* model,
87 const BookmarkNode* node) {}
89 // Invoked when a favicon has been loaded or changed.
90 virtual void BookmarkNodeFaviconChanged(BookmarkModel* model,
91 const BookmarkNode* node) = 0;
93 // Invoked before the direct children of |node| have been reordered in some
94 // way, such as sorted.
95 virtual void OnWillReorderBookmarkNode(BookmarkModel* model,
96 const BookmarkNode* node) {}
98 // Invoked when the children (just direct children, not descendants) of
99 // |node| have been reordered in some way, such as sorted.
100 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model,
101 const BookmarkNode* node) = 0;
103 // Invoked before an extensive set of model changes is about to begin.
104 // This tells UI intensive observers to wait until the updates finish to
105 // update themselves.
106 // These methods should only be used for imports and sync.
107 // Observers should still respond to BookmarkNodeRemoved immediately,
108 // to avoid holding onto stale node pointers.
109 virtual void ExtensiveBookmarkChangesBeginning(BookmarkModel* model) {}
111 // Invoked after an extensive set of model changes has ended.
112 // This tells observers to update themselves if they were waiting for the
113 // update to finish.
114 virtual void ExtensiveBookmarkChangesEnded(BookmarkModel* model) {}
116 // Invoked before all non-permanent bookmark nodes that are editable by
117 // the user are removed.
118 virtual void OnWillRemoveAllUserBookmarks(BookmarkModel* model) {}
120 // Invoked when all non-permanent bookmark nodes that are editable by the
121 // user have been removed.
122 // |removed_urls| is populated with the urls which no longer have any
123 // bookmarks associated with them.
124 virtual void BookmarkAllUserNodesRemoved(
125 BookmarkModel* model,
126 const std::set<GURL>& removed_urls) = 0;
128 // Invoked before a set of model changes that is initiated by a single user
129 // action. For example, this is called a single time when pasting from the
130 // clipboard before each pasted bookmark is added to the bookmark model.
131 virtual void GroupedBookmarkChangesBeginning(BookmarkModel* model) {}
133 // Invoked after a set of model changes triggered by a single user action has
134 // ended.
135 virtual void GroupedBookmarkChangesEnded(BookmarkModel* model) {}
137 protected:
138 virtual ~BookmarkModelObserver() {}
141 } // namespace bookmarks
143 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_OBSERVER_H_