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

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: new string&icons; rebase Created 5 years, 11 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 BookmarkNode; 14 class BookmarkNode;
15 class BookmarkPermanentNode; 15 class BookmarkPermanentNode;
16 class GURL; 16 class GURL;
17 class PrefService; 17 class PrefService;
18 18
19 namespace base { 19 namespace base {
20 class ListValue; 20 class ListValue;
21 } 21 }
22 22
23 namespace bookmarks { 23 namespace bookmarks {
24 class BookmarkModel; 24 class BookmarkModel;
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(BookmarkNode* folder, 57 static int64 LoadInitial(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 policy for updates to the managed/supervised bookmarks.
bartfab (slow) 2015/01/26 15:40:14 Nit: s/policy/pref/
Marc Treib 2015/01/26 16:16:47 Done.
57 // be called after loading the initial bookmarks. 62 // Should be called after loading the initial bookmarks.
58 void Init(BookmarkPermanentNode* managed_node); 63 void Init(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;
bartfab (slow) 2015/01/26 15:40:14 Nit: #include "base/strings/string16.h"
Marc Treib 2015/01/26 16:16:47 That's already there.
73
61 void ReloadManagedBookmarks(); 74 void ReloadManagedBookmarks();
75
62 void UpdateBookmarks(const BookmarkNode* folder, const base::ListValue* list); 76 void UpdateBookmarks(const BookmarkNode* folder, const base::ListValue* list);
63 static bool LoadBookmark(const base::ListValue* list, 77 static bool LoadBookmark(const base::ListValue* list,
64 size_t index, 78 size_t index,
65 base::string16* title, 79 base::string16* title,
66 GURL* url, 80 GURL* url,
67 const base::ListValue** children); 81 const base::ListValue** children);
68 82
69 bookmarks::BookmarkModel* model_; 83 bookmarks::BookmarkModel* model_;
84 bool is_supervised_;
bartfab (slow) 2015/01/26 15:40:14 Nit: const.
Marc Treib 2015/01/26 16:16:47 Done.
70 BookmarkPermanentNode* managed_node_; 85 BookmarkPermanentNode* managed_node_;
71 PrefService* prefs_; 86 PrefService* prefs_;
72 PrefChangeRegistrar registrar_; 87 PrefChangeRegistrar registrar_;
73 GetManagementDomainCallback get_management_domain_callback_; 88 GetManagementDomainCallback get_management_domain_callback_;
74 89
75 DISALLOW_COPY_AND_ASSIGN(ManagedBookmarksTracker); 90 DISALLOW_COPY_AND_ASSIGN(ManagedBookmarksTracker);
76 }; 91 };
77 92
78 } // namespace policy 93 } // namespace policy
79 94
80 #endif // COMPONENTS_POLICY_CORE_BROWSER_MANAGED_BOOKMARKS_TRACKER_H_ 95 #endif // COMPONENTS_POLICY_CORE_BROWSER_MANAGED_BOOKMARKS_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698