Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / bookmarks / bookmark_model_observer.h
blobd9116e82ea5f3a8039611343353e30d2f0a0bdda
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_
8 class BookmarkModel;
9 class BookmarkNode;
11 // Observer for the BookmarkModel.
12 class BookmarkModelObserver {
13 public:
14 // Invoked when the model has finished loading. |ids_reassigned| mirrors
15 // that of BookmarkLoadDetails::ids_reassigned. See it for details.
16 virtual void BookmarkModelLoaded(BookmarkModel* model,
17 bool ids_reassigned) = 0;
19 // Invoked from the destructor of the BookmarkModel.
20 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) {}
22 // Invoked when a node has moved.
23 virtual void BookmarkNodeMoved(BookmarkModel* model,
24 const BookmarkNode* old_parent,
25 int old_index,
26 const BookmarkNode* new_parent,
27 int new_index) = 0;
29 // Invoked when a node has been added.
30 virtual void BookmarkNodeAdded(BookmarkModel* model,
31 const BookmarkNode* parent,
32 int index) = 0;
34 // Invoked before a node is removed.
35 // |parent| the parent of the node that will be removed.
36 // |old_index| the index of the node about to be removed in |parent|.
37 // |node| is the node to be removed.
38 virtual void OnWillRemoveBookmarks(BookmarkModel* model,
39 const BookmarkNode* parent,
40 int old_index,
41 const BookmarkNode* node) {}
43 // Invoked when a node has been removed, the item may still be starred though.
44 // |parent| the parent of the node that was removed.
45 // |old_index| the index of the removed node in |parent| before it was
46 // removed.
47 // |node| is the node that was removed.
48 virtual void BookmarkNodeRemoved(BookmarkModel* model,
49 const BookmarkNode* parent,
50 int old_index,
51 const BookmarkNode* node) = 0;
53 // Invoked before the title or url of a node is changed.
54 virtual void OnWillChangeBookmarkNode(BookmarkModel* model,
55 const BookmarkNode* node) {}
57 // Invoked when the title or url of a node changes.
58 virtual void BookmarkNodeChanged(BookmarkModel* model,
59 const BookmarkNode* node) = 0;
61 // Invoked before the metainfo of a node is changed.
62 virtual void OnWillChangeBookmarkMetaInfo(BookmarkModel* model,
63 const BookmarkNode* node) {}
65 // Invoked when the metainfo on a node changes.
66 virtual void BookmarkMetaInfoChanged(BookmarkModel* model,
67 const BookmarkNode* node) {}
69 // Invoked when a favicon has been loaded or changed.
70 virtual void BookmarkNodeFaviconChanged(BookmarkModel* model,
71 const BookmarkNode* node) = 0;
73 // Invoked before the direct children of |node| have been reordered in some
74 // way, such as sorted.
75 virtual void OnWillReorderBookmarkNode(BookmarkModel* model,
76 const BookmarkNode* node) {}
78 // Invoked when the children (just direct children, not descendants) of
79 // |node| have been reordered in some way, such as sorted.
80 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model,
81 const BookmarkNode* node) = 0;
83 // Invoked before an extensive set of model changes is about to begin.
84 // This tells UI intensive observers to wait until the updates finish to
85 // update themselves.
86 // These methods should only be used for imports and sync.
87 // Observers should still respond to BookmarkNodeRemoved immediately,
88 // to avoid holding onto stale node pointers.
89 virtual void ExtensiveBookmarkChangesBeginning(BookmarkModel* model) {}
91 // Invoked after an extensive set of model changes has ended.
92 // This tells observers to update themselves if they were waiting for the
93 // update to finish.
94 virtual void ExtensiveBookmarkChangesEnded(BookmarkModel* model) {}
96 // Invoked before all non-permanent bookmark nodes are removed.
97 virtual void OnWillRemoveAllBookmarks(BookmarkModel* model) {}
99 // Invoked when all non-permanent bookmark nodes have been removed.
100 virtual void BookmarkAllNodesRemoved(BookmarkModel* model) = 0;
102 protected:
103 virtual ~BookmarkModelObserver() {}
106 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_OBSERVER_H_