| OLD | NEW |
| 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 // Custom binding for the chrome.app.runtime API. | 5 // Custom binding for the chrome.app.runtime API. |
| 6 | 6 |
| 7 var binding = require('binding').Binding.create('app.runtime'); | 7 var binding = require('binding').Binding.create('app.runtime'); |
| 8 | 8 |
| 9 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); | |
| 10 var chrome = requireNative('chrome').GetChrome(); | 9 var chrome = requireNative('chrome').GetChrome(); |
| 10 var eventBindings = require('event_bindings'); |
| 11 var fileSystemHelpers = requireNative('file_system_natives'); | 11 var fileSystemHelpers = requireNative('file_system_natives'); |
| 12 var forEach = require('utils').forEach; | 12 var forEach = require('utils').forEach; |
| 13 var GetIsolatedFileSystem = fileSystemHelpers.GetIsolatedFileSystem; | 13 var GetIsolatedFileSystem = fileSystemHelpers.GetIsolatedFileSystem; |
| 14 var appNatives = requireNative('app_runtime'); | 14 var appNatives = requireNative('app_runtime'); |
| 15 var DeserializeString = appNatives.DeserializeString; | 15 var DeserializeString = appNatives.DeserializeString; |
| 16 var SerializeToString = appNatives.SerializeToString; | 16 var SerializeToString = appNatives.SerializeToString; |
| 17 var CreateBlob = appNatives.CreateBlob; | 17 var CreateBlob = appNatives.CreateBlob; |
| 18 var entryIdManager = require('entryIdManager'); | 18 var entryIdManager = require('entryIdManager'); |
| 19 | 19 |
| 20 chromeHidden.Event.registerArgumentMassager('app.runtime.onLaunched', | 20 eventBindings.registerArgumentMassager('app.runtime.onLaunched', |
| 21 function(args, dispatch) { | 21 function(args, dispatch) { |
| 22 var launchData = args[0]; | 22 var launchData = args[0]; |
| 23 | 23 |
| 24 if (launchData && typeof launchData.id !== 'undefined') { | 24 if (launchData && typeof launchData.id !== 'undefined') { |
| 25 // new-style dispatch. | 25 // new-style dispatch. |
| 26 var items = [] | 26 var items = [] |
| 27 var numItems = launchData.items.length; | 27 var numItems = launchData.items.length; |
| 28 var itemLoaded = function(err, item) { | 28 var itemLoaded = function(err, item) { |
| 29 if (err) { | 29 if (err) { |
| 30 console.error('Error getting fileEntry, code: ' + err.code); | 30 console.error('Error getting fileEntry, code: ' + err.code); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 50 }); | 50 }); |
| 51 }); | 51 }); |
| 52 } else if (launchData) { | 52 } else if (launchData) { |
| 53 dispatch([launchData]); | 53 dispatch([launchData]); |
| 54 } else { | 54 } else { |
| 55 dispatch([]); | 55 dispatch([]); |
| 56 } | 56 } |
| 57 }); | 57 }); |
| 58 | 58 |
| 59 exports.binding = binding.generate(); | 59 exports.binding = binding.generate(); |
| OLD | NEW |