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

Unified Diff: components/autocomplete/search_suggestion_parser.h

Issue 423093013: Move DeserializeJsonData() and UTF-8 conversion code to SearchSuggestionParser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clear image URLs Created 6 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 side-by-side diff with in-line comments
Download patch
Index: components/autocomplete/search_suggestion_parser.h
diff --git a/components/autocomplete/search_suggestion_parser.h b/components/autocomplete/search_suggestion_parser.h
index ca2ac8f714b52f27d6207a3604a7259d4c7e7ba9..264700ef8ebcc1921fb544a703140dadf8f9e39c 100644
--- a/components/autocomplete/search_suggestion_parser.h
+++ b/components/autocomplete/search_suggestion_parser.h
@@ -9,7 +9,6 @@
#include <vector>
#include "base/basictypes.h"
-#include "base/callback_forward.h"
#include "base/strings/string16.h"
#include "components/autocomplete/autocomplete_match.h"
#include "components/autocomplete/autocomplete_match_type.h"
@@ -23,6 +22,10 @@ class DictionaryValue;
class Value;
}
+namespace net {
+class URLFetcher;
+}
+
class SearchSuggestionParser {
public:
// The Result classes are intermediate representations of AutocompleteMatches,
@@ -246,11 +249,23 @@ class SearchSuggestionParser {
// If the active suggest field trial (if any) has triggered.
bool field_trial_triggered;
+ // If the relevance values of the results are from the server.
+ bool relevances_from_server;
+
+ // URLs of any images in Answers results.
+ std::vector<GURL> answers_image_urls;
+
private:
DISALLOW_COPY_AND_ASSIGN(Results);
};
- typedef base::Callback<void(const GURL& image_url)> ImagePrefetchCallback;
+ // Extracts JSON data fetched by |source| and converts it to UTF-8.
+ static std::string ExtractJsonData(const net::URLFetcher* source);
+
+ // Parses JSON response received from the provider, stripping XSSI
+ // protection if needed. Returns the parsed data if successful, NULL
+ // otherwise.
+ static scoped_ptr<base::Value> DeserializeJsonData(std::string json_data);
// Parses results from the suggest server and updates the appropriate suggest
// and navigation result lists in |results|. |is_keyword_result| indicates
@@ -260,18 +275,15 @@ class SearchSuggestionParser {
const base::Value& root_val,
const AutocompleteInput& input,
const AutocompleteSchemeClassifier& scheme_classifier,
- const ImagePrefetchCallback& image_prefetch_callback,
int default_result_relevance,
const std::string& languages,
bool is_keyword_result,
- bool* relevances_from_server,
Results* results);
private:
- // Prefetches any images in Answers results.
- static void PrefetchAnswersImages(
- const base::DictionaryValue* answer_json,
- const ImagePrefetchCallback& image_prefetch_callback);
+ // Gets URLs of any images in Answers results.
+ static void GetAnswersImageURLs(const base::DictionaryValue* answer_json,
+ std::vector<GURL>* urls);
DISALLOW_COPY_AND_ASSIGN(SearchSuggestionParser);
};
« no previous file with comments | « chrome/browser/autocomplete/zero_suggest_provider.cc ('k') | components/autocomplete/search_suggestion_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698