• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2009 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 #pragma once
8 
9 class BookmarkModel;
10 class BookmarkNode;
11 
12 // Observer for the BookmarkModel.
13 class BookmarkModelObserver {
14  public:
15   // Invoked when the model has finished loading.
16   virtual void Loaded(BookmarkModel* model) = 0;
17 
18   // Invoked from the destructor of the BookmarkModel.
BookmarkModelBeingDeleted(BookmarkModel * model)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 when a node has been removed, the item may still be starred though.
34   // |parent| the parent of the node that was removed.
35   // |old_index| the index of the removed node in |parent| before it was
36   // removed.
37   // |node| is the node that was removed.
38   virtual void BookmarkNodeRemoved(BookmarkModel* model,
39                                    const BookmarkNode* parent,
40                                    int old_index,
41                                    const BookmarkNode* node) = 0;
42 
43   // Invoked when the title, url or favicon of a node has changed.
44   virtual void BookmarkNodeChanged(BookmarkModel* model,
45                                    const BookmarkNode* node) = 0;
46 
47   // Invoked when a favicon has finished loading.
48   virtual void BookmarkNodeFaviconLoaded(BookmarkModel* model,
49                                          const BookmarkNode* node) = 0;
50 
51   // Invoked when the children (just direct children, not descendants) of
52   // |node| have been reordered in some way, such as sorted.
53   virtual void BookmarkNodeChildrenReordered(BookmarkModel* model,
54                                              const BookmarkNode* node) = 0;
55 
56   // Invoked before a batch import begins.  This tells UI intensive observers
57   // to wait until the updates finish to update themselves.
58   // These methods should only be used for imports. Observers should still
59   // respond to BookmarkNodeRemoved immediately, to avoid holding onto
60   // stale node pointers.
BookmarkImportBeginning(BookmarkModel * model)61   virtual void BookmarkImportBeginning(BookmarkModel* model) {}
62 
63   // Invoked after a batch import finishes.  This tells observers to update
64   // themselves if they were waiting for the update to finish.
BookmarkImportEnding(BookmarkModel * model)65   virtual void BookmarkImportEnding(BookmarkModel* model) {}
66 
67  protected:
~BookmarkModelObserver()68   virtual ~BookmarkModelObserver() {}
69 };
70 
71 #endif  // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_OBSERVER_H_
72