| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 // Custom bindings for the downloads API. | 5 // Custom bindings for the downloads API. |
| 6 | 6 |
| 7 var binding = require('binding').Binding.create('downloads'); | 7 var binding = require('binding').Binding.create('downloads'); |
| 8 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); | |
| 9 var downloadsInternal = require('binding').Binding.create( | 8 var downloadsInternal = require('binding').Binding.create( |
| 10 'downloadsInternal').generate(); | 9 'downloadsInternal').generate(); |
| 10 var eventBindings = require('event_bindings'); |
| 11 | 11 |
| 12 chromeHidden.Event.registerArgumentMassager( | 12 eventBindings.registerArgumentMassager( |
| 13 'downloads.onDeterminingFilename', | 13 'downloads.onDeterminingFilename', |
| 14 function massage_determining_filename(args, dispatch) { | 14 function massage_determining_filename(args, dispatch) { |
| 15 var downloadItem = args[0]; | 15 var downloadItem = args[0]; |
| 16 // Copy the id so that extensions can't change it. | 16 // Copy the id so that extensions can't change it. |
| 17 var downloadId = downloadItem.id; | 17 var downloadId = downloadItem.id; |
| 18 var suggestable = true; | 18 var suggestable = true; |
| 19 function suggestCallback(result) { | 19 function suggestCallback(result) { |
| 20 if (!suggestable) { | 20 if (!suggestable) { |
| 21 console.error('suggestCallback may not be called more than once.'); | 21 console.error('suggestCallback may not be called more than once.'); |
| 22 return; | 22 return; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 40 (results.results.length != 0) && | 40 (results.results.length != 0) && |
| 41 (results.results[0] === true)); | 41 (results.results[0] === true)); |
| 42 if (suggestable && !async) | 42 if (suggestable && !async) |
| 43 suggestCallback(); | 43 suggestCallback(); |
| 44 } catch (e) { | 44 } catch (e) { |
| 45 suggestCallback(); | 45 suggestCallback(); |
| 46 throw e; | 46 throw e; |
| 47 } | 47 } |
| 48 }); | 48 }); |
| 49 exports.binding = binding.generate(); | 49 exports.binding = binding.generate(); |
| OLD | NEW |