Commit ff78ba27 authored by Pauline Leitao's avatar Pauline Leitao Committed by Commit Bot

Remove GUID validity check for BookmarkPermanentNode

This patch is a follow-up to CL 1676167, found in [1], and introduces
minor mechanical changes to the DecodeNode() method so that GUID
validity is only checked for bookmarks that are not of type
BookmarkPermanentNode.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/1676167

Bug: 978430
Change-Id: I44ba7699482c229bb9c651d5b213e68036c9d233
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1728883Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarMohamed Amir Yosef <mamir@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Commit-Queue: Pauline Leitao <psivieroleitao@google.com>
Cr-Commit-Position: refs/heads/master@{#689533}
parent e9d549e3
...@@ -319,19 +319,22 @@ bool BookmarkCodec::DecodeNode(const base::DictionaryValue& value, ...@@ -319,19 +319,22 @@ bool BookmarkCodec::DecodeNode(const base::DictionaryValue& value,
base::string16 title; base::string16 title;
value.GetString(kNameKey, &title); value.GetString(kNameKey, &title);
std::string guid; std::string guid;
// GUIDs can be empty for bookmarks that were created before GUIDs were // |node| is only passed in for bookmarks of type BookmarkPermanentNode, in
// required. When encountering one such bookmark we thus assign to it a new // which case we do not need to check for GUID validity as their GUIDs are
// GUID. The same applies if the stored GUID is invalid or a duplicate. // hard-coded and not read from the persisted file.
if (!value.GetString(kGuidKey, &guid) || guid.empty() || if (!node) {
!base::IsValidGUID(guid) // GUIDs can be empty for bookmarks that were created before GUIDs were
// GUID can only already be present in the set if bookmark is of type // required. When encountering one such bookmark we thus assign to it a new
// BookmarkPermanentNode. // GUID. The same applies if the stored GUID is invalid or a duplicate.
|| (guids_.count(guid) != 0 && !node)) { if (!value.GetString(kGuidKey, &guid) || guid.empty() ||
guid = base::GenerateGUID(); !base::IsValidGUID(guid) || guids_.count(guid) != 0) {
guids_reassigned_ = true; guid = base::GenerateGUID();
guids_reassigned_ = true;
}
guids_.insert(guid);
} }
guids_.insert(guid);
std::string date_added_string; std::string date_added_string;
if (!value.GetString(kDateAddedKey, &date_added_string)) if (!value.GetString(kDateAddedKey, &date_added_string))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment