OLD | NEW |
---|---|
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_CORE_BROWSER_BOOKMARK_CLIENT_H_ | 5 #ifndef COMPONENTS_BOOKMARKS_CORE_BROWSER_BOOKMARK_CLIENT_H_ |
6 #define COMPONENTS_BOOKMARKS_CORE_BROWSER_BOOKMARK_CLIENT_H_ | 6 #define COMPONENTS_BOOKMARKS_CORE_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/task/cancelable_task_tracker.h" | 13 #include "base/task/cancelable_task_tracker.h" |
14 #include "components/favicon_base/favicon_callback.h" | |
14 | 15 |
15 class BookmarkNode; | 16 class BookmarkNode; |
16 class GURL; | 17 class GURL; |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 struct UserMetricsAction; | 20 struct UserMetricsAction; |
20 } | 21 } |
21 | 22 |
22 namespace favicon_base { | 23 namespace favicon_base { |
23 struct FaviconImageResult; | 24 struct FaviconImageResult; |
tfarina
2014/05/16 20:30:17
you can remove this forward declaration now, it is
Jiang Jiang
2014/05/16 20:56:16
Done.
| |
24 } | 25 } |
25 | 26 |
26 // This class abstracts operations that depends on the embedder's environment, | 27 // This class abstracts operations that depends on the embedder's environment, |
27 // e.g. Chrome. | 28 // e.g. Chrome. |
28 class BookmarkClient { | 29 class BookmarkClient { |
29 public: | 30 public: |
30 // Callback for GetFaviconImageForURL(). | |
31 typedef base::Callback<void(const favicon_base::FaviconImageResult&)> | |
32 FaviconImageCallback; | |
33 | |
34 // Types representing a set of BookmarkNode and a mapping from BookmarkNode | 31 // 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 | 32 // to the number of time the corresponding URL has been typed by the user in |
36 // the Omnibox. | 33 // the Omnibox. |
37 typedef std::set<const BookmarkNode*> NodeSet; | 34 typedef std::set<const BookmarkNode*> NodeSet; |
38 typedef std::pair<const BookmarkNode*, int> NodeTypedCountPair; | 35 typedef std::pair<const BookmarkNode*, int> NodeTypedCountPair; |
39 typedef std::vector<NodeTypedCountPair> NodeTypedCountPairs; | 36 typedef std::vector<NodeTypedCountPair> NodeTypedCountPairs; |
40 | 37 |
41 // Returns true if the embedder favors touch icons over favicons. | 38 // Returns true if the embedder favors touch icons over favicons. |
42 virtual bool PreferTouchIcon(); | 39 virtual bool PreferTouchIcon(); |
43 | 40 |
44 // Requests the favicon of any of |icon_types| whose pixel sizes most | 41 // Requests the favicon of any of |icon_types| whose pixel sizes most |
45 // closely match |desired_size_in_dip| (if value is 0, the largest favicon | 42 // closely match |desired_size_in_dip| (if value is 0, the largest favicon |
46 // is returned) and desired scale factor for |page_url|. |callback| is run | 43 // is returned) and desired scale factor for |page_url|. |callback| is run |
47 // when the bits have been fetched. |icon_types| can be any combination of | 44 // when the bits have been fetched. |icon_types| can be any combination of |
48 // IconType value, but only one icon will be returned. | 45 // IconType value, but only one icon will be returned. |
49 virtual base::CancelableTaskTracker::TaskId GetFaviconImageForURL( | 46 virtual base::CancelableTaskTracker::TaskId GetFaviconImageForURL( |
50 const GURL& page_url, | 47 const GURL& page_url, |
51 int icon_types, | 48 int icon_types, |
52 int desired_size_in_dip, | 49 int desired_size_in_dip, |
53 const FaviconImageCallback& callback, | 50 const favicon_base::FaviconImageCallback& callback, |
54 base::CancelableTaskTracker* tracker); | 51 base::CancelableTaskTracker* tracker); |
55 | 52 |
56 // Returns true if the embedder supports typed count for URL. | 53 // Returns true if the embedder supports typed count for URL. |
57 virtual bool SupportsTypedCountForNodes(); | 54 virtual bool SupportsTypedCountForNodes(); |
58 | 55 |
59 // Retrieves the number of time each BookmarkNode URL has been typed in | 56 // Retrieves the number of time each BookmarkNode URL has been typed in |
60 // the Omnibox by the user. | 57 // the Omnibox by the user. |
61 virtual void GetTypedCountForNodes( | 58 virtual void GetTypedCountForNodes( |
62 const NodeSet& nodes, | 59 const NodeSet& nodes, |
63 NodeTypedCountPairs* node_typed_count_pairs); | 60 NodeTypedCountPairs* node_typed_count_pairs); |
64 | 61 |
65 // Returns whether the embedder wants permanent node of type |node_type| | 62 // Returns whether the embedder wants permanent node of type |node_type| |
66 // to always be visible or to only show them when not empty. | 63 // to always be visible or to only show them when not empty. |
67 virtual bool IsPermanentNodeVisible(int node_type) = 0; | 64 virtual bool IsPermanentNodeVisible(int node_type) = 0; |
68 | 65 |
69 // Wrapper around RecordAction defined in base/metrics/user_metrics.h | 66 // Wrapper around RecordAction defined in base/metrics/user_metrics.h |
70 // that ensure that the action is posted from the correct thread. | 67 // that ensure that the action is posted from the correct thread. |
71 virtual void RecordAction(const base::UserMetricsAction& action) = 0; | 68 virtual void RecordAction(const base::UserMetricsAction& action) = 0; |
72 | 69 |
73 protected: | 70 protected: |
74 virtual ~BookmarkClient() {} | 71 virtual ~BookmarkClient() {} |
75 }; | 72 }; |
76 | 73 |
77 #endif // COMPONENTS_BOOKMARKS_CORE_BROWSER_BOOKMARK_CLIENT_H_ | 74 #endif // COMPONENTS_BOOKMARKS_CORE_BROWSER_BOOKMARK_CLIENT_H_ |
OLD | NEW |