| 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_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/task/cancelable_task_tracker.h" | 13 #include "base/task/cancelable_task_tracker.h" |
| 14 #include "components/bookmarks/browser/bookmark_storage.h" | 14 #include "components/bookmarks/browser/bookmark_storage.h" |
| 15 #include "components/favicon_base/favicon_callback.h" | 15 #include "components/favicon_base/favicon_callback.h" |
| 16 #include "components/favicon_base/favicon_types.h" |
| 16 #include "components/keyed_service/core/keyed_service.h" | 17 #include "components/keyed_service/core/keyed_service.h" |
| 17 | 18 |
| 18 class BookmarkNode; | 19 class BookmarkNode; |
| 19 class BookmarkPermanentNode; | 20 class BookmarkPermanentNode; |
| 20 class GURL; | 21 class GURL; |
| 21 | 22 |
| 22 namespace base { | 23 namespace base { |
| 23 struct UserMetricsAction; | 24 struct UserMetricsAction; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace bookmarks { | 27 namespace bookmarks { |
| 27 | 28 |
| 28 // This class abstracts operations that depends on the embedder's environment, | 29 // This class abstracts operations that depends on the embedder's environment, |
| 29 // e.g. Chrome. | 30 // e.g. Chrome. |
| 30 class BookmarkClient : public KeyedService { | 31 class BookmarkClient : public KeyedService { |
| 31 public: | 32 public: |
| 32 // Types representing a set of BookmarkNode and a mapping from BookmarkNode | 33 // Types representing a set of BookmarkNode and a mapping from BookmarkNode |
| 33 // to the number of time the corresponding URL has been typed by the user in | 34 // to the number of time the corresponding URL has been typed by the user in |
| 34 // the Omnibox. | 35 // the Omnibox. |
| 35 typedef std::set<const BookmarkNode*> NodeSet; | 36 typedef std::set<const BookmarkNode*> NodeSet; |
| 36 typedef std::pair<const BookmarkNode*, int> NodeTypedCountPair; | 37 typedef std::pair<const BookmarkNode*, int> NodeTypedCountPair; |
| 37 typedef std::vector<NodeTypedCountPair> NodeTypedCountPairs; | 38 typedef std::vector<NodeTypedCountPair> NodeTypedCountPairs; |
| 38 | 39 |
| 39 // Returns true if the embedder favors touch icons over favicons. | 40 // Returns true if the embedder favors touch icons over favicons. |
| 40 virtual bool PreferTouchIcon(); | 41 virtual bool PreferTouchIcon(); |
| 41 | 42 |
| 42 // Requests the favicon of any of |icon_types| whose pixel sizes most | 43 // Requests a favicon from the history cache for the web page at |page_url|. |
| 43 // closely match |desired_size_in_dip| (if value is 0, the largest favicon | 44 // |callback| is run when the favicon has been fetched. If |type| is: |
| 44 // is returned) and desired scale factor for |page_url|. |callback| is run | 45 // - favicon_base::FAVICON, the returned gfx::Image is a multi-resolution |
| 45 // when the bits have been fetched. |icon_types| can be any combination of | 46 // image of gfx::kFaviconSize DIP width and height. The data from the |
| 46 // IconType value, but only one icon will be returned. | 47 // history cache is resized if need be. |
| 47 virtual base::CancelableTaskTracker::TaskId GetFaviconImageForURL( | 48 // - not favicon_base::FAVICON, the returned gfx::Image is a single-resolution |
| 49 // image with the largest bitmap in the history cache for |page_url| and |
| 50 // |type|. |
| 51 virtual base::CancelableTaskTracker::TaskId GetFaviconImageForPageURL( |
| 48 const GURL& page_url, | 52 const GURL& page_url, |
| 49 int icon_types, | 53 favicon_base::IconType type, |
| 50 int desired_size_in_dip, | |
| 51 const favicon_base::FaviconImageCallback& callback, | 54 const favicon_base::FaviconImageCallback& callback, |
| 52 base::CancelableTaskTracker* tracker); | 55 base::CancelableTaskTracker* tracker); |
| 53 | 56 |
| 54 // Returns true if the embedder supports typed count for URL. | 57 // Returns true if the embedder supports typed count for URL. |
| 55 virtual bool SupportsTypedCountForNodes(); | 58 virtual bool SupportsTypedCountForNodes(); |
| 56 | 59 |
| 57 // Retrieves the number of time each BookmarkNode URL has been typed in | 60 // Retrieves the number of time each BookmarkNode URL has been typed in |
| 58 // the Omnibox by the user. | 61 // the Omnibox by the user. |
| 59 virtual void GetTypedCountForNodes( | 62 virtual void GetTypedCountForNodes( |
| 60 const NodeSet& nodes, | 63 const NodeSet& nodes, |
| 61 NodeTypedCountPairs* node_typed_count_pairs); | 64 NodeTypedCountPairs* node_typed_count_pairs); |
| 62 | 65 |
| 63 // Returns whether the embedder wants permanent node |node| | 66 // Returns whether the embedder wants permanent node |node| |
| 64 // to always be visible or to only show them when not empty. | 67 // to always be visible or to only show them when not empty. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 84 // http://crbug.com/49598 | 87 // http://crbug.com/49598 |
| 85 virtual bool CanBeEditedByUser(const BookmarkNode* node) = 0; | 88 virtual bool CanBeEditedByUser(const BookmarkNode* node) = 0; |
| 86 | 89 |
| 87 protected: | 90 protected: |
| 88 virtual ~BookmarkClient() {} | 91 virtual ~BookmarkClient() {} |
| 89 }; | 92 }; |
| 90 | 93 |
| 91 } // namespace bookmarks | 94 } // namespace bookmarks |
| 92 | 95 |
| 93 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_CLIENT_H_ | 96 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_CLIENT_H_ |
| OLD | NEW |