Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_OMNIBOX_BROWSER_SUGGESTION_ANSWER_H_ | 5 #ifndef COMPONENTS_OMNIBOX_BROWSER_SUGGESTION_ANSWER_H_ |
| 6 #define COMPONENTS_OMNIBOX_BROWSER_SUGGESTION_ANSWER_H_ | 6 #define COMPONENTS_OMNIBOX_BROWSER_SUGGESTION_ANSWER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 // Parses |line_json| and populates |image_line| with the contents. If any | 101 // Parses |line_json| and populates |image_line| with the contents. If any |
| 102 // of the required elements is missing, returns false and leaves text_field | 102 // of the required elements is missing, returns false and leaves text_field |
| 103 // in a partially populated state. | 103 // in a partially populated state. |
| 104 static bool ParseImageLine(const base::DictionaryValue* line_json, | 104 static bool ParseImageLine(const base::DictionaryValue* line_json, |
| 105 ImageLine* image_line); | 105 ImageLine* image_line); |
| 106 | 106 |
| 107 const TextFields& text_fields() const { return text_fields_; } | 107 const TextFields& text_fields() const { return text_fields_; } |
| 108 const TextField* additional_text() const { return additional_text_.get(); } | 108 const TextField* additional_text() const { return additional_text_.get(); } |
| 109 const TextField* status_text() const { return status_text_.get(); } | 109 const TextField* status_text() const { return status_text_.get(); } |
| 110 const GURL& image_url() const { return image_url_; } | 110 const GURL& image_url() const { return image_url_; } |
| 111 int TextNumLines() const { return text_num_lines_; } | |
|
groby-ooo-7-16
2016/06/28 17:20:04
Nit: NumTextLines? Also, since it's a cheap functi
Kevin Bailey
2016/06/28 18:46:24
Done.
| |
| 111 | 112 |
| 112 bool Equals(const ImageLine& line) const; | 113 bool Equals(const ImageLine& line) const; |
| 113 | 114 |
| 114 // Returns a string appropriate for use as a readable representation of the | 115 // Returns a string appropriate for use as a readable representation of the |
| 115 // content of this line. | 116 // content of this line. |
| 116 base::string16 AccessibleText() const; | 117 base::string16 AccessibleText() const; |
| 117 | 118 |
| 118 private: | 119 private: |
| 119 // Forbid assignment. | 120 // Forbid assignment. |
| 120 ImageLine& operator=(const ImageLine&); | 121 ImageLine& operator=(const ImageLine&); |
| 121 | 122 |
| 122 TextFields text_fields_; | 123 TextFields text_fields_; |
| 124 int text_num_lines_; | |
| 123 std::unique_ptr<TextField> additional_text_; | 125 std::unique_ptr<TextField> additional_text_; |
| 124 std::unique_ptr<TextField> status_text_; | 126 std::unique_ptr<TextField> status_text_; |
| 125 GURL image_url_; | 127 GURL image_url_; |
| 126 | 128 |
| 127 FRIEND_TEST_ALL_PREFIXES(SuggestionAnswerTest, DifferentValuesAreUnequal); | 129 FRIEND_TEST_ALL_PREFIXES(SuggestionAnswerTest, DifferentValuesAreUnequal); |
| 128 }; | 130 }; |
| 129 | 131 |
| 130 SuggestionAnswer(); | 132 SuggestionAnswer(); |
| 131 SuggestionAnswer(const SuggestionAnswer& answer); | 133 SuggestionAnswer(const SuggestionAnswer& answer) = default; |
| 132 ~SuggestionAnswer(); | 134 ~SuggestionAnswer(); |
| 133 | 135 |
| 134 // Parses |answer_json| and returns a SuggestionAnswer containing the | 136 // Parses |answer_json| and returns a SuggestionAnswer containing the |
| 135 // contents. If the supplied data is not well formed or is missing required | 137 // contents. If the supplied data is not well formed or is missing required |
| 136 // elements, returns nullptr instead. | 138 // elements, returns nullptr instead. |
| 137 static std::unique_ptr<SuggestionAnswer> ParseAnswer( | 139 static std::unique_ptr<SuggestionAnswer> ParseAnswer( |
| 138 const base::DictionaryValue* answer_json); | 140 const base::DictionaryValue* answer_json); |
| 139 | 141 |
| 140 // TODO(jdonnelly): Once something like std::optional<T> is available in base/ | 142 // TODO(jdonnelly): Once something like std::optional<T> is available in base/ |
| 141 // (see discussion at http://goo.gl/zN2GNy) remove this in favor of having | 143 // (see discussion at http://goo.gl/zN2GNy) remove this in favor of having |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 163 SuggestionAnswer& operator=(const SuggestionAnswer&); | 165 SuggestionAnswer& operator=(const SuggestionAnswer&); |
| 164 | 166 |
| 165 ImageLine first_line_; | 167 ImageLine first_line_; |
| 166 ImageLine second_line_; | 168 ImageLine second_line_; |
| 167 int type_; | 169 int type_; |
| 168 | 170 |
| 169 FRIEND_TEST_ALL_PREFIXES(SuggestionAnswerTest, DifferentValuesAreUnequal); | 171 FRIEND_TEST_ALL_PREFIXES(SuggestionAnswerTest, DifferentValuesAreUnequal); |
| 170 }; | 172 }; |
| 171 | 173 |
| 172 #endif // COMPONENTS_OMNIBOX_BROWSER_SUGGESTION_ANSWER_H_ | 174 #endif // COMPONENTS_OMNIBOX_BROWSER_SUGGESTION_ANSWER_H_ |
| OLD | NEW |