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

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

Issue 242693003: Introduce BookmarkClient interface to abstract embedder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 8 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
(Empty)
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.
4
5 #ifndef COMPONENTS_BOOKMARKS_CORE_BROWSER_BOOKMARK_CLIENT_H_
6 #define COMPONENTS_BOOKMARKS_CORE_BROWSER_BOOKMARK_CLIENT_H_
7
8 #include <set>
9 #include <vector>
10
11 #include "base/callback.h"
12 #include "base/task/cancelable_task_tracker.h"
13
14 class GURL;
15 class BookmarkNode;
16 class BookmarkModel;
17
18 namespace base {
19 struct UserMetricsAction;
20 }
21
22 namespace favicon_base {
23 struct FaviconImageResult;
24 }
25
26 namespace tracked_objects {
27 class Location;
tfarina 2014/04/22 21:19:58 Can you remove this? It looks unused.
sdefresne 2014/04/23 16:10:18 Done.
28 }
29
30 // This class abstracts operations that depends on the embedder's environment,
31 // e.g. Chrome.
32 class BookmarkClient {
33 public:
34 // Callback for GetFaviconImageForURL().
35 typedef base::Callback<void(const favicon_base::FaviconImageResult&)>
36 FaviconImageCallback;
37
38 // Types representing a set of BookmarkNode and a mapping from BookmarkNode
39 // to the number of time the corresponding URL has been typed by the user in
40 // the Omnibox.
41 typedef std::set<const BookmarkNode*> NodeSet;
42 typedef std::pair<const BookmarkNode*, int> NodeTypedCountPair;
43 typedef std::vector<NodeTypedCountPair> NodeTypedCountPairs;
44
45 // Requests the favicon of any of |icon_types| whose pixel sizes most
46 // closely match |desired_size_in_dip| (if value is 0, the largest favicon
47 // is returned) and desired scale factor for |page_url|. |callback| is run
48 // when the bits have been fetched. |icon_types| can be any combination of
49 // IconType value, but only one icon will be returned.
50 virtual base::CancelableTaskTracker::TaskId GetFaviconImageForURL(
51 const GURL& page_url,
52 int icon_types,
53 int desired_size_in_dip,
54 const FaviconImageCallback& callback,
55 base::CancelableTaskTracker* tracker) = 0;
56
57 // Returns true if the embedder supports typed count for URL.
58 virtual bool SupportsTypedCountForNodes() = 0;
59
60 // Retrieves the number of time each BookmarkNode URL has been typed in
61 // the Omnibox by the user.
62 virtual void GetTypedCountForNodes(
63 const NodeSet& nodes,
64 NodeTypedCountPairs* node_typed_count_pairs) = 0;
65
66 // Wrapper around RecordAction defined in base/metrics/user_metrics.h
67 // that ensure that the action is posted from the correct thread.
68 virtual void RecordAction(const base::UserMetricsAction& action) = 0;
69
70 private:
tfarina 2014/04/22 21:19:58 protected section should come before the private s
sdefresne 2014/04/23 16:10:18 I removed the private section.
71 friend class BookmarkModel;
tfarina 2014/04/22 21:19:58 Why do they need to be friends?
sdefresne 2014/04/23 16:10:18 They needed to be friend to call OnLoad / OnClearS
72
73 virtual void OnLoad() = 0;
74
75 virtual void OnClearStore() = 0;
tfarina 2014/04/22 21:19:58 Could you add docs for this method? If, me, as an
sdefresne 2014/04/23 16:10:18 Removed it.
76
77 // Notifies the history backend about urls of removed bookmarks.
78 virtual void NotifyHistoryAboutRemovedBookmarks(
79 const std::set<GURL>& removed_bookmark_urls) = 0;
80
81 protected:
82 virtual ~BookmarkClient() {}
83 };
84
85 #endif // COMPONENTS_BOOKMARKS_CORE_BROWSER_BOOKMARK_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698