OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_ | 5 #ifndef COMPONENTS_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_ |
6 #define COMPONENTS_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_ | 6 #define COMPONENTS_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 class BookmarkNode; | |
13 class GURL; | 12 class GURL; |
14 | 13 |
15 namespace bookmarks { | 14 namespace bookmarks { |
16 class BookmarkModel; | 15 class BookmarkModel; |
| 16 class BookmarkNode; |
17 } | 17 } |
18 | 18 |
19 // TODO(rfevang): Remove this file once the remaining caller | 19 // TODO(rfevang): Remove this file once the remaining caller |
20 // is converted (enhanced_bookmarks_bridge.cc) | 20 // is converted (enhanced_bookmarks_bridge.cc) |
21 | 21 |
22 // The functions in this file store and retrieve structured data encoded in the | 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 | 23 // bookmark metadata. This information suplements the data in the bookmark with |
24 // images and descriptions related to the url. | 24 // images and descriptions related to the url. |
25 namespace enhanced_bookmarks { | 25 namespace enhanced_bookmarks { |
26 | 26 |
27 typedef std::vector<const BookmarkNode*> NodeVector; | 27 typedef std::vector<const bookmarks::BookmarkNode*> NodeVector; |
28 typedef std::set<const BookmarkNode*> NodeSet; | 28 typedef std::set<const bookmarks::BookmarkNode*> NodeSet; |
29 | 29 |
30 // The keys used to store the data in the bookmarks metadata dictionary. | 30 // The keys used to store the data in the bookmarks metadata dictionary. |
31 extern const char* kPageDataKey; | 31 extern const char* kPageDataKey; |
32 extern const char* kImageDataKey; | 32 extern const char* kImageDataKey; |
33 extern const char* kIdDataKey; | 33 extern const char* kIdDataKey; |
34 extern const char* kNoteKey; | 34 extern const char* kNoteKey; |
35 | 35 |
36 // Returns the remoteId for a bookmark. If the bookmark doesn't have one already | 36 // Returns the remoteId for a bookmark. If the bookmark doesn't have one already |
37 // this function will create and set one. | 37 // this function will create and set one. |
38 std::string RemoteIdFromBookmark(bookmarks::BookmarkModel* bookmark_model, | 38 std::string RemoteIdFromBookmark(bookmarks::BookmarkModel* bookmark_model, |
39 const BookmarkNode* node); | 39 const bookmarks::BookmarkNode* node); |
40 | 40 |
41 // Sets the description of a bookmark. | 41 // Sets the description of a bookmark. |
42 void SetDescriptionForBookmark(bookmarks::BookmarkModel* bookmark_model, | 42 void SetDescriptionForBookmark(bookmarks::BookmarkModel* bookmark_model, |
43 const BookmarkNode* node, | 43 const bookmarks::BookmarkNode* node, |
44 const std::string& description); | 44 const std::string& description); |
45 | 45 |
46 // Returns the description of a bookmark. | 46 // Returns the description of a bookmark. |
47 std::string DescriptionFromBookmark(const BookmarkNode* node); | 47 std::string DescriptionFromBookmark(const bookmarks::BookmarkNode* node); |
48 | 48 |
49 // Sets the URL of an image representative of the page. | 49 // Sets the URL of an image representative of the page. |
50 // Expects the URL to be valid and not empty. | 50 // Expects the URL to be valid and not empty. |
51 // Returns true if the metainfo is successfully populated. | 51 // Returns true if the metainfo is successfully populated. |
52 bool SetOriginalImageForBookmark(bookmarks::BookmarkModel* bookmark_model, | 52 bool SetOriginalImageForBookmark(bookmarks::BookmarkModel* bookmark_model, |
53 const BookmarkNode* node, | 53 const bookmarks::BookmarkNode* node, |
54 const GURL& url, | 54 const GURL& url, |
55 int width, | 55 int width, |
56 int height); | 56 int height); |
57 | 57 |
58 // Returns the url and dimensions of the original scraped image. | 58 // Returns the url and dimensions of the original scraped image. |
59 // Returns true if the out variables are populated, false otherwise. | 59 // Returns true if the out variables are populated, false otherwise. |
60 bool OriginalImageFromBookmark(const BookmarkNode* node, | 60 bool OriginalImageFromBookmark(const bookmarks::BookmarkNode* node, |
61 GURL* url, | 61 GURL* url, |
62 int* width, | 62 int* width, |
63 int* height); | 63 int* height); |
64 | 64 |
65 // Returns the url and dimensions of the server provided thumbnail image. | 65 // Returns the url and dimensions of the server provided thumbnail image. |
66 // Returns true if the out variables are populated, false otherwise. | 66 // Returns true if the out variables are populated, false otherwise. |
67 bool ThumbnailImageFromBookmark(const BookmarkNode* node, | 67 bool ThumbnailImageFromBookmark(const bookmarks::BookmarkNode* node, |
68 GURL* url, | 68 GURL* url, |
69 int* width, | 69 int* width, |
70 int* height); | 70 int* height); |
71 | 71 |
72 // Returns a brief server provided synopsis of the bookmarked page. | 72 // Returns a brief server provided synopsis of the bookmarked page. |
73 // Returns the empty string if the snippet could not be extracted. | 73 // Returns the empty string if the snippet could not be extracted. |
74 std::string SnippetFromBookmark(const BookmarkNode* node); | 74 std::string SnippetFromBookmark(const bookmarks::BookmarkNode* node); |
75 | 75 |
76 // Used for testing, simulates the process that creates the thumnails. Will | 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. | 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 | 78 // expects valid or empty urls. Returns true if the metainfo is successfully |
79 // populated. | 79 // populated. |
80 bool SetAllImagesForBookmark(bookmarks::BookmarkModel* bookmark_model, | 80 bool SetAllImagesForBookmark(bookmarks::BookmarkModel* bookmark_model, |
81 const BookmarkNode* node, | 81 const bookmarks::BookmarkNode* node, |
82 const GURL& image_url, | 82 const GURL& image_url, |
83 int image_width, | 83 int image_width, |
84 int image_height, | 84 int image_height, |
85 const GURL& thumbnail_url, | 85 const GURL& thumbnail_url, |
86 int thumbnail_width, | 86 int thumbnail_width, |
87 int thumbnail_height); | 87 int thumbnail_height); |
88 | 88 |
89 } // namespace enhanced_bookmarks | 89 } // namespace enhanced_bookmarks |
90 | 90 |
91 #endif // COMPONENTS_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_ | 91 #endif // COMPONENTS_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_ |
OLD | NEW |