| 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 "components/omnibox/browser/base_search_provider.h" | 5 #include "components/omnibox/browser/base_search_provider.h" |
| 6 | 6 |
| 7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "components/data_use_measurement/core/data_use_user_data.h" | 10 #include "components/data_use_measurement/core/data_use_user_data.h" |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 match.allowed_to_be_default_match = true; | 254 match.allowed_to_be_default_match = true; |
| 255 } | 255 } |
| 256 match.fill_into_edit.append(suggestion.suggestion()); | 256 match.fill_into_edit.append(suggestion.suggestion()); |
| 257 | 257 |
| 258 const TemplateURLRef& search_url = template_url->url_ref(); | 258 const TemplateURLRef& search_url = template_url->url_ref(); |
| 259 DCHECK(search_url.SupportsReplacement(search_terms_data)); | 259 DCHECK(search_url.SupportsReplacement(search_terms_data)); |
| 260 match.search_terms_args.reset( | 260 match.search_terms_args.reset( |
| 261 new TemplateURLRef::SearchTermsArgs(suggestion.suggestion())); | 261 new TemplateURLRef::SearchTermsArgs(suggestion.suggestion())); |
| 262 match.search_terms_args->original_query = input.text(); | 262 match.search_terms_args->original_query = input.text(); |
| 263 match.search_terms_args->accepted_suggestion = accepted_suggestion; | 263 match.search_terms_args->accepted_suggestion = accepted_suggestion; |
| 264 match.search_terms_args->enable_omnibox_start_margin = true; | |
| 265 match.search_terms_args->suggest_query_params = | 264 match.search_terms_args->suggest_query_params = |
| 266 suggestion.suggest_query_params(); | 265 suggestion.suggest_query_params(); |
| 267 match.search_terms_args->append_extra_query_params = | 266 match.search_terms_args->append_extra_query_params = |
| 268 append_extra_query_params; | 267 append_extra_query_params; |
| 269 // This is the destination URL sans assisted query stats. This must be set | 268 // This is the destination URL sans assisted query stats. This must be set |
| 270 // so the AutocompleteController can properly de-dupe; the controller will | 269 // so the AutocompleteController can properly de-dupe; the controller will |
| 271 // eventually overwrite it before it reaches the user. | 270 // eventually overwrite it before it reaches the user. |
| 272 match.destination_url = | 271 match.destination_url = |
| 273 GURL(search_url.ReplaceSearchTerms(*match.search_terms_args.get(), | 272 GURL(search_url.ReplaceSearchTerms(*match.search_terms_args.get(), |
| 274 search_terms_data)); | 273 search_terms_data)); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 bool mark_as_deletable, | 360 bool mark_as_deletable, |
| 362 bool in_keyword_mode, | 361 bool in_keyword_mode, |
| 363 MatchMap* map) { | 362 MatchMap* map) { |
| 364 AutocompleteMatch match = CreateSearchSuggestion( | 363 AutocompleteMatch match = CreateSearchSuggestion( |
| 365 this, GetInput(result.from_keyword_provider()), in_keyword_mode, result, | 364 this, GetInput(result.from_keyword_provider()), in_keyword_mode, result, |
| 366 GetTemplateURL(result.from_keyword_provider()), | 365 GetTemplateURL(result.from_keyword_provider()), |
| 367 client_->GetTemplateURLService()->search_terms_data(), | 366 client_->GetTemplateURLService()->search_terms_data(), |
| 368 accepted_suggestion, ShouldAppendExtraParams(result)); | 367 accepted_suggestion, ShouldAppendExtraParams(result)); |
| 369 if (!match.destination_url.is_valid()) | 368 if (!match.destination_url.is_valid()) |
| 370 return; | 369 return; |
| 371 match.search_terms_args->bookmark_bar_pinned = | |
| 372 client_->BookmarkBarIsVisible(); | |
| 373 match.RecordAdditionalInfo(kRelevanceFromServerKey, | 370 match.RecordAdditionalInfo(kRelevanceFromServerKey, |
| 374 result.relevance_from_server() ? kTrue : kFalse); | 371 result.relevance_from_server() ? kTrue : kFalse); |
| 375 match.RecordAdditionalInfo(kShouldPrefetchKey, | 372 match.RecordAdditionalInfo(kShouldPrefetchKey, |
| 376 result.should_prefetch() ? kTrue : kFalse); | 373 result.should_prefetch() ? kTrue : kFalse); |
| 377 SetDeletionURL(result.deletion_url(), &match); | 374 SetDeletionURL(result.deletion_url(), &match); |
| 378 if (mark_as_deletable) | 375 if (mark_as_deletable) |
| 379 match.deletable = true; | 376 match.deletable = true; |
| 380 // Metadata is needed only for prefetching queries. | 377 // Metadata is needed only for prefetching queries. |
| 381 if (result.should_prefetch()) | 378 if (result.should_prefetch()) |
| 382 match.RecordAdditionalInfo(kSuggestMetadataKey, metadata); | 379 match.RecordAdditionalInfo(kSuggestMetadataKey, metadata); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 } | 476 } |
| 480 | 477 |
| 481 void BaseSearchProvider::OnDeletionComplete( | 478 void BaseSearchProvider::OnDeletionComplete( |
| 482 bool success, SuggestionDeletionHandler* handler) { | 479 bool success, SuggestionDeletionHandler* handler) { |
| 483 RecordDeletionResult(success); | 480 RecordDeletionResult(success); |
| 484 SuggestionDeletionHandlers::iterator it = std::find( | 481 SuggestionDeletionHandlers::iterator it = std::find( |
| 485 deletion_handlers_.begin(), deletion_handlers_.end(), handler); | 482 deletion_handlers_.begin(), deletion_handlers_.end(), handler); |
| 486 DCHECK(it != deletion_handlers_.end()); | 483 DCHECK(it != deletion_handlers_.end()); |
| 487 deletion_handlers_.erase(it); | 484 deletion_handlers_.erase(it); |
| 488 } | 485 } |
| OLD | NEW |