OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // BookmarkCodec is responsible for encoding and decoding the BookmarkModel | 5 // BookmarkCodec is responsible for encoding and decoding the BookmarkModel |
6 // into JSON values. The encoded values are written to disk via the | 6 // into JSON values. The encoded values are written to disk via the |
7 // BookmarkService. | 7 // BookmarkService. |
8 | 8 |
9 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_CODEC_H_ | 9 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_CODEC_H_ |
10 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_CODEC_H_ | 10 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_CODEC_H_ |
(...skipping 25 matching lines...) Expand all Loading... |
36 // bookmarks out of the database. | 36 // bookmarks out of the database. |
37 Value* Encode(BookmarkNode* bookmark_bar_node, | 37 Value* Encode(BookmarkNode* bookmark_bar_node, |
38 BookmarkNode* other_folder_node); | 38 BookmarkNode* other_folder_node); |
39 | 39 |
40 // Decodes the previously encoded value to the specified model. Returns true | 40 // Decodes the previously encoded value to the specified model. Returns true |
41 // on success, false otherwise. If there is an error (such as unexpected | 41 // on success, false otherwise. If there is an error (such as unexpected |
42 // version) all children are removed from the bookmark bar and other folder | 42 // version) all children are removed from the bookmark bar and other folder |
43 // nodes. | 43 // nodes. |
44 bool Decode(BookmarkModel* model, const Value& value); | 44 bool Decode(BookmarkModel* model, const Value& value); |
45 | 45 |
| 46 // Names of the various keys written to the Value. |
| 47 static const wchar_t* kRootsKey; |
| 48 static const wchar_t* kRootFolderNameKey; |
| 49 static const wchar_t* kOtherBookmarFolderNameKey; |
| 50 static const wchar_t* kVersionKey; |
| 51 static const wchar_t* kTypeKey; |
| 52 static const wchar_t* kNameKey; |
| 53 static const wchar_t* kDateAddedKey; |
| 54 static const wchar_t* kURLKey; |
| 55 static const wchar_t* kDateModifiedKey; |
| 56 static const wchar_t* kChildrenKey; |
| 57 |
| 58 // Possible values for kTypeKey. |
| 59 static const wchar_t* kTypeURL; |
| 60 static const wchar_t* kTypeFolder; |
| 61 |
46 private: | 62 private: |
47 // Encodes node and all its children into a Value object and returns it. | 63 // Encodes node and all its children into a Value object and returns it. |
48 // The caller takes ownership of the returned object. | 64 // The caller takes ownership of the returned object. |
49 Value* EncodeNode(BookmarkNode* node); | 65 Value* EncodeNode(BookmarkNode* node); |
50 | 66 |
51 // Decodes the children of the specified node. Returns true on success. | 67 // Decodes the children of the specified node. Returns true on success. |
52 bool DecodeChildren(BookmarkModel* model, | 68 bool DecodeChildren(BookmarkModel* model, |
53 const ListValue& child_value_list, | 69 const ListValue& child_value_list, |
54 BookmarkNode* parent); | 70 BookmarkNode* parent); |
55 | 71 |
56 // Decodes the supplied node from the supplied value. Child nodes are | 72 // Decodes the supplied node from the supplied value. Child nodes are |
57 // created appropriately by way of DecodeChildren. If node is NULL a new | 73 // created appropriately by way of DecodeChildren. If node is NULL a new |
58 // node is created and added to parent, otherwise node is used. | 74 // node is created and added to parent, otherwise node is used. |
59 bool DecodeNode(BookmarkModel* model, | 75 bool DecodeNode(BookmarkModel* model, |
60 const DictionaryValue& value, | 76 const DictionaryValue& value, |
61 BookmarkNode* parent, | 77 BookmarkNode* parent, |
62 BookmarkNode* node); | 78 BookmarkNode* node); |
63 | 79 |
64 DISALLOW_COPY_AND_ASSIGN(BookmarkCodec); | 80 DISALLOW_COPY_AND_ASSIGN(BookmarkCodec); |
65 }; | 81 }; |
66 | 82 |
67 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_CODEC_H_ | 83 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_CODEC_H_ |
OLD | NEW |