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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 return true; | 93 return true; |
94 } | 94 } |
95 | 95 |
96 } // namespace | 96 } // namespace |
97 | 97 |
98 namespace password_manager { | 98 namespace password_manager { |
99 | 99 |
100 bool ReadCSV(base::StringPiece csv, | 100 bool ReadCSV(base::StringPiece csv, |
101 std::vector<std::string>* column_names, | 101 std::vector<std::string>* column_names, |
102 std::vector<std::map<std::string, std::string>>* records) { | 102 std::vector<ColumnNameToValueMap>* records) { |
103 DCHECK(column_names); | 103 DCHECK(column_names); |
104 DCHECK(records); | 104 DCHECK(records); |
105 | 105 |
106 column_names->clear(); | 106 column_names->clear(); |
107 records->clear(); | 107 records->clear(); |
108 | 108 |
109 // Normalize EOL sequences so that we uniformly use a single LF character. | 109 // Normalize EOL sequences so that we uniformly use a single LF character. |
110 std::string normalized_csv(csv.as_string()); | 110 std::string normalized_csv(csv.as_string()); |
111 base::ReplaceSubstringsAfterOffset(&normalized_csv, 0, "\r\n", "\n"); | 111 base::ReplaceSubstringsAfterOffset(&normalized_csv, 0, "\r\n", "\n"); |
112 | 112 |
(...skipping 11 matching lines...) Expand all Loading... |
124 records->resize(records->size() + 1); | 124 records->resize(records->size() + 1); |
125 for (size_t i = 0; i < column_names->size() && i < fields.size(); ++i) { | 125 for (size_t i = 0; i < column_names->size() && i < fields.size(); ++i) { |
126 records->back()[(*column_names)[i]].swap(fields[i]); | 126 records->back()[(*column_names)[i]].swap(fields[i]); |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 return true; | 130 return true; |
131 } | 131 } |
132 | 132 |
133 } // namespace password_manager | 133 } // namespace password_manager |
OLD | NEW |