Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_BOOKMARKS_BROWSER_MANAGED_BOOKMARKS_TRACKER_H_ | |
| 6 #define COMPONENTS_BOOKMARKS_BROWSER_MANAGED_BOOKMARKS_TRACKER_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/prefs/pref_change_registrar.h" | |
| 10 #include "base/strings/string16.h" | |
| 11 | |
| 12 class BookmarkModel; | |
| 13 class BookmarkNode; | |
| 14 class GURL; | |
| 15 class PrefService; | |
| 16 | |
| 17 namespace base { | |
| 18 class ListValue; | |
| 19 } | |
| 20 | |
| 21 // Tracks the Managed Bookmarks policy value and makes the managed_node() in | |
| 22 // the BookmarkModel follow the policy-defined bookmark tree. | |
| 23 class ManagedBookmarksTracker { | |
| 24 public: | |
| 25 ManagedBookmarksTracker(BookmarkModel* model, PrefService* prefs); | |
| 26 ~ManagedBookmarksTracker(); | |
| 27 | |
| 28 // Shared constants used in the policy configuration. | |
| 29 static const char kName[]; | |
|
sky
2014/05/30 22:31:37
nit: constants before constructor.
Joao da Silva
2014/06/01 13:32:07
Done.
| |
| 30 static const char kUrl[]; | |
| 31 static const char kChildren[]; | |
| 32 | |
| 33 // Returns the initial list of managed bookmarks, which can be passed to | |
| 34 // LoadInitial() to do the initial load. | |
| 35 scoped_ptr<base::ListValue> GetInitialManagedBookmarks(); | |
| 36 | |
| 37 // Loads the initial managed bookmarks in |list| into |folder|. New nodes | |
| 38 // will be assigned IDs starting at |next_node_id|. | |
| 39 // Returns the next node ID to use. | |
| 40 static int64 LoadInitial(BookmarkNode* folder, | |
| 41 const base::ListValue* list, | |
| 42 int64 next_node_id); | |
| 43 | |
| 44 // Starts tracking the policy for updates to the managed bookmarks. Should | |
| 45 // be called after loading the initial bookmarks. | |
| 46 void Init(); | |
| 47 | |
| 48 private: | |
| 49 void ReloadManagedBookmarks(); | |
| 50 void UpdateBookmarks(const BookmarkNode* folder, const base::ListValue* list); | |
| 51 static bool LoadBookmark(const base::ListValue* list, | |
| 52 size_t index, | |
| 53 base::string16* title, | |
| 54 GURL* url, | |
| 55 const base::ListValue** children); | |
| 56 | |
| 57 BookmarkModel* model_; | |
| 58 PrefService* prefs_; | |
| 59 PrefChangeRegistrar registrar_; | |
| 60 | |
| 61 DISALLOW_COPY_AND_ASSIGN(ManagedBookmarksTracker); | |
| 62 }; | |
| 63 | |
| 64 #endif // COMPONENTS_BOOKMARKS_BROWSER_MANAGED_BOOKMARKS_TRACKER_H_ | |
| OLD | NEW |