Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / chrome / browser / bookmarks / chrome_bookmark_client.h
blob30646be27b787c205741aff18f18fdce39fe325e
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 <vector>
10 #include "base/deferred_sequenced_task_runner.h"
11 #include "base/macros.h"
12 #include "components/bookmarks/browser/base_bookmark_model_observer.h"
13 #include "components/bookmarks/browser/bookmark_client.h"
14 #include "components/policy/core/browser/managed_bookmarks_tracker.h"
15 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h"
18 class BookmarkModel;
19 class Profile;
21 class ChromeBookmarkClient : public bookmarks::BookmarkClient,
22 public content::NotificationObserver,
23 public BaseBookmarkModelObserver {
24 public:
25 explicit ChromeBookmarkClient(Profile* profile);
26 virtual ~ChromeBookmarkClient();
28 void Init(BookmarkModel* model);
30 // KeyedService:
31 virtual void Shutdown() OVERRIDE;
33 // Returns the managed_node.
34 const BookmarkNode* managed_node() { return managed_node_; }
36 // Returns true if the given node belongs to the managed bookmarks tree.
37 bool IsDescendantOfManagedNode(const BookmarkNode* node);
39 // Returns true if there is at least one managed node in the |list|.
40 bool HasDescendantsOfManagedNode(
41 const std::vector<const BookmarkNode*>& list);
43 // bookmarks::BookmarkClient:
44 virtual bool PreferTouchIcon() OVERRIDE;
45 virtual base::CancelableTaskTracker::TaskId GetFaviconImageForPageURL(
46 const GURL& page_url,
47 favicon_base::IconType type,
48 const favicon_base::FaviconImageCallback& callback,
49 base::CancelableTaskTracker* tracker) OVERRIDE;
50 virtual bool SupportsTypedCountForNodes() OVERRIDE;
51 virtual void GetTypedCountForNodes(
52 const NodeSet& nodes,
53 NodeTypedCountPairs* node_typed_count_pairs) OVERRIDE;
54 virtual bool IsPermanentNodeVisible(
55 const BookmarkPermanentNode* node) OVERRIDE;
56 virtual void RecordAction(const base::UserMetricsAction& action) OVERRIDE;
57 virtual bookmarks::LoadExtraCallback GetLoadExtraNodesCallback() OVERRIDE;
58 virtual bool CanSetPermanentNodeTitle(
59 const BookmarkNode* permanent_node) OVERRIDE;
60 virtual bool CanSyncNode(const BookmarkNode* node) OVERRIDE;
61 virtual bool CanBeEditedByUser(const BookmarkNode* node) OVERRIDE;
63 // content::NotificationObserver:
64 virtual void Observe(int type,
65 const content::NotificationSource& source,
66 const content::NotificationDetails& details) OVERRIDE;
68 private:
69 // BaseBookmarkModelObserver:
70 virtual void BookmarkModelChanged() OVERRIDE;
71 virtual void BookmarkNodeRemoved(BookmarkModel* model,
72 const BookmarkNode* parent,
73 int old_index,
74 const BookmarkNode* node,
75 const std::set<GURL>& removed_urls) OVERRIDE;
76 virtual void BookmarkAllUserNodesRemoved(
77 BookmarkModel* model,
78 const std::set<GURL>& removed_urls) OVERRIDE;
79 virtual void BookmarkModelLoaded(BookmarkModel* model,
80 bool ids_reassigned) OVERRIDE;
82 // Helper for GetLoadExtraNodesCallback().
83 static bookmarks::BookmarkPermanentNodeList LoadExtraNodes(
84 scoped_ptr<BookmarkPermanentNode> managed_node,
85 scoped_ptr<base::ListValue> initial_managed_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 content::NotificationRegistrar registrar_;
96 // Pointer to the BookmarkModel. Will be non-NULL from the call to Init to
97 // the call to Shutdown. Must be valid for the whole interval.
98 BookmarkModel* model_;
100 scoped_ptr<policy::ManagedBookmarksTracker> managed_bookmarks_tracker_;
101 BookmarkPermanentNode* managed_node_;
103 DISALLOW_COPY_AND_ASSIGN(ChromeBookmarkClient);
106 #endif // CHROME_BROWSER_BOOKMARKS_CHROME_BOOKMARK_CLIENT_H_