Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: chrome/utility/importer/bookmark_html_reader.cc

Issue 1119453003: [Importer] Allow Chrome to import bookmark files without a charset specified. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/utility/importer/bookmark_html_reader.h" 5 #include "chrome/utility/importer/bookmark_html_reader.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/i18n/icu_string_conversions.h" 9 #include "base/i18n/icu_string_conversions.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 std::vector<std::string> lines; 99 std::vector<std::string> lines;
100 base::SplitString(content, '\n', &lines); 100 base::SplitString(content, '\n', &lines);
101 101
102 base::string16 last_folder; 102 base::string16 last_folder;
103 bool last_folder_on_toolbar = false; 103 bool last_folder_on_toolbar = false;
104 bool last_folder_is_empty = true; 104 bool last_folder_is_empty = true;
105 bool has_subfolder = false; 105 bool has_subfolder = false;
106 base::Time last_folder_add_date; 106 base::Time last_folder_add_date;
107 std::vector<base::string16> path; 107 std::vector<base::string16> path;
108 size_t toolbar_folder_index = 0; 108 size_t toolbar_folder_index = 0;
109 std::string charset; 109 std::string charset = "UTF-8"; // If no charset is specified, assume utf-8.
110 for (size_t i = 0; 110 for (size_t i = 0;
111 i < lines.size() && 111 i < lines.size() &&
112 (cancellation_callback.is_null() || !cancellation_callback.Run()); 112 (cancellation_callback.is_null() || !cancellation_callback.Run());
113 ++i) { 113 ++i) {
114 std::string line; 114 std::string line;
115 base::TrimString(lines[i], " ", &line); 115 base::TrimString(lines[i], " ", &line);
116 116
117 // Remove "<HR>" if |line| starts with it. "<HR>" is the bookmark entries 117 // Remove "<HR>" if |line| starts with it. "<HR>" is the bookmark entries
118 // separator in Firefox that Chrome does not support. Note that there can be 118 // separator in Firefox that Chrome does not support. Note that there can be
119 // multiple "<HR>" tags at the beginning of a single line. 119 // multiple "<HR>" tags at the beginning of a single line.
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 *url = GURL(value); 469 *url = GURL(value);
470 } 470 }
471 } 471 }
472 472
473 return true; 473 return true;
474 } 474 }
475 475
476 } // namespace internal 476 } // namespace internal
477 477
478 } // namespace bookmark_html_reader 478 } // namespace bookmark_html_reader
OLDNEW
« no previous file with comments | « chrome/test/data/bookmark_html_reader/ie_sans_charset.html ('k') | chrome/utility/importer/bookmark_html_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698