Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: components/omnibox/browser/builtin_provider.cc

Issue 1171333003: Move net::FormatUrl and friends outside of //net and into //components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase again now that CQ is fixed Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <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 "components/metrics/proto/omnibox_input_type.pb.h" 11 #include "components/metrics/proto/omnibox_input_type.pb.h"
12 #include "components/omnibox/browser/autocomplete_input.h" 12 #include "components/omnibox/browser/autocomplete_input.h"
13 #include "components/omnibox/browser/autocomplete_provider_client.h" 13 #include "components/omnibox/browser/autocomplete_provider_client.h"
14 #include "components/omnibox/browser/history_provider.h" 14 #include "components/omnibox/browser/history_provider.h"
15 #include "components/url_fixer/url_fixer.h" 15 #include "components/url_formatter/url_fixer.h"
16 16
17 const int BuiltinProvider::kRelevance = 860; 17 const int BuiltinProvider::kRelevance = 860;
18 18
19 BuiltinProvider::BuiltinProvider(AutocompleteProviderClient* client) 19 BuiltinProvider::BuiltinProvider(AutocompleteProviderClient* client)
20 : AutocompleteProvider(AutocompleteProvider::TYPE_BUILTIN), 20 : AutocompleteProvider(AutocompleteProvider::TYPE_BUILTIN),
21 client_(client) { 21 client_(client) {
22 builtins_ = client_->GetBuiltinURLs(); 22 builtins_ = client_->GetBuiltinURLs();
23 } 23 }
24 24
25 void BuiltinProvider::Start(const AutocompleteInput& input, 25 void BuiltinProvider::Start(const AutocompleteInput& input,
(...skipping 28 matching lines...) Expand all
54 bool highlight = starting_about || text.length() > kAboutSchemeLength; 54 bool highlight = starting_about || text.length() > kAboutSchemeLength;
55 styles.push_back(ACMatchClassification(0, highlight ? kMatch : kUrl)); 55 styles.push_back(ACMatchClassification(0, highlight ? kMatch : kUrl));
56 size_t offset = starting_about ? text.length() : embedderAbout.length(); 56 size_t offset = starting_about ? text.length() : embedderAbout.length();
57 if (highlight) 57 if (highlight)
58 styles.push_back(ACMatchClassification(offset, kUrl)); 58 styles.push_back(ACMatchClassification(offset, kUrl));
59 // Include some common builtin URLs as the user types the scheme. 59 // Include some common builtin URLs as the user types the scheme.
60 for (base::string16 url : client_->GetBuiltinsToProvideAsUserTypes()) 60 for (base::string16 url : client_->GetBuiltinsToProvideAsUserTypes())
61 AddMatch(url, base::string16(), styles); 61 AddMatch(url, base::string16(), styles);
62 } else { 62 } else {
63 // Match input about: or |embedderAbout| URL input against builtin URLs. 63 // Match input about: or |embedderAbout| URL input against builtin URLs.
64 GURL url = url_fixer::FixupURL(base::UTF16ToUTF8(text), std::string()); 64 GURL url = url_formatter::FixupURL(base::UTF16ToUTF8(text), std::string());
65 // BuiltinProvider doesn't know how to suggest valid ?query or #fragment 65 // BuiltinProvider doesn't know how to suggest valid ?query or #fragment
66 // extensions to builtin URLs. 66 // extensions to builtin URLs.
67 if (url.SchemeIs( 67 if (url.SchemeIs(
68 client_->GetEmbedderRepresentationOfAboutScheme().c_str()) && 68 client_->GetEmbedderRepresentationOfAboutScheme().c_str()) &&
69 url.has_host() && !url.has_query() && !url.has_ref()) { 69 url.has_host() && !url.has_query() && !url.has_ref()) {
70 // Suggest about:blank for substrings, taking URL fixup into account. 70 // Suggest about:blank for substrings, taking URL fixup into account.
71 // Chrome does not support trailing slashes or paths for about:blank. 71 // Chrome does not support trailing slashes or paths for about:blank.
72 const base::string16 blank_host = base::ASCIIToUTF16("blank"); 72 const base::string16 blank_host = base::ASCIIToUTF16("blank");
73 const base::string16 host = base::UTF8ToUTF16(url.host()); 73 const base::string16 host = base::UTF8ToUTF16(url.host());
74 if (base::StartsWith(text, base::ASCIIToUTF16(url::kAboutScheme), 74 if (base::StartsWith(text, base::ASCIIToUTF16(url::kAboutScheme),
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 const ACMatchClassifications& styles) { 127 const ACMatchClassifications& styles) {
128 AutocompleteMatch match(this, kRelevance, false, 128 AutocompleteMatch match(this, kRelevance, false,
129 AutocompleteMatchType::NAVSUGGEST); 129 AutocompleteMatchType::NAVSUGGEST);
130 match.fill_into_edit = match_string; 130 match.fill_into_edit = match_string;
131 match.inline_autocompletion = inline_completion; 131 match.inline_autocompletion = inline_completion;
132 match.destination_url = GURL(match_string); 132 match.destination_url = GURL(match_string);
133 match.contents = match_string; 133 match.contents = match_string;
134 match.contents_class = styles; 134 match.contents_class = styles;
135 matches_.push_back(match); 135 matches_.push_back(match);
136 } 136 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/bookmark_provider.cc ('k') | components/omnibox/browser/history_quick_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698