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_EXPANDED_STATE_TRACKER_H_
6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_EXPANDED_STATE_TRACKER_H_
10 #include "chrome/browser/bookmarks/base_bookmark_model_observer.h"
16 // BookmarkExpandedStateTracker is used to track a set of expanded nodes. The
17 // nodes are persisted in preferences. If an expanded node is removed from the
18 // model BookmarkExpandedStateTracker removes the node.
19 class BookmarkExpandedStateTracker
: public BaseBookmarkModelObserver
{
21 typedef std::set
<const BookmarkNode
*> Nodes
;
23 BookmarkExpandedStateTracker(BookmarkModel
* bookmark_model
,
24 PrefService
* pref_service
);
25 virtual ~BookmarkExpandedStateTracker();
27 // The set of expanded nodes.
28 void SetExpandedNodes(const Nodes
& nodes
);
29 Nodes
GetExpandedNodes();
32 // BaseBookmarkModelObserver:
33 virtual void BookmarkModelLoaded(BookmarkModel
* model
,
34 bool ids_reassigned
) OVERRIDE
;
35 virtual void BookmarkModelChanged() OVERRIDE
;
36 virtual void BookmarkModelBeingDeleted(BookmarkModel
* model
) OVERRIDE
;
37 virtual void BookmarkNodeRemoved(BookmarkModel
* model
,
38 const BookmarkNode
* parent
,
40 const BookmarkNode
* node
) OVERRIDE
;
41 virtual void BookmarkAllNodesRemoved(BookmarkModel
* model
) OVERRIDE
;
43 // Updates the value for |prefs::kBookmarkEditorExpandedNodes| from
44 // GetExpandedNodes().
45 void UpdatePrefs(const Nodes
& nodes
);
47 BookmarkModel
* bookmark_model_
;
48 PrefService
* pref_service_
;
50 DISALLOW_COPY_AND_ASSIGN(BookmarkExpandedStateTracker
);
53 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_EXPANDED_STATE_TRACKER_H_