OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #include "components/bookmarks/browser/bookmark_codec.h" | 5 #include "components/bookmarks/browser/bookmark_codec.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "components/bookmarks/browser/bookmark_model.h" | 13 #include "components/bookmarks/browser/bookmark_model.h" |
14 #include "grit/components_strings.h" | 14 #include "grit/components_strings.h" |
15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
16 #include "url/gurl.h" | 16 #include "url/gurl.h" |
17 | 17 |
18 using base::Time; | 18 using base::Time; |
19 | 19 |
20 namespace bookmarks { | 20 namespace bookmarks { |
21 | 21 |
22 const char* BookmarkCodec::kRootsKey = "roots"; | 22 const char BookmarkCodec::kRootsKey[] = "roots"; |
23 const char* BookmarkCodec::kRootFolderNameKey = "bookmark_bar"; | 23 const char BookmarkCodec::kRootFolderNameKey[] = "bookmark_bar"; |
24 const char* BookmarkCodec::kOtherBookmarkFolderNameKey = "other"; | 24 const char BookmarkCodec::kOtherBookmarkFolderNameKey[] = "other"; |
25 // The value is left as 'synced' for historical reasons. | 25 // The value is left as 'synced' for historical reasons. |
26 const char* BookmarkCodec::kMobileBookmarkFolderNameKey = "synced"; | 26 const char BookmarkCodec::kMobileBookmarkFolderNameKey[] = "synced"; |
27 const char* BookmarkCodec::kVersionKey = "version"; | 27 const char BookmarkCodec::kVersionKey[] = "version"; |
28 const char* BookmarkCodec::kChecksumKey = "checksum"; | 28 const char BookmarkCodec::kChecksumKey[] = "checksum"; |
29 const char* BookmarkCodec::kIdKey = "id"; | 29 const char BookmarkCodec::kIdKey[] = "id"; |
30 const char* BookmarkCodec::kTypeKey = "type"; | 30 const char BookmarkCodec::kTypeKey[] = "type"; |
31 const char* BookmarkCodec::kNameKey = "name"; | 31 const char BookmarkCodec::kNameKey[] = "name"; |
32 const char* BookmarkCodec::kDateAddedKey = "date_added"; | 32 const char BookmarkCodec::kDateAddedKey[] = "date_added"; |
33 const char* BookmarkCodec::kURLKey = "url"; | 33 const char BookmarkCodec::kURLKey[] = "url"; |
34 const char* BookmarkCodec::kDateModifiedKey = "date_modified"; | 34 const char BookmarkCodec::kDateModifiedKey[] = "date_modified"; |
35 const char* BookmarkCodec::kChildrenKey = "children"; | 35 const char BookmarkCodec::kChildrenKey[] = "children"; |
36 const char* BookmarkCodec::kMetaInfo = "meta_info"; | 36 const char BookmarkCodec::kMetaInfo[] = "meta_info"; |
37 const char* BookmarkCodec::kSyncTransactionVersion = "sync_transaction_version"; | 37 const char BookmarkCodec::kSyncTransactionVersion[] = |
38 const char* BookmarkCodec::kTypeURL = "url"; | 38 "sync_transaction_version"; |
39 const char* BookmarkCodec::kTypeFolder = "folder"; | 39 const char BookmarkCodec::kTypeURL[] = "url"; |
| 40 const char BookmarkCodec::kTypeFolder[] = "folder"; |
40 | 41 |
41 // Current version of the file. | 42 // Current version of the file. |
42 static const int kCurrentVersion = 1; | 43 static const int kCurrentVersion = 1; |
43 | 44 |
44 BookmarkCodec::BookmarkCodec() | 45 BookmarkCodec::BookmarkCodec() |
45 : ids_reassigned_(false), | 46 : ids_reassigned_(false), |
46 ids_valid_(true), | 47 ids_valid_(true), |
47 maximum_id_(0), | 48 maximum_id_(0), |
48 model_sync_transaction_version_( | 49 model_sync_transaction_version_( |
49 BookmarkNode::kInvalidSyncTransactionVersion) { | 50 BookmarkNode::kInvalidSyncTransactionVersion) { |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 base::MD5Init(&md5_context_); | 481 base::MD5Init(&md5_context_); |
481 } | 482 } |
482 | 483 |
483 void BookmarkCodec::FinalizeChecksum() { | 484 void BookmarkCodec::FinalizeChecksum() { |
484 base::MD5Digest digest; | 485 base::MD5Digest digest; |
485 base::MD5Final(&digest, &md5_context_); | 486 base::MD5Final(&digest, &md5_context_); |
486 computed_checksum_ = base::MD5DigestToBase16(digest); | 487 computed_checksum_ = base::MD5DigestToBase16(digest); |
487 } | 488 } |
488 | 489 |
489 } // namespace bookmarks | 490 } // namespace bookmarks |
OLD | NEW |