Index: components/enhanced_bookmarks/enhanced_bookmark_model.h |
diff --git a/components/enhanced_bookmarks/enhanced_bookmark_model.h b/components/enhanced_bookmarks/enhanced_bookmark_model.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9a24f9d35c42d7dde51a9106be506d65439a2e14 |
--- /dev/null |
+++ b/components/enhanced_bookmarks/enhanced_bookmark_model.h |
@@ -0,0 +1,81 @@ |
+// 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_ENHANCED_BOOKMARK_MODEL_H_ |
+#define COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_MODEL_H_ |
+ |
+#include <string> |
+ |
+class BookmarkModel; |
+class BookmarkNode; |
+class GURL; |
+ |
+namespace enhanced_bookmarks { |
+// Wrapper around BookmarkModel providing utility functions for enhanced |
+// bookmarks. |
+class EnhancedBookmarkModel { |
+ public: |
+ explicit EnhancedBookmarkModel(BookmarkModel* bookmark_model); |
noyau (Ping after 24h)
2014/08/26 11:17:47
I don't see the value of making this a class. If y
Yaron
2014/08/26 16:55:22
WIth the current state, I agree with Eric. As this
Rune Fevang
2014/08/26 18:47:52
The plan was to make it a KeyedService in a follow
Yaron
2014/08/27 23:32:36
Ok. That seems fine then. It's tricky though in th
Rune Fevang
2014/08/27 23:52:22
I didn't do it straight away because I wasn't sure
Rune Fevang
2014/08/29 01:10:10
Made it a KeyedService like we talked about.
|
+ ~EnhancedBookmarkModel(); |
+ |
+ void Initialize(const std::string& version); |
noyau (Ping after 24h)
2014/08/26 11:17:47
Having both a constructor and an Initialize is alw
Rune Fevang
2014/08/26 18:47:52
It needs to be settable if we're going to be calli
Yaron
2014/08/27 23:32:36
Well, according to the spec, for mobile clients th
Rune Fevang
2014/08/27 23:52:22
There's no need for the initialized_ member yet, b
Yaron
2014/08/28 00:11:49
If the initialization is handled by this class on
Rune Fevang
2014/08/28 00:30:22
I agree this is where the smarts should be. I'd li
noyau (Ping after 24h)
2014/08/28 08:36:53
The way it is done in a component is usually to ha
Rune Fevang
2014/08/29 01:10:10
I think I understand what you're saying now. Basic
|
+ |
+ // Returns the remote id for a bookmark. |
+ std::string GetRemoteIdForNode(const BookmarkNode* node); |
+ |
+ // Sets the description of a bookmark. |
+ void SetDescriptionForNode(const BookmarkNode* node, |
+ const std::string& description); |
+ |
+ // Returns the description of a bookmark. |
+ std::string GetDescriptionForNode(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 SetOriginalImageForNode(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 GetOriginalImageForNode(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 GetThumbnailImageForNode(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 GetSnippetForNode(const BookmarkNode* node); |
+ |
+ // Returns the version of the last enhanced bookmark client to change this |
+ // node. Returns the empty string if the node doesn't have one set. |
+ std::string GetVersionForNode(const BookmarkNode* node); |
+ |
+ private: |
+ // Generates and sets a remote id for the given bookmark. Returns the id set. |
+ std::string SetRemoteIdForNode(const BookmarkNode* node); |
+ |
+ // Helper method for setting a meta info field on a node. Also updates the |
+ // version field. |
+ void SetNodeMetaInfo(const BookmarkNode* node, |
+ const std::string& field, |
+ const std::string& value); |
+ |
+ BookmarkModel* bookmark_model_; |
Yaron
2014/08/27 23:32:36
Without this being a keyed service, we run the ris
Rune Fevang
2014/08/27 23:52:22
Acknowledged.
|
+ bool initialized_; |
+ std::string version_; |
+}; |
+ |
+} // namespace enhanced_bookmarks |
+ |
+#endif // COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_MODEL_H_ |