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

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

Issue 1841653003: Drop |languages| from {Format,Elide}Url* and IDNToUnicode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo in elide_url.cc Created 4 years, 8 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/bookmark_provider.h" 5 #include "components/omnibox/browser/bookmark_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 } 51 }
52 52
53 } // namespace 53 } // namespace
54 54
55 // BookmarkProvider ------------------------------------------------------------ 55 // BookmarkProvider ------------------------------------------------------------
56 56
57 BookmarkProvider::BookmarkProvider(AutocompleteProviderClient* client) 57 BookmarkProvider::BookmarkProvider(AutocompleteProviderClient* client)
58 : AutocompleteProvider(AutocompleteProvider::TYPE_BOOKMARK), 58 : AutocompleteProvider(AutocompleteProvider::TYPE_BOOKMARK),
59 client_(client), 59 client_(client),
60 bookmark_model_(NULL) { 60 bookmark_model_(client ? client_->GetBookmarkModel() : nullptr) {}
61 if (client_) {
62 bookmark_model_ = client_->GetBookmarkModel();
63 languages_ = client_->GetAcceptLanguages();
64 }
65 }
66 61
67 void BookmarkProvider::Start(const AutocompleteInput& input, 62 void BookmarkProvider::Start(const AutocompleteInput& input,
68 bool minimal_changes) { 63 bool minimal_changes) {
69 TRACE_EVENT0("omnibox", "BookmarkProvider::Start"); 64 TRACE_EVENT0("omnibox", "BookmarkProvider::Start");
70 if (minimal_changes) 65 if (minimal_changes)
71 return; 66 return;
72 matches_.clear(); 67 matches_.clear();
73 68
74 if (input.from_omnibox_focus() || input.text().empty() || 69 if (input.from_omnibox_focus() || input.text().empty() ||
75 (input.type() == metrics::OmniboxInputType::FORCED_QUERY)) 70 (input.type() == metrics::OmniboxInputType::FORCED_QUERY))
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 const bool trim_http = !AutocompleteInput::HasHTTPScheme(input.text()) && 180 const bool trim_http = !AutocompleteInput::HasHTTPScheme(input.text()) &&
186 ((match_start == base::string16::npos) || (match_start != 0)); 181 ((match_start == base::string16::npos) || (match_start != 0));
187 std::vector<size_t> offsets = BookmarkMatch::OffsetsFromMatchPositions( 182 std::vector<size_t> offsets = BookmarkMatch::OffsetsFromMatchPositions(
188 bookmark_match.url_match_positions); 183 bookmark_match.url_match_positions);
189 // In addition to knowing how |offsets| is transformed, we need to know how 184 // In addition to knowing how |offsets| is transformed, we need to know how
190 // |inline_autocomplete_offset| is transformed. We add it to the end of 185 // |inline_autocomplete_offset| is transformed. We add it to the end of
191 // |offsets|, compute how everything is transformed, then remove it from the 186 // |offsets|, compute how everything is transformed, then remove it from the
192 // end. 187 // end.
193 offsets.push_back(inline_autocomplete_offset); 188 offsets.push_back(inline_autocomplete_offset);
194 match.contents = url_formatter::FormatUrlWithOffsets( 189 match.contents = url_formatter::FormatUrlWithOffsets(
195 url, languages_, url_formatter::kFormatUrlOmitAll & 190 url, url_formatter::kFormatUrlOmitAll &
196 ~(trim_http ? 0 : url_formatter::kFormatUrlOmitHTTP), 191 ~(trim_http ? 0 : url_formatter::kFormatUrlOmitHTTP),
197 net::UnescapeRule::SPACES, nullptr, nullptr, &offsets); 192 net::UnescapeRule::SPACES, nullptr, nullptr, &offsets);
198 inline_autocomplete_offset = offsets.back(); 193 inline_autocomplete_offset = offsets.back();
199 offsets.pop_back(); 194 offsets.pop_back();
200 BookmarkMatch::MatchPositions new_url_match_positions = 195 BookmarkMatch::MatchPositions new_url_match_positions =
201 BookmarkMatch::ReplaceOffsetsInMatchPositions( 196 BookmarkMatch::ReplaceOffsetsInMatchPositions(
202 bookmark_match.url_match_positions, offsets); 197 bookmark_match.url_match_positions, offsets);
203 match.contents_class = 198 match.contents_class =
204 ClassificationsFromMatch(new_url_match_positions, 199 ClassificationsFromMatch(new_url_match_positions,
205 match.contents.size(), 200 match.contents.size(),
206 true); 201 true);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 i != positions.end(); 334 i != positions.end();
340 ++i) { 335 ++i) {
341 AutocompleteMatch::ACMatchClassifications new_class; 336 AutocompleteMatch::ACMatchClassifications new_class;
342 AutocompleteMatch::ClassifyLocationInString(i->first, i->second - i->first, 337 AutocompleteMatch::ClassifyLocationInString(i->first, i->second - i->first,
343 text_length, url_style, &new_class); 338 text_length, url_style, &new_class);
344 classifications = AutocompleteMatch::MergeClassifications( 339 classifications = AutocompleteMatch::MergeClassifications(
345 classifications, new_class); 340 classifications, new_class);
346 } 341 }
347 return classifications; 342 return classifications;
348 } 343 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/bookmark_provider.h ('k') | components/omnibox/browser/clipboard_url_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698