Chromium Code Reviews| 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 #include "chrome/browser/autocomplete/base_search_provider.h" | 5 #include "chrome/browser/autocomplete/base_search_provider.h" |
| 6 | 6 |
| 7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
| 8 #include "base/i18n/icu_string_conversions.h" | 8 #include "base/i18n/icu_string_conversions.h" |
| 9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 908 suggestion_detail->GetString("mp", &match_contents_prefix); | 908 suggestion_detail->GetString("mp", &match_contents_prefix); |
| 909 // Error correction for bad data from server. | 909 // Error correction for bad data from server. |
| 910 if (match_contents.empty()) | 910 if (match_contents.empty()) |
| 911 match_contents = suggestion; | 911 match_contents = suggestion; |
| 912 suggestion_detail->GetString("a", &annotation); | 912 suggestion_detail->GetString("a", &annotation); |
| 913 suggestion_detail->GetString("q", &suggest_query_params); | 913 suggestion_detail->GetString("q", &suggest_query_params); |
| 914 | 914 |
| 915 // Extract Answers, if provided. | 915 // Extract Answers, if provided. |
| 916 const base::DictionaryValue* answer_json = NULL; | 916 const base::DictionaryValue* answer_json = NULL; |
| 917 if (suggestion_detail->GetDictionary("ansa", &answer_json)) { | 917 if (suggestion_detail->GetDictionary("ansa", &answer_json)) { |
| 918 match_type = AutocompleteMatchType::SEARCH_SUGGEST_ANSWER; | |
|
Peter Kasting
2014/06/10 21:49:46
My only concern here would be if there's a validat
Justin Donnelly
2014/06/11 15:51:53
Good question, but no we don't plan to downgrade a
| |
| 918 std::string contents; | 919 std::string contents; |
| 919 base::JSONWriter::Write(answer_json, &contents); | 920 base::JSONWriter::Write(answer_json, &contents); |
| 920 answer_contents = base::UTF8ToUTF16(contents); | 921 answer_contents = base::UTF8ToUTF16(contents); |
| 921 suggestion_detail->GetString("ansb", &answer_type); | 922 suggestion_detail->GetString("ansb", &answer_type); |
| 922 } | 923 } |
| 923 } | 924 } |
| 924 } | 925 } |
| 925 | 926 |
| 926 bool should_prefetch = static_cast<int>(index) == prefetch_index; | 927 bool should_prefetch = static_cast<int>(index) == prefetch_index; |
| 927 // TODO(kochi): Improve calculator suggestion presentation. | 928 // TODO(kochi): Improve calculator suggestion presentation. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 968 } | 969 } |
| 969 | 970 |
| 970 void BaseSearchProvider::OnDeletionComplete( | 971 void BaseSearchProvider::OnDeletionComplete( |
| 971 bool success, SuggestionDeletionHandler* handler) { | 972 bool success, SuggestionDeletionHandler* handler) { |
| 972 RecordDeletionResult(success); | 973 RecordDeletionResult(success); |
| 973 SuggestionDeletionHandlers::iterator it = std::find( | 974 SuggestionDeletionHandlers::iterator it = std::find( |
| 974 deletion_handlers_.begin(), deletion_handlers_.end(), handler); | 975 deletion_handlers_.begin(), deletion_handlers_.end(), handler); |
| 975 DCHECK(it != deletion_handlers_.end()); | 976 DCHECK(it != deletion_handlers_.end()); |
| 976 deletion_handlers_.erase(it); | 977 deletion_handlers_.erase(it); |
| 977 } | 978 } |
| OLD | NEW |