| 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 "components/omnibox/browser/builtin_provider.h" | 5 #include "components/omnibox/browser/builtin_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 styles.push_back(ACMatchClassification(0, kMatch)); | 84 styles.push_back(ACMatchClassification(0, kMatch)); |
| 85 base::string16 match = base::ASCIIToUTF16(url::kAboutBlankURL); | 85 base::string16 match = base::ASCIIToUTF16(url::kAboutBlankURL); |
| 86 // Measure the length of the matching host after the "about:" scheme. | 86 // Measure the length of the matching host after the "about:" scheme. |
| 87 const size_t corrected_length = kAboutSchemeLength + 1 + host.length(); | 87 const size_t corrected_length = kAboutSchemeLength + 1 + host.length(); |
| 88 if (blank_host.length() > host.length()) | 88 if (blank_host.length() > host.length()) |
| 89 styles.push_back(ACMatchClassification(corrected_length, kUrl)); | 89 styles.push_back(ACMatchClassification(corrected_length, kUrl)); |
| 90 AddMatch(match, match.substr(corrected_length), styles); | 90 AddMatch(match, match.substr(corrected_length), styles); |
| 91 } | 91 } |
| 92 | 92 |
| 93 // Include the path for sub-pages (e.g. "chrome://settings/browser"). | 93 // Include the path for sub-pages (e.g. "chrome://settings/browser"). |
| 94 base::string16 host_and_path = base::UTF8ToUTF16(url.host() + url.path()); | 94 base::string16 host_and_path = |
| 95 base::UTF8ToUTF16(url.host() + url.path().as_string()); |
| 95 base::TrimString(host_and_path, base::ASCIIToUTF16("/"), &host_and_path); | 96 base::TrimString(host_and_path, base::ASCIIToUTF16("/"), &host_and_path); |
| 96 size_t match_length = embedderAbout.length() + host_and_path.length(); | 97 size_t match_length = embedderAbout.length() + host_and_path.length(); |
| 97 for (Builtins::const_iterator i(builtins_.begin()); | 98 for (Builtins::const_iterator i(builtins_.begin()); |
| 98 (i != builtins_.end()) && (matches_.size() < kMaxMatches); ++i) { | 99 (i != builtins_.end()) && (matches_.size() < kMaxMatches); ++i) { |
| 99 if (base::StartsWith(*i, host_and_path, | 100 if (base::StartsWith(*i, host_and_path, |
| 100 base::CompareCase::INSENSITIVE_ASCII)) { | 101 base::CompareCase::INSENSITIVE_ASCII)) { |
| 101 ACMatchClassifications styles; | 102 ACMatchClassifications styles; |
| 102 // Highlight |embedderAbout|, even for input "about:foo". | 103 // Highlight |embedderAbout|, even for input "about:foo". |
| 103 styles.push_back(ACMatchClassification(0, kMatch)); | 104 styles.push_back(ACMatchClassification(0, kMatch)); |
| 104 base::string16 match_string = embedderAbout + *i; | 105 base::string16 match_string = embedderAbout + *i; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 const ACMatchClassifications& styles) { | 140 const ACMatchClassifications& styles) { |
| 140 AutocompleteMatch match(this, kRelevance, false, | 141 AutocompleteMatch match(this, kRelevance, false, |
| 141 AutocompleteMatchType::NAVSUGGEST); | 142 AutocompleteMatchType::NAVSUGGEST); |
| 142 match.fill_into_edit = match_string; | 143 match.fill_into_edit = match_string; |
| 143 match.inline_autocompletion = inline_completion; | 144 match.inline_autocompletion = inline_completion; |
| 144 match.destination_url = GURL(match_string); | 145 match.destination_url = GURL(match_string); |
| 145 match.contents = match_string; | 146 match.contents = match_string; |
| 146 match.contents_class = styles; | 147 match.contents_class = styles; |
| 147 matches_.push_back(match); | 148 matches_.push_back(match); |
| 148 } | 149 } |
| OLD | NEW |