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

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

Issue 769153007: Managed bookmarks for supervised users (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix build (Android & unit_tests) Created 5 years, 10 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
OLDNEW
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 GURL; 14 class GURL;
15 class PrefService; 15 class PrefService;
16 16
17 namespace base { 17 namespace base {
18 class ListValue; 18 class ListValue;
19 } 19 }
20 20
21 namespace bookmarks { 21 namespace bookmarks {
22 class BookmarkModel; 22 class BookmarkModel;
23 class BookmarkNode; 23 class BookmarkNode;
24 class BookmarkPermanentNode; 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 either the Managed Bookmarks pref (set by policy) or the Supervised
30 // the BookmarkModel follow the policy-defined bookmark tree. 30 // Bookmarks pref (set for a supervised user by their custodian) and makes the
31 // managed_node()/supervised_node() in the BookmarkModel follow the
32 // policy/custodian-defined bookmark tree.
31 class POLICY_EXPORT ManagedBookmarksTracker { 33 class POLICY_EXPORT ManagedBookmarksTracker {
32 public: 34 public:
33 typedef base::Callback<std::string()> GetManagementDomainCallback; 35 typedef base::Callback<std::string()> GetManagementDomainCallback;
34 36
35 // Shared constants used in the policy configuration. 37 // Shared constants used in the policy configuration.
36 static const char kName[]; 38 static const char kName[];
37 static const char kUrl[]; 39 static const char kUrl[];
38 static const char kChildren[]; 40 static const char kChildren[];
39 41
42 // If |is_supervised| is true, this will track supervised bookmarks rather
43 // than managed bookmarks.
40 ManagedBookmarksTracker(bookmarks::BookmarkModel* model, 44 ManagedBookmarksTracker(bookmarks::BookmarkModel* model,
41 PrefService* prefs, 45 PrefService* prefs,
46 bool is_supervised,
42 const GetManagementDomainCallback& callback); 47 const GetManagementDomainCallback& callback);
43 ~ManagedBookmarksTracker(); 48 ~ManagedBookmarksTracker();
44 49
45 // Returns the initial list of managed bookmarks, which can be passed to 50 // Returns the initial list of managed bookmarks, which can be passed to
46 // LoadInitial() to do the initial load. 51 // LoadInitial() to do the initial load.
47 scoped_ptr<base::ListValue> GetInitialManagedBookmarks(); 52 scoped_ptr<base::ListValue> GetInitialManagedBookmarks();
48 53
49 // Loads the initial managed bookmarks in |list| into |folder|. New nodes 54 // Loads the initial managed/supervised bookmarks in |list| into |folder|.
50 // will be assigned IDs starting at |next_node_id|. 55 // New nodes will be assigned IDs starting at |next_node_id|.
51 // Returns the next node ID to use. 56 // Returns the next node ID to use.
52 static int64 LoadInitial(bookmarks::BookmarkNode* folder, 57 static int64 LoadInitial(bookmarks::BookmarkNode* folder,
53 const base::ListValue* list, 58 const base::ListValue* list,
54 int64 next_node_id); 59 int64 next_node_id);
55 60
56 // Starts tracking the policy for updates to the managed bookmarks. Should 61 // Starts tracking the pref for updates to the managed/supervised bookmarks.
57 // be called after loading the initial bookmarks. 62 // Should be called after loading the initial bookmarks.
58 void Init(bookmarks::BookmarkPermanentNode* managed_node); 63 void Init(bookmarks::BookmarkPermanentNode* managed_node);
59 64
65 bool is_supervised() const { return is_supervised_; }
66
67 // Public for testing.
68 static const char* GetPrefName(bool is_supervised);
69
60 private: 70 private:
71 const char* GetPrefName() const;
72 base::string16 GetBookmarksFolderTitle() const;
73
61 void ReloadManagedBookmarks(); 74 void ReloadManagedBookmarks();
75
62 void UpdateBookmarks(const bookmarks::BookmarkNode* folder, 76 void UpdateBookmarks(const bookmarks::BookmarkNode* folder,
63 const base::ListValue* list); 77 const base::ListValue* list);
64 static bool LoadBookmark(const base::ListValue* list, 78 static bool LoadBookmark(const base::ListValue* list,
65 size_t index, 79 size_t index,
66 base::string16* title, 80 base::string16* title,
67 GURL* url, 81 GURL* url,
68 const base::ListValue** children); 82 const base::ListValue** children);
69 83
70 bookmarks::BookmarkModel* model_; 84 bookmarks::BookmarkModel* model_;
85 const bool is_supervised_;
71 bookmarks::BookmarkPermanentNode* managed_node_; 86 bookmarks::BookmarkPermanentNode* managed_node_;
72 PrefService* prefs_; 87 PrefService* prefs_;
73 PrefChangeRegistrar registrar_; 88 PrefChangeRegistrar registrar_;
74 GetManagementDomainCallback get_management_domain_callback_; 89 GetManagementDomainCallback get_management_domain_callback_;
75 90
76 DISALLOW_COPY_AND_ASSIGN(ManagedBookmarksTracker); 91 DISALLOW_COPY_AND_ASSIGN(ManagedBookmarksTracker);
77 }; 92 };
78 93
79 } // namespace policy 94 } // namespace policy
80 95
81 #endif // COMPONENTS_POLICY_CORE_BROWSER_MANAGED_BOOKMARKS_TRACKER_H_ 96 #endif // COMPONENTS_POLICY_CORE_BROWSER_MANAGED_BOOKMARKS_TRACKER_H_
82 97
OLDNEW
« no previous file with comments | « components/bookmarks/common/bookmark_pref_names.cc ('k') | components/policy/core/browser/managed_bookmarks_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698