Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: components/enhanced_bookmarks/enhanced_bookmark_model.h

Issue 476573004: Set version field when changes are made to enhanced bookmarks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Merge with ImageService CL Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #ifndef COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_MODEL_H_
6 #define COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_MODEL_H_
7
8 #include <string>
9
10 #include "base/strings/string16.h"
11 #include "components/bookmarks/browser/bookmark_node.h"
12 #include "components/keyed_service/core/keyed_service.h"
13
14 namespace base {
15 class Time;
16 } // namespace base
17
18 class BookmarkModel;
19 class GURL;
20
21 namespace enhanced_bookmarks {
22 // Wrapper around BookmarkModel providing utility functions for enhanced
23 // bookmarks.
Mark 2014/09/03 23:31:16 I'm assuming everything around stars.userEdits wil
Rune Fevang 2014/09/04 01:03:13 Added stars.userEdit handling.
24 class EnhancedBookmarkModel : public KeyedService {
25 public:
26 explicit EnhancedBookmarkModel(BookmarkModel* bookmark_model);
27 virtual ~EnhancedBookmarkModel();
28
29 void Initialize(const std::string& version);
30
31 // Moves |node| to |new_parent| and inserts it at the given |index|.
32 void Move(const BookmarkNode* node,
33 const BookmarkNode* new_parent,
34 int index);
35
36 // Adds a new folder node at the specified position.
37 const BookmarkNode* AddFolder(const BookmarkNode* parent,
38 int index,
39 const base::string16& title,
40 const BookmarkNode::MetaInfoMap* meta_info);
41
42 // Adds a url at the specified position.
43 const BookmarkNode* AddURL(const BookmarkNode* parent,
44 int index,
45 const base::string16& title,
46 const GURL& url,
47 const base::Time& creation_time,
48 const BookmarkNode::MetaInfoMap* meta_info);
49
50 // Returns the remote id for a bookmark.
51 std::string GetRemoteIdForNode(const BookmarkNode* node);
52
53 // Sets the description of a bookmark.
54 void SetDescriptionForNode(const BookmarkNode* node,
55 const std::string& description);
56
57 // Returns the description of a bookmark.
58 std::string GetDescriptionForNode(const BookmarkNode* node);
59
60 // Sets the URL of an image representative of the page.
61 // Expects the URL to be valid and not empty.
62 // Returns true if the metainfo is successfully populated.
63 bool SetOriginalImageForNode(const BookmarkNode* node,
64 const GURL& url,
65 int width,
66 int height);
67
68 // Returns the url and dimensions of the original scraped image.
69 // Returns true if the out variables are populated, false otherwise.
70 bool GetOriginalImageForNode(const BookmarkNode* node,
71 GURL* url,
72 int* width,
73 int* height);
74
75 // Returns the url and dimensions of the server provided thumbnail image.
76 // Returns true if the out variables are populated, false otherwise.
77 bool GetThumbnailImageForNode(const BookmarkNode* node,
78 GURL* url,
79 int* width,
80 int* height);
81
82 // Returns a brief server provided synopsis of the bookmarked page.
83 // Returns the empty string if the snippet could not be extracted.
84 std::string GetSnippetForNode(const BookmarkNode* node);
85
86 // Returns the version of the last enhanced bookmark client to change this
87 // node. Returns the empty string if the node doesn't have one set.
Mark 2014/09/03 23:31:16 This should ONLY be used for debugging. The serve
Rune Fevang 2014/09/04 01:03:13 Moved the function to the test class.
88 std::string GetVersionForNode(const BookmarkNode* node);
Mark 2014/09/03 23:31:16 Clients should be agnostic to this and this should
Rune Fevang 2014/09/04 01:03:13 Acknowledged.
89
90 // Used for testing, simulates the process that creates the thumnails. Will
Mark 2014/09/03 23:31:16 Nit: s/thumnails/thumbnails
Rune Fevang 2014/09/04 01:03:13 Done.
91 // remove existing entries for empty urls or set them if the url is not empty.
92 // expects valid or empty urls. Returns true if the metainfo is successfully
Mark 2014/09/03 23:31:16 s/expects/Expects
Rune Fevang 2014/09/04 01:03:13 Done.
93 // populated.
94 // TODO(rfevang): Move this to a testing only utility file.
95 static bool SetAllImagesForBookmark(BookmarkModel* bookmark_model,
96 const BookmarkNode* node,
97 const GURL& image_url,
98 int image_width,
99 int image_height,
100 const GURL& thumbnail_url,
101 int thumbnail_width,
102 int thumbnail_height);
103
Mark 2014/09/03 23:31:16 Add TODO to add method for setting and getting the
Rune Fevang 2014/09/04 01:03:13 Getting and setting which flags?
Mark 2014/09/04 01:52:10 stars.flag. This could be handled by generic SetN
104 private:
105 // Generates and sets a remote id for the given bookmark. Returns the id set.
106 std::string SetRemoteIdForNode(const BookmarkNode* node);
107
108 // Helper method for setting a meta info field on a node. Also updates the
109 // version field.
110 void SetNodeMetaInfo(const BookmarkNode* node,
111 const std::string& field,
112 const std::string& value);
113
114 BookmarkModel* bookmark_model_;
115 bool initialized_;
116 std::string version_;
117 };
118
119 } // namespace enhanced_bookmarks
120
121 #endif // COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698