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