Allow immediate snapping after scrolling starts
[chromium-blink-merge.git] / components / enhanced_bookmarks / metadata_accessor.h
blob313705b497fce2e7d4fdfb4cbf31ef340af072a9
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_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_
6 #define COMPONENTS_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_
8 #include <set>
9 #include <string>
10 #include <vector>
12 class BookmarkModel;
13 class BookmarkNode;
14 class GURL;
16 // TODO(rfevang): Remove this file once the remaining caller
17 // is converted (enhanced_bookmarks_bridge.cc)
19 // The functions in this file store and retrieve structured data encoded in the
20 // bookmark metadata. This information suplements the data in the bookmark with
21 // images and descriptions related to the url.
22 namespace enhanced_bookmarks {
24 typedef std::vector<const BookmarkNode*> NodeVector;
25 typedef std::set<const BookmarkNode*> NodeSet;
27 // The keys used to store the data in the bookmarks metadata dictionary.
28 extern const char* kPageDataKey;
29 extern const char* kImageDataKey;
30 extern const char* kIdDataKey;
31 extern const char* kNoteKey;
33 // Returns the remoteId for a bookmark. If the bookmark doesn't have one already
34 // this function will create and set one.
35 std::string RemoteIdFromBookmark(BookmarkModel* bookmark_model,
36 const BookmarkNode* node);
38 // Sets the description of a bookmark.
39 void SetDescriptionForBookmark(BookmarkModel* bookmark_model,
40 const BookmarkNode* node,
41 const std::string& description);
43 // Returns the description of a bookmark.
44 std::string DescriptionFromBookmark(const BookmarkNode* node);
46 // Sets the URL of an image representative of the page.
47 // Expects the URL to be valid and not empty.
48 // Returns true if the metainfo is successfully populated.
49 bool SetOriginalImageForBookmark(BookmarkModel* bookmark_model,
50 const BookmarkNode* node,
51 const GURL& url,
52 int width,
53 int height);
55 // Returns the url and dimensions of the original scraped image.
56 // Returns true if the out variables are populated, false otherwise.
57 bool OriginalImageFromBookmark(const BookmarkNode* node,
58 GURL* url,
59 int* width,
60 int* height);
62 // Returns the url and dimensions of the server provided thumbnail image.
63 // Returns true if the out variables are populated, false otherwise.
64 bool ThumbnailImageFromBookmark(const BookmarkNode* node,
65 GURL* url,
66 int* width,
67 int* height);
69 // Returns a brief server provided synopsis of the bookmarked page.
70 // Returns the empty string if the snippet could not be extracted.
71 std::string SnippetFromBookmark(const BookmarkNode* node);
73 // Used for testing, simulates the process that creates the thumnails. Will
74 // remove existing entries for empty urls or set them if the url is not empty.
75 // expects valid or empty urls. Returns true if the metainfo is successfully
76 // populated.
77 bool SetAllImagesForBookmark(BookmarkModel* bookmark_model,
78 const BookmarkNode* node,
79 const GURL& image_url,
80 int image_width,
81 int image_height,
82 const GURL& thumbnail_url,
83 int thumbnail_width,
84 int thumbnail_height);
86 } // namespace enhanced_bookmarks
88 #endif // COMPONENTS_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_