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

Unified Diff: components/omnibox/search_suggestion_parser.cc

Issue 470403003: [AiS] Fix parsing for Answers Images. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Created 6 years, 4 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/omnibox/search_suggestion_parser.cc
diff --git a/components/omnibox/search_suggestion_parser.cc b/components/omnibox/search_suggestion_parser.cc
index a481def345dee8aec352842f70e423d10125faeb..a24571c2f4ae429c5a95adb60b12c4b6cefd1836 100644
--- a/components/omnibox/search_suggestion_parser.cc
+++ b/components/omnibox/search_suggestion_parser.cc
@@ -17,6 +17,7 @@
#include "net/base/net_util.h"
#include "net/http/http_response_headers.h"
#include "net/url_request/url_fetcher.h"
+#include "url/url_constants.h"
namespace {
@@ -483,22 +484,20 @@ void SearchSuggestionParser::GetAnswersImageURLs(
const base::DictionaryValue* answer_json,
std::vector<GURL>* urls) {
DCHECK(answer_json);
+
const base::ListValue* lines = NULL;
- answer_json->GetList("l", &lines);
- if (!lines || lines->GetSize() == 0)
+ if (!answer_json->GetList("l", &lines) || !lines || lines->GetSize() == 0)
return;
- 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)
+ for (base::ListValue::const_iterator iter = lines->begin();
+ iter != lines->end(); ++iter) {
+ const base::DictionaryValue* line = NULL;
+ if (!(*iter)->GetAsDictionary(&line) || !line)
continue;
+
std::string imageUrl;
Mark P 2014/08/22 16:21:08 I thought you said you'd use host_and_path? Regar
groby-ooo-7-16 2014/08/22 18:23:11 Done. Now for real.
- imageData->GetString("d", &imageUrl);
- urls->push_back(GURL(imageUrl));
+ if (!line->GetString("il.i.d", &imageUrl) || imageUrl.empty())
+ continue;
+ urls->push_back(GURL(std::string(url::kHttpsScheme) + ":" + imageUrl));
Mark P 2014/08/22 16:21:08 Only ":", not "://" (the url::kStandardSchemeSepar
groby-ooo-7-16 2014/08/22 18:23:11 Done.
}
}
« no previous file with comments | « components/omnibox/search_suggestion_parser.h ('k') | components/omnibox/search_suggestion_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698