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

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: rebased, most Android targets locally built successfully 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_(nullptr) {
Peter Kasting 2016/04/05 02:42:32 Nit: Eliminates need for function body: boo
jungshik at Google 2016/04/05 18:56:18 Done.
61 if (client_) { 61 if (client_)
62 bookmark_model_ = client_->GetBookmarkModel(); 62 bookmark_model_ = client_->GetBookmarkModel();
63 languages_ = client_->GetAcceptLanguages();
64 }
65 } 63 }
66 64
67 void BookmarkProvider::Start(const AutocompleteInput& input, 65 void BookmarkProvider::Start(const AutocompleteInput& input,
68 bool minimal_changes) { 66 bool minimal_changes) {
69 TRACE_EVENT0("omnibox", "BookmarkProvider::Start"); 67 TRACE_EVENT0("omnibox", "BookmarkProvider::Start");
70 if (minimal_changes) 68 if (minimal_changes)
71 return; 69 return;
72 matches_.clear(); 70 matches_.clear();
73 71
74 if (input.from_omnibox_focus() || input.text().empty() || 72 if (input.from_omnibox_focus() || input.text().empty() ||
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 const bool trim_http = !AutocompleteInput::HasHTTPScheme(input.text()) && 183 const bool trim_http = !AutocompleteInput::HasHTTPScheme(input.text()) &&
186 ((match_start == base::string16::npos) || (match_start != 0)); 184 ((match_start == base::string16::npos) || (match_start != 0));
187 std::vector<size_t> offsets = BookmarkMatch::OffsetsFromMatchPositions( 185 std::vector<size_t> offsets = BookmarkMatch::OffsetsFromMatchPositions(
188 bookmark_match.url_match_positions); 186 bookmark_match.url_match_positions);
189 // In addition to knowing how |offsets| is transformed, we need to know how 187 // 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 188 // |inline_autocomplete_offset| is transformed. We add it to the end of
191 // |offsets|, compute how everything is transformed, then remove it from the 189 // |offsets|, compute how everything is transformed, then remove it from the
192 // end. 190 // end.
193 offsets.push_back(inline_autocomplete_offset); 191 offsets.push_back(inline_autocomplete_offset);
194 match.contents = url_formatter::FormatUrlWithOffsets( 192 match.contents = url_formatter::FormatUrlWithOffsets(
195 url, languages_, url_formatter::kFormatUrlOmitAll & 193 url, url_formatter::kFormatUrlOmitAll &
196 ~(trim_http ? 0 : url_formatter::kFormatUrlOmitHTTP), 194 ~(trim_http ? 0 : url_formatter::kFormatUrlOmitHTTP),
197 net::UnescapeRule::SPACES, nullptr, nullptr, &offsets); 195 net::UnescapeRule::SPACES, nullptr, nullptr, &offsets);
198 inline_autocomplete_offset = offsets.back(); 196 inline_autocomplete_offset = offsets.back();
199 offsets.pop_back(); 197 offsets.pop_back();
200 BookmarkMatch::MatchPositions new_url_match_positions = 198 BookmarkMatch::MatchPositions new_url_match_positions =
201 BookmarkMatch::ReplaceOffsetsInMatchPositions( 199 BookmarkMatch::ReplaceOffsetsInMatchPositions(
202 bookmark_match.url_match_positions, offsets); 200 bookmark_match.url_match_positions, offsets);
203 match.contents_class = 201 match.contents_class =
204 ClassificationsFromMatch(new_url_match_positions, 202 ClassificationsFromMatch(new_url_match_positions,
205 match.contents.size(), 203 match.contents.size(),
206 true); 204 true);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 i != positions.end(); 337 i != positions.end();
340 ++i) { 338 ++i) {
341 AutocompleteMatch::ACMatchClassifications new_class; 339 AutocompleteMatch::ACMatchClassifications new_class;
342 AutocompleteMatch::ClassifyLocationInString(i->first, i->second - i->first, 340 AutocompleteMatch::ClassifyLocationInString(i->first, i->second - i->first,
343 text_length, url_style, &new_class); 341 text_length, url_style, &new_class);
344 classifications = AutocompleteMatch::MergeClassifications( 342 classifications = AutocompleteMatch::MergeClassifications(
345 classifications, new_class); 343 classifications, new_class);
346 } 344 }
347 return classifications; 345 return classifications;
348 } 346 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698