| Index: chrome/browser/autocomplete/base_search_provider.cc
|
| diff --git a/chrome/browser/autocomplete/base_search_provider.cc b/chrome/browser/autocomplete/base_search_provider.cc
|
| index 3d47edadc95ad8d42459c129cb5354b3de578d87..0ca8dd0b41896dccda9b461b0dbddcc69d9651df 100644
|
| --- a/chrome/browser/autocomplete/base_search_provider.cc
|
| +++ b/chrome/browser/autocomplete/base_search_provider.cc
|
| @@ -14,6 +14,8 @@
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "chrome/browser/autocomplete/autocomplete_provider_listener.h"
|
| #include "chrome/browser/autocomplete/url_prefix.h"
|
| +#include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h"
|
| +#include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service_factory.h"
|
| #include "chrome/browser/history/history_service.h"
|
| #include "chrome/browser/history/history_service_factory.h"
|
| #include "chrome/browser/omnibox/omnibox_field_trial.h"
|
| @@ -913,6 +915,7 @@ bool BaseSearchProvider::ParseSuggestResults(const base::Value& root_val,
|
| // Extract Answers, if provided.
|
| const base::DictionaryValue* answer_json = NULL;
|
| if (suggestion_detail->GetDictionary("ansa", &answer_json)) {
|
| + PrefetchAnswersImages(answer_json);
|
| std::string contents;
|
| base::JSONWriter::Write(answer_json, &contents);
|
| answer_contents = base::UTF8ToUTF16(contents);
|
| @@ -935,6 +938,33 @@ bool BaseSearchProvider::ParseSuggestResults(const base::Value& root_val,
|
| return true;
|
| }
|
|
|
| +void BaseSearchProvider::PrefetchAnswersImages(
|
| + const base::DictionaryValue* answer_json) {
|
| + DCHECK(answer_json);
|
| + const base::ListValue* lines = NULL;
|
| + answer_json->GetList("l", &lines);
|
| + if (!lines || lines->GetSize() == 0)
|
| + return;
|
| +
|
| + BitmapFetcherService* image_service =
|
| + BitmapFetcherServiceFactory::GetForBrowserContext(profile_);
|
| + DCHECK(image_service);
|
| +
|
| + for (size_t line = 0; line < lines->GetSize(); ++line) {
|
| + const base::DictionaryValue* imageLine = NULL;
|
| + lines->GetDictionary(line, &imageLine);
|
| + if (!imageLine)
|
| + continue;
|
| + const base::DictionaryValue* imageData = NULL;
|
| + imageLine->GetDictionary("i", &imageData);
|
| + if (!imageData)
|
| + continue;
|
| + std::string imageUrl;
|
| + imageData->GetString("d", &imageUrl);
|
| + image_service->Prefetch(GURL(imageUrl));
|
| + }
|
| +}
|
| +
|
| void BaseSearchProvider::SortResults(bool is_keyword,
|
| const base::ListValue* relevances,
|
| Results* results) {
|
|
|