Chromium Code Reviews| Index: chrome/renderer/resources/extensions/experimental.app_custom_bindings.js |
| diff --git a/chrome/renderer/resources/extensions/experimental.app_custom_bindings.js b/chrome/renderer/resources/extensions/experimental.app_custom_bindings.js |
| index a586df96f8e9e8eec8cb6c98678c7a71a9962894..49ebaba946981fbe417c9040e1a4e6753c02039f 100644 |
| --- a/chrome/renderer/resources/extensions/experimental.app_custom_bindings.js |
| +++ b/chrome/renderer/resources/extensions/experimental.app_custom_bindings.js |
| @@ -9,12 +9,26 @@ var fileSystemHelpers = requireNative('file_system_natives'); |
| var GetIsolatedFileSystem = fileSystemHelpers.GetIsolatedFileSystem; |
| var appNatives = requireNative('experimental_app'); |
| var DeserializeString = appNatives.DeserializeString; |
| +var SerializeToString = appNatives.SerializeToString; |
| var CreateBlob = appNatives.CreateBlob; |
| chromeHidden.Event.registerArgumentMassager('experimental.app.onLaunched', |
| function(args, dispatch) { |
| - var launchData = args[0]; |
| - var intentData = args[1]; |
| + var intentId = args[0]; |
| + var launchData = args[1]; |
|
benwells
2012/08/13 08:27:29
This will break the case where we launch with file
thorogood
2012/08/14 02:59:08
Thanks for the tip. I've dealt with this by using
benwells
2012/08/14 06:57:07
A nicer way to do this would be to have the intent
thorogood
2012/08/15 06:15:49
Done, although I've had to modify DispatchOnLaunch
|
| + var intentData = args[2]; |
| + |
| + if (launchData) { |
| + var fn = function(success, data) { |
| + chrome.experimental.app.postIntentResponse({ |
| + 'intentId': intentId, |
| + 'success': success, |
| + 'data': SerializeToString(data) |
|
benwells
2012/08/13 08:27:29
What happens if the data cannot be serialized? E.g
thorogood
2012/08/14 02:59:08
I suspect this won't work (but I'm not sure if rep
benwells
2012/08/14 06:57:07
You should make sure there are no explosions.
|
| + }); |
| + }; |
| + launchData.intent.postResult = fn.bind(undefined, true); |
| + launchData.intent.postFailure = fn.bind(undefined, false); |
| + } |
| if (launchData && intentData) { |
| switch(intentData.format) { |
| @@ -23,8 +37,6 @@ chromeHidden.Event.registerArgumentMassager('experimental.app.onLaunched', |
| try { |
| fs.root.getFile(intentData.baseName, {}, function(fileEntry) { |
| launchData.intent.data = fileEntry; |
|
benwells
2012/08/13 08:27:29
This is the case where there should be empty callb
thorogood
2012/08/14 02:59:08
Noted, I've implemented this differently though (c
|
| - launchData.intent.postResult = function() {}; |
| - launchData.intent.postFailure = function() {}; |
| dispatch([launchData]); |
| }, function(fileError) { |
| console.error('Error getting fileEntry, code: ' + fileError.code); |
| @@ -38,16 +50,12 @@ chromeHidden.Event.registerArgumentMassager('experimental.app.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: |