| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/password_manager/core/browser/import/csv_reader.h" | 5 #include "components/password_manager/core/browser/import/csv_reader.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "third_party/re2/re2/re2.h" | 9 #include "third_party/re2/re2/re2.h" |
| 10 | 10 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 return true; | 90 return true; |
| 91 } | 91 } |
| 92 | 92 |
| 93 } // namespace | 93 } // namespace |
| 94 | 94 |
| 95 namespace password_manager { | 95 namespace password_manager { |
| 96 | 96 |
| 97 bool ReadCSV(base::StringPiece csv, | 97 bool ReadCSV(base::StringPiece csv, |
| 98 std::vector<std::string>* column_names, | 98 std::vector<std::string>* column_names, |
| 99 std::vector<std::map<std::string, std::string>>* records) { | 99 std::vector<ColumnNameToValueMap>* records) { |
| 100 DCHECK(column_names); | 100 DCHECK(column_names); |
| 101 DCHECK(records); | 101 DCHECK(records); |
| 102 | 102 |
| 103 column_names->clear(); | 103 column_names->clear(); |
| 104 records->clear(); | 104 records->clear(); |
| 105 | 105 |
| 106 // Normalize EOL sequences so that we uniformly use a single LF character. | 106 // Normalize EOL sequences so that we uniformly use a single LF character. |
| 107 std::string normalized_csv(csv.as_string()); | 107 std::string normalized_csv(csv.as_string()); |
| 108 base::ReplaceSubstringsAfterOffset(&normalized_csv, 0, "\r\n", "\n"); | 108 base::ReplaceSubstringsAfterOffset(&normalized_csv, 0, "\r\n", "\n"); |
| 109 | 109 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 121 records->resize(records->size() + 1); | 121 records->resize(records->size() + 1); |
| 122 for (size_t i = 0; i < column_names->size() && i < fields.size(); ++i) { | 122 for (size_t i = 0; i < column_names->size() && i < fields.size(); ++i) { |
| 123 records->back()[(*column_names)[i]].swap(fields[i]); | 123 records->back()[(*column_names)[i]].swap(fields[i]); |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 return true; | 127 return true; |
| 128 } | 128 } |
| 129 | 129 |
| 130 } // namespace password_manager | 130 } // namespace password_manager |
| OLD | NEW |