blob: 581330d0490ce288823dca8e5c9670daf2559388 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_EXPANDED_STATE_TRACKER_H_
#define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_EXPANDED_STATE_TRACKER_H_
#include <set>
#include "components/bookmarks/browser/base_bookmark_model_observer.h"
class BookmarkModel;
class BookmarkNode;
class PrefService;
namespace bookmarks {
// BookmarkExpandedStateTracker is used to track a set of expanded nodes. The
// nodes are persisted in preferences. If an expanded node is removed from the
// model BookmarkExpandedStateTracker removes the node.
class BookmarkExpandedStateTracker : public BaseBookmarkModelObserver {
public:
typedef std::set<const BookmarkNode*> Nodes;
BookmarkExpandedStateTracker(BookmarkModel* bookmark_model,
PrefService* pref_service);
virtual ~BookmarkExpandedStateTracker();
// The set of expanded nodes.
void SetExpandedNodes(const Nodes& nodes);
Nodes GetExpandedNodes();
private:
// BaseBookmarkModelObserver:
virtual void BookmarkModelLoaded(BookmarkModel* model,
bool ids_reassigned) override;
virtual void BookmarkModelChanged() override;
virtual void BookmarkModelBeingDeleted(BookmarkModel* model) override;
virtual void BookmarkNodeRemoved(BookmarkModel* model,
const BookmarkNode* parent,
int old_index,
const BookmarkNode* node,
const std::set<GURL>& removed_urls) override;
virtual void BookmarkAllUserNodesRemoved(
BookmarkModel* model,
const std::set<GURL>& removed_urls) override;
// Updates the value for |prefs::kBookmarkEditorExpandedNodes| from
// GetExpandedNodes().
void UpdatePrefs(const Nodes& nodes);
BookmarkModel* bookmark_model_;
PrefService* pref_service_;
DISALLOW_COPY_AND_ASSIGN(BookmarkExpandedStateTracker);
};
} // namespace bookmarks
#endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_EXPANDED_STATE_TRACKER_H_
|