- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / bookmarks / bookmark_model_observer.h
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.
4
5 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_OBSERVER_H_
6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_OBSERVER_H_
7
8 class BookmarkModel;
9 class BookmarkNode;
10
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 Loaded(BookmarkModel* model, bool ids_reassigned) = 0;
17
18   // Invoked from the destructor of the BookmarkModel.
19   virtual void BookmarkModelBeingDeleted(BookmarkModel* model) {}
20
21   // Invoked when a node has moved.
22   virtual void BookmarkNodeMoved(BookmarkModel* model,
23                                  const BookmarkNode* old_parent,
24                                  int old_index,
25                                  const BookmarkNode* new_parent,
26                                  int new_index) = 0;
27
28   // Invoked when a node has been added.
29   virtual void BookmarkNodeAdded(BookmarkModel* model,
30                                  const BookmarkNode* parent,
31                                  int index) = 0;
32
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,
39                                      int old_index,
40                                      const BookmarkNode* node) {}
41
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
45   // removed.
46   // |node| is the node that was removed.
47   virtual void BookmarkNodeRemoved(BookmarkModel* model,
48                                    const BookmarkNode* parent,
49                                    int old_index,
50                                    const BookmarkNode* node) = 0;
51
52   // Invoked before the title or url of a node is changed.
53   virtual void OnWillChangeBookmarkNode(BookmarkModel* model,
54                                         const BookmarkNode* node) {}
55
56   // Invoked when the title or url of a node changes.
57   virtual void BookmarkNodeChanged(BookmarkModel* model,
58                                    const BookmarkNode* node) = 0;
59
60   // Invoked before the metainfo of a node is changed.
61   virtual void OnWillChangeBookmarkMetaInfo(BookmarkModel* model,
62                                             const BookmarkNode* node) {}
63
64   // Invoked when the metainfo on a node changes.
65   virtual void BookmarkMetaInfoChanged(BookmarkModel* model,
66                                        const BookmarkNode* node) {}
67
68   // Invoked when a favicon has been loaded or changed.
69   virtual void BookmarkNodeFaviconChanged(BookmarkModel* model,
70                                           const BookmarkNode* node) = 0;
71
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) {}
76
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;
81
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
84   // update themselves.
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) {}
89
90   // Invoked after an extensive set of model changes has ended.
91   // This tells observers to update themselves if they were waiting for the
92   // update to finish.
93   virtual void ExtensiveBookmarkChangesEnded(BookmarkModel* model) {}
94
95   // Invoked before all non-permanent bookmark nodes are removed.
96   virtual void OnWillRemoveAllBookmarks(BookmarkModel* model) {}
97
98   // Invoked when all non-permanent bookmark nodes have been removed.
99   virtual void BookmarkAllNodesRemoved(BookmarkModel* model) = 0;
100
101  protected:
102   virtual ~BookmarkModelObserver() {}
103 };
104
105 #endif  // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_OBSERVER_H_