ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chrome / browser / bookmarks / chrome_bookmark_client.h
bloba7f023e5f3bd741a3fff0124da2848e34ced884e
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_BOOKMARKS_CHROME_BOOKMARK_CLIENT_H_
6 #define CHROME_BROWSER_BOOKMARKS_CHROME_BOOKMARK_CLIENT_H_
8 #include <set>
9 #include <vector>
11 #include "base/callback_list.h"
12 #include "base/deferred_sequenced_task_runner.h"
13 #include "base/macros.h"
14 #include "components/bookmarks/browser/base_bookmark_model_observer.h"
15 #include "components/bookmarks/browser/bookmark_client.h"
16 #include "components/policy/core/browser/managed_bookmarks_tracker.h"
18 class GURL;
19 class HistoryService;
20 class HistoryServiceFactory;
21 class Profile;
23 namespace bookmarks {
24 class BookmarkModel;
27 class ChromeBookmarkClient : public bookmarks::BookmarkClient,
28 public bookmarks::BaseBookmarkModelObserver {
29 public:
30 explicit ChromeBookmarkClient(Profile* profile);
31 ~ChromeBookmarkClient() override;
33 void Init(bookmarks::BookmarkModel* model);
35 // KeyedService:
36 void Shutdown() override;
38 // The top-level managed bookmarks folder, defined by an enterprise policy.
39 const bookmarks::BookmarkNode* managed_node() { return managed_node_; }
40 // The top-level supervised bookmarks folder, defined by the custodian of a
41 // supervised user.
42 const bookmarks::BookmarkNode* supervised_node() { return supervised_node_; }
44 // bookmarks::BookmarkClient:
45 bool PreferTouchIcon() override;
46 base::CancelableTaskTracker::TaskId GetFaviconImageForPageURL(
47 const GURL& page_url,
48 favicon_base::IconType type,
49 const favicon_base::FaviconImageCallback& callback,
50 base::CancelableTaskTracker* tracker) override;
51 bool SupportsTypedCountForNodes() override;
52 void GetTypedCountForNodes(
53 const NodeSet& nodes,
54 NodeTypedCountPairs* node_typed_count_pairs) override;
55 bool IsPermanentNodeVisible(
56 const bookmarks::BookmarkPermanentNode* node) override;
57 void RecordAction(const base::UserMetricsAction& action) override;
58 bookmarks::LoadExtraCallback GetLoadExtraNodesCallback() override;
59 bool CanSetPermanentNodeTitle(
60 const bookmarks::BookmarkNode* permanent_node) override;
61 bool CanSyncNode(const bookmarks::BookmarkNode* node) override;
62 bool CanBeEditedByUser(const bookmarks::BookmarkNode* node) override;
64 private:
65 friend class HistoryServiceFactory;
66 void SetHistoryService(HistoryService* history_service);
68 // bookmarks::BaseBookmarkModelObserver:
69 void BookmarkModelChanged() override;
70 void BookmarkNodeRemoved(bookmarks::BookmarkModel* model,
71 const bookmarks::BookmarkNode* parent,
72 int old_index,
73 const bookmarks::BookmarkNode* node,
74 const std::set<GURL>& removed_urls) override;
75 void BookmarkAllUserNodesRemoved(bookmarks::BookmarkModel* model,
76 const std::set<GURL>& removed_urls) override;
77 void BookmarkModelLoaded(bookmarks::BookmarkModel* model,
78 bool ids_reassigned) override;
80 // Helper for GetLoadExtraNodesCallback().
81 static bookmarks::BookmarkPermanentNodeList LoadExtraNodes(
82 scoped_ptr<bookmarks::BookmarkPermanentNode> managed_node,
83 scoped_ptr<base::ListValue> initial_managed_bookmarks,
84 scoped_ptr<bookmarks::BookmarkPermanentNode> supervised_node,
85 scoped_ptr<base::ListValue> initial_supervised_bookmarks,
86 int64* next_node_id);
88 // Returns the management domain that configured the managed bookmarks,
89 // or an empty string.
90 std::string GetManagedBookmarksDomain();
92 Profile* profile_;
94 // HistoryService associated to the Profile. Due to circular dependency, this
95 // cannot be passed to the constructor, nor lazily fetched. Instead the value
96 // is initialized from HistoryServiceFactory.
97 HistoryService* history_service_;
99 scoped_ptr<base::CallbackList<void(const std::set<GURL>&)>::Subscription>
100 favicon_changed_subscription_;
102 // Pointer to the BookmarkModel. Will be non-NULL from the call to Init to
103 // the call to Shutdown. Must be valid for the whole interval.
104 bookmarks::BookmarkModel* model_;
106 // Managed bookmarks are defined by an enterprise policy.
107 scoped_ptr<policy::ManagedBookmarksTracker> managed_bookmarks_tracker_;
108 // The top-level managed bookmarks folder.
109 bookmarks::BookmarkPermanentNode* managed_node_;
111 // Supervised bookmarks are defined by the custodian of a supervised user.
112 scoped_ptr<policy::ManagedBookmarksTracker> supervised_bookmarks_tracker_;
113 // The top-level supervised bookmarks folder.
114 bookmarks::BookmarkPermanentNode* supervised_node_;
116 DISALLOW_COPY_AND_ASSIGN(ChromeBookmarkClient);
119 #endif // CHROME_BROWSER_BOOKMARKS_CHROME_BOOKMARK_CLIENT_H_