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" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "components/policy/policy_export.h" | 12 #include "components/policy/policy_export.h" |
13 | 13 |
14 class BookmarkNode; | |
15 class BookmarkPermanentNode; | |
16 class GURL; | 14 class GURL; |
17 class PrefService; | 15 class PrefService; |
18 | 16 |
19 namespace base { | 17 namespace base { |
20 class ListValue; | 18 class ListValue; |
21 } | 19 } |
22 | 20 |
23 namespace bookmarks { | 21 namespace bookmarks { |
24 class BookmarkModel; | 22 class BookmarkModel; |
23 class BookmarkNode; | |
24 class BookmarkPermanentNode; | |
25 } | 25 } |
26 | 26 |
27 namespace policy { | 27 namespace policy { |
28 | 28 |
29 // Tracks the Managed Bookmarks policy value and makes the managed_node() in | 29 // Tracks the Managed Bookmarks policy value and makes the managed_node() in |
30 // the BookmarkModel follow the policy-defined bookmark tree. | 30 // the BookmarkModel follow the policy-defined bookmark tree. |
31 class POLICY_EXPORT ManagedBookmarksTracker { | 31 class POLICY_EXPORT ManagedBookmarksTracker { |
32 public: | 32 public: |
33 typedef base::Callback<std::string()> GetManagementDomainCallback; | 33 typedef base::Callback<std::string()> GetManagementDomainCallback; |
34 | 34 |
35 // Shared constants used in the policy configuration. | 35 // Shared constants used in the policy configuration. |
36 static const char kName[]; | 36 static const char kName[]; |
37 static const char kUrl[]; | 37 static const char kUrl[]; |
38 static const char kChildren[]; | 38 static const char kChildren[]; |
39 | 39 |
40 ManagedBookmarksTracker(bookmarks::BookmarkModel* model, | 40 ManagedBookmarksTracker(bookmarks::BookmarkModel* model, |
41 PrefService* prefs, | 41 PrefService* prefs, |
42 const GetManagementDomainCallback& callback); | 42 const GetManagementDomainCallback& callback); |
43 ~ManagedBookmarksTracker(); | 43 ~ManagedBookmarksTracker(); |
44 | 44 |
45 // Returns the initial list of managed bookmarks, which can be passed to | 45 // Returns the initial list of managed bookmarks, which can be passed to |
46 // LoadInitial() to do the initial load. | 46 // LoadInitial() to do the initial load. |
47 scoped_ptr<base::ListValue> GetInitialManagedBookmarks(); | 47 scoped_ptr<base::ListValue> GetInitialManagedBookmarks(); |
48 | 48 |
49 // Loads the initial managed bookmarks in |list| into |folder|. New nodes | 49 // Loads the initial managed bookmarks in |list| into |folder|. New nodes |
50 // will be assigned IDs starting at |next_node_id|. | 50 // will be assigned IDs starting at |next_node_id|. |
51 // Returns the next node ID to use. | 51 // Returns the next node ID to use. |
52 static int64 LoadInitial(BookmarkNode* folder, | 52 static int64 LoadInitial(bookmarks::BookmarkNode* folder, |
53 const base::ListValue* list, | 53 const base::ListValue* list, |
54 int64 next_node_id); | 54 int64 next_node_id); |
55 | 55 |
56 // Starts tracking the policy for updates to the managed bookmarks. Should | 56 // Starts tracking the policy for updates to the managed bookmarks. Should |
57 // be called after loading the initial bookmarks. | 57 // be called after loading the initial bookmarks. |
58 void Init(BookmarkPermanentNode* managed_node); | 58 void Init(bookmarks::BookmarkPermanentNode* managed_node); |
59 | 59 |
60 private: | 60 private: |
61 void ReloadManagedBookmarks(); | 61 void ReloadManagedBookmarks(); |
62 void UpdateBookmarks(const BookmarkNode* folder, const base::ListValue* list); | 62 void UpdateBookmarks(const bookmarks::BookmarkNode* folder, |
63 const base::ListValue* list); | |
63 static bool LoadBookmark(const base::ListValue* list, | 64 static bool LoadBookmark(const base::ListValue* list, |
64 size_t index, | 65 size_t index, |
65 base::string16* title, | 66 base::string16* title, |
66 GURL* url, | 67 GURL* url, |
67 const base::ListValue** children); | 68 const base::ListValue** children); |
68 | 69 |
69 bookmarks::BookmarkModel* model_; | 70 bookmarks::BookmarkModel* model_; |
70 BookmarkPermanentNode* managed_node_; | 71 bookmarks::BookmarkPermanentNode* managed_node_; |
71 PrefService* prefs_; | 72 PrefService* prefs_; |
72 PrefChangeRegistrar registrar_; | 73 PrefChangeRegistrar registrar_; |
73 GetManagementDomainCallback get_management_domain_callback_; | 74 GetManagementDomainCallback get_management_domain_callback_; |
74 | 75 |
75 DISALLOW_COPY_AND_ASSIGN(ManagedBookmarksTracker); | 76 DISALLOW_COPY_AND_ASSIGN(ManagedBookmarksTracker); |
76 }; | 77 }; |
77 | 78 |
78 } // namespace policy | 79 } // namespace policy |
79 | 80 |
80 #endif // COMPONENTS_POLICY_CORE_BROWSER_MANAGED_BOOKMARKS_TRACKER_H_ | 81 #endif // COMPONENTS_POLICY_CORE_BROWSER_MANAGED_BOOKMARKS_TRACKER_H_ |
82 | |
Joao da Silva
2015/02/05 10:12:58
nit: remove this newline in some future CL
| |
OLD | NEW |