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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 for (base::string16 url : client_->GetBuiltinsToProvideAsUserTypes()) | 61 for (base::string16 url : client_->GetBuiltinsToProvideAsUserTypes()) |
62 AddMatch(url, base::string16(), styles); | 62 AddMatch(url, base::string16(), styles); |
63 } else { | 63 } else { |
64 // Match input about: or |embedderAbout| URL input against builtin URLs. | 64 // Match input about: or |embedderAbout| URL input against builtin URLs. |
65 GURL url = url_formatter::FixupURL(base::UTF16ToUTF8(text), std::string()); | 65 GURL url = url_formatter::FixupURL(base::UTF16ToUTF8(text), std::string()); |
66 const bool text_ends_with_slash = | 66 const bool text_ends_with_slash = |
67 base::EndsWith(text, base::ASCIIToUTF16("/"), | 67 base::EndsWith(text, base::ASCIIToUTF16("/"), |
68 base::CompareCase::SENSITIVE); | 68 base::CompareCase::SENSITIVE); |
69 // BuiltinProvider doesn't know how to suggest valid ?query or #fragment | 69 // BuiltinProvider doesn't know how to suggest valid ?query or #fragment |
70 // extensions to builtin URLs. | 70 // extensions to builtin URLs. |
71 if (url.SchemeIs( | 71 if (url.SchemeIs(client_->GetEmbedderRepresentationOfAboutScheme()) && |
72 client_->GetEmbedderRepresentationOfAboutScheme().c_str()) && | |
73 url.has_host() && !url.has_query() && !url.has_ref()) { | 72 url.has_host() && !url.has_query() && !url.has_ref()) { |
74 // Suggest about:blank for substrings, taking URL fixup into account. | 73 // Suggest about:blank for substrings, taking URL fixup into account. |
75 // Chrome does not support trailing slashes or paths for about:blank. | 74 // Chrome does not support trailing slashes or paths for about:blank. |
76 const base::string16 blank_host = base::ASCIIToUTF16("blank"); | 75 const base::string16 blank_host = base::ASCIIToUTF16("blank"); |
77 const base::string16 host = base::UTF8ToUTF16(url.host()); | 76 const base::string16 host = base::UTF8ToUTF16(url.host()); |
78 if (base::StartsWith(text, base::ASCIIToUTF16(url::kAboutScheme), | 77 if (base::StartsWith(text, base::ASCIIToUTF16(url::kAboutScheme), |
79 base::CompareCase::INSENSITIVE_ASCII) && | 78 base::CompareCase::INSENSITIVE_ASCII) && |
80 base::StartsWith(blank_host, host, | 79 base::StartsWith(blank_host, host, |
81 base::CompareCase::INSENSITIVE_ASCII) && | 80 base::CompareCase::INSENSITIVE_ASCII) && |
82 (url.path().length() <= 1) && !text_ends_with_slash) { | 81 (url.path().length() <= 1) && !text_ends_with_slash) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 const ACMatchClassifications& styles) { | 138 const ACMatchClassifications& styles) { |
140 AutocompleteMatch match(this, kRelevance, false, | 139 AutocompleteMatch match(this, kRelevance, false, |
141 AutocompleteMatchType::NAVSUGGEST); | 140 AutocompleteMatchType::NAVSUGGEST); |
142 match.fill_into_edit = match_string; | 141 match.fill_into_edit = match_string; |
143 match.inline_autocompletion = inline_completion; | 142 match.inline_autocompletion = inline_completion; |
144 match.destination_url = GURL(match_string); | 143 match.destination_url = GURL(match_string); |
145 match.contents = match_string; | 144 match.contents = match_string; |
146 match.contents_class = styles; | 145 match.contents_class = styles; |
147 matches_.push_back(match); | 146 matches_.push_back(match); |
148 } | 147 } |
OLD | NEW |