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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 } | 332 } |
333 } | 333 } |
334 } else { | 334 } else { |
335 // Otherwise, match_contents_ is a verbatim (what-you-typed) match, either | 335 // Otherwise, match_contents_ is a verbatim (what-you-typed) match, either |
336 // for the default provider or a keyword search provider. | 336 // for the default provider or a keyword search provider. |
337 match_contents_class_.push_back( | 337 match_contents_class_.push_back( |
338 ACMatchClassification(0, ACMatchClassification::NONE)); | 338 ACMatchClassification(0, ACMatchClassification::NONE)); |
339 } | 339 } |
340 } | 340 } |
341 | 341 |
342 bool BaseSearchProvider::SuggestResult::IsInlineable( | |
343 const base::string16& input) const { | |
344 return StartsWith(suggestion_, input, false); | |
345 } | |
346 | |
347 int BaseSearchProvider::SuggestResult::CalculateRelevance( | 342 int BaseSearchProvider::SuggestResult::CalculateRelevance( |
348 const AutocompleteInput& input, | 343 const AutocompleteInput& input, |
349 bool keyword_provider_requested) const { | 344 bool keyword_provider_requested) const { |
350 if (!from_keyword_provider_ && keyword_provider_requested) | 345 if (!from_keyword_provider_ && keyword_provider_requested) |
351 return 100; | 346 return 100; |
352 return ((input.type() == metrics::OmniboxInputType::URL) ? 300 : 600); | 347 return ((input.type() == metrics::OmniboxInputType::URL) ? 300 : 600); |
353 } | 348 } |
354 | 349 |
355 // BaseSearchProvider::NavigationResult ---------------------------------------- | 350 // BaseSearchProvider::NavigationResult ---------------------------------------- |
356 | 351 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 if (allow_bolding_nothing || (match_start != base::string16::npos)) { | 408 if (allow_bolding_nothing || (match_start != base::string16::npos)) { |
414 match_contents_ = match_contents; | 409 match_contents_ = match_contents; |
415 // Safe if |match_start| is npos; also safe if the input is longer than the | 410 // Safe if |match_start| is npos; also safe if the input is longer than the |
416 // remaining contents after |match_start|. | 411 // remaining contents after |match_start|. |
417 AutocompleteMatch::ClassifyLocationInString(match_start, | 412 AutocompleteMatch::ClassifyLocationInString(match_start, |
418 input_text.length(), match_contents_.length(), | 413 input_text.length(), match_contents_.length(), |
419 ACMatchClassification::URL, &match_contents_class_); | 414 ACMatchClassification::URL, &match_contents_class_); |
420 } | 415 } |
421 } | 416 } |
422 | 417 |
423 bool BaseSearchProvider::NavigationResult::IsInlineable( | |
424 const base::string16& input) const { | |
425 return | |
426 URLPrefix::BestURLPrefix(base::UTF8ToUTF16(url_.spec()), input) != NULL; | |
427 } | |
428 | |
429 int BaseSearchProvider::NavigationResult::CalculateRelevance( | 418 int BaseSearchProvider::NavigationResult::CalculateRelevance( |
430 const AutocompleteInput& input, | 419 const AutocompleteInput& input, |
431 bool keyword_provider_requested) const { | 420 bool keyword_provider_requested) const { |
432 return (from_keyword_provider_ || !keyword_provider_requested) ? 800 : 150; | 421 return (from_keyword_provider_ || !keyword_provider_requested) ? 800 : 150; |
433 } | 422 } |
434 | 423 |
435 // BaseSearchProvider::Results ------------------------------------------------- | 424 // BaseSearchProvider::Results ------------------------------------------------- |
436 | 425 |
437 BaseSearchProvider::Results::Results() : verbatim_relevance(-1) {} | 426 BaseSearchProvider::Results::Results() : verbatim_relevance(-1) {} |
438 | 427 |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 } | 1002 } |
1014 | 1003 |
1015 void BaseSearchProvider::OnDeletionComplete( | 1004 void BaseSearchProvider::OnDeletionComplete( |
1016 bool success, SuggestionDeletionHandler* handler) { | 1005 bool success, SuggestionDeletionHandler* handler) { |
1017 RecordDeletionResult(success); | 1006 RecordDeletionResult(success); |
1018 SuggestionDeletionHandlers::iterator it = std::find( | 1007 SuggestionDeletionHandlers::iterator it = std::find( |
1019 deletion_handlers_.begin(), deletion_handlers_.end(), handler); | 1008 deletion_handlers_.begin(), deletion_handlers_.end(), handler); |
1020 DCHECK(it != deletion_handlers_.end()); | 1009 DCHECK(it != deletion_handlers_.end()); |
1021 deletion_handlers_.erase(it); | 1010 deletion_handlers_.erase(it); |
1022 } | 1011 } |
OLD | NEW |