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

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

Issue 9307027: Fix DCHECK with Trailing Slash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/history_quick_provider.h" 5 #include "chrome/browser/autocomplete/history_quick_provider.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/i18n/break_iterator.h" 10 #include "base/i18n/break_iterator.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 121
122 // Format the URL autocomplete presentation. 122 // Format the URL autocomplete presentation.
123 std::vector<size_t> offsets = 123 std::vector<size_t> offsets =
124 OffsetsFromTermMatches(history_match.url_matches); 124 OffsetsFromTermMatches(history_match.url_matches);
125 const net::FormatUrlTypes format_types = net::kFormatUrlOmitAll & 125 const net::FormatUrlTypes format_types = net::kFormatUrlOmitAll &
126 ~(!history_match.match_in_scheme ? 0 : net::kFormatUrlOmitHTTP); 126 ~(!history_match.match_in_scheme ? 0 : net::kFormatUrlOmitHTTP);
127 match.fill_into_edit = 127 match.fill_into_edit =
128 AutocompleteInput::FormattedStringWithEquivalentMeaning(info.url(), 128 AutocompleteInput::FormattedStringWithEquivalentMeaning(info.url(),
129 net::FormatUrlWithOffsets(info.url(), languages_, format_types, 129 net::FormatUrlWithOffsets(info.url(), languages_, format_types,
130 net::UnescapeRule::SPACES, NULL, NULL, &offsets)); 130 net::UnescapeRule::SPACES, NULL, NULL, &offsets));
131 history::TermMatches new_matches =
132 ReplaceOffsetsInTermMatches(history_match.url_matches, offsets);
131 match.contents = net::FormatUrl(info.url(), languages_, format_types, 133 match.contents = net::FormatUrl(info.url(), languages_, format_types,
132 net::UnescapeRule::SPACES, NULL, NULL, NULL); 134 net::UnescapeRule::SPACES, NULL, NULL, NULL);
133 history::TermMatches new_matches =
134 ReplaceOffsetsInTermMatches(history_match.url_matches, offsets);
135 match.contents_class = 135 match.contents_class =
136 SpansFromTermMatch(new_matches, match.contents.length(), true); 136 SpansFromTermMatch(new_matches, match.contents.length(), true);
137 137
138 if (prevent_inline_autocomplete || !history_match.can_inline) { 138 if (prevent_inline_autocomplete || !history_match.can_inline) {
139 match.inline_autocomplete_offset = string16::npos; 139 match.inline_autocomplete_offset = string16::npos;
140 } else { 140 } else {
141 DCHECK(!new_matches.empty()); 141 DCHECK(!new_matches.empty());
142 match.inline_autocomplete_offset = new_matches[0].offset + 142 match.inline_autocomplete_offset = new_matches[0].offset +
143 new_matches[0].length; 143 new_matches[0].length;
144 DCHECK_LE(match.inline_autocomplete_offset, match.fill_into_edit.length()); 144 // The following will happen if the user has typed an URL with a scheme
145 // and the last character typed is a slash because that slash is removed
146 // by the FormatURLWithOffsets call above.
Peter Kasting 2012/02/02 06:35:14 We should not be stripping slashes that the user t
147 if (match.inline_autocomplete_offset > match.fill_into_edit.length())
148 match.inline_autocomplete_offset = match.fill_into_edit.length();
145 } 149 }
146 150
147 // Format the description autocomplete presentation. 151 // Format the description autocomplete presentation.
148 match.description = info.title(); 152 match.description = info.title();
149 match.description_class = SpansFromTermMatch( 153 match.description_class = SpansFromTermMatch(
150 history_match.title_matches, match.description.length(), false); 154 history_match.title_matches, match.description.length(), false);
151 155
152 return match; 156 return match;
153 } 157 }
154 158
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 do { 208 do {
205 offset += matches[i].length; 209 offset += matches[i].length;
206 ++i; 210 ++i;
207 } while ((i < match_count) && (offset == matches[i].offset)); 211 } while ((i < match_count) && (offset == matches[i].offset));
208 if (offset < text_length) 212 if (offset < text_length)
209 spans.push_back(ACMatchClassification(offset, url_style)); 213 spans.push_back(ACMatchClassification(offset, url_style));
210 } 214 }
211 215
212 return spans; 216 return spans;
213 } 217 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698