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/autocomplete_match.h" | 5 #include "components/omnibox/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/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/string_piece.h" |
11 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
14 #include "components/omnibox/autocomplete_provider.h" | 15 #include "components/omnibox/autocomplete_provider.h" |
15 #include "components/omnibox/suggestion_answer.h" | 16 #include "components/omnibox/suggestion_answer.h" |
16 #include "components/search_engines/template_url.h" | 17 #include "components/search_engines/template_url.h" |
17 #include "components/search_engines/template_url_service.h" | 18 #include "components/search_engines/template_url_service.h" |
18 #include "grit/components_scaled_resources.h" | 19 #include "grit/components_scaled_resources.h" |
19 | 20 |
20 namespace { | 21 namespace { |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 // is a helper variable that helps us keep track of whether we need | 405 // is a helper variable that helps us keep track of whether we need |
405 // to apply the replacement. | 406 // to apply the replacement. |
406 bool needs_replacement = false; | 407 bool needs_replacement = false; |
407 GURL::Replacements replacements; | 408 GURL::Replacements replacements; |
408 | 409 |
409 // Remove the www. prefix from the host. | 410 // Remove the www. prefix from the host. |
410 static const char prefix[] = "www."; | 411 static const char prefix[] = "www."; |
411 static const size_t prefix_len = arraysize(prefix) - 1; | 412 static const size_t prefix_len = arraysize(prefix) - 1; |
412 std::string host = stripped_destination_url.host(); | 413 std::string host = stripped_destination_url.host(); |
413 if (host.compare(0, prefix_len, prefix) == 0) { | 414 if (host.compare(0, prefix_len, prefix) == 0) { |
414 host = host.substr(prefix_len); | 415 replacements.SetHostStr(base::StringPiece(host).substr(prefix_len)); |
415 replacements.SetHostStr(host); | |
416 needs_replacement = true; | 416 needs_replacement = true; |
417 } | 417 } |
418 | 418 |
419 // Replace https protocol with http protocol. | 419 // Replace https protocol with http protocol. |
420 if (stripped_destination_url.SchemeIs(url::kHttpsScheme)) { | 420 if (stripped_destination_url.SchemeIs(url::kHttpsScheme)) { |
421 replacements.SetScheme(url::kHttpScheme, | 421 replacements.SetScheme(url::kHttpScheme, |
422 url::Component(0, strlen(url::kHttpScheme))); | 422 url::Component(0, strlen(url::kHttpScheme))); |
423 needs_replacement = true; | 423 needs_replacement = true; |
424 } | 424 } |
425 | 425 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 << " is unsorted in relation to last offset of " << last_offset | 558 << " is unsorted in relation to last offset of " << last_offset |
559 << ". Provider: " << provider_name << "."; | 559 << ". Provider: " << provider_name << "."; |
560 DCHECK_LT(i->offset, text.length()) | 560 DCHECK_LT(i->offset, text.length()) |
561 << " Classification of [" << i->offset << "," << text.length() | 561 << " Classification of [" << i->offset << "," << text.length() |
562 << "] is out of bounds for \"" << text << "\". Provider: " | 562 << "] is out of bounds for \"" << text << "\". Provider: " |
563 << provider_name << "."; | 563 << provider_name << "."; |
564 last_offset = i->offset; | 564 last_offset = i->offset; |
565 } | 565 } |
566 } | 566 } |
567 #endif | 567 #endif |
OLD | NEW |