OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 return result; | 159 return result; |
160 } | 160 } |
161 | 161 |
162 // Writes out the text string (as UTF8). The text is escaped based on | 162 // Writes out the text string (as UTF8). The text is escaped based on |
163 // type. | 163 // type. |
164 bool Write(const std::wstring& text, TextType type) { | 164 bool Write(const std::wstring& text, TextType type) { |
165 std::string utf8_string; | 165 std::string utf8_string; |
166 | 166 |
167 switch (type) { | 167 switch (type) { |
168 case ATTRIBUTE_VALUE: | 168 case ATTRIBUTE_VALUE: |
169 // Convert " to \" | 169 // Convert " to " |
170 if (text.find(L"\"") != std::wstring::npos) { | 170 if (text.find(L"\"") != std::wstring::npos) { |
171 string16 replaced_string = WideToUTF16Hack(text); | 171 string16 replaced_string = WideToUTF16Hack(text); |
172 ReplaceSubstringsAfterOffset(&replaced_string, 0, | 172 ReplaceSubstringsAfterOffset(&replaced_string, 0, |
173 ASCIIToUTF16("\""), | 173 ASCIIToUTF16("\""), |
174 ASCIIToUTF16("\\\"")); | 174 ASCIIToUTF16(""")); |
175 utf8_string = UTF16ToUTF8(replaced_string); | 175 utf8_string = UTF16ToUTF8(replaced_string); |
176 } else { | 176 } else { |
177 utf8_string = WideToUTF8(text); | 177 utf8_string = WideToUTF8(text); |
178 } | 178 } |
179 break; | 179 break; |
180 | 180 |
181 case CONTENT: | 181 case CONTENT: |
182 utf8_string = WideToUTF8(EscapeForHTML(text)); | 182 utf8_string = WideToUTF8(EscapeForHTML(text)); |
183 break; | 183 break; |
184 | 184 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 BookmarkCodec codec; | 326 BookmarkCodec codec; |
327 scoped_ptr<Writer> writer(new Writer(codec.Encode(model), | 327 scoped_ptr<Writer> writer(new Writer(codec.Encode(model), |
328 FilePath::FromWStringHack(path))); | 328 FilePath::FromWStringHack(path))); |
329 if (thread) | 329 if (thread) |
330 thread->PostTask(FROM_HERE, writer.release()); | 330 thread->PostTask(FROM_HERE, writer.release()); |
331 else | 331 else |
332 writer->Run(); | 332 writer->Run(); |
333 } | 333 } |
334 | 334 |
335 } // namespace bookmark_html_writer | 335 } // namespace bookmark_html_writer |
OLD | NEW |