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

Side by Side Diff: components/bookmarks/managed/managed_bookmark_service.h

Issue 1233673002: Fix componentization of chrome/browser/bookmarks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix "gn check" and compilation on Mac Created 5 years, 5 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_BOOKMARKS_MANAGED_MANAGED_BOOKMARK_SERVICE_H_
6 #define COMPONENTS_BOOKMARKS_MANAGED_MANAGED_BOOKMARK_SERVICE_H_
7
8 #include <string>
9
10 #include "base/callback_forward.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "components/bookmarks/browser/base_bookmark_model_observer.h"
14 #include "components/bookmarks/browser/bookmark_node.h"
15 #include "components/bookmarks/browser/bookmark_storage.h"
16 #include "components/keyed_service/core/keyed_service.h"
17
18 class PrefService;
19
20 namespace bookmarks {
21
22 class BookmarkModel;
23 class ManagedBookmarksTracker;
24
25 // ManagedBookmarkService manages the bookmark folder controlled by enterprise
26 // policy or custodian of supervised users.
27 class ManagedBookmarkService : public KeyedService,
28 public BaseBookmarkModelObserver {
29 public:
30 typedef base::Callback<std::string()> GetManagementDomainCallback;
31
32 ManagedBookmarkService(PrefService* prefs,
33 const GetManagementDomainCallback& callback);
34 ~ManagedBookmarkService() override;
35
36 // Called upon creation of the BookmarkModel.
37 void BookmarkModelCreated(BookmarkModel* bookmark_model);
38
39 // Returns a task that will be used to load any additional root nodes. This
40 // task will be invoked in the Profile's IO task runner.
41 LoadExtraCallback GetLoadExtraNodesCallback();
42
43 // Returns true if the |node| can have its title updated.
44 bool CanSetPermanentNodeTitle(const BookmarkNode* node);
45
46 // Returns true if |node| should sync.
47 bool CanSyncNode(const BookmarkNode* node);
48
49 // Returns true if |node| can be edited by the user.
50 // TODO(joaodasilva): the model should check this more aggressively, and
51 // should give the client a means to temporarily disable those checks.
52 // http://crbug.com/49598
53 bool CanBeEditedByUser(const BookmarkNode* node);
54
55 // Top-level managed bookmarks folder, defined by an enterprise policy; may be
56 // null.
57 const BookmarkNode* managed_node() { return managed_node_; }
58
59 // Top-level supervised bookmarks folder, defined by the custodian of a
60 // supervised user; may be null.
61 const BookmarkNode* supervised_node() { return supervised_node_; }
62
63 private:
64 // KeyedService implementation.
65 void Shutdown() override;
66
67 // BaseBookmarkModelObserver implementation.
68 void BookmarkModelChanged() override;
69
70 // BookmarkModelObserver implementation.
71 void BookmarkModelLoaded(bookmarks::BookmarkModel* bookmark_model,
72 bool ids_reassigned) override;
73 void BookmarkModelBeingDeleted(BookmarkModel* bookmark_model) override;
74
75 // Cleanup, called when service is shutdown or when BookmarkModel is being
76 // destroyed.
77 void Cleanup();
78
79 // Pointer to the PrefService. Must outlive ManagedBookmarkService.
80 PrefService* prefs_;
81
82 // Pointer to the BookmarkModel; may be null. Only valid between the calls to
83 // BookmarkModelCreated() and to BookmarkModelBeingDestroyed().
84 BookmarkModel* bookmark_model_;
85
86 // Managed bookmarks are defined by an enterprise policy. The lifetime of the
87 // BookmarkPermanentNode is controlled by BookmarkModel.
88 scoped_ptr<ManagedBookmarksTracker> managed_bookmarks_tracker_;
89 GetManagementDomainCallback managed_domain_callback_;
90 BookmarkPermanentNode* managed_node_;
91
92 // Supervised bookmarks are defined by the custodian of a supervised user. The
93 // lifetime of the BookmarkPermanentNode is controlled by BookmarkModel.
94 scoped_ptr<ManagedBookmarksTracker> supervised_bookmarks_tracker_;
95 BookmarkPermanentNode* supervised_node_;
96
97 DISALLOW_COPY_AND_ASSIGN(ManagedBookmarkService);
98 };
99
100 } // namespace bookmarks
101
102 #endif // COMPONENTS_BOOKMARKS_MANAGED_MANAGED_BOOKMARK_SERVICE_H_
OLDNEW
« no previous file with comments | « components/bookmarks/managed/BUILD.gn ('k') | components/bookmarks/managed/managed_bookmark_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698