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