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_provider.h" | 5 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/autocomplete/autocomplete_match.h" | 10 #include "chrome/browser/autocomplete/autocomplete_match.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 input->UpdateText(output, base::string16::npos, parts); | 207 input->UpdateText(output, base::string16::npos, parts); |
208 return !output.empty(); | 208 return !output.empty(); |
209 } | 209 } |
210 | 210 |
211 // static | 211 // static |
212 size_t AutocompleteProvider::TrimHttpPrefix(base::string16* url) { | 212 size_t AutocompleteProvider::TrimHttpPrefix(base::string16* url) { |
213 // Find any "http:". | 213 // Find any "http:". |
214 if (!AutocompleteInput::HasHTTPScheme(*url)) | 214 if (!AutocompleteInput::HasHTTPScheme(*url)) |
215 return 0; | 215 return 0; |
216 size_t scheme_pos = | 216 size_t scheme_pos = |
217 url->find(base::ASCIIToUTF16(content::kHttpScheme) + char16(':')); | 217 url->find(base::ASCIIToUTF16(content::kHttpScheme) + base::char16(':')); |
218 DCHECK_NE(base::string16::npos, scheme_pos); | 218 DCHECK_NE(base::string16::npos, scheme_pos); |
219 | 219 |
220 // Erase scheme plus up to two slashes. | 220 // Erase scheme plus up to two slashes. |
221 size_t prefix_end = scheme_pos + strlen(content::kHttpScheme) + 1; | 221 size_t prefix_end = scheme_pos + strlen(content::kHttpScheme) + 1; |
222 const size_t after_slashes = std::min(url->length(), prefix_end + 2); | 222 const size_t after_slashes = std::min(url->length(), prefix_end + 2); |
223 while ((prefix_end < after_slashes) && ((*url)[prefix_end] == '/')) | 223 while ((prefix_end < after_slashes) && ((*url)[prefix_end] == '/')) |
224 ++prefix_end; | 224 ++prefix_end; |
225 url->erase(scheme_pos, prefix_end - scheme_pos); | 225 url->erase(scheme_pos, prefix_end - scheme_pos); |
226 return (scheme_pos == 0) ? prefix_end : 0; | 226 return (scheme_pos == 0) ? prefix_end : 0; |
227 } | 227 } |
228 | 228 |
OLD | NEW |