[AndroidWebViewShell] Replace rebaseline script with a new version using test_runner.py
[chromium-blink-merge.git] / components / bookmarks / browser / bookmark_client.h
blob3ea0269cface46c0d34da06088515e635f1c517a
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.
5 #ifndef COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_CLIENT_H_
6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_CLIENT_H_
8 #include <set>
9 #include <utility>
10 #include <vector>
12 #include "base/callback_forward.h"
13 #include "base/task/cancelable_task_tracker.h"
14 #include "components/bookmarks/browser/bookmark_storage.h"
15 #include "components/favicon_base/favicon_callback.h"
16 #include "components/favicon_base/favicon_types.h"
17 #include "components/keyed_service/core/keyed_service.h"
19 class GURL;
21 namespace base {
22 struct UserMetricsAction;
25 namespace bookmarks {
27 class BookmarkNode;
28 class BookmarkPermanentNode;
30 // This class abstracts operations that depends on the embedder's environment,
31 // e.g. Chrome.
32 class BookmarkClient : public KeyedService {
33 public:
34 // 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 // the Omnibox.
37 typedef std::set<const BookmarkNode*> NodeSet;
38 typedef std::pair<const BookmarkNode*, int> NodeTypedCountPair;
39 typedef std::vector<NodeTypedCountPair> NodeTypedCountPairs;
41 // Returns true if the embedder favors touch icons over favicons.
42 virtual bool PreferTouchIcon();
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:
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
48 // history cache is resized if need be.
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
51 // |type|.
52 virtual base::CancelableTaskTracker::TaskId GetFaviconImageForPageURL(
53 const GURL& page_url,
54 favicon_base::IconType type,
55 const favicon_base::FaviconImageCallback& callback,
56 base::CancelableTaskTracker* tracker);
58 // Returns true if the embedder supports typed count for URL.
59 virtual bool SupportsTypedCountForNodes();
61 // Retrieves the number of time each BookmarkNode URL has been typed in
62 // the Omnibox by the user.
63 virtual void GetTypedCountForNodes(
64 const NodeSet& nodes,
65 NodeTypedCountPairs* node_typed_count_pairs);
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;
71 // Wrapper around RecordAction defined in base/metrics/user_metrics.h
72 // that ensure that the action is posted from the correct thread.
73 virtual void RecordAction(const base::UserMetricsAction& action) = 0;
75 // 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.
77 virtual LoadExtraCallback GetLoadExtraNodesCallback() = 0;
79 // Returns true if the |permanent_node| can have its title updated.
80 virtual bool CanSetPermanentNodeTitle(const BookmarkNode* permanent_node) = 0;
82 // Returns true if |node| should sync.
83 virtual bool CanSyncNode(const BookmarkNode* node) = 0;
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;
91 protected:
92 ~BookmarkClient() override {}
95 } // namespace bookmarks
97 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_CLIENT_H_