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

Side by Side Diff: components/omnibox/autocomplete_match.cc

Issue 669573005: Add a class to parse answer json. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/autocomplete_match.h" 5 #include "components/omnibox/autocomplete_match.h"
6 6
7 #include "base/i18n/time_formatting.h" 7 #include "base/i18n/time_formatting.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "components/omnibox/autocomplete_provider.h" 14 #include "components/omnibox/autocomplete_provider.h"
15 #include "components/omnibox/suggestion_answer.h"
15 #include "components/search_engines/template_url.h" 16 #include "components/search_engines/template_url.h"
16 #include "components/search_engines/template_url_service.h" 17 #include "components/search_engines/template_url_service.h"
17 #include "grit/components_scaled_resources.h" 18 #include "grit/components_scaled_resources.h"
18 19
19 namespace { 20 namespace {
20 21
21 bool IsTrivialClassification(const ACMatchClassifications& classifications) { 22 bool IsTrivialClassification(const ACMatchClassifications& classifications) {
22 return classifications.empty() || 23 return classifications.empty() ||
23 ((classifications.size() == 1) && 24 ((classifications.size() == 1) &&
24 (classifications.back().style == ACMatchClassification::NONE)); 25 (classifications.back().style == ACMatchClassification::NONE));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 inline_autocompletion(match.inline_autocompletion), 73 inline_autocompletion(match.inline_autocompletion),
73 allowed_to_be_default_match(match.allowed_to_be_default_match), 74 allowed_to_be_default_match(match.allowed_to_be_default_match),
74 destination_url(match.destination_url), 75 destination_url(match.destination_url),
75 stripped_destination_url(match.stripped_destination_url), 76 stripped_destination_url(match.stripped_destination_url),
76 contents(match.contents), 77 contents(match.contents),
77 contents_class(match.contents_class), 78 contents_class(match.contents_class),
78 description(match.description), 79 description(match.description),
79 description_class(match.description_class), 80 description_class(match.description_class),
80 answer_contents(match.answer_contents), 81 answer_contents(match.answer_contents),
81 answer_type(match.answer_type), 82 answer_type(match.answer_type),
83 answer(match.answer.get() ? new SuggestionAnswer(*match.answer) : NULL),
groby-ooo-7-16 2014/10/21 00:35:54 UGH. I forgot that AutocompleteMatch can be copy-c
Justin Donnelly 2014/10/21 21:43:54 Yes, I agree that option #2 is probably the right
82 transition(match.transition), 84 transition(match.transition),
83 is_history_what_you_typed_match(match.is_history_what_you_typed_match), 85 is_history_what_you_typed_match(match.is_history_what_you_typed_match),
84 type(match.type), 86 type(match.type),
85 associated_keyword(match.associated_keyword.get() ? 87 associated_keyword(match.associated_keyword.get() ?
86 new AutocompleteMatch(*match.associated_keyword) : NULL), 88 new AutocompleteMatch(*match.associated_keyword) : NULL),
87 keyword(match.keyword), 89 keyword(match.keyword),
88 from_previous(match.from_previous), 90 from_previous(match.from_previous),
89 search_terms_args(match.search_terms_args.get() ? 91 search_terms_args(match.search_terms_args.get() ?
90 new TemplateURLRef::SearchTermsArgs(*match.search_terms_args) : 92 new TemplateURLRef::SearchTermsArgs(*match.search_terms_args) :
91 NULL), 93 NULL),
(...skipping 17 matching lines...) Expand all
109 inline_autocompletion = match.inline_autocompletion; 111 inline_autocompletion = match.inline_autocompletion;
110 allowed_to_be_default_match = match.allowed_to_be_default_match; 112 allowed_to_be_default_match = match.allowed_to_be_default_match;
111 destination_url = match.destination_url; 113 destination_url = match.destination_url;
112 stripped_destination_url = match.stripped_destination_url; 114 stripped_destination_url = match.stripped_destination_url;
113 contents = match.contents; 115 contents = match.contents;
114 contents_class = match.contents_class; 116 contents_class = match.contents_class;
115 description = match.description; 117 description = match.description;
116 description_class = match.description_class; 118 description_class = match.description_class;
117 answer_contents = match.answer_contents; 119 answer_contents = match.answer_contents;
118 answer_type = match.answer_type; 120 answer_type = match.answer_type;
121 answer.reset(match.answer.get() ? new SuggestionAnswer(*match.answer) : NULL);
119 transition = match.transition; 122 transition = match.transition;
120 is_history_what_you_typed_match = match.is_history_what_you_typed_match; 123 is_history_what_you_typed_match = match.is_history_what_you_typed_match;
121 type = match.type; 124 type = match.type;
122 associated_keyword.reset(match.associated_keyword.get() ? 125 associated_keyword.reset(match.associated_keyword.get() ?
123 new AutocompleteMatch(*match.associated_keyword) : NULL); 126 new AutocompleteMatch(*match.associated_keyword) : NULL);
124 keyword = match.keyword; 127 keyword = match.keyword;
125 from_previous = match.from_previous; 128 from_previous = match.from_previous;
126 search_terms_args.reset(match.search_terms_args.get() ? 129 search_terms_args.reset(match.search_terms_args.get() ?
127 new TemplateURLRef::SearchTermsArgs(*match.search_terms_args) : NULL); 130 new TemplateURLRef::SearchTermsArgs(*match.search_terms_args) : NULL);
128 additional_info = match.additional_info; 131 additional_info = match.additional_info;
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 << " is unsorted in relation to last offset of " << last_offset 537 << " is unsorted in relation to last offset of " << last_offset
535 << ". Provider: " << provider_name << "."; 538 << ". Provider: " << provider_name << ".";
536 DCHECK_LT(i->offset, text.length()) 539 DCHECK_LT(i->offset, text.length())
537 << " Classification of [" << i->offset << "," << text.length() 540 << " Classification of [" << i->offset << "," << text.length()
538 << "] is out of bounds for \"" << text << "\". Provider: " 541 << "] is out of bounds for \"" << text << "\". Provider: "
539 << provider_name << "."; 542 << provider_name << ".";
540 last_offset = i->offset; 543 last_offset = i->offset;
541 } 544 }
542 } 545 }
543 #endif 546 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698