Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / bookmarks / chrome_bookmark_client.h
blobe7ae884d4a7fe6974b514caaf7a4e3a331cffa0a
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"
17 class GURL;
18 class HistoryServiceFactory;
19 class Profile;
21 namespace base {
22 class ListValue;
25 namespace bookmarks {
26 class BookmarkModel;
27 class BookmarkNode;
28 class BookmarkPermanentNode;
29 class ManagedBookmarksTracker;
32 namespace history {
33 class HistoryService;
36 class ChromeBookmarkClient : public bookmarks::BookmarkClient,
37 public bookmarks::BaseBookmarkModelObserver {
38 public:
39 explicit ChromeBookmarkClient(Profile* profile);
40 ~ChromeBookmarkClient() override;
42 void Init(bookmarks::BookmarkModel* model);
44 // KeyedService:
45 void Shutdown() override;
47 // The top-level managed bookmarks folder, defined by an enterprise policy.
48 const bookmarks::BookmarkNode* managed_node() { return managed_node_; }
49 // The top-level supervised bookmarks folder, defined by the custodian of a
50 // supervised user.
51 const bookmarks::BookmarkNode* supervised_node() { return supervised_node_; }
53 // bookmarks::BookmarkClient:
54 bool PreferTouchIcon() override;
55 base::CancelableTaskTracker::TaskId GetFaviconImageForPageURL(
56 const GURL& page_url,
57 favicon_base::IconType type,
58 const favicon_base::FaviconImageCallback& callback,
59 base::CancelableTaskTracker* tracker) override;
60 bool SupportsTypedCountForNodes() override;
61 void GetTypedCountForNodes(
62 const NodeSet& nodes,
63 NodeTypedCountPairs* node_typed_count_pairs) override;
64 bool IsPermanentNodeVisible(
65 const bookmarks::BookmarkPermanentNode* node) override;
66 void RecordAction(const base::UserMetricsAction& action) override;
67 bookmarks::LoadExtraCallback GetLoadExtraNodesCallback() override;
68 bool CanSetPermanentNodeTitle(
69 const bookmarks::BookmarkNode* permanent_node) override;
70 bool CanSyncNode(const bookmarks::BookmarkNode* node) override;
71 bool CanBeEditedByUser(const bookmarks::BookmarkNode* node) override;
73 private:
74 friend class HistoryServiceFactory;
75 void SetHistoryService(history::HistoryService* history_service);
77 // bookmarks::BaseBookmarkModelObserver:
78 void BookmarkModelChanged() override;
79 void BookmarkNodeRemoved(bookmarks::BookmarkModel* model,
80 const bookmarks::BookmarkNode* parent,
81 int old_index,
82 const bookmarks::BookmarkNode* node,
83 const std::set<GURL>& removed_urls) override;
84 void BookmarkAllUserNodesRemoved(bookmarks::BookmarkModel* model,
85 const std::set<GURL>& removed_urls) override;
86 void BookmarkModelLoaded(bookmarks::BookmarkModel* model,
87 bool ids_reassigned) override;
89 // Helper for GetLoadExtraNodesCallback().
90 static bookmarks::BookmarkPermanentNodeList LoadExtraNodes(
91 scoped_ptr<bookmarks::BookmarkPermanentNode> managed_node,
92 scoped_ptr<base::ListValue> initial_managed_bookmarks,
93 scoped_ptr<bookmarks::BookmarkPermanentNode> supervised_node,
94 scoped_ptr<base::ListValue> initial_supervised_bookmarks,
95 int64* next_node_id);
97 // Returns the management domain that configured the managed bookmarks,
98 // or an empty string.
99 std::string GetManagedBookmarksDomain();
101 Profile* profile_;
103 // HistoryService associated to the Profile. Due to circular dependency, this
104 // cannot be passed to the constructor, nor lazily fetched. Instead the value
105 // is initialized from HistoryServiceFactory.
106 history::HistoryService* history_service_;
108 scoped_ptr<base::CallbackList<void(const std::set<GURL>&)>::Subscription>
109 favicon_changed_subscription_;
111 // Pointer to the BookmarkModel. Will be non-NULL from the call to Init to
112 // the call to Shutdown. Must be valid for the whole interval.
113 bookmarks::BookmarkModel* model_;
115 // Managed bookmarks are defined by an enterprise policy.
116 scoped_ptr<bookmarks::ManagedBookmarksTracker> managed_bookmarks_tracker_;
117 // The top-level managed bookmarks folder.
118 bookmarks::BookmarkPermanentNode* managed_node_;
120 // Supervised bookmarks are defined by the custodian of a supervised user.
121 scoped_ptr<bookmarks::ManagedBookmarksTracker> supervised_bookmarks_tracker_;
122 // The top-level supervised bookmarks folder.
123 bookmarks::BookmarkPermanentNode* supervised_node_;
125 DISALLOW_COPY_AND_ASSIGN(ChromeBookmarkClient);
128 #endif // CHROME_BROWSER_BOOKMARKS_CHROME_BOOKMARK_CLIENT_H_