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

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: 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.
24 class EnhancedBookmarkModel : public KeyedService {
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
40 // Adds a url at the specified position.
41 const BookmarkNode* AddURL(const BookmarkNode* parent,
42 int index,
43 const base::string16& title,
44 const GURL& url,
45 const base::Time& creation_time);
46
47 // Returns the remote id for a bookmark |node|.
48 std::string GetRemoteId(const BookmarkNode* node);
49
50 // Sets the description of a bookmark |node|.
51 void SetDescription(const BookmarkNode* node, const std::string& description);
52
53 // Returns the description of a bookmark |node|.
54 std::string GetDescription(const BookmarkNode* node);
55
56 // Sets the URL of an image representative of a bookmark |node|.
57 // Expects the URL to be valid and not empty.
58 // Returns true if the metainfo is successfully populated.
59 bool SetOriginalImage(const BookmarkNode* node,
60 const GURL& url,
61 int width,
62 int height);
63
64 // Returns the url and dimensions of the original scraped image of a
65 // bookmark |node|.
66 // Returns true if the out variables are populated, false otherwise.
67 bool GetOriginalImage(const BookmarkNode* node,
68 GURL* url,
69 int* width,
70 int* height);
71
72 // Returns the url and dimensions of the server provided thumbnail image for
73 // a given bookmark |node|.
74 // Returns true if the out variables are populated, false otherwise.
75 bool GetThumbnailImage(const BookmarkNode* node,
76 GURL* url,
77 int* width,
78 int* height);
79
80 // Returns a brief server provided synopsis of the bookmarked page.
81 // Returns the empty string if the snippet could not be extracted.
82 std::string GetSnippet(const BookmarkNode* node);
83
84 // Sets a custom suffix to be added to the version field when writing meta
85 // info fields.
86 void SetVersionSuffix(const std::string& version_suffix);
87
88 // TODO(rfevang): Add method + enum for accessing/writing flags.
89
90 // Used for testing, simulates the process that creates the thumbnails. Will
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
93 // populated.
94 // TODO(rfevang): Move this to a testing only utility file.
95 bool SetAllImages(const BookmarkNode* node,
96 const GURL& image_url,
97 int image_width,
98 int image_height,
99 const GURL& thumbnail_url,
100 int thumbnail_width,
101 int thumbnail_height);
102
103 // TODO(rfevang): Ideally nothing should need the underlying bookmark model.
104 // Remove when that is actually the case.
105 BookmarkModel* bookmark_model() { return bookmark_model_; }
106
107 private:
108 // Generates and sets a remote id for the given bookmark |node|.
109 // Returns the id set.
110 std::string SetRemoteId(const BookmarkNode* node);
111
112 // Helper method for setting a meta info field on a node. Also updates the
113 // version and userEdits fields.
114 void SetMetaInfo(const BookmarkNode* node,
115 const std::string& field,
116 const std::string& value,
117 bool user_edit);
118
119 // Returns the version string to use when setting stars.version.
120 std::string GetVersionString();
121
122 BookmarkModel* bookmark_model_;
123 std::string version_;
124 std::string version_suffix_;
125 };
126
127 } // namespace enhanced_bookmarks
128
129 #endif // COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_MODEL_H_
OLDNEW
« no previous file with comments | « components/enhanced_bookmarks/bookmark_image_service.cc ('k') | components/enhanced_bookmarks/enhanced_bookmark_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698