Chromium Code Reviews| Index: chrome/renderer/resources/extensions/app_runtime_custom_bindings.js |
| diff --git a/chrome/renderer/resources/extensions/app_runtime_custom_bindings.js b/chrome/renderer/resources/extensions/app_runtime_custom_bindings.js |
| index 77da14918a4abcd929ad60cb8d410bbfbf8f99f5..2eb8f7baa3da32867dad3616e22df4a849c72c2e 100644 |
| --- a/chrome/renderer/resources/extensions/app_runtime_custom_bindings.js |
| +++ b/chrome/renderer/resources/extensions/app_runtime_custom_bindings.js |
| @@ -9,12 +9,32 @@ var fileSystemHelpers = requireNative('file_system_natives'); |
| var GetIsolatedFileSystem = fileSystemHelpers.GetIsolatedFileSystem; |
| var appNatives = requireNative('app_runtime'); |
| var DeserializeString = appNatives.DeserializeString; |
| +var SerializeToString = appNatives.SerializeToString; |
| var CreateBlob = appNatives.CreateBlob; |
| chromeHidden.Event.registerArgumentMassager('app.runtime.onLaunched', |
| function(args, dispatch) { |
| var launchData = args[0]; |
| var intentData = args[1]; |
| + var intentId = args[2]; |
| + |
| + if (launchData) { |
| + if (intentId) { |
| + var fn = function(success, data) { |
| + // TODO(thorogood): What if data is not of a serializable type? |
|
benwells
2012/08/29 12:19:21
We should answer this question before landing this
thorogood
2012/09/03 03:37:40
I have answered it, as discussed in person! Non-se
|
| + chrome.app.runtime.postIntentResponse({ |
| + 'intentId': intentId, |
| + 'success': success, |
| + 'data': SerializeToString(data) |
| + }); |
| + }; |
| + launchData.intent.postResult = fn.bind(undefined, true); |
| + launchData.intent.postFailure = fn.bind(undefined, false); |
| + } else { |
| + launchData.intent.postResult = function() {}; |
| + launchData.intent.postFailure = function() {}; |
| + } |
| + } |
| if (launchData && intentData) { |
| switch(intentData.format) { |
| @@ -23,8 +43,6 @@ chromeHidden.Event.registerArgumentMassager('app.runtime.onLaunched', |
| try { |
| fs.root.getFile(intentData.baseName, {}, function(fileEntry) { |
| launchData.intent.data = fileEntry; |
| - launchData.intent.postResult = function() {}; |
| - launchData.intent.postFailure = function() {}; |
| dispatch([launchData]); |
| }, function(fileError) { |
| console.error('Error getting fileEntry, code: ' + fileError.code); |
| @@ -38,16 +56,12 @@ chromeHidden.Event.registerArgumentMassager('app.runtime.onLaunched', |
| case('serialized'): |
| var deserializedData = DeserializeString(intentData.data); |
| launchData.intent.data = deserializedData; |
| - launchData.intent.postResult = function() {}; |
| - launchData.intent.postFailure = function() {}; |
| dispatch([launchData]); |
| break; |
| case('blob'): |
| var blobData = CreateBlob(intentData.blobFilePath, |
| intentData.blobLength); |
| launchData.intent.data = blobData; |
| - launchData.intent.postResult = function() {}; |
| - launchData.intent.postFailure = function() {}; |
| dispatch([launchData]); |
| break; |
| default: |