| 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/autocomplete/url_prefix.h" | 5 #include "components/autocomplete/url_prefix.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 : prefix(prefix), | 32 : prefix(prefix), |
| 33 num_components(num_components) { | 33 num_components(num_components) { |
| 34 } | 34 } |
| 35 | 35 |
| 36 // static | 36 // static |
| 37 const URLPrefixes& URLPrefix::GetURLPrefixes() { | 37 const URLPrefixes& URLPrefix::GetURLPrefixes() { |
| 38 CR_DEFINE_STATIC_LOCAL(URLPrefixes, prefixes, ()); | 38 CR_DEFINE_STATIC_LOCAL(URLPrefixes, prefixes, ()); |
| 39 if (prefixes.empty()) { | 39 if (prefixes.empty()) { |
| 40 prefixes.push_back(URLPrefix(base::ASCIIToUTF16("https://www."), 2)); | 40 prefixes.push_back(URLPrefix(base::ASCIIToUTF16("https://www."), 2)); |
| 41 prefixes.push_back(URLPrefix(base::ASCIIToUTF16("http://www."), 2)); | 41 prefixes.push_back(URLPrefix(base::ASCIIToUTF16("http://www."), 2)); |
| 42 prefixes.push_back(URLPrefix(base::ASCIIToUTF16("ftp://ftp."), 2)); | |
| 43 prefixes.push_back(URLPrefix(base::ASCIIToUTF16("ftp://www."), 2)); | 42 prefixes.push_back(URLPrefix(base::ASCIIToUTF16("ftp://www."), 2)); |
| 44 prefixes.push_back(URLPrefix(base::ASCIIToUTF16("https://"), 1)); | 43 prefixes.push_back(URLPrefix(base::ASCIIToUTF16("https://"), 1)); |
| 45 prefixes.push_back(URLPrefix(base::ASCIIToUTF16("http://"), 1)); | 44 prefixes.push_back(URLPrefix(base::ASCIIToUTF16("http://"), 1)); |
| 46 prefixes.push_back(URLPrefix(base::ASCIIToUTF16("ftp://"), 1)); | 45 prefixes.push_back(URLPrefix(base::ASCIIToUTF16("ftp://"), 1)); |
| 47 prefixes.push_back(URLPrefix(base::string16(), 0)); | 46 prefixes.push_back(URLPrefix(base::string16(), 0)); |
| 48 } | 47 } |
| 49 return prefixes; | 48 return prefixes; |
| 50 } | 49 } |
| 51 | 50 |
| 52 // static | 51 // static |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 if (!best_prefix && !fixed_up_input.empty() && (fixed_up_input != input)) { | 90 if (!best_prefix && !fixed_up_input.empty() && (fixed_up_input != input)) { |
| 92 best_prefix = allow_www_prefix_without_scheme ? | 91 best_prefix = allow_www_prefix_without_scheme ? |
| 93 BestURLPrefixWithWWWCase(text, fixed_up_input) : | 92 BestURLPrefixWithWWWCase(text, fixed_up_input) : |
| 94 BestURLPrefix(text, fixed_up_input); | 93 BestURLPrefix(text, fixed_up_input); |
| 95 matching_string = &fixed_up_input; | 94 matching_string = &fixed_up_input; |
| 96 } | 95 } |
| 97 return (best_prefix != NULL) ? | 96 return (best_prefix != NULL) ? |
| 98 (best_prefix->prefix.length() + matching_string->length()) : | 97 (best_prefix->prefix.length() + matching_string->length()) : |
| 99 base::string16::npos; | 98 base::string16::npos; |
| 100 } | 99 } |
| OLD | NEW |