| 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" |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 if (!value.Get(kMetaInfo, &meta_info)) | 379 if (!value.Get(kMetaInfo, &meta_info)) |
| 380 return true; | 380 return true; |
| 381 | 381 |
| 382 scoped_ptr<base::Value> deserialized_holder; | 382 scoped_ptr<base::Value> deserialized_holder; |
| 383 | 383 |
| 384 // Meta info used to be stored as a serialized dictionary, so attempt to | 384 // Meta info used to be stored as a serialized dictionary, so attempt to |
| 385 // parse the value as one. | 385 // parse the value as one. |
| 386 if (meta_info->IsType(base::Value::TYPE_STRING)) { | 386 if (meta_info->IsType(base::Value::TYPE_STRING)) { |
| 387 std::string meta_info_str; | 387 std::string meta_info_str; |
| 388 meta_info->GetAsString(&meta_info_str); | 388 meta_info->GetAsString(&meta_info_str); |
| 389 JSONStringValueSerializer serializer(meta_info_str); | 389 JSONStringValueDeserializer deserializer(meta_info_str); |
| 390 deserialized_holder.reset(serializer.Deserialize(nullptr, nullptr)); | 390 deserialized_holder.reset(deserializer.Deserialize(nullptr, nullptr)); |
| 391 if (!deserialized_holder) | 391 if (!deserialized_holder) |
| 392 return false; | 392 return false; |
| 393 meta_info = deserialized_holder.get(); | 393 meta_info = deserialized_holder.get(); |
| 394 } | 394 } |
| 395 // meta_info is now either the kMetaInfo node, or the deserialized node if it | 395 // meta_info is now either the kMetaInfo node, or the deserialized node if it |
| 396 // was stored as a string. Either way it should now be a (possibly nested) | 396 // was stored as a string. Either way it should now be a (possibly nested) |
| 397 // dictionary of meta info values. | 397 // dictionary of meta info values. |
| 398 const base::DictionaryValue* meta_info_dict; | 398 const base::DictionaryValue* meta_info_dict; |
| 399 if (!meta_info->GetAsDictionary(&meta_info_dict)) | 399 if (!meta_info->GetAsDictionary(&meta_info_dict)) |
| 400 return false; | 400 return false; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 base::MD5Init(&md5_context_); | 480 base::MD5Init(&md5_context_); |
| 481 } | 481 } |
| 482 | 482 |
| 483 void BookmarkCodec::FinalizeChecksum() { | 483 void BookmarkCodec::FinalizeChecksum() { |
| 484 base::MD5Digest digest; | 484 base::MD5Digest digest; |
| 485 base::MD5Final(&digest, &md5_context_); | 485 base::MD5Final(&digest, &md5_context_); |
| 486 computed_checksum_ = base::MD5DigestToBase16(digest); | 486 computed_checksum_ = base::MD5DigestToBase16(digest); |
| 487 } | 487 } |
| 488 | 488 |
| 489 } // namespace bookmarks | 489 } // namespace bookmarks |
| OLD | NEW |