| 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/history_provider.h" | 5 #include "chrome/browser/autocomplete/history_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 const url_parse::Parsed& parts = | 88 const url_parse::Parsed& parts = |
| 89 canonical_gurl.parsed_for_possibly_invalid_spec(); | 89 canonical_gurl.parsed_for_possibly_invalid_spec(); |
| 90 // parts.host must not be empty when HostIsIPAddress() is true. | 90 // parts.host must not be empty when HostIsIPAddress() is true. |
| 91 DCHECK(parts.host.is_nonempty()); | 91 DCHECK(parts.host.is_nonempty()); |
| 92 canonical_gurl_str.replace(parts.host.begin, parts.host.len, | 92 canonical_gurl_str.replace(parts.host.begin, parts.host.len, |
| 93 original_hostname); | 93 original_hostname); |
| 94 } | 94 } |
| 95 string16 output = UTF8ToUTF16(canonical_gurl_str); | 95 string16 output = UTF8ToUTF16(canonical_gurl_str); |
| 96 // Don't prepend a scheme when the user didn't have one. Since the fixer | 96 // Don't prepend a scheme when the user didn't have one. Since the fixer |
| 97 // upper only prepends the "http" scheme, that's all we need to check for. | 97 // upper only prepends the "http" scheme, that's all we need to check for. |
| 98 if (canonical_gurl.SchemeIs(chrome::kHttpScheme) && | 98 if (!HasHTTPScheme(input_text)) |
| 99 !url_util::FindAndCompareScheme(UTF16ToUTF8(input_text), | |
| 100 chrome::kHttpScheme, NULL)) | |
| 101 TrimHttpPrefix(&output); | 99 TrimHttpPrefix(&output); |
| 102 | 100 |
| 103 // Make the number of trailing slashes on the output exactly match the input. | 101 // Make the number of trailing slashes on the output exactly match the input. |
| 104 // Examples of why not doing this would matter: | 102 // Examples of why not doing this would matter: |
| 105 // * The user types "a" and has this fixed up to "a/". Now no other sites | 103 // * The user types "a" and has this fixed up to "a/". Now no other sites |
| 106 // beginning with "a" will match. | 104 // beginning with "a" will match. |
| 107 // * The user types "file:" and has this fixed up to "file://". Now inline | 105 // * The user types "file:" and has this fixed up to "file://". Now inline |
| 108 // autocomplete will append too few slashes, resulting in e.g. "file:/b..." | 106 // autocomplete will append too few slashes, resulting in e.g. "file:/b..." |
| 109 // instead of "file:///b..." | 107 // instead of "file:///b..." |
| 110 // * The user types "http:/" and has this fixed up to "http:". Now inline | 108 // * The user types "http:/" and has this fixed up to "http:". Now inline |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 return (scheme_pos == 0) ? prefix_end : 0; | 150 return (scheme_pos == 0) ? prefix_end : 0; |
| 153 } | 151 } |
| 154 | 152 |
| 155 // static | 153 // static |
| 156 bool HistoryProvider::PreventInlineAutocomplete( | 154 bool HistoryProvider::PreventInlineAutocomplete( |
| 157 const AutocompleteInput& input) { | 155 const AutocompleteInput& input) { |
| 158 return input.prevent_inline_autocomplete() || | 156 return input.prevent_inline_autocomplete() || |
| 159 (!input.text().empty() && | 157 (!input.text().empty() && |
| 160 IsWhitespace(input.text()[input.text().length() - 1])); | 158 IsWhitespace(input.text()[input.text().length() - 1])); |
| 161 } | 159 } |
| OLD | NEW |