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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
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 #include "components/omnibox/search_suggestion_parser.h" 5 #include "components/omnibox/search_suggestion_parser.h"
6 6
7 #include "base/i18n/icu_string_conversions.h" 7 #include "base/i18n/icu_string_conversions.h"
8 #include "base/json/json_string_value_serializer.h" 8 #include "base/json/json_string_value_serializer.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 void SearchSuggestionParser::GetAnswersImageURLs( 482 void SearchSuggestionParser::GetAnswersImageURLs(
483 const base::DictionaryValue* answer_json, 483 const base::DictionaryValue* answer_json,
484 std::vector<GURL>* urls) { 484 std::vector<GURL>* urls) {
485 DCHECK(answer_json); 485 DCHECK(answer_json);
486 const base::ListValue* lines = NULL; 486 const base::ListValue* lines = NULL;
487 answer_json->GetList("l", &lines); 487 answer_json->GetList("l", &lines);
488 if (!lines || lines->GetSize() == 0) 488 if (!lines || lines->GetSize() == 0)
489 return; 489 return;
490 490
491 for (size_t line = 0; line < lines->GetSize(); ++line) { 491 for (size_t line = 0; line < lines->GetSize(); ++line) {
492 const base::DictionaryValue* value = NULL;
492 const base::DictionaryValue* imageLine = NULL; 493 const base::DictionaryValue* imageLine = NULL;
493 lines->GetDictionary(line, &imageLine); 494 lines->GetDictionary(line, &value);
Mark P 2014/08/15 22:49:16 comment: you and put this at the beginning of the
groby-ooo-7-16 2014/08/22 00:43:58 I'm actually taking all comments here and rewritin
494 if (!imageLine) 495 if (!value || !value->GetDictionary("il", &imageLine))
Mark P 2014/08/15 22:49:16 consider || !imageLine at the end
groby-ooo-7-16 2014/08/22 00:43:58 imageLine is guaranteed non-NULL if GetDictionary
495 continue; 496 continue;
496 const base::DictionaryValue* imageData = NULL; 497 const base::DictionaryValue* imageData = NULL;
497 imageLine->GetDictionary("i", &imageData); 498 imageLine->GetDictionary("i", &imageData);
498 if (!imageData) 499 if (!imageData)
499 continue; 500 continue;
500 std::string imageUrl; 501 std::string imageUrl;
Mark P 2014/08/15 22:49:16 If you're going to prepend a protocol to this, the
groby-ooo-7-16 2014/08/22 00:43:58 It's odd because GWS returns paths without scheme,
501 imageData->GetString("d", &imageUrl); 502 imageData->GetString("d", &imageUrl);
Mark P 2014/08/15 22:49:16 Please don't ignore the return value.
groby-ooo-7-16 2014/08/22 00:43:58 Done.
502 urls->push_back(GURL(imageUrl)); 503 urls->push_back(GURL("https:" + imageUrl));
Mark P 2014/08/15 22:49:16 This probably should be one of the protocol value
groby-ooo-7-16 2014/08/22 00:43:58 Done.
503 } 504 }
504 } 505 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698