| 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" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 base::string16(), styles); | 100 base::string16(), styles); |
| 101 } else { | 101 } else { |
| 102 // Match input about: or chrome: URL input against builtin chrome URLs. | 102 // Match input about: or chrome: URL input against builtin chrome URLs. |
| 103 GURL url = URLFixerUpper::FixupURL(base::UTF16ToUTF8(text), std::string()); | 103 GURL url = URLFixerUpper::FixupURL(base::UTF16ToUTF8(text), std::string()); |
| 104 // BuiltinProvider doesn't know how to suggest valid ?query or #fragment | 104 // BuiltinProvider doesn't know how to suggest valid ?query or #fragment |
| 105 // extensions to chrome: URLs. | 105 // extensions to chrome: URLs. |
| 106 if (url.SchemeIs(content::kChromeUIScheme) && url.has_host() && | 106 if (url.SchemeIs(content::kChromeUIScheme) && url.has_host() && |
| 107 !url.has_query() && !url.has_ref()) { | 107 !url.has_query() && !url.has_ref()) { |
| 108 // Include the path for sub-pages (e.g. "chrome://settings/browser"). | 108 // Include the path for sub-pages (e.g. "chrome://settings/browser"). |
| 109 base::string16 host_and_path = base::UTF8ToUTF16(url.host() + url.path()); | 109 base::string16 host_and_path = base::UTF8ToUTF16(url.host() + url.path()); |
| 110 base::TrimString(host_and_path, base::ASCIIToUTF16("/").c_str(), | 110 base::TrimString(host_and_path, base::ASCIIToUTF16("/"), &host_and_path); |
| 111 &host_and_path); | |
| 112 size_t match_length = kChrome.length() + host_and_path.length(); | 111 size_t match_length = kChrome.length() + host_and_path.length(); |
| 113 for (Builtins::const_iterator i(builtins_.begin()); | 112 for (Builtins::const_iterator i(builtins_.begin()); |
| 114 (i != builtins_.end()) && (matches_.size() < kMaxMatches); ++i) { | 113 (i != builtins_.end()) && (matches_.size() < kMaxMatches); ++i) { |
| 115 if (StartsWith(*i, host_and_path, false)) { | 114 if (StartsWith(*i, host_and_path, false)) { |
| 116 ACMatchClassifications styles; | 115 ACMatchClassifications styles; |
| 117 // Highlight the "chrome://" scheme, even for input "about:foo". | 116 // Highlight the "chrome://" scheme, even for input "about:foo". |
| 118 styles.push_back(ACMatchClassification(0, kMatch)); | 117 styles.push_back(ACMatchClassification(0, kMatch)); |
| 119 base::string16 match_string = kChrome + *i; | 118 base::string16 match_string = kChrome + *i; |
| 120 if (match_string.length() > match_length) | 119 if (match_string.length() > match_length) |
| 121 styles.push_back(ACMatchClassification(match_length, kUrl)); | 120 styles.push_back(ACMatchClassification(match_length, kUrl)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 144 const ACMatchClassifications& styles) { | 143 const ACMatchClassifications& styles) { |
| 145 AutocompleteMatch match(this, kRelevance, false, | 144 AutocompleteMatch match(this, kRelevance, false, |
| 146 AutocompleteMatchType::NAVSUGGEST); | 145 AutocompleteMatchType::NAVSUGGEST); |
| 147 match.fill_into_edit = match_string; | 146 match.fill_into_edit = match_string; |
| 148 match.inline_autocompletion = inline_completion; | 147 match.inline_autocompletion = inline_completion; |
| 149 match.destination_url = GURL(match_string); | 148 match.destination_url = GURL(match_string); |
| 150 match.contents = match_string; | 149 match.contents = match_string; |
| 151 match.contents_class = styles; | 150 match.contents_class = styles; |
| 152 matches_.push_back(match); | 151 matches_.push_back(match); |
| 153 } | 152 } |
| OLD | NEW |