[Hotword] Remove optin_client.js now that optin bubble display happens from search...
[chromium-blink-merge.git] / components / enhanced_bookmarks / metadata_accessor.h
blob2f20aae31b455808ee8c58a9dfe7a3cd76882922
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 // The functions in this file store and retrieve structured data encoded in the
17 // bookmark metadata. This information suplements the data in the bookmark with
18 // images and descriptions related to the url.
19 namespace enhanced_bookmarks {
21 typedef std::vector<const BookmarkNode*> NodeVector;
22 typedef std::set<const BookmarkNode*> NodeSet;
24 // The keys used to store the data in the bookmarks metadata dictionary.
25 extern const char* kPageDataKey;
26 extern const char* kImageDataKey;
27 extern const char* kIdDataKey;
28 extern const char* kNoteKey;
30 // Returns the remoteId for a bookmark. If the bookmark doesn't have one already
31 // this function will create and set one.
32 std::string RemoteIdFromBookmark(BookmarkModel* bookmark_model,
33 const BookmarkNode* node);
35 // Sets the description of a bookmark.
36 void SetDescriptionForBookmark(BookmarkModel* bookmark_model,
37 const BookmarkNode* node,
38 const std::string& description);
40 // Returns the description of a bookmark.
41 std::string DescriptionFromBookmark(const BookmarkNode* node);
43 // Sets the URL of an image representative of the page.
44 // Expects the URL to be valid and not empty.
45 // Returns true if the metainfo is successfully populated.
46 bool SetOriginalImageForBookmark(BookmarkModel* bookmark_model,
47 const BookmarkNode* node,
48 const GURL& url,
49 int width,
50 int height);
52 // Returns the url and dimensions of the original scraped image.
53 // Returns true if the out variables are populated, false otherwise.
54 bool OriginalImageFromBookmark(const BookmarkNode* node,
55 GURL* url,
56 int* width,
57 int* height);
59 // Returns the url and dimensions of the server provided thumbnail image.
60 // Returns true if the out variables are populated, false otherwise.
61 bool ThumbnailImageFromBookmark(const BookmarkNode* node,
62 GURL* url,
63 int* width,
64 int* height);
66 // Returns a brief server provided synopsis of the bookmarked page.
67 // Returns the empty string if the snippet could not be extracted.
68 std::string SnippetFromBookmark(const BookmarkNode* node);
70 // Used for testing, simulates the process that creates the thumnails. Will
71 // remove existing entries for empty urls or set them if the url is not empty.
72 // expects valid or empty urls. Returns true if the metainfo is successfully
73 // populated.
74 bool SetAllImagesForBookmark(BookmarkModel* bookmark_model,
75 const BookmarkNode* node,
76 const GURL& image_url,
77 int image_width,
78 int image_height,
79 const GURL& thumbnail_url,
80 int thumbnail_width,
81 int thumbnail_height);
83 } // namespace enhanced_bookmarks
85 #endif // COMPONENTS_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_