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

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: Removed import-complete dialog. Created 4 years, 9 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 <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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698