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" |
11 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" | 11 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" |
12 #include "chrome/browser/bookmarks/bookmark_model.h" | 12 #include "chrome/browser/bookmarks/bookmark_model.h" |
13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/common/net/url_fixer_upper.h" | 15 #include "chrome/common/net/url_fixer_upper.h" |
16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
17 #include "content/public/common/url_constants.h" | 17 #include "content/public/common/url_constants.h" |
18 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 20 #include "url/url_constants.h" |
20 | 21 |
21 // static | 22 // static |
22 const size_t AutocompleteProvider::kMaxMatches = 3; | 23 const size_t AutocompleteProvider::kMaxMatches = 3; |
23 | 24 |
24 AutocompleteProvider::AutocompleteProvider( | 25 AutocompleteProvider::AutocompleteProvider( |
25 AutocompleteProviderListener* listener, | 26 AutocompleteProviderListener* listener, |
26 Profile* profile, | 27 Profile* profile, |
27 Type type) | 28 Type type) |
28 : profile_(profile), | 29 : profile_(profile), |
29 listener_(listener), | 30 listener_(listener), |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 input->UpdateText(output, base::string16::npos, parts); | 204 input->UpdateText(output, base::string16::npos, parts); |
204 return !output.empty(); | 205 return !output.empty(); |
205 } | 206 } |
206 | 207 |
207 // static | 208 // static |
208 size_t AutocompleteProvider::TrimHttpPrefix(base::string16* url) { | 209 size_t AutocompleteProvider::TrimHttpPrefix(base::string16* url) { |
209 // Find any "http:". | 210 // Find any "http:". |
210 if (!AutocompleteInput::HasHTTPScheme(*url)) | 211 if (!AutocompleteInput::HasHTTPScheme(*url)) |
211 return 0; | 212 return 0; |
212 size_t scheme_pos = | 213 size_t scheme_pos = |
213 url->find(base::ASCIIToUTF16(content::kHttpScheme) + base::char16(':')); | 214 url->find(base::ASCIIToUTF16(url::kHttpScheme) + base::char16(':')); |
214 DCHECK_NE(base::string16::npos, scheme_pos); | 215 DCHECK_NE(base::string16::npos, scheme_pos); |
215 | 216 |
216 // Erase scheme plus up to two slashes. | 217 // Erase scheme plus up to two slashes. |
217 size_t prefix_end = scheme_pos + strlen(content::kHttpScheme) + 1; | 218 size_t prefix_end = scheme_pos + strlen(url::kHttpScheme) + 1; |
218 const size_t after_slashes = std::min(url->length(), prefix_end + 2); | 219 const size_t after_slashes = std::min(url->length(), prefix_end + 2); |
219 while ((prefix_end < after_slashes) && ((*url)[prefix_end] == '/')) | 220 while ((prefix_end < after_slashes) && ((*url)[prefix_end] == '/')) |
220 ++prefix_end; | 221 ++prefix_end; |
221 url->erase(scheme_pos, prefix_end - scheme_pos); | 222 url->erase(scheme_pos, prefix_end - scheme_pos); |
222 return (scheme_pos == 0) ? prefix_end : 0; | 223 return (scheme_pos == 0) ? prefix_end : 0; |
223 } | 224 } |
224 | 225 |
OLD | NEW |