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

Side by Side Diff: chrome/common/extensions/docs/examples/api/downloads/download_links/popup.js

Issue 9617010: Move chrome.downloads out of experimental to dev (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This extension demonstrates using chrome.experimental.downloads.download() to 5 // This extension demonstrates using chrome.downloads.download() to
6 // download URLs. 6 // download URLs.
7 7
8 var allLinks = []; 8 var allLinks = [];
9 var visibleLinks = []; 9 var visibleLinks = [];
10 10
11 // Display all visible links. 11 // Display all visible links.
12 function showLinks() { 12 function showLinks() {
13 var linksTable = document.getElementById('links'); 13 var linksTable = document.getElementById('links');
14 while (linksTable.children.length > 1) { 14 while (linksTable.children.length > 1) {
15 linksTable.removeChild(linksTable.children[linksTable.children.length - 1]) 15 linksTable.removeChild(linksTable.children[linksTable.children.length - 1])
(...skipping 23 matching lines...) Expand all
39 var checked = document.getElementById('toggle_all').checked; 39 var checked = document.getElementById('toggle_all').checked;
40 for (var i = 0; i < visibleLinks.length; ++i) { 40 for (var i = 0; i < visibleLinks.length; ++i) {
41 document.getElementById('check' + i).checked = checked; 41 document.getElementById('check' + i).checked = checked;
42 } 42 }
43 } 43 }
44 44
45 // Download all visible checked links. 45 // Download all visible checked links.
46 function downloadCheckedLinks() { 46 function downloadCheckedLinks() {
47 for (var i = 0; i < visibleLinks.length; ++i) { 47 for (var i = 0; i < visibleLinks.length; ++i) {
48 if (document.getElementById('check' + i).checked) { 48 if (document.getElementById('check' + i).checked) {
49 chrome.experimental.downloads.download({url: visibleLinks[i]}, 49 chrome.downloads.download({url: visibleLinks[i]},
50 function(id) { 50 function(id) {
51 }); 51 });
52 } 52 }
53 } 53 }
54 window.close(); 54 window.close();
55 } 55 }
56 56
57 // Re-filter allLinks into visibleLinks and reshow visibleLinks. 57 // Re-filter allLinks into visibleLinks and reshow visibleLinks.
58 function filterLinks() { 58 function filterLinks() {
59 var filterValue = document.getElementById('filter').value; 59 var filterValue = document.getElementById('filter').value;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 document.getElementById('download1').onclick = downloadCheckedLinks; 108 document.getElementById('download1').onclick = downloadCheckedLinks;
109 109
110 chrome.windows.getCurrent(function (currentWindow) { 110 chrome.windows.getCurrent(function (currentWindow) {
111 chrome.tabs.query({active: true, windowId: currentWindow.id}, 111 chrome.tabs.query({active: true, windowId: currentWindow.id},
112 function(activeTabs) { 112 function(activeTabs) {
113 chrome.tabs.executeScript( 113 chrome.tabs.executeScript(
114 activeTabs[0].id, {file: 'send_links.js', allFrames: true}); 114 activeTabs[0].id, {file: 'send_links.js', allFrames: true});
115 }); 115 });
116 }); 116 });
117 }; 117 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698