summaryrefslogtreecommitdiffstats
path: root/chrome/browser/bookmarks/bookmark_codec.cc
diff options
context:
space:
mode:
authormhm@chromium.org <mhm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-09 18:24:03 +0000
committermhm@chromium.org <mhm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-09 18:24:03 +0000
commit9525f84d9793bfebe1a0918bb527a5a9bde3b4b0 (patch)
treeee7c63c85349e360534bef9c6b6226b7313fbaa7 /chrome/browser/bookmarks/bookmark_codec.cc
parent73963eed65b38f564d84e8195f83377dee00b2e0 (diff)
downloadchromium_src-9525f84d9793bfebe1a0918bb527a5a9bde3b4b0.zip
chromium_src-9525f84d9793bfebe1a0918bb527a5a9bde3b4b0.tar.gz
chromium_src-9525f84d9793bfebe1a0918bb527a5a9bde3b4b0.tar.bz2
Should provide checks while loading bookmarks
Instead of providing a separate check to validate bookmarks while loading, we could assume invalid bookmarks are invalid, hence we don't break the loading sequence. We keep looping since another bookmark might be valid. If the JSON syntax is broken, it will exit gracefully because the parser can't parse the file. This patch is only good for people who are editing their bookmarks directly and missing a item in the bookmark node. BUG=10709 (http://crbug.com/10709) TEST=Deleted any line from the Bookmarks file within the bookmark children node. Loaded up Chromium and it loaded the error free bookmarks. Review URL: http://codereview.chromium.org/118351 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17960 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/bookmarks/bookmark_codec.cc')
-rw-r--r--chrome/browser/bookmarks/bookmark_codec.cc18
1 files changed, 6 insertions, 12 deletions
diff --git a/chrome/browser/bookmarks/bookmark_codec.cc b/chrome/browser/bookmarks/bookmark_codec.cc
index 80dbc4b..03b7028 100644
--- a/chrome/browser/bookmarks/bookmark_codec.cc
+++ b/chrome/browser/bookmarks/bookmark_codec.cc
@@ -222,10 +222,7 @@ bool BookmarkCodec::DecodeChildren(const ListValue& child_value_list,
if (child_value->GetType() != Value::TYPE_DICTIONARY)
return false;
- if (!DecodeNode(*static_cast<DictionaryValue*>(child_value), parent,
- NULL)) {
- return false;
- }
+ DecodeNode(*static_cast<DictionaryValue*>(child_value), parent, NULL);
}
return true;
}
@@ -244,13 +241,11 @@ bool BookmarkCodec::DecodeNode(const DictionaryValue& value,
std::wstring title;
if (!value.GetString(kNameKey, &title))
- return false;
+ title = std::wstring();
- // TODO(sky): this should be more flexible. Don't hoark if we can't parse it
- // all.
std::wstring date_added_string;
if (!value.GetString(kDateAddedKey, &date_added_string))
- return false;
+ date_added_string = Int64ToWString(Time::Now().ToInternalValue());
std::wstring type_string;
if (!value.GetString(kTypeKey, &type_string))
@@ -263,12 +258,11 @@ bool BookmarkCodec::DecodeNode(const DictionaryValue& value,
std::wstring url_string;
if (!value.GetString(kURLKey, &url_string))
return false;
- // TODO(sky): this should ignore the node if not a valid URL.
+
if (!node)
node = new BookmarkNode(id, GURL(WideToUTF8(url_string)));
else
- NOTREACHED(); // In case of a URL type node should always be NULL.
-
+ return false; // Node invalid.
if (parent)
parent->Add(parent->GetChildCount(), node);
@@ -277,7 +271,7 @@ bool BookmarkCodec::DecodeNode(const DictionaryValue& value,
} else {
std::wstring last_modified_date;
if (!value.GetString(kDateModifiedKey, &last_modified_date))
- return false;
+ last_modified_date = Int64ToWString(Time::Now().ToInternalValue());
Value* child_values;
if (!value.Get(kChildrenKey, &child_values))