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

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: Small fixes and sync. 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. See |result_type_identifier| in omnibox.proto for more
95 // details.
96 // The identifier 0 is reserved for cases where this specific type is unset.
97 int subtype_identifier_;
98
91 // The relevance score. 99 // The relevance score.
92 int relevance_; 100 int relevance_;
93 101
94 private: 102 private:
95 // Whether this result's relevance score was fully or partly calculated 103 // Whether this result's relevance score was fully or partly calculated
96 // based on server information, and thus is assumed to be more accurate. 104 // based on server information, and thus is assumed to be more accurate.
97 // This is ultimately used in 105 // This is ultimately used in
98 // SearchProvider::ConvertResultsToAutocompleteMatches(), see comments 106 // SearchProvider::ConvertResultsToAutocompleteMatches(), see comments
99 // there. 107 // there.
100 bool relevance_from_server_; 108 bool relevance_from_server_;
101 109
102 // Whether this result was received asynchronously after the last 110 // Whether this result was received asynchronously after the last
103 // keystroke, otherwise it must have come from prior cached results 111 // keystroke, otherwise it must have come from prior cached results
104 // or from a synchronous provider. 112 // or from a synchronous provider.
105 bool received_after_last_keystroke_; 113 bool received_after_last_keystroke_;
106 114
107 // Optional deletion URL provided with suggestions. Fetching this URL 115 // Optional deletion URL provided with suggestions. Fetching this URL
108 // should result in some reasonable deletion behaviour on the server, 116 // 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. 117 // e.g. deleting this term out of a user's server-side search history.
110 std::string deletion_url_; 118 std::string deletion_url_;
111 }; 119 };
112 120
113 class SuggestResult : public Result { 121 class SuggestResult : public Result {
114 public: 122 public:
115 SuggestResult(const base::string16& suggestion, 123 SuggestResult(const base::string16& suggestion,
116 AutocompleteMatchType::Type type, 124 AutocompleteMatchType::Type type,
125 int subtype_identifier,
117 const base::string16& match_contents, 126 const base::string16& match_contents,
118 const base::string16& match_contents_prefix, 127 const base::string16& match_contents_prefix,
119 const base::string16& annotation, 128 const base::string16& annotation,
120 const base::string16& answer_contents, 129 const base::string16& answer_contents,
121 const base::string16& answer_type, 130 const base::string16& answer_type,
122 std::unique_ptr<SuggestionAnswer> answer, 131 std::unique_ptr<SuggestionAnswer> answer,
123 const std::string& suggest_query_params, 132 const std::string& suggest_query_params,
124 const std::string& deletion_url, 133 const std::string& deletion_url,
125 bool from_keyword_provider, 134 bool from_keyword_provider,
126 int relevance, 135 int relevance,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 198
190 // Should this result be prefetched? 199 // Should this result be prefetched?
191 bool should_prefetch_; 200 bool should_prefetch_;
192 }; 201 };
193 202
194 class NavigationResult : public Result { 203 class NavigationResult : public Result {
195 public: 204 public:
196 NavigationResult(const AutocompleteSchemeClassifier& scheme_classifier, 205 NavigationResult(const AutocompleteSchemeClassifier& scheme_classifier,
197 const GURL& url, 206 const GURL& url,
198 AutocompleteMatchType::Type type, 207 AutocompleteMatchType::Type type,
208 int subtype_identifier,
199 const base::string16& description, 209 const base::string16& description,
200 const std::string& deletion_url, 210 const std::string& deletion_url,
201 bool from_keyword_provider, 211 bool from_keyword_provider,
202 int relevance, 212 int relevance,
203 bool relevance_from_server, 213 bool relevance_from_server,
204 const base::string16& input_text); 214 const base::string16& input_text);
205 ~NavigationResult() override; 215 ~NavigationResult() override;
206 216
207 const GURL& url() const { return url_; } 217 const GURL& url() const { return url_; }
208 const base::string16& description() const { return description_; } 218 const base::string16& description() const { return description_; }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 const AutocompleteSchemeClassifier& scheme_classifier, 307 const AutocompleteSchemeClassifier& scheme_classifier,
298 int default_result_relevance, 308 int default_result_relevance,
299 bool is_keyword_result, 309 bool is_keyword_result,
300 Results* results); 310 Results* results);
301 311
302 private: 312 private:
303 DISALLOW_COPY_AND_ASSIGN(SearchSuggestionParser); 313 DISALLOW_COPY_AND_ASSIGN(SearchSuggestionParser);
304 }; 314 };
305 315
306 #endif // COMPONENTS_OMNIBOX_BROWSER_SEARCH_SUGGESTION_PARSER_H_ 316 #endif // COMPONENTS_OMNIBOX_BROWSER_SEARCH_SUGGESTION_PARSER_H_
OLDNEW
« no previous file with comments | « components/omnibox/browser/search_provider.cc ('k') | components/omnibox/browser/search_suggestion_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698