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

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

Issue 1240853002: Slice MD downloads into more components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: license Created 5 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 cr.define('downloads', function() {
6 /**
7 * @param {string} chromeSendName
8 * @return {function(string):void} A chrome.send() callback with curried name.
9 */
10 function chromeSendWithId(chromeSendName) {
11 return function(id) { chrome.send(chromeSendName, [id]); };
12 }
13
14 /** @constructor */
15 function ActionService() {}
16
17 ActionService.prototype = {
18 /** @param {string} id ID of the download to cancel. */
19 cancel: chromeSendWithId('cancel'),
20
21 /** Instructs the browser to clear all finished downloads. */
22 clearAll: function() {
23 if (loadTimeData.getBoolean('allowDeletingHistory')) {
24 chrome.send('clearAll');
25 this.search('');
26 }
27 },
28
29 /** @param {string} id ID of the dangerous download to discard. */
30 discardDangerous: chromeSendWithId('discardDangerous'),
31
32 /** @param {string} id ID of the download that the user started dragging. */
33 drag: chromeSendWithId('drag'),
34
35 /** Opens the current local destination for downloads. */
36 openDownloadsFolder: chrome.send.bind(chrome, 'openDownloadsFolder'),
37
38 /**
39 * @param {string} id ID of the download to run locally on the user's box.
40 */
41 openFile: chromeSendWithId('openFile'),
42
43 /** @param {string} id ID the of the progressing download to pause. */
44 pause: chromeSendWithId('pause'),
45
46 /** @param {string} id ID of the finished download to remove. */
47 remove: chromeSendWithId('remove'),
48
49 /** @param {string} id ID of the paused download to resume. */
50 resume: chromeSendWithId('resume'),
51
52 /**
53 * @param {string} id ID of the dangerous download to save despite
54 * warnings.
55 */
56 saveDangerous: chromeSendWithId('saveDangerous'),
57
58 /** @param {string} searchText What to search for. */
59 search: function(searchText) {
60 // Split quoted terms (e.g., 'The "lazy" dog' => ['The', 'lazy', 'dog']).
61 function trim(s) { return s.trim(); }
62 chrome.send('getDownloads', searchText.split(/"([^"]*)"/).map(trim));
63 },
64
65 /**
66 * Shows the local folder a finished download resides in.
67 * @param {string} id ID of the download to show.
68 */
69 show: chromeSendWithId('show'),
70
71 /** Undo download removal. */
72 undo: chrome.send.bind(chrome, 'undo'),
73 };
74
75 return {ActionService: ActionService};
76 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698