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

Side by Side Diff: chrome/browser/resources/md_downloads/action_service.js

Issue 1492273002: MD Downloads: limit the amount of downloads we send (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new-dl-data
Patch Set: self-review Created 5 years 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 download: function(url) { 54 download: function(url) {
55 var a = document.createElement('a'); 55 var a = document.createElement('a');
56 a.href = url; 56 a.href = url;
57 a.setAttribute('download', ''); 57 a.setAttribute('download', '');
58 a.click(); 58 a.click();
59 }, 59 },
60 60
61 /** @param {string} id ID of the download that the user started dragging. */ 61 /** @param {string} id ID of the download that the user started dragging. */
62 drag: chromeSendWithId('drag'), 62 drag: chromeSendWithId('drag'),
63 63
64 /** @private {boolean} */ 64 /** Loads more downloads with the current search terms. */
65 isSearching_: false, 65 loadMore: function() {
66 chrome.send('getDownloads', this.searchTerms_);
67 },
66 68
67 /** 69 /**
68 * @return {boolean} Whether the user is currently searching for downloads 70 * @return {boolean} Whether the user is currently searching for downloads
69 * (i.e. has a non-empty search term). 71 * (i.e. has a non-empty search term).
70 */ 72 */
71 isSearching: function() { 73 isSearching: function() {
72 return this.isSearching_; 74 return this.searchTerms_.length > 0;
73 }, 75 },
74 76
75 /** Opens the current local destination for downloads. */ 77 /** Opens the current local destination for downloads. */
76 openDownloadsFolder: chrome.send.bind(chrome, 'openDownloadsFolder'), 78 openDownloadsFolder: chrome.send.bind(chrome, 'openDownloadsFolder'),
77 79
78 /** 80 /**
79 * @param {string} id ID of the download to run locally on the user's box. 81 * @param {string} id ID of the download to run locally on the user's box.
80 */ 82 */
81 openFile: chromeSendWithId('openFile'), 83 openFile: chromeSendWithId('openFile'),
82 84
(...skipping 11 matching lines...) Expand all
94 * warnings. 96 * warnings.
95 */ 97 */
96 saveDangerous: chromeSendWithId('saveDangerous'), 98 saveDangerous: chromeSendWithId('saveDangerous'),
97 99
98 /** @param {string} searchText What to search for. */ 100 /** @param {string} searchText What to search for. */
99 search: function(searchText) { 101 search: function(searchText) {
100 if (this.searchText_ == searchText) 102 if (this.searchText_ == searchText)
101 return; 103 return;
102 104
103 this.searchText_ = searchText; 105 this.searchText_ = searchText;
106 this.searchTerms_ = ActionService.splitTerms(this.searchText_);
107 this.loadMore();
108 },
104 109
105 var terms = ActionService.splitTerms(searchText); 110 /** @private {Array<string>} */
106 this.isSearching_ = terms.length > 0; 111 searchTerms_: [],
107 112
108 chrome.send('getDownloads', terms); 113 /** @private {string} */
109 }, 114 searchText_: '',
asanka 2015/12/07 20:31:50 Why do you keep this around?
asanka 2015/12/08 17:50:31 To clarity, I meant: "Isn't this redundant since w
Dan Beam 2015/12/09 06:55:21 Done.
110 115
111 /** 116 /**
112 * Shows the local folder a finished download resides in. 117 * Shows the local folder a finished download resides in.
113 * @param {string} id ID of the download to show. 118 * @param {string} id ID of the download to show.
114 */ 119 */
115 show: chromeSendWithId('show'), 120 show: chromeSendWithId('show'),
116 121
117 /** Undo download removal. */ 122 /** Undo download removal. */
118 undo: chrome.send.bind(chrome, 'undo'), 123 undo: chrome.send.bind(chrome, 'undo'),
119 }; 124 };
120 125
121 cr.addSingletonGetter(ActionService); 126 cr.addSingletonGetter(ActionService);
122 127
123 return {ActionService: ActionService}; 128 return {ActionService: ActionService};
124 }); 129 });
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