Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(639)

Side by Side Diff: components/policy/core/browser/managed_bookmarks_tracker.h

Issue 305973004: BookmarkClient can add extra nodes to BookmarkModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added support for extra nodes from the client Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #ifndef COMPONENTS_POLICY_CORE_BROWSER_MANAGED_BOOKMARKS_TRACKER_H_
6 #define COMPONENTS_POLICY_CORE_BROWSER_MANAGED_BOOKMARKS_TRACKER_H_
7
8 #include "base/callback_forward.h"
9 #include "base/macros.h"
10 #include "base/prefs/pref_change_registrar.h"
11 #include "base/strings/string16.h"
12 #include "components/policy/policy_export.h"
13
14 class BookmarkModel;
15 class BookmarkNode;
16 class BookmarkPermanentNode;
17 class GURL;
18 class PrefService;
19
20 namespace base {
21 class ListValue;
22 }
23
24 namespace policy {
25
26 // Tracks the Managed Bookmarks policy value and makes the managed_node() in
27 // the BookmarkModel follow the policy-defined bookmark tree.
28 class POLICY_EXPORT ManagedBookmarksTracker {
29 public:
30 typedef base::Callback<std::string()> GetManagementDomainCallback;
31
32 // Shared constants used in the policy configuration.
33 static const char kName[];
34 static const char kUrl[];
35 static const char kChildren[];
36
37 ManagedBookmarksTracker(BookmarkModel* model,
38 PrefService* prefs,
39 const GetManagementDomainCallback& callback);
40 ~ManagedBookmarksTracker();
41
42 // Returns the initial list of managed bookmarks, which can be passed to
43 // LoadInitial() to do the initial load.
44 scoped_ptr<base::ListValue> GetInitialManagedBookmarks();
45
46 // Loads the initial managed bookmarks in |list| into |folder|. New nodes
47 // will be assigned IDs starting at |next_node_id|.
48 // Returns the next node ID to use.
49 static int64 LoadInitial(BookmarkNode* folder,
50 const base::ListValue* list,
51 int64 next_node_id);
52
53 // Starts tracking the policy for updates to the managed bookmarks. Should
54 // be called after loading the initial bookmarks.
55 void Init(BookmarkPermanentNode* managed_node);
56
57 private:
58 void ReloadManagedBookmarks();
59 void UpdateBookmarks(const BookmarkNode* folder, const base::ListValue* list);
60 static bool LoadBookmark(const base::ListValue* list,
61 size_t index,
62 base::string16* title,
63 GURL* url,
64 const base::ListValue** children);
65
66 BookmarkModel* model_;
67 BookmarkPermanentNode* managed_node_;
68 PrefService* prefs_;
69 PrefChangeRegistrar registrar_;
70 GetManagementDomainCallback get_management_domain_callback_;
71
72 DISALLOW_COPY_AND_ASSIGN(ManagedBookmarksTracker);
73 };
74
75 } // namespace policy
76
77 #endif // COMPONENTS_POLICY_CORE_BROWSER_MANAGED_BOOKMARKS_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698