1 // Copyright 2014 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 COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_EXPANDED_STATE_TRACKER_H_
6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_EXPANDED_STATE_TRACKER_H_
10 #include "components/bookmarks/browser/base_bookmark_model_observer.h"
18 // BookmarkExpandedStateTracker is used to track a set of expanded nodes. The
19 // nodes are persisted in preferences. If an expanded node is removed from the
20 // model BookmarkExpandedStateTracker removes the node.
21 class BookmarkExpandedStateTracker
: public BaseBookmarkModelObserver
{
23 typedef std::set
<const BookmarkNode
*> Nodes
;
25 BookmarkExpandedStateTracker(BookmarkModel
* bookmark_model
,
26 PrefService
* pref_service
);
27 virtual ~BookmarkExpandedStateTracker();
29 // The set of expanded nodes.
30 void SetExpandedNodes(const Nodes
& nodes
);
31 Nodes
GetExpandedNodes();
34 // BaseBookmarkModelObserver:
35 virtual void BookmarkModelLoaded(BookmarkModel
* model
,
36 bool ids_reassigned
) OVERRIDE
;
37 virtual void BookmarkModelChanged() OVERRIDE
;
38 virtual void BookmarkModelBeingDeleted(BookmarkModel
* model
) OVERRIDE
;
39 virtual void BookmarkNodeRemoved(BookmarkModel
* model
,
40 const BookmarkNode
* parent
,
42 const BookmarkNode
* node
,
43 const std::set
<GURL
>& removed_urls
) OVERRIDE
;
44 virtual void BookmarkAllUserNodesRemoved(
46 const std::set
<GURL
>& removed_urls
) OVERRIDE
;
48 // Updates the value for |prefs::kBookmarkEditorExpandedNodes| from
49 // GetExpandedNodes().
50 void UpdatePrefs(const Nodes
& nodes
);
52 BookmarkModel
* bookmark_model_
;
53 PrefService
* pref_service_
;
55 DISALLOW_COPY_AND_ASSIGN(BookmarkExpandedStateTracker
);
58 } // namespace bookmarks
60 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_EXPANDED_STATE_TRACKER_H_