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

Side by Side Diff: chrome/browser/autocomplete/bookmark_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: Compile fixes following rebase Created 5 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
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/bookmark_provider.h" 5 #include "chrome/browser/autocomplete/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
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" 14 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
15 #include "chrome/browser/autocomplete/history_provider.h" 15 #include "chrome/browser/autocomplete/history_provider.h"
16 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 16 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
19 #include "components/bookmarks/browser/bookmark_match.h" 19 #include "components/bookmarks/browser/bookmark_match.h"
20 #include "components/bookmarks/browser/bookmark_model.h" 20 #include "components/bookmarks/browser/bookmark_model.h"
21 #include "components/metrics/proto/omnibox_input_type.pb.h" 21 #include "components/metrics/proto/omnibox_input_type.pb.h"
22 #include "components/omnibox/autocomplete_result.h" 22 #include "components/omnibox/autocomplete_result.h"
23 #include "components/omnibox/url_prefix.h" 23 #include "components/omnibox/url_prefix.h"
24 #include "net/base/net_util.h" 24 #include "components/url_formatter/url_formatter.h"
25 #include "url/url_constants.h" 25 #include "url/url_constants.h"
26 26
27 using bookmarks::BookmarkMatch; 27 using bookmarks::BookmarkMatch;
28 using bookmarks::BookmarkNode; 28 using bookmarks::BookmarkNode;
29 29
30 typedef std::vector<BookmarkMatch> BookmarkMatches; 30 typedef std::vector<BookmarkMatch> BookmarkMatches;
31 31
32 namespace { 32 namespace {
33 33
34 // Removes leading spaces from |title| before displaying, otherwise it looks 34 // Removes leading spaces from |title| before displaying, otherwise it looks
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 0 : bookmark_match.url_match_positions[0].first; 185 0 : bookmark_match.url_match_positions[0].first;
186 const bool trim_http = !AutocompleteInput::HasHTTPScheme(input.text()) && 186 const bool trim_http = !AutocompleteInput::HasHTTPScheme(input.text()) &&
187 ((match_start == base::string16::npos) || (match_start != 0)); 187 ((match_start == base::string16::npos) || (match_start != 0));
188 std::vector<size_t> offsets = BookmarkMatch::OffsetsFromMatchPositions( 188 std::vector<size_t> offsets = BookmarkMatch::OffsetsFromMatchPositions(
189 bookmark_match.url_match_positions); 189 bookmark_match.url_match_positions);
190 // In addition to knowing how |offsets| is transformed, we need to know how 190 // In addition to knowing how |offsets| is transformed, we need to know how
191 // |inline_autocomplete_offset| is transformed. We add it to the end of 191 // |inline_autocomplete_offset| is transformed. We add it to the end of
192 // |offsets|, compute how everything is transformed, then remove it from the 192 // |offsets|, compute how everything is transformed, then remove it from the
193 // end. 193 // end.
194 offsets.push_back(inline_autocomplete_offset); 194 offsets.push_back(inline_autocomplete_offset);
195 match.contents = net::FormatUrlWithOffsets(url, languages_, 195 match.contents = url_formatter::FormatUrlWithOffsets(
196 net::kFormatUrlOmitAll & ~(trim_http ? 0 : net::kFormatUrlOmitHTTP), 196 url, languages_, url_formatter::kFormatUrlOmitAll &
197 net::UnescapeRule::SPACES, NULL, NULL, &offsets); 197 ~(trim_http ? 0 : url_formatter::kFormatUrlOmitHTTP),
198 net::UnescapeRule::SPACES, nullptr, nullptr, &offsets);
198 inline_autocomplete_offset = offsets.back(); 199 inline_autocomplete_offset = offsets.back();
199 offsets.pop_back(); 200 offsets.pop_back();
200 BookmarkMatch::MatchPositions new_url_match_positions = 201 BookmarkMatch::MatchPositions new_url_match_positions =
201 BookmarkMatch::ReplaceOffsetsInMatchPositions( 202 BookmarkMatch::ReplaceOffsetsInMatchPositions(
202 bookmark_match.url_match_positions, offsets); 203 bookmark_match.url_match_positions, offsets);
203 match.contents_class = 204 match.contents_class =
204 ClassificationsFromMatch(new_url_match_positions, 205 ClassificationsFromMatch(new_url_match_positions,
205 match.contents.size(), 206 match.contents.size(),
206 true); 207 true);
207 match.fill_into_edit = 208 match.fill_into_edit =
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 i != positions.end(); 340 i != positions.end();
340 ++i) { 341 ++i) {
341 AutocompleteMatch::ACMatchClassifications new_class; 342 AutocompleteMatch::ACMatchClassifications new_class;
342 AutocompleteMatch::ClassifyLocationInString(i->first, i->second - i->first, 343 AutocompleteMatch::ClassifyLocationInString(i->first, i->second - i->first,
343 text_length, url_style, &new_class); 344 text_length, url_style, &new_class);
344 classifications = AutocompleteMatch::MergeClassifications( 345 classifications = AutocompleteMatch::MergeClassifications(
345 classifications, new_class); 346 classifications, new_class);
346 } 347 }
347 return classifications; 348 return classifications;
348 } 349 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698