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

Side by Side Diff: chrome/browser/autocomplete/base_search_provider.cc

Issue 353223002: Omnibox: Fix URL-What-You-Typed Allowed-To-Be-Default-Match Issues (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: polish Created 6 years, 5 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 | Annotate | Revision Log
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 "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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 } 328 }
329 } 329 }
330 } else { 330 } else {
331 // Otherwise, match_contents_ is a verbatim (what-you-typed) match, either 331 // Otherwise, match_contents_ is a verbatim (what-you-typed) match, either
332 // for the default provider or a keyword search provider. 332 // for the default provider or a keyword search provider.
333 match_contents_class_.push_back( 333 match_contents_class_.push_back(
334 ACMatchClassification(0, ACMatchClassification::NONE)); 334 ACMatchClassification(0, ACMatchClassification::NONE));
335 } 335 }
336 } 336 }
337 337
338 bool BaseSearchProvider::SuggestResult::IsInlineable(
339 const base::string16& input) const {
340 return StartsWith(suggestion_, input, false);
341 }
342
343 int BaseSearchProvider::SuggestResult::CalculateRelevance( 338 int BaseSearchProvider::SuggestResult::CalculateRelevance(
344 const AutocompleteInput& input, 339 const AutocompleteInput& input,
345 bool keyword_provider_requested) const { 340 bool keyword_provider_requested) const {
346 if (!from_keyword_provider_ && keyword_provider_requested) 341 if (!from_keyword_provider_ && keyword_provider_requested)
347 return 100; 342 return 100;
348 return ((input.type() == metrics::OmniboxInputType::URL) ? 300 : 600); 343 return ((input.type() == metrics::OmniboxInputType::URL) ? 300 : 600);
349 } 344 }
350 345
351 // BaseSearchProvider::NavigationResult ---------------------------------------- 346 // BaseSearchProvider::NavigationResult ----------------------------------------
352 347
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 if (allow_bolding_nothing || (match_start != base::string16::npos)) { 402 if (allow_bolding_nothing || (match_start != base::string16::npos)) {
408 match_contents_ = match_contents; 403 match_contents_ = match_contents;
409 // Safe if |match_start| is npos; also safe if the input is longer than the 404 // Safe if |match_start| is npos; also safe if the input is longer than the
410 // remaining contents after |match_start|. 405 // remaining contents after |match_start|.
411 AutocompleteMatch::ClassifyLocationInString(match_start, 406 AutocompleteMatch::ClassifyLocationInString(match_start,
412 input_text.length(), match_contents_.length(), 407 input_text.length(), match_contents_.length(),
413 ACMatchClassification::URL, &match_contents_class_); 408 ACMatchClassification::URL, &match_contents_class_);
414 } 409 }
415 } 410 }
416 411
417 bool BaseSearchProvider::NavigationResult::IsInlineable(
418 const base::string16& input) const {
419 return
420 URLPrefix::BestURLPrefix(base::UTF8ToUTF16(url_.spec()), input) != NULL;
Peter Kasting 2014/06/30 23:02:58 Can we remove any #includes due to deleting this c
Mark P 2014/06/30 23:27:36 I just checked. The answer is no.
421 }
422
423 int BaseSearchProvider::NavigationResult::CalculateRelevance( 412 int BaseSearchProvider::NavigationResult::CalculateRelevance(
424 const AutocompleteInput& input, 413 const AutocompleteInput& input,
425 bool keyword_provider_requested) const { 414 bool keyword_provider_requested) const {
426 return (from_keyword_provider_ || !keyword_provider_requested) ? 800 : 150; 415 return (from_keyword_provider_ || !keyword_provider_requested) ? 800 : 150;
427 } 416 }
428 417
429 // BaseSearchProvider::Results ------------------------------------------------- 418 // BaseSearchProvider::Results -------------------------------------------------
430 419
431 BaseSearchProvider::Results::Results() : verbatim_relevance(-1) {} 420 BaseSearchProvider::Results::Results() : verbatim_relevance(-1) {}
432 421
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 } 996 }
1008 997
1009 void BaseSearchProvider::OnDeletionComplete( 998 void BaseSearchProvider::OnDeletionComplete(
1010 bool success, SuggestionDeletionHandler* handler) { 999 bool success, SuggestionDeletionHandler* handler) {
1011 RecordDeletionResult(success); 1000 RecordDeletionResult(success);
1012 SuggestionDeletionHandlers::iterator it = std::find( 1001 SuggestionDeletionHandlers::iterator it = std::find(
1013 deletion_handlers_.begin(), deletion_handlers_.end(), handler); 1002 deletion_handlers_.begin(), deletion_handlers_.end(), handler);
1014 DCHECK(it != deletion_handlers_.end()); 1003 DCHECK(it != deletion_handlers_.end());
1015 deletion_handlers_.erase(it); 1004 deletion_handlers_.erase(it);
1016 } 1005 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698