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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 ~TextField(); | 68 ~TextField(); |
69 | 69 |
70 // Parses |field_json| and populates |text_field| with the contents. If any | 70 // Parses |field_json| and populates |text_field| with the contents. If any |
71 // of the required elements is missing, returns false and leaves text_field | 71 // of the required elements is missing, returns false and leaves text_field |
72 // in a partially populated state. | 72 // in a partially populated state. |
73 static bool ParseTextField(const base::DictionaryValue* field_json, | 73 static bool ParseTextField(const base::DictionaryValue* field_json, |
74 TextField* text_field); | 74 TextField* text_field); |
75 | 75 |
76 const base::string16& text() const { return text_; } | 76 const base::string16& text() const { return text_; } |
77 int type() const { return type_; } | 77 int type() const { return type_; } |
78 bool has_num_lines() const { return has_num_lines_; } | 78 bool has_num_lines() const { return has_num_lines_; } |
groby-ooo-7-16
2016/06/23 20:49:27
Since we discussed this as well: Will you kill thi
Kevin Bailey
2016/06/23 21:49:23
I actually like this method, since it closely corr
groby-ooo-7-16
2016/06/28 17:20:04
It is *implicit* that a TextField has a single lin
Kevin Bailey
2016/06/28 18:46:23
'ParseImageLine()' uses the first "ln" field that
| |
79 int num_lines() const { return num_lines_; } | 79 int num_lines() const { return num_lines_; } |
80 | 80 |
81 bool Equals(const TextField& field) const; | 81 bool Equals(const TextField& field) const; |
82 | 82 |
83 private: | 83 private: |
84 base::string16 text_; | 84 base::string16 text_; |
85 int type_; | 85 int type_; |
86 bool has_num_lines_; | 86 bool has_num_lines_; |
87 int num_lines_; | 87 int num_lines_; |
88 | 88 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 // TODO(jdonnelly): Once something like std::optional<T> is available in base/ | 140 // 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 | 141 // (see discussion at http://goo.gl/zN2GNy) remove this in favor of having |
142 // SuggestResult and AutocompleteMatch use optional<SuggestionAnswer>. | 142 // SuggestResult and AutocompleteMatch use optional<SuggestionAnswer>. |
143 static std::unique_ptr<SuggestionAnswer> copy( | 143 static std::unique_ptr<SuggestionAnswer> copy( |
144 const SuggestionAnswer* source) { | 144 const SuggestionAnswer* source) { |
145 return base::WrapUnique(source ? new SuggestionAnswer(*source) : nullptr); | 145 return base::WrapUnique(source ? new SuggestionAnswer(*source) : nullptr); |
146 } | 146 } |
147 | 147 |
148 const ImageLine& first_line() const { return first_line_; } | 148 const ImageLine& first_line() const { return first_line_; } |
149 const ImageLine& second_line() const { return second_line_; } | 149 const ImageLine& second_line() const { return second_line_; } |
150 int SecondLineSize() const { return second_line_size_; } | |
groby-ooo-7-16
2016/06/23 20:49:27
Why not simply have a LineSize() function on Image
Kevin Bailey
2016/06/23 21:49:22
Yes, I like the idea of moving it to ImageLine, bu
Kevin Bailey
2016/06/28 15:59:32
Done.
| |
150 | 151 |
151 // Answer type accessors. Valid types are non-negative and defined at | 152 // Answer type accessors. Valid types are non-negative and defined at |
152 // https://goto.google.com/visual_element_configuration. | 153 // https://goto.google.com/visual_element_configuration. |
153 int type() const { return type_; } | 154 int type() const { return type_; } |
154 void set_type(int type) { type_ = type; } | 155 void set_type(int type) { type_ = type; } |
155 | 156 |
156 bool Equals(const SuggestionAnswer& answer) const; | 157 bool Equals(const SuggestionAnswer& answer) const; |
157 | 158 |
158 // Retrieves any image URLs appearing in this answer and adds them to |urls|. | 159 // Retrieves any image URLs appearing in this answer and adds them to |urls|. |
159 void AddImageURLsTo(URLs* urls) const; | 160 void AddImageURLsTo(URLs* urls) const; |
160 | 161 |
161 private: | 162 private: |
162 // Forbid assignment. | 163 // Forbid assignment. |
163 SuggestionAnswer& operator=(const SuggestionAnswer&); | 164 SuggestionAnswer& operator=(const SuggestionAnswer&); |
164 | 165 |
165 ImageLine first_line_; | 166 ImageLine first_line_; |
166 ImageLine second_line_; | 167 ImageLine second_line_; |
167 int type_; | 168 int type_; |
169 int second_line_size_; | |
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 |