| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_html_writer.h" | 5 #include "chrome/browser/bookmarks/bookmark_html_writer.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 !Write(title, CONTENT) || | 285 !Write(title, CONTENT) || |
| 286 !Write(kBookmarkEnd) || | 286 !Write(kBookmarkEnd) || |
| 287 !Write(kNewline)) { | 287 !Write(kNewline)) { |
| 288 return false; | 288 return false; |
| 289 } | 289 } |
| 290 return true; | 290 return true; |
| 291 } | 291 } |
| 292 | 292 |
| 293 // Folder. | 293 // Folder. |
| 294 std::string last_modified_date; | 294 std::string last_modified_date; |
| 295 Value* child_values; | 295 const Value* child_values; |
| 296 if (!value.GetString(BookmarkCodec::kDateModifiedKey, | 296 if (!value.GetString(BookmarkCodec::kDateModifiedKey, |
| 297 &last_modified_date) || | 297 &last_modified_date) || |
| 298 !value.Get(BookmarkCodec::kChildrenKey, &child_values) || | 298 !value.Get(BookmarkCodec::kChildrenKey, &child_values) || |
| 299 child_values->GetType() != Value::TYPE_LIST) { | 299 child_values->GetType() != Value::TYPE_LIST) { |
| 300 NOTREACHED(); | 300 NOTREACHED(); |
| 301 return false; | 301 return false; |
| 302 } | 302 } |
| 303 if (folder_type != BookmarkNode::OTHER_NODE && | 303 if (folder_type != BookmarkNode::OTHER_NODE && |
| 304 folder_type != BookmarkNode::MOBILE) { | 304 folder_type != BookmarkNode::MOBILE) { |
| 305 // The other/mobile folder name are not written out. This gives the effect | 305 // The other/mobile folder name are not written out. This gives the effect |
| (...skipping 18 matching lines...) Expand all Loading... |
| 324 !Write(kNewline) || | 324 !Write(kNewline) || |
| 325 !WriteIndent() || | 325 !WriteIndent() || |
| 326 !Write(kFolderChildren) || | 326 !Write(kFolderChildren) || |
| 327 !Write(kNewline)) { | 327 !Write(kNewline)) { |
| 328 return false; | 328 return false; |
| 329 } | 329 } |
| 330 IncrementIndent(); | 330 IncrementIndent(); |
| 331 } | 331 } |
| 332 | 332 |
| 333 // Write the children. | 333 // Write the children. |
| 334 ListValue* children = static_cast<ListValue*>(child_values); | 334 const ListValue* children = static_cast<const ListValue*>(child_values); |
| 335 for (size_t i = 0; i < children->GetSize(); ++i) { | 335 for (size_t i = 0; i < children->GetSize(); ++i) { |
| 336 Value* child_value; | 336 Value* child_value; |
| 337 if (!children->Get(i, &child_value) || | 337 if (!children->Get(i, &child_value) || |
| 338 child_value->GetType() != Value::TYPE_DICTIONARY) { | 338 child_value->GetType() != Value::TYPE_DICTIONARY) { |
| 339 NOTREACHED(); | 339 NOTREACHED(); |
| 340 return false; | 340 return false; |
| 341 } | 341 } |
| 342 if (!WriteNode(*static_cast<DictionaryValue*>(child_value), | 342 if (!WriteNode(*static_cast<const DictionaryValue*>(child_value), |
| 343 BookmarkNode::FOLDER)) { | 343 BookmarkNode::FOLDER)) { |
| 344 return false; | 344 return false; |
| 345 } | 345 } |
| 346 } | 346 } |
| 347 if (folder_type != BookmarkNode::OTHER_NODE && | 347 if (folder_type != BookmarkNode::OTHER_NODE && |
| 348 folder_type != BookmarkNode::MOBILE) { | 348 folder_type != BookmarkNode::MOBILE) { |
| 349 // Close out the folder. | 349 // Close out the folder. |
| 350 DecrementIndent(); | 350 DecrementIndent(); |
| 351 if (!WriteIndent() || | 351 if (!WriteIndent() || |
| 352 !Write(kFolderChildrenEnd) || | 352 !Write(kFolderChildrenEnd) || |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 // BookmarkModel isn't thread safe (nor would we want to lock it down | 494 // BookmarkModel isn't thread safe (nor would we want to lock it down |
| 495 // for the duration of the write), as such we make a copy of the | 495 // for the duration of the write), as such we make a copy of the |
| 496 // BookmarkModel using BookmarkCodec then write from that. | 496 // BookmarkModel using BookmarkCodec then write from that. |
| 497 if (fetcher == NULL) { | 497 if (fetcher == NULL) { |
| 498 fetcher = new BookmarkFaviconFetcher(profile, path, observer); | 498 fetcher = new BookmarkFaviconFetcher(profile, path, observer); |
| 499 fetcher->ExportBookmarks(); | 499 fetcher->ExportBookmarks(); |
| 500 } | 500 } |
| 501 } | 501 } |
| 502 | 502 |
| 503 } // namespace bookmark_html_writer | 503 } // namespace bookmark_html_writer |
| OLD | NEW |