| 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_SEARCH_SUGGESTION_PARSER_H_ | 5 #ifndef COMPONENTS_OMNIBOX_SEARCH_SUGGESTION_PARSER_H_ |
| 6 #define COMPONENTS_OMNIBOX_SEARCH_SUGGESTION_PARSER_H_ | 6 #define COMPONENTS_OMNIBOX_SEARCH_SUGGESTION_PARSER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "base/strings/string_piece.h" |
| 13 #include "components/omnibox/autocomplete_match.h" | 14 #include "components/omnibox/autocomplete_match.h" |
| 14 #include "components/omnibox/autocomplete_match_type.h" | 15 #include "components/omnibox/autocomplete_match_type.h" |
| 15 #include "components/omnibox/suggestion_answer.h" | 16 #include "components/omnibox/suggestion_answer.h" |
| 16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 17 | 18 |
| 18 class AutocompleteInput; | 19 class AutocompleteInput; |
| 19 class AutocompleteSchemeClassifier; | 20 class AutocompleteSchemeClassifier; |
| 20 | 21 |
| 21 namespace base { | 22 namespace base { |
| 22 class DictionaryValue; | 23 class DictionaryValue; |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 private: | 280 private: |
| 280 DISALLOW_COPY_AND_ASSIGN(Results); | 281 DISALLOW_COPY_AND_ASSIGN(Results); |
| 281 }; | 282 }; |
| 282 | 283 |
| 283 // Extracts JSON data fetched by |source| and converts it to UTF-8. | 284 // Extracts JSON data fetched by |source| and converts it to UTF-8. |
| 284 static std::string ExtractJsonData(const net::URLFetcher* source); | 285 static std::string ExtractJsonData(const net::URLFetcher* source); |
| 285 | 286 |
| 286 // Parses JSON response received from the provider, stripping XSSI | 287 // Parses JSON response received from the provider, stripping XSSI |
| 287 // protection if needed. Returns the parsed data if successful, NULL | 288 // protection if needed. Returns the parsed data if successful, NULL |
| 288 // otherwise. | 289 // otherwise. |
| 289 static scoped_ptr<base::Value> DeserializeJsonData(std::string json_data); | 290 static scoped_ptr<base::Value> DeserializeJsonData( |
| 291 base::StringPiece json_data); |
| 290 | 292 |
| 291 // Parses results from the suggest server and updates the appropriate suggest | 293 // Parses results from the suggest server and updates the appropriate suggest |
| 292 // and navigation result lists in |results|. |is_keyword_result| indicates | 294 // and navigation result lists in |results|. |is_keyword_result| indicates |
| 293 // whether the response was received from the keyword provider. | 295 // whether the response was received from the keyword provider. |
| 294 // Returns whether the appropriate result list members were updated. | 296 // Returns whether the appropriate result list members were updated. |
| 295 static bool ParseSuggestResults( | 297 static bool ParseSuggestResults( |
| 296 const base::Value& root_val, | 298 const base::Value& root_val, |
| 297 const AutocompleteInput& input, | 299 const AutocompleteInput& input, |
| 298 const AutocompleteSchemeClassifier& scheme_classifier, | 300 const AutocompleteSchemeClassifier& scheme_classifier, |
| 299 int default_result_relevance, | 301 int default_result_relevance, |
| 300 const std::string& languages, | 302 const std::string& languages, |
| 301 bool is_keyword_result, | 303 bool is_keyword_result, |
| 302 Results* results); | 304 Results* results); |
| 303 | 305 |
| 304 private: | 306 private: |
| 305 DISALLOW_COPY_AND_ASSIGN(SearchSuggestionParser); | 307 DISALLOW_COPY_AND_ASSIGN(SearchSuggestionParser); |
| 306 }; | 308 }; |
| 307 | 309 |
| 308 #endif // COMPONENTS_OMNIBOX_SEARCH_SUGGESTION_PARSER_H_ | 310 #endif // COMPONENTS_OMNIBOX_SEARCH_SUGGESTION_PARSER_H_ |
| OLD | NEW |