16d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 26d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 36d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// found in the LICENSE file. 46d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 56d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#ifndef COMPONENTS_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_ 66d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#define COMPONENTS_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_ 76d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 86d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include <set> 96d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include <string> 106d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include <vector> 116d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 126d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)class BookmarkModel; 136d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)class BookmarkNode; 146d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)class GURL; 156d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 161320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// TODO(rfevang): Remove this file once the remaining caller 171320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// is converted (enhanced_bookmarks_bridge.cc) 181320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 196d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// The functions in this file store and retrieve structured data encoded in the 206d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// bookmark metadata. This information suplements the data in the bookmark with 216d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// images and descriptions related to the url. 226d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)namespace enhanced_bookmarks { 236d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 246d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)typedef std::vector<const BookmarkNode*> NodeVector; 256d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)typedef std::set<const BookmarkNode*> NodeSet; 266d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 276d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// The keys used to store the data in the bookmarks metadata dictionary. 286d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)extern const char* kPageDataKey; 296d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)extern const char* kImageDataKey; 306d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)extern const char* kIdDataKey; 316d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)extern const char* kNoteKey; 326d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 336d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Returns the remoteId for a bookmark. If the bookmark doesn't have one already 346d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// this function will create and set one. 356d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)std::string RemoteIdFromBookmark(BookmarkModel* bookmark_model, 366d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) const BookmarkNode* node); 376d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 386d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Sets the description of a bookmark. 396d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)void SetDescriptionForBookmark(BookmarkModel* bookmark_model, 406d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) const BookmarkNode* node, 416d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) const std::string& description); 426d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 436d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Returns the description of a bookmark. 446d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)std::string DescriptionFromBookmark(const BookmarkNode* node); 456d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 466d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Sets the URL of an image representative of the page. 476d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Expects the URL to be valid and not empty. 486d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Returns true if the metainfo is successfully populated. 496d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)bool SetOriginalImageForBookmark(BookmarkModel* bookmark_model, 506d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) const BookmarkNode* node, 516d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) const GURL& url, 526d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) int width, 536d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) int height); 546d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 556d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Returns the url and dimensions of the original scraped image. 566d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Returns true if the out variables are populated, false otherwise. 576d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)bool OriginalImageFromBookmark(const BookmarkNode* node, 586d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) GURL* url, 596d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) int* width, 606d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) int* height); 616d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 626d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Returns the url and dimensions of the server provided thumbnail image. 636d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Returns true if the out variables are populated, false otherwise. 646d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)bool ThumbnailImageFromBookmark(const BookmarkNode* node, 656d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) GURL* url, 666d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) int* width, 676d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) int* height); 686d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 696d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Returns a brief server provided synopsis of the bookmarked page. 706d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Returns the empty string if the snippet could not be extracted. 716d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)std::string SnippetFromBookmark(const BookmarkNode* node); 726d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 736d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Used for testing, simulates the process that creates the thumnails. Will 746d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// remove existing entries for empty urls or set them if the url is not empty. 756d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// expects valid or empty urls. Returns true if the metainfo is successfully 766d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// populated. 776d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)bool SetAllImagesForBookmark(BookmarkModel* bookmark_model, 786d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) const BookmarkNode* node, 796d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) const GURL& image_url, 806d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) int image_width, 816d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) int image_height, 826d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) const GURL& thumbnail_url, 836d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) int thumbnail_width, 846d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) int thumbnail_height); 856d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 866d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)} // namespace enhanced_bookmarks 876d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 886d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#endif // COMPONENTS_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_ 89