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