| 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 return true; | 200 return true; |
| 201 size_t wrote = file_stream_->WriteSync(text.c_str(), text.length()); | 201 size_t wrote = file_stream_->WriteSync(text.c_str(), text.length()); |
| 202 bool result = (wrote == text.length()); | 202 bool result = (wrote == text.length()); |
| 203 DCHECK(result); | 203 DCHECK(result); |
| 204 return result; | 204 return result; |
| 205 } | 205 } |
| 206 | 206 |
| 207 // Writes out the text string (as UTF8). The text is escaped based on | 207 // Writes out the text string (as UTF8). The text is escaped based on |
| 208 // type. | 208 // type. |
| 209 bool Write(const std::string& text, TextType type) { | 209 bool Write(const std::string& text, TextType type) { |
| 210 DCHECK(IsStringUTF8(text)); | 210 DCHECK(base::IsStringUTF8(text)); |
| 211 std::string utf8_string; | 211 std::string utf8_string; |
| 212 | 212 |
| 213 switch (type) { | 213 switch (type) { |
| 214 case ATTRIBUTE_VALUE: | 214 case ATTRIBUTE_VALUE: |
| 215 // Convert " to " | 215 // Convert " to " |
| 216 utf8_string = text; | 216 utf8_string = text; |
| 217 ReplaceSubstringsAfterOffset(&utf8_string, 0, "\"", """); | 217 ReplaceSubstringsAfterOffset(&utf8_string, 0, "\"", """); |
| 218 break; | 218 break; |
| 219 | 219 |
| 220 case CONTENT: | 220 case CONTENT: |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 // BookmarkModel isn't thread safe (nor would we want to lock it down | 501 // BookmarkModel isn't thread safe (nor would we want to lock it down |
| 502 // for the duration of the write), as such we make a copy of the | 502 // for the duration of the write), as such we make a copy of the |
| 503 // BookmarkModel using BookmarkCodec then write from that. | 503 // BookmarkModel using BookmarkCodec then write from that. |
| 504 if (fetcher == NULL) { | 504 if (fetcher == NULL) { |
| 505 fetcher = new BookmarkFaviconFetcher(profile, path, observer); | 505 fetcher = new BookmarkFaviconFetcher(profile, path, observer); |
| 506 fetcher->ExportBookmarks(); | 506 fetcher->ExportBookmarks(); |
| 507 } | 507 } |
| 508 } | 508 } |
| 509 | 509 |
| 510 } // namespace bookmark_html_writer | 510 } // namespace bookmark_html_writer |
| OLD | NEW |