Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / components / bookmarks / browser / bookmark_expanded_state_tracker.h
blob6aadaf260135e69ec45c0b9937a75dc0fe549c78
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_
8 #include <set>
10 #include "components/bookmarks/browser/base_bookmark_model_observer.h"
12 class BookmarkModel;
13 class BookmarkNode;
14 class PrefService;
16 namespace bookmarks {
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 {
22 public:
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();
33 private:
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,
41 int old_index,
42 const BookmarkNode* node,
43 const std::set<GURL>& removed_urls) OVERRIDE;
44 virtual void BookmarkAllUserNodesRemoved(
45 BookmarkModel* model,
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_