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

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

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: asdf 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 f984fe5a14614e3b853993e4dcaad33b70577641..70c5e59af948b83f9ccb65ea2f3976fab249d2bf 100644
--- a/chrome/browser/resources/md_downloads/action_service.js
+++ b/chrome/browser/resources/md_downloads/action_service.js
@@ -45,7 +45,7 @@ cr.define('downloads', function() {
* (i.e. has a non-empty search term).
*/
isSearching: function() {
- return this.searchText_.length > 0;
+ return (this.searchText_ || '').length > 0;
asanka 2015/11/24 22:08:22 !!this.searchText_ or do you folks dislike that e
Dan Beam 2015/11/25 04:06:36 Done.
},
/** Opens the current local destination for downloads. */
@@ -78,9 +78,16 @@ cr.define('downloads', function() {
this.searchText_ = searchText;
- // Split quoted terms (e.g., 'The "lazy" dog' => ['The', 'lazy', 'dog']).
+ /**
+ * @param {string} s
+ * @return {string} |s| without whitespace at the ends (trimmed).
+ */
function trim(s) { return s.trim(); }
- chrome.send('getDownloads', searchText.split(/"([^"]*)"/).map(trim));
+
+ // Split quoted terms (e.g., 'The "lazy" dog' => ['The', 'lazy', 'dog']).
+ var terms = searchText ? searchText.split(/"([^"]*)"/).map(trim) : [];
dpapad 2015/11/24 18:42:33 Is it worth adding tests for the regular expressio
Dan Beam 2015/11/25 04:06:36 Done.
+
+ chrome.send('getDownloads', terms);
},
/**

Powered by Google App Engine
This is Rietveld 408576698