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

Side by Side Diff: chrome/browser/download/download_query.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 "chrome/browser/download/download_query.h" 5 #include "chrome/browser/download/download_query.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
17 #include "base/i18n/case_conversion.h" 17 #include "base/i18n/case_conversion.h"
18 #include "base/i18n/string_search.h" 18 #include "base/i18n/string_search.h"
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
21 #include "base/stl_util.h" 21 #include "base/stl_util.h"
22 #include "base/strings/string16.h" 22 #include "base/strings/string16.h"
23 #include "base/strings/string_split.h" 23 #include "base/strings/string_split.h"
24 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
25 #include "base/strings/utf_string_conversions.h" 25 #include "base/strings/utf_string_conversions.h"
26 #include "base/time/time.h" 26 #include "base/time/time.h"
27 #include "base/values.h" 27 #include "base/values.h"
28 #include "chrome/browser/profiles/profile.h"
29 #include "chrome/common/pref_names.h"
30 #include "components/prefs/pref_service.h"
31 #include "components/url_formatter/url_formatter.h" 28 #include "components/url_formatter/url_formatter.h"
32 #include "content/public/browser/content_browser_client.h" 29 #include "content/public/browser/content_browser_client.h"
33 #include "content/public/browser/download_item.h" 30 #include "content/public/browser/download_item.h"
34 #include "third_party/re2/src/re2/re2.h" 31 #include "third_party/re2/src/re2/re2.h"
35 #include "url/gurl.h" 32 #include "url/gurl.h"
36 33
37 using content::DownloadDangerType; 34 using content::DownloadDangerType;
38 using content::DownloadItem; 35 using content::DownloadItem;
39 36
40 namespace { 37 namespace {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } // anonymous namespace 209 } // anonymous namespace
213 210
214 // static 211 // static
215 bool DownloadQuery::MatchesQuery(const std::vector<base::string16>& query_terms, 212 bool DownloadQuery::MatchesQuery(const std::vector<base::string16>& query_terms,
216 const DownloadItem& item) { 213 const DownloadItem& item) {
217 if (query_terms.empty()) 214 if (query_terms.empty())
218 return true; 215 return true;
219 216
220 base::string16 url_raw(base::UTF8ToUTF16(item.GetOriginalUrl().spec())); 217 base::string16 url_raw(base::UTF8ToUTF16(item.GetOriginalUrl().spec()));
221 base::string16 url_formatted = url_raw; 218 base::string16 url_formatted = url_raw;
222 if (item.GetBrowserContext()) { 219 if (item.GetBrowserContext())
223 Profile* profile = Profile::FromBrowserContext(item.GetBrowserContext()); 220 url_formatted = url_formatter::FormatUrl(item.GetOriginalUrl());
224 url_formatted = url_formatter::FormatUrl(
225 item.GetOriginalUrl(),
226 profile->GetPrefs()->GetString(prefs::kAcceptLanguages));
227 }
228 base::string16 path(item.GetTargetFilePath().LossyDisplayName()); 221 base::string16 path(item.GetTargetFilePath().LossyDisplayName());
229 222
230 for (std::vector<base::string16>::const_iterator it = query_terms.begin(); 223 for (std::vector<base::string16>::const_iterator it = query_terms.begin();
231 it != query_terms.end(); ++it) { 224 it != query_terms.end(); ++it) {
232 base::string16 term = base::i18n::ToLower(*it); 225 base::string16 term = base::i18n::ToLower(*it);
233 if (!base::i18n::StringSearchIgnoringCaseAndAccents( 226 if (!base::i18n::StringSearchIgnoringCaseAndAccents(
234 term, url_raw, NULL, NULL) && 227 term, url_raw, NULL, NULL) &&
235 !base::i18n::StringSearchIgnoringCaseAndAccents( 228 !base::i18n::StringSearchIgnoringCaseAndAccents(
236 term, url_formatted, NULL, NULL) && 229 term, url_formatted, NULL, NULL) &&
237 !base::i18n::StringSearchIgnoringCaseAndAccents( 230 !base::i18n::StringSearchIgnoringCaseAndAccents(
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 if (!sorters_.empty()) { 430 if (!sorters_.empty()) {
438 std::partial_sort(results->begin(), 431 std::partial_sort(results->begin(),
439 results->begin() + std::min(limit_, results->size()), 432 results->begin() + std::min(limit_, results->size()),
440 results->end(), 433 results->end(),
441 DownloadComparator(sorters_)); 434 DownloadComparator(sorters_));
442 } 435 }
443 436
444 if (results->size() > limit_) 437 if (results->size() > limit_)
445 results->resize(limit_); 438 results->resize(limit_);
446 } 439 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_distiller/tab_utils_android.cc ('k') | chrome/browser/download/notification/download_item_notification.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698