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

Unified Diff: chrome/browser/ui/webui/downloads_dom_handler.cc

Issue 22773003: Fix searching on chrome://downloads (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/downloads_dom_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/downloads_dom_handler.cc
diff --git a/chrome/browser/ui/webui/downloads_dom_handler.cc b/chrome/browser/ui/webui/downloads_dom_handler.cc
index 737cfdda3f782d6dedd595cece0f5ebd3599a23b..47ac8ccf6a672d1a3d5f46f2b9f4f9cd12865bfb 100644
--- a/chrome/browser/ui/webui/downloads_dom_handler.cc
+++ b/chrome/browser/ui/webui/downloads_dom_handler.cc
@@ -262,8 +262,7 @@ bool IsDownloadDisplayable(const content::DownloadItem& item) {
} // namespace
DownloadsDOMHandler::DownloadsDOMHandler(content::DownloadManager* dlm)
- : search_text_(),
- main_notifier_(dlm, this),
+ : main_notifier_(dlm, this),
update_scheduled_(false),
weak_ptr_factory_(this) {
// Create our fileicon data source.
@@ -338,16 +337,14 @@ void DownloadsDOMHandler::OnDownloadUpdated(
content::DownloadManager* manager,
content::DownloadItem* download_item) {
if (IsDownloadDisplayable(*download_item)) {
- if (!search_text_.empty()) {
+ if (search_terms_ && !search_terms_->empty()) {
// Don't CallDownloadUpdated() if download_item doesn't match
- // search_text_.
+ // search_terms_.
// TODO(benjhayden): Consider splitting MatchesQuery() out to a function.
content::DownloadManager::DownloadVector all_items, filtered_items;
all_items.push_back(download_item);
DownloadQuery query;
- scoped_ptr<base::Value> query_text(base::Value::CreateStringValue(
- search_text_));
- query.AddFilter(DownloadQuery::FILTER_QUERY, *query_text.get());
+ query.AddFilter(DownloadQuery::FILTER_QUERY, *search_terms_.get());
query.Search(all_items.begin(), all_items.end(), &filtered_items);
if (filtered_items.empty())
return;
@@ -379,7 +376,7 @@ void DownloadsDOMHandler::OnDownloadRemoved(
void DownloadsDOMHandler::HandleGetDownloads(const base::ListValue* args) {
CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_GET_DOWNLOADS);
- search_text_ = ExtractStringValue(args);
+ search_terms_.reset((args && !args->empty()) ? args->DeepCopy() : NULL);
SendCurrentDownloads();
}
@@ -523,10 +520,8 @@ void DownloadsDOMHandler::SendCurrentDownloads() {
original_notifier_->GetManager()->CheckForHistoryFilesRemoval();
}
DownloadQuery query;
- if (!search_text_.empty()) {
- scoped_ptr<base::Value> query_text(base::Value::CreateStringValue(
- search_text_));
- query.AddFilter(DownloadQuery::FILTER_QUERY, *query_text.get());
+ if (search_terms_ && !search_terms_->empty()) {
+ query.AddFilter(DownloadQuery::FILTER_QUERY, *search_terms_.get());
}
query.AddFilter(base::Bind(&IsDownloadDisplayable));
query.AddSorter(DownloadQuery::SORT_START_TIME, DownloadQuery::DESCENDING);
« no previous file with comments | « chrome/browser/ui/webui/downloads_dom_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698