OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_util.h" | 10 #include "base/string_util.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 return false; | 230 return false; |
231 | 231 |
232 if (type_string != kTypeURL && type_string != kTypeFolder) | 232 if (type_string != kTypeURL && type_string != kTypeFolder) |
233 return false; // Unknown type. | 233 return false; // Unknown type. |
234 | 234 |
235 if (type_string == kTypeURL) { | 235 if (type_string == kTypeURL) { |
236 std::wstring url_string; | 236 std::wstring url_string; |
237 if (!value.GetString(kURLKey, &url_string)) | 237 if (!value.GetString(kURLKey, &url_string)) |
238 return false; | 238 return false; |
239 | 239 |
240 if (!node) | 240 GURL url = GURL(WideToUTF8(url_string)); |
241 node = new BookmarkNode(id, GURL(WideToUTF8(url_string))); | 241 if (!node && url.is_valid()) |
tim (not reviewing)
2009/10/16 03:20:59
does this affect about: urls? e.g about:memory?
| |
242 node = new BookmarkNode(id, url); | |
242 else | 243 else |
243 return false; // Node invalid. | 244 return false; // Node invalid. |
244 | 245 |
245 if (parent) | 246 if (parent) |
246 parent->Add(parent->GetChildCount(), node); | 247 parent->Add(parent->GetChildCount(), node); |
247 node->SetType(BookmarkNode::URL); | 248 node->SetType(BookmarkNode::URL); |
248 UpdateChecksumWithUrlNode(id_string, title, url_string); | 249 UpdateChecksumWithUrlNode(id_string, title, url_string); |
249 } else { | 250 } else { |
250 std::wstring last_modified_date; | 251 std::wstring last_modified_date; |
251 if (!value.GetString(kDateModifiedKey, &last_modified_date)) | 252 if (!value.GetString(kDateModifiedKey, &last_modified_date)) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 | 325 |
325 void BookmarkCodec::InitializeChecksum() { | 326 void BookmarkCodec::InitializeChecksum() { |
326 MD5Init(&md5_context_); | 327 MD5Init(&md5_context_); |
327 } | 328 } |
328 | 329 |
329 void BookmarkCodec::FinalizeChecksum() { | 330 void BookmarkCodec::FinalizeChecksum() { |
330 MD5Digest digest; | 331 MD5Digest digest; |
331 MD5Final(&digest, &md5_context_); | 332 MD5Final(&digest, &md5_context_); |
332 computed_checksum_ = MD5DigestToBase16(digest); | 333 computed_checksum_ = MD5DigestToBase16(digest); |
333 } | 334 } |
OLD | NEW |