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

Side by Side 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: moar testz 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('downloads', function() { 5 cr.define('downloads', function() {
6 /** 6 /**
7 * @param {string} chromeSendName 7 * @param {string} chromeSendName
8 * @return {function(string):void} A chrome.send() callback with curried name. 8 * @return {function(string):void} A chrome.send() callback with curried name.
9 */ 9 */
10 function chromeSendWithId(chromeSendName) { 10 function chromeSendWithId(chromeSendName) {
(...skipping 27 matching lines...) Expand all
38 }, 38 },
39 39
40 /** @param {string} id ID of the download that the user started dragging. */ 40 /** @param {string} id ID of the download that the user started dragging. */
41 drag: chromeSendWithId('drag'), 41 drag: chromeSendWithId('drag'),
42 42
43 /** 43 /**
44 * @return {boolean} Whether the user is currently searching for downloads 44 * @return {boolean} Whether the user is currently searching for downloads
45 * (i.e. has a non-empty search term). 45 * (i.e. has a non-empty search term).
46 */ 46 */
47 isSearching: function() { 47 isSearching: function() {
48 return this.searchText_.length > 0; 48 return (this.searchText_ || '').length > 0;
49 }, 49 },
50 50
51 /** Opens the current local destination for downloads. */ 51 /** Opens the current local destination for downloads. */
52 openDownloadsFolder: chrome.send.bind(chrome, 'openDownloadsFolder'), 52 openDownloadsFolder: chrome.send.bind(chrome, 'openDownloadsFolder'),
53 53
54 /** 54 /**
55 * @param {string} id ID of the download to run locally on the user's box. 55 * @param {string} id ID of the download to run locally on the user's box.
56 */ 56 */
57 openFile: chromeSendWithId('openFile'), 57 openFile: chromeSendWithId('openFile'),
58 58
(...skipping 13 matching lines...) Expand all
72 saveDangerous: chromeSendWithId('saveDangerous'), 72 saveDangerous: chromeSendWithId('saveDangerous'),
73 73
74 /** @param {string} searchText What to search for. */ 74 /** @param {string} searchText What to search for. */
75 search: function(searchText) { 75 search: function(searchText) {
76 if (this.searchText_ == searchText) 76 if (this.searchText_ == searchText)
77 return; 77 return;
78 78
79 this.searchText_ = searchText; 79 this.searchText_ = searchText;
80 80
81 // Split quoted terms (e.g., 'The "lazy" dog' => ['The', 'lazy', 'dog']). 81 // Split quoted terms (e.g., 'The "lazy" dog' => ['The', 'lazy', 'dog']).
82 function trim(s) { return s.trim(); } 82 function trim(s) { return s.trim(); }
dpapad 2015/11/20 21:55:15 Nit: Add @param, @return?
Dan Beam 2015/11/21 01:40:42 Done.
83 chrome.send('getDownloads', searchText.split(/"([^"]*)"/).map(trim)); 83 chrome.send('getDownloads',
84 searchText ? searchText.split(/"([^"]*)"/).map(trim) : []);
dpapad 2015/11/20 21:55:15 Nit: Use isSearching instead of implicit conversio
Dan Beam 2015/11/21 01:40:42 ehhhhhhhhh
84 }, 85 },
85 86
86 /** 87 /**
87 * Shows the local folder a finished download resides in. 88 * Shows the local folder a finished download resides in.
88 * @param {string} id ID of the download to show. 89 * @param {string} id ID of the download to show.
89 */ 90 */
90 show: chromeSendWithId('show'), 91 show: chromeSendWithId('show'),
91 92
92 /** Undo download removal. */ 93 /** Undo download removal. */
93 undo: chrome.send.bind(chrome, 'undo'), 94 undo: chrome.send.bind(chrome, 'undo'),
94 }; 95 };
95 96
96 cr.addSingletonGetter(ActionService); 97 cr.addSingletonGetter(ActionService);
97 98
98 return {ActionService: ActionService}; 99 return {ActionService: ActionService};
99 }); 100 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/md_downloads/crisper.js » ('j') | chrome/browser/resources/md_downloads/manager.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698