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

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

Issue 1193143003: Enable import/export of passwords into/from Password Manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 8 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 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_EXPORT_CSV_READER_H_ 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_EXPORT_CSV_READER_H_
6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_EXPORT_CSV_READER_H_ 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_EXPORT_CSV_READER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/strings/string_piece.h" 13 #include "base/strings/string_piece.h"
14 14
15 namespace password_manager { 15 namespace password_manager {
16 16
17 // Reads tabular data from CSV (Comma Separated Values) format as defined in RFC 17 // Reads tabular data from CSV (Comma Separated Values) format as defined in RFC
18 // 4180, with the following limitations/relaxations: 18 // 4180, with the following limitations/relaxations:
19 // * The input should be UTF-8 encoded. No code points should be escaped. 19 // * The input should be UTF-8 encoded. No code points should be escaped.
20 // * The first line must be a header that contains the column names. 20 // * The first line must be a header that contains the column names.
21 // * Records may be separated by either LF or CRLF sequences. Each CRLF will 21 // * Records may be separated by either LF or CRLF sequences. Each CRLF will
22 // be converted to LF characters inside quotes. 22 // be converted to LF characters inside quotes.
23 // * Inconsistent number of fields within records is handled gracefully. Extra 23 // * Inconsistent number of fields within records is handled gracefully. Extra
24 // fields are ignored. Missing fields will have no corresponding key-value 24 // fields are ignored. Missing fields will have no corresponding key-value
25 // pair in the record's ColumnNameToValueMap. 25 // pair in the record.
26 // * Repeated columns of the same name are not supported (the last value will 26 // * Repeated columns of the same name are not supported (the last value will
27 // be preserved). 27 // be preserved).
28 // 28 //
29 // The CSV representation of the data will be read from |csv|. The first line of 29 // The CSV representation of the data will be read from |csv|. The first line of
30 // the file should be a header to extract |column_names| from. From each 30 // the file should be a header to extract |column_names| from. From each
31 // subsequent line, the extracted values are put into a map mapping column names 31 // subsequent line, the extracted values are put into a map mapping column names
32 // to the value of the corresponding field, and inserted into |records|. Both 32 // to the value of the corresponding field, and inserted into |records|. Both
33 // |column_names| and |records| will be overwritten. Returns false if parsing 33 // |column_names| and |records| will be overwritten. Returns false if parsing
34 // failed due to a syntax error. 34 // failed due to a syntax error.
35 bool ReadCSV(base::StringPiece csv, 35 bool ReadCSV(base::StringPiece csv,
36 std::vector<std::string>* column_names, 36 std::vector<std::string>* column_names,
37 std::vector<std::map<std::string, std::string>>* records); 37 std::vector<std::map<std::string, std::string>>* records);
38 38
39 } // namespace password_manager 39 } // namespace password_manager
40 40
41 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_EXPORT_CSV_READER_H_ 41 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_EXPORT_CSV_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698