OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/autocomplete_match.h" | 5 #include "chrome/browser/autocomplete/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/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 | 365 |
366 // If the destination URL looks like it was generated from a TemplateURL, | 366 // If the destination URL looks like it was generated from a TemplateURL, |
367 // remove all substitutions other than the search terms. This allows us | 367 // remove all substitutions other than the search terms. This allows us |
368 // to eliminate cases like past search URLs from history that differ only | 368 // to eliminate cases like past search URLs from history that differ only |
369 // by some obscure query param from each other or from the search/keyword | 369 // by some obscure query param from each other or from the search/keyword |
370 // provider matches. | 370 // provider matches. |
371 TemplateURL* template_url = GetTemplateURL(profile, true); | 371 TemplateURL* template_url = GetTemplateURL(profile, true); |
372 if (template_url != NULL && template_url->SupportsReplacement()) { | 372 if (template_url != NULL && template_url->SupportsReplacement()) { |
373 string16 search_terms; | 373 string16 search_terms; |
374 if (template_url->ExtractSearchTermsFromURL(stripped_destination_url, | 374 if (template_url->ExtractSearchTermsFromURL(stripped_destination_url, |
375 &search_terms)) { | 375 &search_terms, false)) { |
376 stripped_destination_url = | 376 stripped_destination_url = |
377 GURL(template_url->url_ref().ReplaceSearchTerms( | 377 GURL(template_url->url_ref().ReplaceSearchTerms( |
378 TemplateURLRef::SearchTermsArgs(search_terms))); | 378 TemplateURLRef::SearchTermsArgs(search_terms))); |
379 } | 379 } |
380 } | 380 } |
381 | 381 |
382 // |replacements| keeps all the substitions we're going to make to | 382 // |replacements| keeps all the substitions we're going to make to |
383 // from {destination_url} to {stripped_destination_url}. |need_replacement| | 383 // from {destination_url} to {stripped_destination_url}. |need_replacement| |
384 // is a helper variable that helps us keep track of whether we need | 384 // is a helper variable that helps us keep track of whether we need |
385 // to apply the replacement. | 385 // to apply the replacement. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 << " is unsorted in relation to last offset of " << last_offset | 490 << " is unsorted in relation to last offset of " << last_offset |
491 << ". Provider: " << provider_name << "."; | 491 << ". Provider: " << provider_name << "."; |
492 DCHECK_LT(i->offset, text.length()) | 492 DCHECK_LT(i->offset, text.length()) |
493 << " Classification of [" << i->offset << "," << text.length() | 493 << " Classification of [" << i->offset << "," << text.length() |
494 << "] is out of bounds for \"" << text << "\". Provider: " | 494 << "] is out of bounds for \"" << text << "\". Provider: " |
495 << provider_name << "."; | 495 << provider_name << "."; |
496 last_offset = i->offset; | 496 last_offset = i->offset; |
497 } | 497 } |
498 } | 498 } |
499 #endif | 499 #endif |
OLD | NEW |