OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/bookmarks/bookmark_codec.h" | 5 #include "chrome/browser/bookmarks/bookmark_codec.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 ReassignIDs(bb_node, other_folder_node); | 81 ReassignIDs(bb_node, other_folder_node); |
82 *max_id = maximum_id_ + 1; | 82 *max_id = maximum_id_ + 1; |
83 return success; | 83 return success; |
84 } | 84 } |
85 | 85 |
86 Value* BookmarkCodec::EncodeNode(const BookmarkNode* node) { | 86 Value* BookmarkCodec::EncodeNode(const BookmarkNode* node) { |
87 DictionaryValue* value = new DictionaryValue(); | 87 DictionaryValue* value = new DictionaryValue(); |
88 std::string id = base::Int64ToString(node->id()); | 88 std::string id = base::Int64ToString(node->id()); |
89 value->SetString(kIdKey, id); | 89 value->SetString(kIdKey, id); |
90 const string16& title = node->GetTitleAsString16(); | 90 const string16& title = node->GetTitleAsString16(); |
91 value->SetStringFromUTF16(kNameKey, title); | 91 value->SetString(kNameKey, title); |
92 value->SetString(kDateAddedKey, | 92 value->SetString(kDateAddedKey, |
93 base::Int64ToString(node->date_added().ToInternalValue())); | 93 base::Int64ToString(node->date_added().ToInternalValue())); |
94 if (node->type() == BookmarkNode::URL) { | 94 if (node->type() == BookmarkNode::URL) { |
95 value->SetString(kTypeKey, kTypeURL); | 95 value->SetString(kTypeKey, kTypeURL); |
96 std::string url = node->GetURL().possibly_invalid_spec(); | 96 std::string url = node->GetURL().possibly_invalid_spec(); |
97 value->SetString(kURLKey, url); | 97 value->SetString(kURLKey, url); |
98 UpdateChecksumWithUrlNode(id, title, url); | 98 UpdateChecksumWithUrlNode(id, title, url); |
99 } else { | 99 } else { |
100 value->SetString(kTypeKey, kTypeFolder); | 100 value->SetString(kTypeKey, kTypeFolder); |
101 value->SetString(kDateModifiedKey, | 101 value->SetString(kDateModifiedKey, |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 328 |
329 void BookmarkCodec::InitializeChecksum() { | 329 void BookmarkCodec::InitializeChecksum() { |
330 MD5Init(&md5_context_); | 330 MD5Init(&md5_context_); |
331 } | 331 } |
332 | 332 |
333 void BookmarkCodec::FinalizeChecksum() { | 333 void BookmarkCodec::FinalizeChecksum() { |
334 MD5Digest digest; | 334 MD5Digest digest; |
335 MD5Final(&digest, &md5_context_); | 335 MD5Final(&digest, &md5_context_); |
336 computed_checksum_ = MD5DigestToBase16(digest); | 336 computed_checksum_ = MD5DigestToBase16(digest); |
337 } | 337 } |
OLD | NEW |