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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_provider.cc

Issue 319523005: Omnibox: Combine Two Input Type Enums into One (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove blank line Created 6 years, 6 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 | Annotate | Revision Log
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 "chrome/browser/autocomplete/autocomplete_provider.h" 5 #include "chrome/browser/autocomplete/autocomplete_provider.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/autocomplete/autocomplete_match.h" 10 #include "chrome/browser/autocomplete/autocomplete_match.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // This probably won't happen, but there are no guarantees. 144 // This probably won't happen, but there are no guarantees.
145 return false; 145 return false;
146 } 146 }
147 147
148 // If the user types a number, GURL will convert it to a dotted quad. 148 // If the user types a number, GURL will convert it to a dotted quad.
149 // However, if the parser did not mark this as a URL, then the user probably 149 // However, if the parser did not mark this as a URL, then the user probably
150 // didn't intend this interpretation. Since this can break history matching 150 // didn't intend this interpretation. Since this can break history matching
151 // for hostname beginning with numbers (e.g. input of "17173" will be matched 151 // for hostname beginning with numbers (e.g. input of "17173" will be matched
152 // against "0.0.67.21" instead of the original "17173", failing to find 152 // against "0.0.67.21" instead of the original "17173", failing to find
153 // "17173.com"), swap the original hostname in for the fixed-up one. 153 // "17173.com"), swap the original hostname in for the fixed-up one.
154 if ((input->type() != AutocompleteInput::URL) && 154 if ((input->type() != metrics::OmniboxInputType::URL) &&
155 canonical_gurl.HostIsIPAddress()) { 155 canonical_gurl.HostIsIPAddress()) {
156 std::string original_hostname = 156 std::string original_hostname =
157 base::UTF16ToUTF8(input_text.substr(input->parts().host.begin, 157 base::UTF16ToUTF8(input_text.substr(input->parts().host.begin,
158 input->parts().host.len)); 158 input->parts().host.len));
159 const url::Parsed& parts = 159 const url::Parsed& parts =
160 canonical_gurl.parsed_for_possibly_invalid_spec(); 160 canonical_gurl.parsed_for_possibly_invalid_spec();
161 // parts.host must not be empty when HostIsIPAddress() is true. 161 // parts.host must not be empty when HostIsIPAddress() is true.
162 DCHECK(parts.host.is_nonempty()); 162 DCHECK(parts.host.is_nonempty());
163 canonical_gurl_str.replace(parts.host.begin, parts.host.len, 163 canonical_gurl_str.replace(parts.host.begin, parts.host.len,
164 original_hostname); 164 original_hostname);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 215
216 // Erase scheme plus up to two slashes. 216 // Erase scheme plus up to two slashes.
217 size_t prefix_end = scheme_pos + strlen(url::kHttpScheme) + 1; 217 size_t prefix_end = scheme_pos + strlen(url::kHttpScheme) + 1;
218 const size_t after_slashes = std::min(url->length(), prefix_end + 2); 218 const size_t after_slashes = std::min(url->length(), prefix_end + 2);
219 while ((prefix_end < after_slashes) && ((*url)[prefix_end] == '/')) 219 while ((prefix_end < after_slashes) && ((*url)[prefix_end] == '/'))
220 ++prefix_end; 220 ++prefix_end;
221 url->erase(scheme_pos, prefix_end - scheme_pos); 221 url->erase(scheme_pos, prefix_end - scheme_pos);
222 return (scheme_pos == 0) ? prefix_end : 0; 222 return (scheme_pos == 0) ? prefix_end : 0;
223 } 223 }
224 224
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698