Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / bookmarks / bookmark_expanded_state_tracker.h
blob99ee84331596c33f2cba7308dd2bc5f41337a310
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_
8 #include <set>
10 #include "chrome/browser/bookmarks/base_bookmark_model_observer.h"
12 class BookmarkModel;
13 class BookmarkNode;
14 class PrefService;
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 {
20 public:
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();
31 private:
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,
39 int old_index,
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_