Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / components / bookmarks / browser / bookmark_client.h
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_BROWSER_BOOKMARK_CLIENT_H_
6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_CLIENT_H_
7
8 #include <set>
9 #include <utility>
10 #include <vector>
11
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"
18
19 class BookmarkNode;
20 class BookmarkPermanentNode;
21 class GURL;
22
23 namespace base {
24 struct UserMetricsAction;
25 }
26
27 namespace bookmarks {
28
29 // This class abstracts operations that depends on the embedder's environment,
30 // e.g. Chrome.
31 class BookmarkClient : public KeyedService {
32  public:
33   // Types representing a set of BookmarkNode and a mapping from BookmarkNode
34   // to the number of time the corresponding URL has been typed by the user in
35   // the Omnibox.
36   typedef std::set<const BookmarkNode*> NodeSet;
37   typedef std::pair<const BookmarkNode*, int> NodeTypedCountPair;
38   typedef std::vector<NodeTypedCountPair> NodeTypedCountPairs;
39
40   // Returns true if the embedder favors touch icons over favicons.
41   virtual bool PreferTouchIcon();
42
43   // Requests a favicon from the history cache for the web page at |page_url|.
44   // |callback| is run when the favicon has been fetched. If |type| is:
45   // - favicon_base::FAVICON, the returned gfx::Image is a multi-resolution
46   //   image of gfx::kFaviconSize DIP width and height. The data from the
47   //   history cache is resized if need be.
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(
52       const GURL& page_url,
53       favicon_base::IconType type,
54       const favicon_base::FaviconImageCallback& callback,
55       base::CancelableTaskTracker* tracker);
56
57     // Returns true if the embedder supports typed count for URL.
58   virtual bool SupportsTypedCountForNodes();
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);
65
66   // Returns whether the embedder wants permanent node |node|
67   // to always be visible or to only show them when not empty.
68   virtual bool IsPermanentNodeVisible(const BookmarkPermanentNode* node) = 0;
69
70   // Wrapper around RecordAction defined in base/metrics/user_metrics.h
71   // that ensure that the action is posted from the correct thread.
72   virtual void RecordAction(const base::UserMetricsAction& action) = 0;
73
74   // Returns a task that will be used to load any additional root nodes. This
75   // task will be invoked in the Profile's IO task runner.
76   virtual LoadExtraCallback GetLoadExtraNodesCallback() = 0;
77
78   // Returns true if the |permanent_node| can have its title updated.
79   virtual bool CanSetPermanentNodeTitle(const BookmarkNode* permanent_node) = 0;
80
81   // Returns true if |node| should sync.
82   virtual bool CanSyncNode(const BookmarkNode* node) = 0;
83
84   // Returns true if this node can be edited by the user.
85   // TODO(joaodasilva): the model should check this more aggressively, and
86   // should give the client a means to temporarily disable those checks.
87   // http://crbug.com/49598
88   virtual bool CanBeEditedByUser(const BookmarkNode* node) = 0;
89
90  protected:
91   ~BookmarkClient() override {}
92 };
93
94 }  // namespace bookmarks
95
96 #endif  // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_CLIENT_H_