Upstream version 7.35.144.0
[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 BookmarkModelLoaded(BookmarkModel* model,
17                                    bool ids_reassigned) = 0;
18
19   // Invoked from the destructor of the BookmarkModel.
20   virtual void BookmarkModelBeingDeleted(BookmarkModel* model) {}
21
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;
28
29   // Invoked when a node has been added.
30   virtual void BookmarkNodeAdded(BookmarkModel* model,
31                                  const BookmarkNode* parent,
32                                  int index) = 0;
33
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) {}
42
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;
52
53   // Invoked before the title or url of a node is changed.
54   virtual void OnWillChangeBookmarkNode(BookmarkModel* model,
55                                         const BookmarkNode* node) {}
56
57   // Invoked when the title or url of a node changes.
58   virtual void BookmarkNodeChanged(BookmarkModel* model,
59                                    const BookmarkNode* node) = 0;
60
61   // Invoked before the metainfo of a node is changed.
62   virtual void OnWillChangeBookmarkMetaInfo(BookmarkModel* model,
63                                             const BookmarkNode* node) {}
64
65   // Invoked when the metainfo on a node changes.
66   virtual void BookmarkMetaInfoChanged(BookmarkModel* model,
67                                        const BookmarkNode* node) {}
68
69   // Invoked when a favicon has been loaded or changed.
70   virtual void BookmarkNodeFaviconChanged(BookmarkModel* model,
71                                           const BookmarkNode* node) = 0;
72
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) {}
77
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;
82
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) {}
90
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) {}
95
96   // Invoked before all non-permanent bookmark nodes are removed.
97   virtual void OnWillRemoveAllBookmarks(BookmarkModel* model) {}
98
99   // Invoked when all non-permanent bookmark nodes have been removed.
100   virtual void BookmarkAllNodesRemoved(BookmarkModel* model) = 0;
101
102   // Invoked before a set of model changes that is initiated by a single user
103   // action. For example, this is called a single time when pasting from the
104   // clipboard before each pasted bookmark is added to the bookmark model.
105   virtual void GroupedBookmarkChangesBeginning(BookmarkModel* model) {}
106
107   // Invoked after a set of model changes triggered by a single user action has
108   // ended.
109   virtual void GroupedBookmarkChangesEnded(BookmarkModel* model) {}
110
111  protected:
112   virtual ~BookmarkModelObserver() {}
113 };
114
115 #endif  // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_OBSERVER_H_