summaryrefslogtreecommitdiffstats
path: root/components/enhanced_bookmarks/metadata_accessor.h
diff options
context:
space:
mode:
authornoyau@chromium.org <noyau@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-20 09:47:37 +0000
committernoyau@chromium.org <noyau@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-20 09:47:37 +0000
commite244e1ae3b065cbe8d9f568a3230d122ce33613e (patch)
treef00aa1fc4389c6a8636f0ecacf1d46d511eb4abb /components/enhanced_bookmarks/metadata_accessor.h
parentcd0ebe9f170dc4997c6fb76d78a217a2de755094 (diff)
downloadchromium_src-e244e1ae3b065cbe8d9f568a3230d122ce33613e.zip
chromium_src-e244e1ae3b065cbe8d9f568a3230d122ce33613e.tar.gz
chromium_src-e244e1ae3b065cbe8d9f568a3230d122ce33613e.tar.bz2
Bring up of the metadata accessors for enhanced bookmarks.
BUG=None Review URL: https://codereview.chromium.org/336263003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278656 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/enhanced_bookmarks/metadata_accessor.h')
-rw-r--r--components/enhanced_bookmarks/metadata_accessor.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/components/enhanced_bookmarks/metadata_accessor.h b/components/enhanced_bookmarks/metadata_accessor.h
new file mode 100644
index 0000000..2f20aae
--- /dev/null
+++ b/components/enhanced_bookmarks/metadata_accessor.h
@@ -0,0 +1,85 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_
+#define COMPONENTS_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_
+
+#include <set>
+#include <string>
+#include <vector>
+
+class BookmarkModel;
+class BookmarkNode;
+class GURL;
+
+// The functions in this file store and retrieve structured data encoded in the
+// bookmark metadata. This information suplements the data in the bookmark with
+// images and descriptions related to the url.
+namespace enhanced_bookmarks {
+
+typedef std::vector<const BookmarkNode*> NodeVector;
+typedef std::set<const BookmarkNode*> NodeSet;
+
+// The keys used to store the data in the bookmarks metadata dictionary.
+extern const char* kPageDataKey;
+extern const char* kImageDataKey;
+extern const char* kIdDataKey;
+extern const char* kNoteKey;
+
+// Returns the remoteId for a bookmark. If the bookmark doesn't have one already
+// this function will create and set one.
+std::string RemoteIdFromBookmark(BookmarkModel* bookmark_model,
+ const BookmarkNode* node);
+
+// Sets the description of a bookmark.
+void SetDescriptionForBookmark(BookmarkModel* bookmark_model,
+ const BookmarkNode* node,
+ const std::string& description);
+
+// Returns the description of a bookmark.
+std::string DescriptionFromBookmark(const BookmarkNode* node);
+
+// Sets the URL of an image representative of the page.
+// Expects the URL to be valid and not empty.
+// Returns true if the metainfo is successfully populated.
+bool SetOriginalImageForBookmark(BookmarkModel* bookmark_model,
+ const BookmarkNode* node,
+ const GURL& url,
+ int width,
+ int height);
+
+// Returns the url and dimensions of the original scraped image.
+// Returns true if the out variables are populated, false otherwise.
+bool OriginalImageFromBookmark(const BookmarkNode* node,
+ GURL* url,
+ int* width,
+ int* height);
+
+// Returns the url and dimensions of the server provided thumbnail image.
+// Returns true if the out variables are populated, false otherwise.
+bool ThumbnailImageFromBookmark(const BookmarkNode* node,
+ GURL* url,
+ int* width,
+ int* height);
+
+// Returns a brief server provided synopsis of the bookmarked page.
+// Returns the empty string if the snippet could not be extracted.
+std::string SnippetFromBookmark(const BookmarkNode* node);
+
+// Used for testing, simulates the process that creates the thumnails. Will
+// remove existing entries for empty urls or set them if the url is not empty.
+// expects valid or empty urls. Returns true if the metainfo is successfully
+// populated.
+bool SetAllImagesForBookmark(BookmarkModel* bookmark_model,
+ const BookmarkNode* node,
+ const GURL& image_url,
+ int image_width,
+ int image_height,
+ const GURL& thumbnail_url,
+ int thumbnail_width,
+ int thumbnail_height);
+
+} // namespace enhanced_bookmarks
+
+#endif // COMPONENTS_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_