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/builtin_provider.h" | 5 #include "chrome/browser/autocomplete/builtin_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
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" |
11 #include "chrome/browser/autocomplete/autocomplete_input.h" | 11 #include "chrome/browser/autocomplete/autocomplete_input.h" |
12 #include "chrome/browser/autocomplete/history_provider.h" | 12 #include "chrome/browser/autocomplete/history_provider.h" |
13 #include "chrome/common/net/url_fixer_upper.h" | |
14 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
15 #include "components/metrics/proto/omnibox_input_type.pb.h" | 14 #include "components/metrics/proto/omnibox_input_type.pb.h" |
| 15 #include "components/url_fixer/url_fixer.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 #if !defined(OS_ANDROID) | 19 #if !defined(OS_ANDROID) |
20 // This list should be kept in sync with chrome/common/url_constants.h. | 20 // This list should be kept in sync with chrome/common/url_constants.h. |
21 // Only include useful sub-pages, confirmation alerts are not useful. | 21 // Only include useful sub-pages, confirmation alerts are not useful. |
22 const char* const kChromeSettingsSubPages[] = { | 22 const char* const kChromeSettingsSubPages[] = { |
23 chrome::kAutofillSubPage, | 23 chrome::kAutofillSubPage, |
24 chrome::kClearBrowserDataSubPage, | 24 chrome::kClearBrowserDataSubPage, |
25 chrome::kContentSettingsSubPage, | 25 chrome::kContentSettingsSubPage, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 AddMatch(base::ASCIIToUTF16(chrome::kChromeUIChromeURLsURL), | 95 AddMatch(base::ASCIIToUTF16(chrome::kChromeUIChromeURLsURL), |
96 base::string16(), styles); | 96 base::string16(), styles); |
97 #if !defined(OS_ANDROID) | 97 #if !defined(OS_ANDROID) |
98 AddMatch(base::ASCIIToUTF16(chrome::kChromeUISettingsURL), | 98 AddMatch(base::ASCIIToUTF16(chrome::kChromeUISettingsURL), |
99 base::string16(), styles); | 99 base::string16(), styles); |
100 #endif | 100 #endif |
101 AddMatch(base::ASCIIToUTF16(chrome::kChromeUIVersionURL), | 101 AddMatch(base::ASCIIToUTF16(chrome::kChromeUIVersionURL), |
102 base::string16(), styles); | 102 base::string16(), styles); |
103 } else { | 103 } else { |
104 // Match input about: or chrome: URL input against builtin chrome URLs. | 104 // Match input about: or chrome: URL input against builtin chrome URLs. |
105 GURL url = URLFixerUpper::FixupURL(base::UTF16ToUTF8(text), std::string()); | 105 GURL url = url_fixer::FixupURL(base::UTF16ToUTF8(text), std::string()); |
106 // BuiltinProvider doesn't know how to suggest valid ?query or #fragment | 106 // BuiltinProvider doesn't know how to suggest valid ?query or #fragment |
107 // extensions to chrome: URLs. | 107 // extensions to chrome: URLs. |
108 if (url.SchemeIs(content::kChromeUIScheme) && url.has_host() && | 108 if (url.SchemeIs(content::kChromeUIScheme) && url.has_host() && |
109 !url.has_query() && !url.has_ref()) { | 109 !url.has_query() && !url.has_ref()) { |
110 // Suggest about:blank for substrings, taking URL fixup into account. | 110 // Suggest about:blank for substrings, taking URL fixup into account. |
111 // Chrome does not support trailing slashes or paths for about:blank. | 111 // Chrome does not support trailing slashes or paths for about:blank. |
112 const base::string16 blank_host = base::ASCIIToUTF16("blank"); | 112 const base::string16 blank_host = base::ASCIIToUTF16("blank"); |
113 const base::string16 host = base::UTF8ToUTF16(url.host()); | 113 const base::string16 host = base::UTF8ToUTF16(url.host()); |
114 if (StartsWith(text, base::ASCIIToUTF16(url::kAboutScheme), false) && | 114 if (StartsWith(text, base::ASCIIToUTF16(url::kAboutScheme), false) && |
115 StartsWith(blank_host, host, false) && (url.path().length() <= 1) && | 115 StartsWith(blank_host, host, false) && (url.path().length() <= 1) && |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 const ACMatchClassifications& styles) { | 162 const ACMatchClassifications& styles) { |
163 AutocompleteMatch match(this, kRelevance, false, | 163 AutocompleteMatch match(this, kRelevance, false, |
164 AutocompleteMatchType::NAVSUGGEST); | 164 AutocompleteMatchType::NAVSUGGEST); |
165 match.fill_into_edit = match_string; | 165 match.fill_into_edit = match_string; |
166 match.inline_autocompletion = inline_completion; | 166 match.inline_autocompletion = inline_completion; |
167 match.destination_url = GURL(match_string); | 167 match.destination_url = GURL(match_string); |
168 match.contents = match_string; | 168 match.contents = match_string; |
169 match.contents_class = styles; | 169 match.contents_class = styles; |
170 matches_.push_back(match); | 170 matches_.push_back(match); |
171 } | 171 } |
OLD | NEW |