OLD | NEW |
---|---|
(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. | |
24 class EnhancedBookmarkModel : public KeyedService { | |
noyau (Ping after 24h)
2014/09/05 12:04:43
This doesn't track changes in the model, and as su
Rune Fevang
2014/09/06 00:01:56
Right, that will come in a later CL (task 4 in the
noyau (Ping after 24h)
2014/09/08 09:04:18
Acknowledged.
| |
25 public: | |
26 EnhancedBookmarkModel(BookmarkModel* bookmark_model, | |
27 const std::string& version); | |
28 virtual ~EnhancedBookmarkModel(); | |
29 | |
30 // Moves |node| to |new_parent| and inserts it at the given |index|. | |
31 void Move(const BookmarkNode* node, | |
32 const BookmarkNode* new_parent, | |
33 int index); | |
34 | |
35 // Adds a new folder node at the specified position. | |
36 const BookmarkNode* AddFolder(const BookmarkNode* parent, | |
37 int index, | |
38 const base::string16& title, | |
39 const BookmarkNode::MetaInfoMap* meta_info); | |
noyau (Ping after 24h)
2014/09/05 12:04:43
Why does this takes a metainfo? I thought the whol
Rune Fevang
2014/09/06 00:01:56
Yes that is the (at least long term) point, but as
| |
40 | |
41 // Adds a url at the specified position. | |
42 const BookmarkNode* AddURL(const BookmarkNode* parent, | |
43 int index, | |
44 const base::string16& title, | |
45 const GURL& url, | |
46 const base::Time& creation_time, | |
47 const BookmarkNode::MetaInfoMap* meta_info); | |
noyau (Ping after 24h)
2014/09/05 12:04:43
Same here. I'd expect addURL to take an optional d
Rune Fevang
2014/09/06 00:01:56
That's fine, the main things that need to be set o
| |
48 | |
49 // Returns the remote id for a bookmark. | |
50 std::string GetRemoteIdForNode(const BookmarkNode* node); | |
51 | |
52 // Sets the description of a bookmark. |user_edit| should be true if | |
53 // setting the description is the direct result of a user action. | |
54 void SetDescriptionForNode(const BookmarkNode* node, | |
55 const std::string& description, | |
56 bool user_edit); | |
noyau (Ping after 24h)
2014/09/05 12:04:43
I don't understand user_edit. I thought the descri
Rune Fevang
2014/09/06 00:01:56
Discussed userEdit with mcolbert@. Decided that it
| |
57 | |
58 // Returns the description of a bookmark. | |
59 std::string GetDescriptionForNode(const BookmarkNode* node); | |
60 | |
61 // Sets the URL of an image representative of the page. | |
62 // Expects the URL to be valid and not empty. |user_edit| should be true if | |
63 // setting the image is the direct result of a user action. | |
64 // Returns true if the metainfo is successfully populated. | |
65 bool SetOriginalImageForNode(const BookmarkNode* node, | |
66 const GURL& url, | |
67 int width, | |
68 int height, | |
69 bool user_edit); | |
noyau (Ping after 24h)
2014/09/05 12:04:43
Here user_edit is confusing, this is always the re
| |
70 | |
71 // Returns the url and dimensions of the original scraped image. | |
72 // Returns true if the out variables are populated, false otherwise. | |
73 bool GetOriginalImageForNode(const BookmarkNode* node, | |
74 GURL* url, | |
75 int* width, | |
76 int* height); | |
77 | |
78 // Returns the url and dimensions of the server provided thumbnail image. | |
79 // Returns true if the out variables are populated, false otherwise. | |
80 bool GetThumbnailImageForNode(const BookmarkNode* node, | |
81 GURL* url, | |
82 int* width, | |
83 int* height); | |
84 | |
85 // Returns a brief server provided synopsis of the bookmarked page. | |
86 // Returns the empty string if the snippet could not be extracted. | |
87 std::string GetSnippetForNode(const BookmarkNode* node); | |
88 | |
89 // Sets a custom suffix to be added to the version field when writing meta | |
90 // info fields. | |
91 void SetVersionSuffix(const std::string& version_suffix); | |
92 | |
93 // TODO(rfevang): Add method + enum for accessing/writing flags. | |
94 | |
95 // Used for testing, simulates the process that creates the thumbnails. Will | |
96 // remove existing entries for empty urls or set them if the url is not empty. | |
97 // Expects valid or empty urls. Returns true if the metainfo is successfully | |
98 // populated. | |
99 // TODO(rfevang): Move this to a testing only utility file. | |
100 static bool SetAllImagesForBookmark(BookmarkModel* bookmark_model, | |
noyau (Ping after 24h)
2014/09/05 12:04:43
The bookmark_model argument is not needed here any
Rune Fevang
2014/09/06 00:01:56
Done.
| |
101 const BookmarkNode* node, | |
102 const GURL& image_url, | |
103 int image_width, | |
104 int image_height, | |
105 const GURL& thumbnail_url, | |
106 int thumbnail_width, | |
107 int thumbnail_height); | |
108 | |
109 private: | |
110 // Generates and sets a remote id for the given bookmark. Returns the id set. | |
111 std::string SetRemoteIdForNode(const BookmarkNode* node); | |
112 | |
113 // Helper method for setting a meta info field on a node. Also updates the | |
114 // version and userEdits fields. | |
115 void SetNodeMetaInfo(const BookmarkNode* node, | |
116 const std::string& field, | |
117 const std::string& value, | |
118 bool user_edit); | |
119 | |
120 // Returns the version string to use when setting stars.version. | |
121 std::string GetVersionString(); | |
122 | |
123 BookmarkModel* bookmark_model_; | |
124 std::string version_; | |
125 std::string version_suffix_; | |
126 }; | |
127 | |
128 } // namespace enhanced_bookmarks | |
129 | |
130 #endif // COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_MODEL_H_ | |
OLD | NEW |