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 ~BookmarkExpandedStateTracker() override
;
29 // The set of expanded nodes.
30 void SetExpandedNodes(const Nodes
& nodes
);
31 Nodes
GetExpandedNodes();
34 // BaseBookmarkModelObserver:
35 void BookmarkModelLoaded(BookmarkModel
* model
, bool ids_reassigned
) override
;
36 void BookmarkModelChanged() override
;
37 void BookmarkModelBeingDeleted(BookmarkModel
* model
) override
;
38 void BookmarkNodeRemoved(BookmarkModel
* model
,
39 const BookmarkNode
* parent
,
41 const BookmarkNode
* node
,
42 const std::set
<GURL
>& removed_urls
) override
;
43 void BookmarkAllUserNodesRemoved(BookmarkModel
* model
,
44 const std::set
<GURL
>& removed_urls
) override
;
46 // Updates the value for |prefs::kBookmarkEditorExpandedNodes| from
47 // GetExpandedNodes().
48 void UpdatePrefs(const Nodes
& nodes
);
50 BookmarkModel
* bookmark_model_
;
51 PrefService
* pref_service_
;
53 DISALLOW_COPY_AND_ASSIGN(BookmarkExpandedStateTracker
);
56 } // namespace bookmarks
58 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_EXPANDED_STATE_TRACKER_H_