| Index: chrome/browser/download/download_query.cc
|
| diff --git a/chrome/browser/download/download_query.cc b/chrome/browser/download/download_query.cc
|
| index c2049d21dd05c2ebec94d887eada5932d4deec97..cd2d4392f4b0f6dc226d818719da04cce1c190e3 100644
|
| --- a/chrome/browser/download/download_query.cc
|
| +++ b/chrome/browser/download/download_query.cc
|
| @@ -11,6 +11,8 @@
|
| #include "base/bind.h"
|
| #include "base/callback.h"
|
| #include "base/file_path.h"
|
| +#include "base/i18n/case_conversion.h"
|
| +#include "base/i18n/string_search.h"
|
| #include "base/logging.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/stl_util.h"
|
| @@ -19,8 +21,10 @@
|
| #include "base/time.h"
|
| #include "base/utf_string_conversions.h"
|
| #include "base/values.h"
|
| +#include "content/public/browser/content_browser_client.h"
|
| #include "content/public/browser/download_item.h"
|
| #include "googleurl/src/gurl.h"
|
| +#include "net/base/net_util.h"
|
| #include "unicode/regex.h"
|
|
|
| using content::DownloadDangerType;
|
| @@ -46,8 +50,33 @@ template<> bool GetAs(const base::Value& in, string16* out) {
|
| // The next several functions are helpers for making Callbacks that access
|
| // DownloadItem fields.
|
|
|
| -static bool MatchesQuery(const string16& value, const DownloadItem& item) {
|
| - return item.MatchesQuery(value);
|
| +static bool MatchesQuery(const string16& query, const DownloadItem& item) {
|
| + if (query.empty())
|
| + return true;
|
| +
|
| + DCHECK_EQ(query, base::i18n::ToLower(query));
|
| +
|
| + string16 url_raw(UTF8ToUTF16(item.GetOriginalUrl().spec()));
|
| + if (base::i18n::StringSearchIgnoringCaseAndAccents(
|
| + query, url_raw, NULL, NULL)) {
|
| + return true;
|
| + }
|
| +
|
| + string16 url_formatted = url_raw;
|
| + if (item.GetBrowserContext()) {
|
| + url_formatted = net::FormatUrl(
|
| + item.GetOriginalUrl(),
|
| + content::GetContentClient()->browser()->GetAcceptLangs(
|
| + item.GetBrowserContext()));
|
| + }
|
| + if (base::i18n::StringSearchIgnoringCaseAndAccents(
|
| + query, url_formatted, NULL, NULL)) {
|
| + return true;
|
| + }
|
| +
|
| + string16 path(item.GetTargetFilePath().LossyDisplayName());
|
| + return base::i18n::StringSearchIgnoringCaseAndAccents(
|
| + query, path, NULL, NULL);
|
| }
|
|
|
| static int GetStartTime(const DownloadItem& item) {
|
| @@ -61,7 +90,7 @@ static bool GetDangerAccepted(const DownloadItem& item) {
|
| static string16 GetFilename(const DownloadItem& item) {
|
| // This filename will be compared with strings that could be passed in by the
|
| // user, who only sees LossyDisplayNames.
|
| - return item.GetFullPath().LossyDisplayName();
|
| + return item.GetTargetFilePath().LossyDisplayName();
|
| }
|
|
|
| static std::string GetFilenameUTF8(const DownloadItem& item) {
|
|
|