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

Side by Side Diff: components/autofill/core/browser/legal_message_line.h

Issue 1540423004: Add card details and legal message to Android save credit card infobar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: components/autofill review. Created 4 years, 11 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_LEGAL_MESSAGE_LINE_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_LEGAL_MESSAGE_LINE_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/gtest_prod_util.h"
12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/strings/string16.h"
15 #include "ui/gfx/range/range.h"
16 #include "url/gurl.h"
17
18 namespace base {
19 class DictionaryValue;
20 }
21
22 namespace autofill {
23
24 class LegalMessageLine;
25
26 using LegalMessageLines = std::vector<LegalMessageLine>;
27
28 class LegalMessageLine {
29 public:
30 struct Link {
31 Link(size_t start, size_t end, const std::string& url_spec);
32 ~Link();
33
34 gfx::Range range;
35 GURL url;
36 };
37
38 LegalMessageLine();
39 virtual ~LegalMessageLine(); // Overridden in TestLegalMessageLine.
40
41 // Parses |legal_message|. Returns false on failure.
42 //
43 // Example of valid |legal_message| data:
44 // {
45 // "line" : [ {
46 // "template" : "The legal documents are: {0} and {1}",
47 // "template_parameter" : [ {
48 // "display_text" : "Terms of Service",
49 // "url": "http://www.example.com/tos"
50 // }, {
51 // "display_text" : "Privacy Policy",
52 // "url": "http://www.example.com/pp"
53 // } ],
54 // }, {
55 // "template" : "This is the second line and it has no parameters"
56 // } ]
57 // }
58 //
59 // Caveats:
60 // 1. '{' and '}' may be displayed by escaping them with an apostrophe in the
61 // template string, e.g. template "Here is a literal '{'".
62 // 2. Two or more consecutive dollar signs in the template string will not
63 // expand correctly.
64 // 3. "${" anywhere in the template string is invalid.
65 // 4. "\n" embedded anywhere in the template string, or an empty template
66 // string, can be used to separate paragraphs. It is not possible to create
67 // a completely blank line by using two consecutive newlines (they will be
68 // treated as a single newline by views::StyledLabel).
69 static bool Parse(const base::DictionaryValue& legal_message,
70 LegalMessageLines* out);
71
72 const base::string16& text() const { return text_; }
73 const std::vector<Link>& links() const { return links_; }
74
75 private:
76 friend class TestLegalMessageLine;
77
78 bool ParseLine(const base::DictionaryValue& line);
79
80 base::string16 text_;
81 std::vector<Link> links_;
82 };
83
84 } // namespace autofill
85
86 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_LEGAL_MESSAGE_LINE_H_
OLDNEW
« no previous file with comments | « components/autofill/core/browser/credit_card.cc ('k') | components/autofill/core/browser/legal_message_line.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698