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

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

Issue 2755503002: Add a new entry to omnibox_event.proto to log specific type of contextual suggestions (Closed)
Patch Set: Fix consistency between comments and field names. Created 3 years, 8 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_SEARCH_SUGGESTION_PARSER_H_ 5 #ifndef COMPONENTS_OMNIBOX_BROWSER_SEARCH_SUGGESTION_PARSER_H_
6 #define COMPONENTS_OMNIBOX_BROWSER_SEARCH_SUGGESTION_PARSER_H_ 6 #define COMPONENTS_OMNIBOX_BROWSER_SEARCH_SUGGESTION_PARSER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 24 matching lines...) Expand all
35 // new suggestions from updated input are in flight. 35 // new suggestions from updated input are in flight.
36 // TODO(msw) Extend these classes to generate their corresponding matches and 36 // TODO(msw) Extend these classes to generate their corresponding matches and
37 // other requisite data, in order to consolidate and simplify the 37 // other requisite data, in order to consolidate and simplify the
38 // highly fragmented SearchProvider logic for each Result type. 38 // highly fragmented SearchProvider logic for each Result type.
39 class Result { 39 class Result {
40 public: 40 public:
41 Result(bool from_keyword_provider, 41 Result(bool from_keyword_provider,
42 int relevance, 42 int relevance,
43 bool relevance_from_server, 43 bool relevance_from_server,
44 AutocompleteMatchType::Type type, 44 AutocompleteMatchType::Type type,
45 int subtype_identifier,
45 const std::string& deletion_url); 46 const std::string& deletion_url);
46 Result(const Result& other); 47 Result(const Result& other);
47 virtual ~Result(); 48 virtual ~Result();
48 49
49 bool from_keyword_provider() const { return from_keyword_provider_; } 50 bool from_keyword_provider() const { return from_keyword_provider_; }
50 51
51 const base::string16& match_contents() const { return match_contents_; } 52 const base::string16& match_contents() const { return match_contents_; }
52 const ACMatchClassifications& match_contents_class() const { 53 const ACMatchClassifications& match_contents_class() const {
53 return match_contents_class_; 54 return match_contents_class_;
54 } 55 }
55 56
56 AutocompleteMatchType::Type type() const { return type_; } 57 AutocompleteMatchType::Type type() const { return type_; }
58 int subtype_identifier() const { return subtype_identifier_; }
57 int relevance() const { return relevance_; } 59 int relevance() const { return relevance_; }
58 void set_relevance(int relevance) { relevance_ = relevance; } 60 void set_relevance(int relevance) { relevance_ = relevance; }
59 bool received_after_last_keystroke() const { 61 bool received_after_last_keystroke() const {
60 return received_after_last_keystroke_; 62 return received_after_last_keystroke_;
61 } 63 }
62 void set_received_after_last_keystroke( 64 void set_received_after_last_keystroke(
63 bool received_after_last_keystroke) { 65 bool received_after_last_keystroke) {
64 received_after_last_keystroke_ = received_after_last_keystroke; 66 received_after_last_keystroke_ = received_after_last_keystroke;
65 } 67 }
66 68
(...skipping 14 matching lines...) Expand all
81 protected: 83 protected:
82 // The contents to be displayed and its style info. 84 // The contents to be displayed and its style info.
83 base::string16 match_contents_; 85 base::string16 match_contents_;
84 ACMatchClassifications match_contents_class_; 86 ACMatchClassifications match_contents_class_;
85 87
86 // True if the result came from the keyword provider. 88 // True if the result came from the keyword provider.
87 bool from_keyword_provider_; 89 bool from_keyword_provider_;
88 90
89 AutocompleteMatchType::Type type_; 91 AutocompleteMatchType::Type type_;
90 92
93 // Used to identify the specific source / type for suggestions by the
94 // suggest server. The meaning of individual values is determined by the
Mark P 2017/03/31 20:50:25 ditto comment in other file
gcomanici 2017/04/01 16:01:52 Done.
95 // provider of each suggestion type and is different for every suggestion
96 // type. Contact service providers for more details.
97 // The identifier 0 is reserved for cases where this specific type is unset.
98 int subtype_identifier_;
99
91 // The relevance score. 100 // The relevance score.
92 int relevance_; 101 int relevance_;
93 102
94 private: 103 private:
95 // Whether this result's relevance score was fully or partly calculated 104 // Whether this result's relevance score was fully or partly calculated
96 // based on server information, and thus is assumed to be more accurate. 105 // based on server information, and thus is assumed to be more accurate.
97 // This is ultimately used in 106 // This is ultimately used in
98 // SearchProvider::ConvertResultsToAutocompleteMatches(), see comments 107 // SearchProvider::ConvertResultsToAutocompleteMatches(), see comments
99 // there. 108 // there.
100 bool relevance_from_server_; 109 bool relevance_from_server_;
101 110
102 // Whether this result was received asynchronously after the last 111 // Whether this result was received asynchronously after the last
103 // keystroke, otherwise it must have come from prior cached results 112 // keystroke, otherwise it must have come from prior cached results
104 // or from a synchronous provider. 113 // or from a synchronous provider.
105 bool received_after_last_keystroke_; 114 bool received_after_last_keystroke_;
106 115
107 // Optional deletion URL provided with suggestions. Fetching this URL 116 // Optional deletion URL provided with suggestions. Fetching this URL
108 // should result in some reasonable deletion behaviour on the server, 117 // should result in some reasonable deletion behaviour on the server,
109 // e.g. deleting this term out of a user's server-side search history. 118 // e.g. deleting this term out of a user's server-side search history.
110 std::string deletion_url_; 119 std::string deletion_url_;
111 }; 120 };
112 121
113 class SuggestResult : public Result { 122 class SuggestResult : public Result {
114 public: 123 public:
115 SuggestResult(const base::string16& suggestion, 124 SuggestResult(const base::string16& suggestion,
116 AutocompleteMatchType::Type type, 125 AutocompleteMatchType::Type type,
126 int subtype_identifier,
117 const base::string16& match_contents, 127 const base::string16& match_contents,
118 const base::string16& match_contents_prefix, 128 const base::string16& match_contents_prefix,
119 const base::string16& annotation, 129 const base::string16& annotation,
120 const base::string16& answer_contents, 130 const base::string16& answer_contents,
121 const base::string16& answer_type, 131 const base::string16& answer_type,
122 std::unique_ptr<SuggestionAnswer> answer, 132 std::unique_ptr<SuggestionAnswer> answer,
123 const std::string& suggest_query_params, 133 const std::string& suggest_query_params,
124 const std::string& deletion_url, 134 const std::string& deletion_url,
125 bool from_keyword_provider, 135 bool from_keyword_provider,
126 int relevance, 136 int relevance,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 199
190 // Should this result be prefetched? 200 // Should this result be prefetched?
191 bool should_prefetch_; 201 bool should_prefetch_;
192 }; 202 };
193 203
194 class NavigationResult : public Result { 204 class NavigationResult : public Result {
195 public: 205 public:
196 NavigationResult(const AutocompleteSchemeClassifier& scheme_classifier, 206 NavigationResult(const AutocompleteSchemeClassifier& scheme_classifier,
197 const GURL& url, 207 const GURL& url,
198 AutocompleteMatchType::Type type, 208 AutocompleteMatchType::Type type,
209 int subtype_identifier,
199 const base::string16& description, 210 const base::string16& description,
200 const std::string& deletion_url, 211 const std::string& deletion_url,
201 bool from_keyword_provider, 212 bool from_keyword_provider,
202 int relevance, 213 int relevance,
203 bool relevance_from_server, 214 bool relevance_from_server,
204 const base::string16& input_text); 215 const base::string16& input_text);
205 ~NavigationResult() override; 216 ~NavigationResult() override;
206 217
207 const GURL& url() const { return url_; } 218 const GURL& url() const { return url_; }
208 const base::string16& description() const { return description_; } 219 const base::string16& description() const { return description_; }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 const AutocompleteSchemeClassifier& scheme_classifier, 308 const AutocompleteSchemeClassifier& scheme_classifier,
298 int default_result_relevance, 309 int default_result_relevance,
299 bool is_keyword_result, 310 bool is_keyword_result,
300 Results* results); 311 Results* results);
301 312
302 private: 313 private:
303 DISALLOW_COPY_AND_ASSIGN(SearchSuggestionParser); 314 DISALLOW_COPY_AND_ASSIGN(SearchSuggestionParser);
304 }; 315 };
305 316
306 #endif // COMPONENTS_OMNIBOX_BROWSER_SEARCH_SUGGESTION_PARSER_H_ 317 #endif // COMPONENTS_OMNIBOX_BROWSER_SEARCH_SUGGESTION_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698