OLD | NEW |
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 /** | 72 /** |
73 * @return {boolean} Whether the user is currently searching for downloads | 73 * @return {boolean} Whether the user is currently searching for downloads |
74 * (i.e. has a non-empty search term). | 74 * (i.e. has a non-empty search term). |
75 */ | 75 */ |
76 isSearching: function() { | 76 isSearching: function() { |
77 return this.searchTerms_.length > 0; | 77 return this.searchTerms_.length > 0; |
78 }, | 78 }, |
79 | 79 |
80 /** Opens the current local destination for downloads. */ | 80 /** Opens the current local destination for downloads. */ |
81 openDownloadsFolder: chrome.send.bind(chrome, 'openDownloadsFolder'), | 81 openDownloadsFolder: function() { |
| 82 chrome.send('openDownloadsFolderRequiringGesture'); |
| 83 }, |
82 | 84 |
83 /** | 85 /** |
84 * @param {string} id ID of the download to run locally on the user's box. | 86 * @param {string} id ID of the download to run locally on the user's box. |
85 */ | 87 */ |
86 openFile: chromeSendWithId('openFile'), | 88 openFile: chromeSendWithId('openFileRequiringGesture'), |
87 | 89 |
88 /** @param {string} id ID the of the progressing download to pause. */ | 90 /** @param {string} id ID the of the progressing download to pause. */ |
89 pause: chromeSendWithId('pause'), | 91 pause: chromeSendWithId('pause'), |
90 | 92 |
91 /** @param {string} id ID of the finished download to remove. */ | 93 /** @param {string} id ID of the finished download to remove. */ |
92 remove: chromeSendWithId('remove'), | 94 remove: chromeSendWithId('remove'), |
93 | 95 |
94 /** @param {string} id ID of the paused download to resume. */ | 96 /** @param {string} id ID of the paused download to resume. */ |
95 resume: chromeSendWithId('resume'), | 97 resume: chromeSendWithId('resume'), |
96 | 98 |
97 /** | 99 /** |
98 * @param {string} id ID of the dangerous download to save despite | 100 * @param {string} id ID of the dangerous download to save despite |
99 * warnings. | 101 * warnings. |
100 */ | 102 */ |
101 saveDangerous: chromeSendWithId('saveDangerous'), | 103 saveDangerous: chromeSendWithId('saveDangerousRequiringGesture'), |
102 | 104 |
103 /** | 105 /** |
104 * @param {string} searchText What to search for. | 106 * @param {string} searchText What to search for. |
105 * @return {boolean} Whether |searchText| resulted in new search terms. | 107 * @return {boolean} Whether |searchText| resulted in new search terms. |
106 */ | 108 */ |
107 search: function(searchText) { | 109 search: function(searchText) { |
108 var searchTerms = ActionService.splitTerms(searchText); | 110 var searchTerms = ActionService.splitTerms(searchText); |
109 var sameTerms = searchTerms.length == this.searchTerms_.length; | 111 var sameTerms = searchTerms.length == this.searchTerms_.length; |
110 | 112 |
111 for (var i = 0; sameTerms && i < searchTerms.length; ++i) { | 113 for (var i = 0; sameTerms && i < searchTerms.length; ++i) { |
(...skipping 16 matching lines...) Expand all Loading... |
128 show: chromeSendWithId('show'), | 130 show: chromeSendWithId('show'), |
129 | 131 |
130 /** Undo download removal. */ | 132 /** Undo download removal. */ |
131 undo: chrome.send.bind(chrome, 'undo'), | 133 undo: chrome.send.bind(chrome, 'undo'), |
132 }; | 134 }; |
133 | 135 |
134 cr.addSingletonGetter(ActionService); | 136 cr.addSingletonGetter(ActionService); |
135 | 137 |
136 return {ActionService: ActionService}; | 138 return {ActionService: ActionService}; |
137 }); | 139 }); |
OLD | NEW |