| 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 if (typeof Polymer == 'undefined') | 5 if (typeof Polymer == 'undefined') |
| 6 Polymer = {dom: 'shadow'}; | 6 Polymer = {dom: 'shadow'}; |
| 7 else | 7 else |
| 8 console.error('Polymer is already defined.'); | 8 console.error('Polymer is already defined.'); |
| 9 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 9 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 10 // Use of this source code is governed by a BSD-style license that can be | 10 // Use of this source code is governed by a BSD-style license that can be |
| (...skipping 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 cr.define('downloads', function() { | 1522 cr.define('downloads', function() { |
| 1523 /** | 1523 /** |
| 1524 * @param {string} chromeSendName | 1524 * @param {string} chromeSendName |
| 1525 * @return {function(string):void} A chrome.send() callback with curried name. | 1525 * @return {function(string):void} A chrome.send() callback with curried name. |
| 1526 */ | 1526 */ |
| 1527 function chromeSendWithId(chromeSendName) { | 1527 function chromeSendWithId(chromeSendName) { |
| 1528 return function(id) { chrome.send(chromeSendName, [id]); }; | 1528 return function(id) { chrome.send(chromeSendName, [id]); }; |
| 1529 } | 1529 } |
| 1530 | 1530 |
| 1531 /** @constructor */ | 1531 /** @constructor */ |
| 1532 function ActionService() {} | 1532 function ActionService() { |
| 1533 /** @private {Array<string>} */ |
| 1534 this.searchTerms_ = []; |
| 1535 } |
| 1533 | 1536 |
| 1534 /** | 1537 /** |
| 1535 * @param {string} s | 1538 * @param {string} s |
| 1536 * @return {string} |s| without whitespace at the beginning or end. | 1539 * @return {string} |s| without whitespace at the beginning or end. |
| 1537 */ | 1540 */ |
| 1538 function trim(s) { return s.trim(); } | 1541 function trim(s) { return s.trim(); } |
| 1539 | 1542 |
| 1540 /** | 1543 /** |
| 1541 * @param {string|undefined} value | 1544 * @param {string|undefined} value |
| 1542 * @return {boolean} Whether |value| is truthy. | 1545 * @return {boolean} Whether |value| is truthy. |
| 1543 */ | 1546 */ |
| 1544 function truthy(value) { return !!value; } | 1547 function truthy(value) { return !!value; } |
| 1545 | 1548 |
| 1546 /** | 1549 /** |
| 1547 * @param {string} searchText Input typed by the user into a search box. | 1550 * @param {string} searchText Input typed by the user into a search box. |
| 1548 * @return {Array<string>} A list of terms extracted from |searchText|. | 1551 * @return {Array<string>} A list of terms extracted from |searchText|. |
| 1549 */ | 1552 */ |
| 1550 ActionService.splitTerms = function(searchText) { | 1553 ActionService.splitTerms = function(searchText) { |
| 1551 // Split quoted terms (e.g., 'The "lazy" dog' => ['The', 'lazy', 'dog']). | 1554 // Split quoted terms (e.g., 'The "lazy" dog' => ['The', 'lazy', 'dog']). |
| 1552 return searchText.split(/"([^"]*)"/).map(trim).filter(truthy); | 1555 return searchText.split(/"([^"]*)"/).map(trim).filter(truthy); |
| 1553 }; | 1556 }; |
| 1554 | 1557 |
| 1555 ActionService.prototype = { | 1558 ActionService.prototype = { |
| 1556 /** @private {Array<string>} */ | |
| 1557 searchTerms_: [], | |
| 1558 | |
| 1559 /** @param {string} id ID of the download to cancel. */ | 1559 /** @param {string} id ID of the download to cancel. */ |
| 1560 cancel: chromeSendWithId('cancel'), | 1560 cancel: chromeSendWithId('cancel'), |
| 1561 | 1561 |
| 1562 /** Instructs the browser to clear all finished downloads. */ | 1562 /** Instructs the browser to clear all finished downloads. */ |
| 1563 clearAll: function() { | 1563 clearAll: function() { |
| 1564 if (loadTimeData.getBoolean('allowDeletingHistory')) { | 1564 if (loadTimeData.getBoolean('allowDeletingHistory')) { |
| 1565 chrome.send('clearAll'); | 1565 chrome.send('clearAll'); |
| 1566 this.search(''); | 1566 this.search(''); |
| 1567 } | 1567 } |
| 1568 }, | 1568 }, |
| (...skipping 15570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17139 Manager.get().updateItem_(index, data); | 17139 Manager.get().updateItem_(index, data); |
| 17140 }; | 17140 }; |
| 17141 | 17141 |
| 17142 return {Manager: Manager}; | 17142 return {Manager: Manager}; |
| 17143 }); | 17143 }); |
| 17144 // Copyright 2015 The Chromium Authors. All rights reserved. | 17144 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 17145 // Use of this source code is governed by a BSD-style license that can be | 17145 // Use of this source code is governed by a BSD-style license that can be |
| 17146 // found in the LICENSE file. | 17146 // found in the LICENSE file. |
| 17147 | 17147 |
| 17148 window.addEventListener('load', downloads.Manager.onLoad); | 17148 window.addEventListener('load', downloads.Manager.onLoad); |
| OLD | NEW |