OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_POLICY_CORE_BROWSER_MANAGED_BOOKMARKS_TRACKER_H_ | 5 #ifndef COMPONENTS_POLICY_CORE_BROWSER_MANAGED_BOOKMARKS_TRACKER_H_ |
6 #define COMPONENTS_POLICY_CORE_BROWSER_MANAGED_BOOKMARKS_TRACKER_H_ | 6 #define COMPONENTS_POLICY_CORE_BROWSER_MANAGED_BOOKMARKS_TRACKER_H_ |
7 | 7 |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/prefs/pref_change_registrar.h" | 10 #include "base/prefs/pref_change_registrar.h" |
(...skipping 16 matching lines...) Expand all Loading... | |
27 // the BookmarkModel follow the policy-defined bookmark tree. | 27 // the BookmarkModel follow the policy-defined bookmark tree. |
28 class POLICY_EXPORT ManagedBookmarksTracker { | 28 class POLICY_EXPORT ManagedBookmarksTracker { |
29 public: | 29 public: |
30 typedef base::Callback<std::string()> GetManagementDomainCallback; | 30 typedef base::Callback<std::string()> GetManagementDomainCallback; |
31 | 31 |
32 // Shared constants used in the policy configuration. | 32 // Shared constants used in the policy configuration. |
33 static const char kName[]; | 33 static const char kName[]; |
34 static const char kUrl[]; | 34 static const char kUrl[]; |
35 static const char kChildren[]; | 35 static const char kChildren[]; |
36 | 36 |
37 ManagedBookmarksTracker(BookmarkModel* model, | 37 ManagedBookmarksTracker(BookmarkModel* model, |
Pam (message me for reviews)
2015/01/14 14:03:37
Please add a comment explaining |is_supervised|.
Marc Treib
2015/01/14 16:40:50
Done. I've also added a class-level comment, and u
| |
38 PrefService* prefs, | 38 PrefService* prefs, |
39 bool is_supervised, | |
39 const GetManagementDomainCallback& callback); | 40 const GetManagementDomainCallback& callback); |
40 ~ManagedBookmarksTracker(); | 41 ~ManagedBookmarksTracker(); |
41 | 42 |
42 // Returns the initial list of managed bookmarks, which can be passed to | 43 // Returns the initial list of managed bookmarks, which can be passed to |
43 // LoadInitial() to do the initial load. | 44 // LoadInitial() to do the initial load. |
44 scoped_ptr<base::ListValue> GetInitialManagedBookmarks(); | 45 scoped_ptr<base::ListValue> GetInitialManagedBookmarks(); |
45 | 46 |
46 // Loads the initial managed bookmarks in |list| into |folder|. New nodes | 47 // Loads the initial managed bookmarks in |list| into |folder|. New nodes |
47 // will be assigned IDs starting at |next_node_id|. | 48 // will be assigned IDs starting at |next_node_id|. |
48 // Returns the next node ID to use. | 49 // Returns the next node ID to use. |
49 static int64 LoadInitial(BookmarkNode* folder, | 50 static int64 LoadInitial(BookmarkNode* folder, |
50 const base::ListValue* list, | 51 const base::ListValue* list, |
51 int64 next_node_id); | 52 int64 next_node_id); |
52 | 53 |
53 // Starts tracking the policy for updates to the managed bookmarks. Should | 54 // Starts tracking the policy for updates to the managed bookmarks. Should |
54 // be called after loading the initial bookmarks. | 55 // be called after loading the initial bookmarks. |
55 void Init(BookmarkPermanentNode* managed_node); | 56 void Init(BookmarkPermanentNode* managed_node); |
56 | 57 |
58 bool is_supervised() const { return is_supervised_; } | |
59 | |
60 // Public for testing. | |
61 static const char* GetPrefName(bool is_supervised); | |
62 | |
57 private: | 63 private: |
64 const char* GetPrefName() const; | |
65 base::string16 GetBookmarksFolderTitle() const; | |
66 | |
58 void ReloadManagedBookmarks(); | 67 void ReloadManagedBookmarks(); |
68 | |
59 void UpdateBookmarks(const BookmarkNode* folder, const base::ListValue* list); | 69 void UpdateBookmarks(const BookmarkNode* folder, const base::ListValue* list); |
60 static bool LoadBookmark(const base::ListValue* list, | 70 static bool LoadBookmark(const base::ListValue* list, |
61 size_t index, | 71 size_t index, |
62 base::string16* title, | 72 base::string16* title, |
63 GURL* url, | 73 GURL* url, |
64 const base::ListValue** children); | 74 const base::ListValue** children); |
65 | 75 |
66 BookmarkModel* model_; | 76 BookmarkModel* model_; |
77 bool is_supervised_; | |
67 BookmarkPermanentNode* managed_node_; | 78 BookmarkPermanentNode* managed_node_; |
68 PrefService* prefs_; | 79 PrefService* prefs_; |
69 PrefChangeRegistrar registrar_; | 80 PrefChangeRegistrar registrar_; |
70 GetManagementDomainCallback get_management_domain_callback_; | 81 GetManagementDomainCallback get_management_domain_callback_; |
71 | 82 |
72 DISALLOW_COPY_AND_ASSIGN(ManagedBookmarksTracker); | 83 DISALLOW_COPY_AND_ASSIGN(ManagedBookmarksTracker); |
73 }; | 84 }; |
74 | 85 |
75 } // namespace policy | 86 } // namespace policy |
76 | 87 |
77 #endif // COMPONENTS_POLICY_CORE_BROWSER_MANAGED_BOOKMARKS_TRACKER_H_ | 88 #endif // COMPONENTS_POLICY_CORE_BROWSER_MANAGED_BOOKMARKS_TRACKER_H_ |
OLD | NEW |