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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: components/bookmarks/core/browser/bookmark_client.h
diff --git a/components/bookmarks/core/browser/bookmark_client.h b/components/bookmarks/core/browser/bookmark_client.h
new file mode 100644
index 0000000000000000000000000000000000000000..beff22b1bf1bdc0bc16c8ef50296f8d562163e05
--- /dev/null
+++ b/components/bookmarks/core/browser/bookmark_client.h
@@ -0,0 +1,85 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_BOOKMARKS_CORE_BROWSER_BOOKMARK_CLIENT_H_
+#define COMPONENTS_BOOKMARKS_CORE_BROWSER_BOOKMARK_CLIENT_H_
+
+#include <set>
+#include <vector>
+
+#include "base/callback.h"
+#include "base/task/cancelable_task_tracker.h"
+
+class GURL;
+class BookmarkNode;
+class BookmarkModel;
+
+namespace base {
+struct UserMetricsAction;
+}
+
+namespace favicon_base {
+struct FaviconImageResult;
+}
+
+namespace tracked_objects {
+class Location;
tfarina 2014/04/22 21:19:58 Can you remove this? It looks unused.
sdefresne 2014/04/23 16:10:18 Done.
+}
+
+// This class abstracts operations that depends on the embedder's environment,
+// e.g. Chrome.
+class BookmarkClient {
+ public:
+ // Callback for GetFaviconImageForURL().
+ typedef base::Callback<void(const favicon_base::FaviconImageResult&)>
+ FaviconImageCallback;
+
+ // Types representing a set of BookmarkNode and a mapping from BookmarkNode
+ // to the number of time the corresponding URL has been typed by the user in
+ // the Omnibox.
+ typedef std::set<const BookmarkNode*> NodeSet;
+ typedef std::pair<const BookmarkNode*, int> NodeTypedCountPair;
+ typedef std::vector<NodeTypedCountPair> NodeTypedCountPairs;
+
+ // Requests the favicon of any of |icon_types| whose pixel sizes most
+ // closely match |desired_size_in_dip| (if value is 0, the largest favicon
+ // is returned) and desired scale factor for |page_url|. |callback| is run
+ // when the bits have been fetched. |icon_types| can be any combination of
+ // IconType value, but only one icon will be returned.
+ virtual base::CancelableTaskTracker::TaskId GetFaviconImageForURL(
+ const GURL& page_url,
+ int icon_types,
+ int desired_size_in_dip,
+ const FaviconImageCallback& callback,
+ base::CancelableTaskTracker* tracker) = 0;
+
+ // Returns true if the embedder supports typed count for URL.
+ virtual bool SupportsTypedCountForNodes() = 0;
+
+ // Retrieves the number of time each BookmarkNode URL has been typed in
+ // the Omnibox by the user.
+ virtual void GetTypedCountForNodes(
+ const NodeSet& nodes,
+ NodeTypedCountPairs* node_typed_count_pairs) = 0;
+
+ // Wrapper around RecordAction defined in base/metrics/user_metrics.h
+ // that ensure that the action is posted from the correct thread.
+ virtual void RecordAction(const base::UserMetricsAction& action) = 0;
+
+ 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.
+ 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
+
+ virtual void OnLoad() = 0;
+
+ 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.
+
+ // Notifies the history backend about urls of removed bookmarks.
+ virtual void NotifyHistoryAboutRemovedBookmarks(
+ const std::set<GURL>& removed_bookmark_urls) = 0;
+
+ protected:
+ virtual ~BookmarkClient() {}
+};
+
+#endif // COMPONENTS_BOOKMARKS_CORE_BROWSER_BOOKMARK_CLIENT_H_

Powered by Google App Engine
This is Rietveld 408576698