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

Side by Side Diff: components/bookmarks/browser/bookmark_client.h

Issue 1203713002: Limit access to ChromeBookmarkClient to bookmarks code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup_bookmark_client
Patch Set: Rebase Created 5 years, 6 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_BOOKMARKS_BROWSER_BOOKMARK_CLIENT_H_ 5 #ifndef COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_CLIENT_H_
6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_CLIENT_H_ 6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_CLIENT_H_
7 7
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
13 #include "base/memory/scoped_ptr.h"
13 #include "base/task/cancelable_task_tracker.h" 14 #include "base/task/cancelable_task_tracker.h"
14 #include "components/bookmarks/browser/bookmark_storage.h" 15 #include "components/bookmarks/browser/bookmark_storage.h"
15 #include "components/favicon_base/favicon_callback.h" 16 #include "components/favicon_base/favicon_callback.h"
16 #include "components/favicon_base/favicon_types.h" 17 #include "components/favicon_base/favicon_types.h"
17 #include "components/keyed_service/core/keyed_service.h" 18 #include "components/keyed_service/core/keyed_service.h"
18 19
19 class GURL; 20 class GURL;
20 21
21 namespace base { 22 namespace base {
22 struct UserMetricsAction; 23 struct UserMetricsAction;
23 } 24 }
24 25
25 namespace bookmarks { 26 namespace bookmarks {
26 27
27 class BookmarkNode; 28 class BookmarkNode;
28 class BookmarkPermanentNode; 29 class BookmarkPermanentNode;
29 30
30 // This class abstracts operations that depends on the embedder's environment, 31 // This class abstracts operations that depends on the embedder's environment,
31 // e.g. Chrome. 32 // e.g. Chrome.
32 class BookmarkClient : public KeyedService { 33 class BookmarkClient : public KeyedService {
33 public: 34 public:
34 // Types representing a set of BookmarkNode and a mapping from BookmarkNode 35 // Types representing a set of BookmarkNode and a mapping from BookmarkNode
35 // to the number of time the corresponding URL has been typed by the user in 36 // to the number of time the corresponding URL has been typed by the user in
36 // the Omnibox. 37 // the Omnibox.
37 typedef std::set<const BookmarkNode*> NodeSet; 38 typedef std::set<const BookmarkNode*> NodeSet;
38 typedef std::pair<const BookmarkNode*, int> NodeTypedCountPair; 39 typedef std::pair<const BookmarkNode*, int> NodeTypedCountPair;
39 typedef std::vector<NodeTypedCountPair> NodeTypedCountPairs; 40 typedef std::vector<NodeTypedCountPair> NodeTypedCountPairs;
40 41 typedef base::Callback<void(BookmarkPermanentNode*, BookmarkPermanentNode*)>
41 // Returns true if the embedder favors touch icons over favicons. 42 ExtraNodeLoadedCallback;
42 virtual bool PreferTouchIcon();
43 43
44 // Requests a favicon from the history cache for the web page at |page_url|. 44 // Requests a favicon from the history cache for the web page at |page_url|.
45 // |callback| is run when the favicon has been fetched. If |type| is: 45 // |callback| is run when the favicon has been fetched. If |type| is:
46 // - favicon_base::FAVICON, the returned gfx::Image is a multi-resolution 46 // - favicon_base::FAVICON, the returned gfx::Image is a multi-resolution
47 // image of gfx::kFaviconSize DIP width and height. The data from the 47 // image of gfx::kFaviconSize DIP width and height. The data from the
48 // history cache is resized if need be. 48 // history cache is resized if need be.
49 // - not favicon_base::FAVICON, the returned gfx::Image is a single-resolution 49 // - not favicon_base::FAVICON, the returned gfx::Image is a single-resolution
50 // image with the largest bitmap in the history cache for |page_url| and 50 // image with the largest bitmap in the history cache for |page_url| and
51 // |type|. 51 // |type|.
52 virtual base::CancelableTaskTracker::TaskId GetFaviconImageForPageURL( 52 virtual base::CancelableTaskTracker::TaskId GetFaviconImageForPageURL(
53 const GURL& page_url, 53 const GURL& page_url,
54 favicon_base::IconType type, 54 favicon_base::IconType type,
55 const favicon_base::FaviconImageCallback& callback, 55 const favicon_base::FaviconImageCallback& callback,
56 base::CancelableTaskTracker* tracker); 56 base::CancelableTaskTracker* tracker);
57 57
58 // Returns true if the embedder supports typed count for URL. 58 // Returns true if the embedder supports typed count for URL.
59 virtual bool SupportsTypedCountForNodes(); 59 virtual bool SupportsTypedCountForNodes();
60 60
61 // Retrieves the number of time each BookmarkNode URL has been typed in 61 // Retrieves the number of time each BookmarkNode URL has been typed in
62 // the Omnibox by the user. 62 // the Omnibox by the user.
63 virtual void GetTypedCountForNodes( 63 virtual void GetTypedCountForNodes(
64 const NodeSet& nodes, 64 const NodeSet& nodes,
65 NodeTypedCountPairs* node_typed_count_pairs); 65 NodeTypedCountPairs* node_typed_count_pairs);
66 66
67 // Returns whether the embedder wants permanent node |node|
68 // to always be visible or to only show them when not empty.
69 virtual bool IsPermanentNodeVisible(const BookmarkPermanentNode* node) = 0;
70
71 // Wrapper around RecordAction defined in base/metrics/user_metrics.h 67 // Wrapper around RecordAction defined in base/metrics/user_metrics.h
72 // that ensure that the action is posted from the correct thread. 68 // that ensure that the action is posted from the correct thread.
73 virtual void RecordAction(const base::UserMetricsAction& action) = 0; 69 virtual void RecordAction(const base::UserMetricsAction& action) = 0;
74 70
75 // Returns a task that will be used to load any additional root nodes. This 71 // Returns a task that will be used to load any additional root nodes. This
76 // task will be invoked in the Profile's IO task runner. 72 // task will be invoked in the Profile's IO task runner.
sky 2015/06/23 22:03:53 Document what callback is.
77 virtual LoadExtraCallback GetLoadExtraNodesCallback() = 0; 73 virtual LoadExtraCallback GetLoadExtraNodesCallback(
74 scoped_ptr<BookmarkPermanentNode> managed_node,
75 scoped_ptr<BookmarkPermanentNode> supervised_node,
76 const ExtraNodeLoadedCallback& callback) = 0;
78 77
79 // Returns true if the |permanent_node| can have its title updated. 78 // Called when BookmarkModel finished loading.
80 virtual bool CanSetPermanentNodeTitle(const BookmarkNode* permanent_node) = 0; 79 virtual void DoneLoading(BookmarkPermanentNode* managed_node,
81 80 BookmarkPermanentNode* supervised_node) = 0;
82 // Returns true if |node| should sync.
83 virtual bool CanSyncNode(const BookmarkNode* node) = 0;
84
85 // Returns true if this node can be edited by the user.
86 // TODO(joaodasilva): the model should check this more aggressively, and
87 // should give the client a means to temporarily disable those checks.
88 // http://crbug.com/49598
89 virtual bool CanBeEditedByUser(const BookmarkNode* node) = 0;
90 81
91 protected: 82 protected:
92 ~BookmarkClient() override {} 83 ~BookmarkClient() override {}
93 }; 84 };
94 85
95 } // namespace bookmarks 86 } // namespace bookmarks
96 87
97 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_CLIENT_H_ 88 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698