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

Side by Side Diff: components/password_manager/core/browser/import/csv_reader.cc

Issue 1193143003: Enable import/export of passwords into/from Password Manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 5 years, 5 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 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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698