OLD | NEW |
(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 <vector> |
| 9 |
| 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/strings/string16.h" |
| 14 #include "ui/gfx/range/range.h" |
| 15 #include "url/gurl.h" |
| 16 |
| 17 namespace base { |
| 18 class DictionaryValue; |
| 19 } |
| 20 |
| 21 namespace autofill { |
| 22 |
| 23 class LegalMessageLine { |
| 24 public: |
| 25 struct Link { |
| 26 gfx::Range range; |
| 27 GURL url; |
| 28 }; |
| 29 |
| 30 // Parses |line|. Returns false on failure. |
| 31 static bool Parse(const base::DictionaryValue& legal_message, |
| 32 std::vector<scoped_ptr<LegalMessageLine>>* out); |
| 33 |
| 34 LegalMessageLine(); |
| 35 ~LegalMessageLine(); |
| 36 |
| 37 const base::string16& text() const { return text_; } |
| 38 const std::vector<Link>& links() const { return links_; } |
| 39 |
| 40 private: |
| 41 FRIEND_TEST_ALL_PREFIXES(LegalMessageLineTest, NoParameters); |
| 42 FRIEND_TEST_ALL_PREFIXES(LegalMessageLineTest, SingleParameter); |
| 43 FRIEND_TEST_ALL_PREFIXES(LegalMessageLineTest, MissingUrl); |
| 44 FRIEND_TEST_ALL_PREFIXES(LegalMessageLineTest, MissingDisplayText); |
| 45 FRIEND_TEST_ALL_PREFIXES(LegalMessageLineTest, EscapeCharacters); |
| 46 FRIEND_TEST_ALL_PREFIXES(LegalMessageLineTest, ConsecutiveDollarSigns); |
| 47 FRIEND_TEST_ALL_PREFIXES(LegalMessageLineTest, DollarAndParenthesis); |
| 48 FRIEND_TEST_ALL_PREFIXES(LegalMessageLineTest, MultipleParameters); |
| 49 FRIEND_TEST_ALL_PREFIXES(LegalMessageLineTest, MultipleLineElements); |
| 50 FRIEND_TEST_ALL_PREFIXES(LegalMessageLineTest, EmbeddedNewlines); |
| 51 FRIEND_TEST_ALL_PREFIXES(LegalMessageLineTest, MaximumPlaceholders); |
| 52 |
| 53 bool ParseLine(const base::DictionaryValue& line); |
| 54 |
| 55 base::string16 text_; |
| 56 std::vector<Link> links_; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(LegalMessageLine); |
| 59 }; |
| 60 |
| 61 typedef std::vector<scoped_ptr<LegalMessageLine>> LegalMessageLines; |
| 62 |
| 63 } // namespace autofill |
| 64 |
| 65 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_LEGAL_MESSAGE_LINE_H_ |
OLD | NEW |