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" |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
408 | 408 |
409 // Remove the www. prefix from the host. | 409 // Remove the www. prefix from the host. |
410 static const char prefix[] = "www."; | 410 static const char prefix[] = "www."; |
411 static const size_t prefix_len = arraysize(prefix) - 1; | 411 static const size_t prefix_len = arraysize(prefix) - 1; |
412 std::string host = stripped_destination_url.host(); | 412 std::string host = stripped_destination_url.host(); |
413 if (host.compare(0, prefix_len, prefix) == 0) { | 413 if (host.compare(0, prefix_len, prefix) == 0) { |
414 replacements.SetHostStr(base::StringPiece(host).substr(prefix_len)); | 414 replacements.SetHostStr(base::StringPiece(host).substr(prefix_len)); |
415 needs_replacement = true; | 415 needs_replacement = true; |
416 } | 416 } |
417 | 417 |
418 // Add a trailing slash if the path does not have one. | |
Peter Kasting
2015/06/11 23:05:37
Nit: I might add "It's OK if this adds a slash eve
Mark P
2015/06/12 17:25:57
Done. (I thought it was clear from preexisting co
Peter Kasting
2015/06/12 17:49:04
It's clear we're not going to navigate there -- bu
Mark P
2015/06/12 18:04:59
I think the problem with lone slashes cannot be ea
Peter Kasting
2015/06/12 18:25:37
Well, just because another protocol may allow an e
| |
419 const std::string& path = stripped_destination_url.path(); | |
420 // |path_with_extra_slash| lives at this scope rather than inside the if | |
421 // statement because it has to live until the ReplaceComponents() call below. | |
422 std::string path_with_extra_slash(path + '/'); | |
423 if (path.empty() || (path.back() != '/')) { | |
424 replacements.SetPathStr(base::StringPiece(path_with_extra_slash)); | |
425 needs_replacement = true; | |
426 } | |
427 | |
418 // Replace https protocol with http protocol. | 428 // Replace https protocol with http protocol. |
419 if (stripped_destination_url.SchemeIs(url::kHttpsScheme)) { | 429 if (stripped_destination_url.SchemeIs(url::kHttpsScheme)) { |
420 replacements.SetScheme(url::kHttpScheme, | 430 replacements.SetScheme(url::kHttpScheme, |
421 url::Component(0, strlen(url::kHttpScheme))); | 431 url::Component(0, strlen(url::kHttpScheme))); |
422 needs_replacement = true; | 432 needs_replacement = true; |
423 } | 433 } |
424 | 434 |
425 if (needs_replacement) | 435 if (needs_replacement) |
426 stripped_destination_url = stripped_destination_url.ReplaceComponents( | 436 stripped_destination_url = stripped_destination_url.ReplaceComponents( |
427 replacements); | 437 replacements); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 << " is unsorted in relation to last offset of " << last_offset | 567 << " is unsorted in relation to last offset of " << last_offset |
558 << ". Provider: " << provider_name << "."; | 568 << ". Provider: " << provider_name << "."; |
559 DCHECK_LT(i->offset, text.length()) | 569 DCHECK_LT(i->offset, text.length()) |
560 << " Classification of [" << i->offset << "," << text.length() | 570 << " Classification of [" << i->offset << "," << text.length() |
561 << "] is out of bounds for \"" << text << "\". Provider: " | 571 << "] is out of bounds for \"" << text << "\". Provider: " |
562 << provider_name << "."; | 572 << provider_name << "."; |
563 last_offset = i->offset; | 573 last_offset = i->offset; |
564 } | 574 } |
565 } | 575 } |
566 #endif | 576 #endif |
OLD | NEW |