1 // Copyright (c) 2013 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.
5 function getOpeningIds() {
8 ids = JSON.parse(localStorage.openWhenComplete);
10 localStorage.openWhenComplete = JSON.stringify(ids);
15 function setOpeningIds(ids) {
16 localStorage.openWhenComplete = JSON.stringify(ids);
19 chrome.downloads.onChanged.addListener(function(delta) {
21 (delta.state.current != 'complete')) {
24 var ids = getOpeningIds();
25 if (ids.indexOf(delta.id) < 0) {
28 chrome.downloads.open(delta.id);
29 ids.splice(ids.indexOf(delta.id), 1);
33 chrome.contextMenus.onClicked.addListener(function(info, tab) {
34 chrome.downloads.download({url: info.linkUrl}, function(downloadId) {
35 var ids = getOpeningIds();
36 if (ids.indexOf(downloadId) >= 0) {
44 chrome.contextMenus.create({
46 title: chrome.i18n.getMessage('openContextMenuTitle'),