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

Side by Side Diff: components/omnibox/browser/suggestion_answer.h

Issue 2091473003: Factor parsing "ln=" to SuggestionAnswer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: TextNumLines -> num_text_lines Created 4 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_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
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 num_text_lines() const { return num_text_lines_; }
Peter Kasting 2016/06/29 23:08:57 Nit: Make accessor order and member declaration or
Kevin Bailey 2016/06/30 13:19:29 Made this one match rest of CL.
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 num_text_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
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_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_result_view.cc ('k') | components/omnibox/browser/suggestion_answer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698