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

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: 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 #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>
9 #include <string>
10 #include <vector> 8 #include <vector>
11 9
12 #include "base/macros.h" 10 #include "base/macros.h"
13 #include "base/strings/string_piece.h" 11 #include "base/strings/string_piece.h"
12 #include "components/password_manager/core/browser/types.h"
14 13
15 namespace password_manager { 14 namespace password_manager {
16 15
17 // Reads tabular data from CSV (Comma Separated Values) format as defined in RFC 16 // Reads tabular data from CSV (Comma Separated Values) format as defined in RFC
18 // 4180, with the following limitations/relaxations: 17 // 4180, with the following limitations/relaxations:
19 // * The input should be UTF-8 encoded. No code points should be escaped. 18 // * 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. 19 // * 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 20 // * Records may be separated by either LF or CRLF sequences. Each CRLF will
22 // be converted to LF characters inside quotes. 21 // be converted to LF characters inside quotes.
23 // * Inconsistent number of fields within records is handled gracefully. Extra 22 // * Inconsistent number of fields within records is handled gracefully. Extra
24 // fields are ignored. Missing fields will have no corresponding key-value 23 // fields are ignored. Missing fields will have no corresponding key-value
25 // pair in the record's ColumnNameToValueMap. 24 // pair in the record's ColumnNameToValueMap.
26 // * Repeated columns of the same name are not supported (the last value will 25 // * Repeated columns of the same name are not supported (the last value will
27 // be preserved). 26 // be preserved).
28 // 27 //
29 // The CSV representation of the data will be read from |csv|. The first line of 28 // 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 29 // 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 30 // 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 31 // to the value of the corresponding field, and inserted into |records|. Both
33 // |column_names| and |records| will be overwritten. Returns false if parsing 32 // |column_names| and |records| will be overwritten. Returns false if parsing
34 // failed due to a syntax error. 33 // failed due to a syntax error.
35 bool ReadCSV(base::StringPiece csv, 34 bool ReadCSV(base::StringPiece csv,
36 std::vector<std::string>* column_names, 35 std::vector<std::string>* column_names,
37 std::vector<std::map<std::string, std::string>>* records); 36 std::vector<ColumnNameToValueMap>* records);
38 37
39 } // namespace password_manager 38 } // namespace password_manager
40 39
41 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_EXPORT_CSV_READER_H_ 40 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_EXPORT_CSV_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698