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_AUTOCOMPLETE_SEARCH_SUGGESTION_PARSER_H_ | 5 #ifndef COMPONENTS_AUTOCOMPLETE_SEARCH_SUGGESTION_PARSER_H_ |
| 6 #define COMPONENTS_AUTOCOMPLETE_SEARCH_SUGGESTION_PARSER_H_ | 6 #define COMPONENTS_AUTOCOMPLETE_SEARCH_SUGGESTION_PARSER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 bool from_keyword_provider() const { return from_keyword_provider_; } | 47 bool from_keyword_provider() const { return from_keyword_provider_; } |
| 48 | 48 |
| 49 const base::string16& match_contents() const { return match_contents_; } | 49 const base::string16& match_contents() const { return match_contents_; } |
| 50 const ACMatchClassifications& match_contents_class() const { | 50 const ACMatchClassifications& match_contents_class() const { |
| 51 return match_contents_class_; | 51 return match_contents_class_; |
| 52 } | 52 } |
| 53 | 53 |
| 54 AutocompleteMatchType::Type type() const { return type_; } | 54 AutocompleteMatchType::Type type() const { return type_; } |
| 55 int relevance() const { return relevance_; } | 55 int relevance() const { return relevance_; } |
| 56 void set_relevance(int relevance) { relevance_ = relevance; } | 56 void set_relevance(int relevance) { relevance_ = relevance; } |
| 57 bool never_allowed_to_be_default_match() const { | |
| 58 return never_allowed_to_be_default_match_; | |
| 59 } | |
| 60 void set_never_allowed_to_be_default_match( | |
| 61 bool never_allowed_to_be_default_match) { | |
| 62 never_allowed_to_be_default_match_ = never_allowed_to_be_default_match; | |
| 63 } | |
| 57 | 64 |
| 58 bool relevance_from_server() const { return relevance_from_server_; } | 65 bool relevance_from_server() const { return relevance_from_server_; } |
| 59 void set_relevance_from_server(bool relevance_from_server) { | 66 void set_relevance_from_server(bool relevance_from_server) { |
| 60 relevance_from_server_ = relevance_from_server; | 67 relevance_from_server_ = relevance_from_server; |
| 61 } | 68 } |
| 62 | 69 |
| 63 const std::string& deletion_url() const { return deletion_url_; } | 70 const std::string& deletion_url() const { return deletion_url_; } |
| 64 | 71 |
| 65 // Returns the default relevance value for this result (which may | 72 // Returns the default relevance value for this result (which may |
| 66 // be left over from a previous omnibox input) given the current | 73 // be left over from a previous omnibox input) given the current |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 83 int relevance_; | 90 int relevance_; |
| 84 | 91 |
| 85 private: | 92 private: |
| 86 // Whether this result's relevance score was fully or partly calculated | 93 // Whether this result's relevance score was fully or partly calculated |
| 87 // based on server information, and thus is assumed to be more accurate. | 94 // based on server information, and thus is assumed to be more accurate. |
| 88 // This is ultimately used in | 95 // This is ultimately used in |
| 89 // SearchProvider::ConvertResultsToAutocompleteMatches(), see comments | 96 // SearchProvider::ConvertResultsToAutocompleteMatches(), see comments |
| 90 // there. | 97 // there. |
| 91 bool relevance_from_server_; | 98 bool relevance_from_server_; |
| 92 | 99 |
| 100 // If true, this result should never be allowed to be the default match. | |
|
msw
2014/08/14 02:57:23
Hmm, seems like this identifier and the relevant c
Mark P
2014/08/15 00:05:56
Done (received_after_last_keystroke). I agree tha
| |
| 101 // This field is ignored for verbatim results; those are regardless | |
| 102 // always allowed to be the default match. | |
| 103 bool never_allowed_to_be_default_match_; | |
| 104 | |
| 93 // Optional deletion URL provided with suggestions. Fetching this URL | 105 // Optional deletion URL provided with suggestions. Fetching this URL |
| 94 // should result in some reasonable deletion behaviour on the server, | 106 // should result in some reasonable deletion behaviour on the server, |
| 95 // e.g. deleting this term out of a user's server-side search history. | 107 // e.g. deleting this term out of a user's server-side search history. |
| 96 std::string deletion_url_; | 108 std::string deletion_url_; |
| 97 }; | 109 }; |
| 98 | 110 |
| 99 class SuggestResult : public Result { | 111 class SuggestResult : public Result { |
| 100 public: | 112 public: |
| 101 SuggestResult(const base::string16& suggestion, | 113 SuggestResult(const base::string16& suggestion, |
| 102 AutocompleteMatchType::Type type, | 114 AutocompleteMatchType::Type type, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 std::string metadata; | 259 std::string metadata; |
| 248 | 260 |
| 249 // If the active suggest field trial (if any) has triggered. | 261 // If the active suggest field trial (if any) has triggered. |
| 250 bool field_trial_triggered; | 262 bool field_trial_triggered; |
| 251 | 263 |
| 252 // If the relevance values of the results are from the server. | 264 // If the relevance values of the results are from the server. |
| 253 bool relevances_from_server; | 265 bool relevances_from_server; |
| 254 | 266 |
| 255 // URLs of any images in Answers results. | 267 // URLs of any images in Answers results. |
| 256 std::vector<GURL> answers_image_urls; | 268 std::vector<GURL> answers_image_urls; |
| 257 | |
| 258 private: | |
| 259 DISALLOW_COPY_AND_ASSIGN(Results); | |
|
msw
2014/08/14 02:57:23
Why are you removing this? To allow the assignment
Mark P
2014/08/15 00:05:56
Restored. I explained why I did this in a previou
| |
| 260 }; | 269 }; |
| 261 | 270 |
| 262 // Extracts JSON data fetched by |source| and converts it to UTF-8. | 271 // Extracts JSON data fetched by |source| and converts it to UTF-8. |
| 263 static std::string ExtractJsonData(const net::URLFetcher* source); | 272 static std::string ExtractJsonData(const net::URLFetcher* source); |
| 264 | 273 |
| 265 // Parses JSON response received from the provider, stripping XSSI | 274 // Parses JSON response received from the provider, stripping XSSI |
| 266 // protection if needed. Returns the parsed data if successful, NULL | 275 // protection if needed. Returns the parsed data if successful, NULL |
| 267 // otherwise. | 276 // otherwise. |
| 268 static scoped_ptr<base::Value> DeserializeJsonData(std::string json_data); | 277 static scoped_ptr<base::Value> DeserializeJsonData(std::string json_data); |
| 269 | 278 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 282 | 291 |
| 283 private: | 292 private: |
| 284 // Gets URLs of any images in Answers results. | 293 // Gets URLs of any images in Answers results. |
| 285 static void GetAnswersImageURLs(const base::DictionaryValue* answer_json, | 294 static void GetAnswersImageURLs(const base::DictionaryValue* answer_json, |
| 286 std::vector<GURL>* urls); | 295 std::vector<GURL>* urls); |
| 287 | 296 |
| 288 DISALLOW_COPY_AND_ASSIGN(SearchSuggestionParser); | 297 DISALLOW_COPY_AND_ASSIGN(SearchSuggestionParser); |
| 289 }; | 298 }; |
| 290 | 299 |
| 291 #endif // COMPONENTS_AUTOCOMPLETE_SEARCH_SUGGESTION_PARSER_H_ | 300 #endif // COMPONENTS_AUTOCOMPLETE_SEARCH_SUGGESTION_PARSER_H_ |
| OLD | NEW |