Chromium Code Reviews| Index: components/bookmarks/browser/managed_bookmarks_tracker.h |
| diff --git a/components/bookmarks/browser/managed_bookmarks_tracker.h b/components/bookmarks/browser/managed_bookmarks_tracker.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..98f109b614ffee9ef8b9900babf97831f2a863b5 |
| --- /dev/null |
| +++ b/components/bookmarks/browser/managed_bookmarks_tracker.h |
| @@ -0,0 +1,64 @@ |
| +// 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_MANAGED_BOOKMARKS_TRACKER_H_ |
| +#define COMPONENTS_BOOKMARKS_BROWSER_MANAGED_BOOKMARKS_TRACKER_H_ |
| + |
| +#include "base/macros.h" |
| +#include "base/prefs/pref_change_registrar.h" |
| +#include "base/strings/string16.h" |
| + |
| +class BookmarkModel; |
| +class BookmarkNode; |
| +class GURL; |
| +class PrefService; |
| + |
| +namespace base { |
| +class ListValue; |
| +} |
| + |
| +// Tracks the Managed Bookmarks policy value and makes the managed_node() in |
| +// the BookmarkModel follow the policy-defined bookmark tree. |
| +class ManagedBookmarksTracker { |
| + public: |
| + ManagedBookmarksTracker(BookmarkModel* model, PrefService* prefs); |
| + ~ManagedBookmarksTracker(); |
| + |
| + // Shared constants used in the policy configuration. |
| + 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.
|
| + static const char kUrl[]; |
| + static const char kChildren[]; |
| + |
| + // Returns the initial list of managed bookmarks, which can be passed to |
| + // LoadInitial() to do the initial load. |
| + scoped_ptr<base::ListValue> GetInitialManagedBookmarks(); |
| + |
| + // Loads the initial managed bookmarks in |list| into |folder|. New nodes |
| + // will be assigned IDs starting at |next_node_id|. |
| + // Returns the next node ID to use. |
| + static int64 LoadInitial(BookmarkNode* folder, |
| + const base::ListValue* list, |
| + int64 next_node_id); |
| + |
| + // Starts tracking the policy for updates to the managed bookmarks. Should |
| + // be called after loading the initial bookmarks. |
| + void Init(); |
| + |
| + private: |
| + void ReloadManagedBookmarks(); |
| + void UpdateBookmarks(const BookmarkNode* folder, const base::ListValue* list); |
| + static bool LoadBookmark(const base::ListValue* list, |
| + size_t index, |
| + base::string16* title, |
| + GURL* url, |
| + const base::ListValue** children); |
| + |
| + BookmarkModel* model_; |
| + PrefService* prefs_; |
| + PrefChangeRegistrar registrar_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ManagedBookmarksTracker); |
| +}; |
| + |
| +#endif // COMPONENTS_BOOKMARKS_BROWSER_MANAGED_BOOKMARKS_TRACKER_H_ |