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

Unified Diff: chrome/browser/download/download_query.cc

Issue 1428833005: MD Downloads: track downloads in C++, dispatch discrete JS updates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dpapad@ + asanka@ feedback + self-review Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/download_query.cc
diff --git a/chrome/browser/download/download_query.cc b/chrome/browser/download/download_query.cc
index 7e6ce7f6b908d3ac73c7db83f83c1833de6c9bcf..f615af816b6c110a73a2d29e64d0831ea81a65df 100644
--- a/chrome/browser/download/download_query.cc
+++ b/chrome/browser/download/download_query.cc
@@ -69,35 +69,6 @@ template<> bool GetAs(const base::Value& in, std::vector<base::string16>* out) {
// The next several functions are helpers for making Callbacks that access
// DownloadItem fields.
-static bool MatchesQuery(
- const std::vector<base::string16>& query_terms,
- const DownloadItem& item) {
- DCHECK(!query_terms.empty());
- base::string16 url_raw(base::UTF8ToUTF16(item.GetOriginalUrl().spec()));
- base::string16 url_formatted = url_raw;
- if (item.GetBrowserContext()) {
- Profile* profile = Profile::FromBrowserContext(item.GetBrowserContext());
- url_formatted = url_formatter::FormatUrl(
- item.GetOriginalUrl(),
- profile->GetPrefs()->GetString(prefs::kAcceptLanguages));
- }
- base::string16 path(item.GetTargetFilePath().LossyDisplayName());
-
- for (std::vector<base::string16>::const_iterator it = query_terms.begin();
- it != query_terms.end(); ++it) {
- base::string16 term = base::i18n::ToLower(*it);
- if (!base::i18n::StringSearchIgnoringCaseAndAccents(
- term, url_raw, NULL, NULL) &&
- !base::i18n::StringSearchIgnoringCaseAndAccents(
- term, url_formatted, NULL, NULL) &&
- !base::i18n::StringSearchIgnoringCaseAndAccents(
- term, path, NULL, NULL)) {
- return false;
- }
- }
- return true;
-}
-
static int64 GetStartTimeMsEpoch(const DownloadItem& item) {
return (item.GetStartTime() - base::Time::UnixEpoch()).InMilliseconds();
}
@@ -237,6 +208,35 @@ static ComparisonType Compare(
} // anonymous namespace
+// static
+bool DownloadQuery::MatchesQuery(const std::vector<base::string16>& query_terms,
+ const DownloadItem& item) {
+ DCHECK(!query_terms.empty());
+ base::string16 url_raw(base::UTF8ToUTF16(item.GetOriginalUrl().spec()));
+ base::string16 url_formatted = url_raw;
+ if (item.GetBrowserContext()) {
+ Profile* profile = Profile::FromBrowserContext(item.GetBrowserContext());
+ url_formatted = url_formatter::FormatUrl(
+ item.GetOriginalUrl(),
+ profile->GetPrefs()->GetString(prefs::kAcceptLanguages));
+ }
+ base::string16 path(item.GetTargetFilePath().LossyDisplayName());
+
+ for (std::vector<base::string16>::const_iterator it = query_terms.begin();
+ it != query_terms.end(); ++it) {
+ base::string16 term = base::i18n::ToLower(*it);
+ if (!base::i18n::StringSearchIgnoringCaseAndAccents(
+ term, url_raw, NULL, NULL) &&
+ !base::i18n::StringSearchIgnoringCaseAndAccents(
+ term, url_formatted, NULL, NULL) &&
+ !base::i18n::StringSearchIgnoringCaseAndAccents(
+ term, path, NULL, NULL)) {
+ return false;
+ }
+ }
+ return true;
+}
+
DownloadQuery::DownloadQuery() : limit_(kuint32max), skip_(0U) {}
DownloadQuery::~DownloadQuery() {}

Powered by Google App Engine
This is Rietveld 408576698