blob: dea97b20c14232daecd4a28034fb0520320e2d9a [file] [log] [blame]
[email protected]e244e1a2014-06-20 09:47:371// 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_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_
6#define COMPONENTS_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_
7
8#include <set>
9#include <string>
10#include <vector>
11
[email protected]e244e1a2014-06-20 09:47:3712class GURL;
13
tfarinaa0ec34e2015-01-12 18:46:4814namespace bookmarks {
15class BookmarkModel;
tfarinaa665b3082015-02-04 22:10:5016class BookmarkNode;
tfarinaa0ec34e2015-01-12 18:46:4817}
18
rfevanga1bf3af92014-09-09 23:07:4119// TODO(rfevang): Remove this file once the remaining caller
20// is converted (enhanced_bookmarks_bridge.cc)
21
[email protected]e244e1a2014-06-20 09:47:3722// 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.
25namespace enhanced_bookmarks {
26
tfarinaa665b3082015-02-04 22:10:5027typedef std::vector<const bookmarks::BookmarkNode*> NodeVector;
28typedef std::set<const bookmarks::BookmarkNode*> NodeSet;
[email protected]e244e1a2014-06-20 09:47:3729
30// The keys used to store the data in the bookmarks metadata dictionary.
31extern const char* kPageDataKey;
32extern const char* kImageDataKey;
33extern const char* kIdDataKey;
34extern const char* kNoteKey;
35
36// Returns the remoteId for a bookmark. If the bookmark doesn't have one already
37// this function will create and set one.
tfarinaa0ec34e2015-01-12 18:46:4838std::string RemoteIdFromBookmark(bookmarks::BookmarkModel* bookmark_model,
tfarinaa665b3082015-02-04 22:10:5039 const bookmarks::BookmarkNode* node);
[email protected]e244e1a2014-06-20 09:47:3740
41// Sets the description of a bookmark.
tfarinaa0ec34e2015-01-12 18:46:4842void SetDescriptionForBookmark(bookmarks::BookmarkModel* bookmark_model,
tfarinaa665b3082015-02-04 22:10:5043 const bookmarks::BookmarkNode* node,
[email protected]e244e1a2014-06-20 09:47:3744 const std::string& description);
45
46// Returns the description of a bookmark.
tfarinaa665b3082015-02-04 22:10:5047std::string DescriptionFromBookmark(const bookmarks::BookmarkNode* node);
[email protected]e244e1a2014-06-20 09:47:3748
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.
tfarinaa0ec34e2015-01-12 18:46:4852bool SetOriginalImageForBookmark(bookmarks::BookmarkModel* bookmark_model,
tfarinaa665b3082015-02-04 22:10:5053 const bookmarks::BookmarkNode* node,
[email protected]e244e1a2014-06-20 09:47:3754 const GURL& url,
55 int width,
56 int height);
57
58// Returns the url and dimensions of the original scraped image.
59// Returns true if the out variables are populated, false otherwise.
tfarinaa665b3082015-02-04 22:10:5060bool OriginalImageFromBookmark(const bookmarks::BookmarkNode* node,
[email protected]e244e1a2014-06-20 09:47:3761 GURL* url,
62 int* width,
63 int* height);
64
65// Returns the url and dimensions of the server provided thumbnail image.
66// Returns true if the out variables are populated, false otherwise.
tfarinaa665b3082015-02-04 22:10:5067bool ThumbnailImageFromBookmark(const bookmarks::BookmarkNode* node,
[email protected]e244e1a2014-06-20 09:47:3768 GURL* url,
69 int* width,
70 int* height);
71
72// Returns a brief server provided synopsis of the bookmarked page.
73// Returns the empty string if the snippet could not be extracted.
tfarinaa665b3082015-02-04 22:10:5074std::string SnippetFromBookmark(const bookmarks::BookmarkNode* node);
[email protected]e244e1a2014-06-20 09:47:3775
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.
tfarinaa0ec34e2015-01-12 18:46:4880bool SetAllImagesForBookmark(bookmarks::BookmarkModel* bookmark_model,
tfarinaa665b3082015-02-04 22:10:5081 const bookmarks::BookmarkNode* node,
[email protected]e244e1a2014-06-20 09:47:3782 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);
88
89} // namespace enhanced_bookmarks
90
91#endif // COMPONENTS_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_