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

Unified Diff: chrome/browser/resources/md_downloads/action_service.js

Issue 1480263002: Revert of MD Downloads: track downloads in C++, dispatch discrete JS updates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/resources/md_downloads/action_service.js
diff --git a/chrome/browser/resources/md_downloads/action_service.js b/chrome/browser/resources/md_downloads/action_service.js
index ee0a1b4a9fdc7384cfca8c7a120ddc7f6f18bf3b..f984fe5a14614e3b853993e4dcaad33b70577641 100644
--- a/chrome/browser/resources/md_downloads/action_service.js
+++ b/chrome/browser/resources/md_downloads/action_service.js
@@ -13,27 +13,6 @@
/** @constructor */
function ActionService() {}
-
- /**
- * @param {string} s
- * @return {string} |s| without whitespace at the beginning or end.
- */
- function trim(s) { return s.trim(); }
-
- /**
- * @param {string|undefined} value
- * @return {boolean} Whether |value| is truthy.
- */
- function truthy(value) { return !!value; }
-
- /**
- * @param {string} searchText Input typed by the user into a search box.
- * @return {Array<string>} A list of terms extracted from |searchText|.
- */
- ActionService.splitTerms = function(searchText) {
- // Split quoted terms (e.g., 'The "lazy" dog' => ['The', 'lazy', 'dog']).
- return searchText.split(/"([^"]*)"/).map(trim).filter(truthy);
- };
ActionService.prototype = {
/** @param {string} id ID of the download to cancel. */
@@ -61,15 +40,12 @@
/** @param {string} id ID of the download that the user started dragging. */
drag: chromeSendWithId('drag'),
- /** @private {boolean} */
- isSearching_: false,
-
/**
* @return {boolean} Whether the user is currently searching for downloads
* (i.e. has a non-empty search term).
*/
isSearching: function() {
- return this.isSearching_;
+ return this.searchText_.length > 0;
},
/** Opens the current local destination for downloads. */
@@ -102,10 +78,9 @@
this.searchText_ = searchText;
- var terms = ActionService.splitTerms(searchText);
- this.isSearching_ = terms.length > 0;
-
- chrome.send('getDownloads', terms);
+ // Split quoted terms (e.g., 'The "lazy" dog' => ['The', 'lazy', 'dog']).
+ function trim(s) { return s.trim(); }
+ chrome.send('getDownloads', searchText.split(/"([^"]*)"/).map(trim));
},
/**
« no previous file with comments | « chrome/browser/download/download_query.cc ('k') | chrome/browser/resources/md_downloads/action_service_unittest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698