Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: chrome/renderer/resources/extensions/experimental.app_custom_bindings.js

Issue 10704073: Plumb listenerIDs correctly for events that clobber chrome.Event.prototype.dispatch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: respond to commens Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 bindings for the experimental.app API. 5 // Custom bindings for the experimental.app API.
6 6
7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); 7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
8 var fileSystemHelpers = requireNative('file_system_natives'); 8 var fileSystemHelpers = requireNative('file_system_natives');
9 var GetIsolatedFileSystem = fileSystemHelpers.GetIsolatedFileSystem; 9 var GetIsolatedFileSystem = fileSystemHelpers.GetIsolatedFileSystem;
10 var appNatives = requireNative('experimental_app'); 10 var appNatives = requireNative('experimental_app');
11 var DeserializeString = appNatives.DeserializeString; 11 var DeserializeString = appNatives.DeserializeString;
12 var CreateBlob = appNatives.CreateBlob; 12 var CreateBlob = appNatives.CreateBlob;
13 13
14 chromeHidden.registerCustomHook('experimental.app', function(bindingsAPI) { 14 chromeHidden.Event.registerArgumentMassager('experimental.app.onLaunched',
15 chrome.experimental.app.onLaunched.dispatch = 15 function(args, dispatch) {
16 function(launchData, intentData) { 16 var launchData = args[0];
17 if (launchData && intentData) { 17 var intentData = args[1];
18 switch(intentData.format) { 18
19 case('fileEntry'): 19 if (launchData && intentData) {
20 var event = this; 20 switch(intentData.format) {
21 var fs = GetIsolatedFileSystem(intentData.fileSystemId); 21 case('fileEntry'):
22 try { 22 var fs = GetIsolatedFileSystem(intentData.fileSystemId);
23 fs.root.getFile(intentData.baseName, {}, function(fileEntry) { 23 try {
24 launchData.intent.data = fileEntry; 24 fs.root.getFile(intentData.baseName, {}, function(fileEntry) {
25 launchData.intent.postResult = function() {}; 25 launchData.intent.data = fileEntry;
26 launchData.intent.postFailure = function() {}; 26 launchData.intent.postResult = function() {};
27 chrome.Event.prototype.dispatch.call(event, launchData); 27 launchData.intent.postFailure = function() {};
28 }, function(fileError) { 28 dispatch([launchData]);
29 console.error('Error getting fileEntry, code: ' + fileError.code); 29 }, function(fileError) {
30 chrome.Event.prototype.dispatch.call(event); 30 console.error('Error getting fileEntry, code: ' + fileError.code);
31 }); 31 dispatch([]);
32 } catch (e) { 32 });
33 console.error('Error in event handler for onLaunched: ' + e.stack); 33 } catch (e) {
34 chrome.Event.prototype.dispatch.call(event); 34 console.error('Error in event handler for onLaunched: ' + e.stack);
35 } 35 dispatch([]);
36 break; 36 }
37 case('serialized'): 37 break;
38 var deserializedData = DeserializeString(intentData.data); 38 case('serialized'):
39 launchData.intent.data = deserializedData; 39 var deserializedData = DeserializeString(intentData.data);
40 launchData.intent.postResult = function() {}; 40 launchData.intent.data = deserializedData;
41 launchData.intent.postFailure = function() {}; 41 launchData.intent.postResult = function() {};
42 chrome.Event.prototype.dispatch.call(this, launchData); 42 launchData.intent.postFailure = function() {};
43 break; 43 dispatch([launchData]);
44 case('blob'): 44 break;
45 var blobData = CreateBlob(intentData.blobFilePath, 45 case('blob'):
46 intentData.blobLength); 46 var blobData = CreateBlob(intentData.blobFilePath,
47 launchData.intent.data = blobData; 47 intentData.blobLength);
48 launchData.intent.postResult = function() {}; 48 launchData.intent.data = blobData;
49 launchData.intent.postFailure = function() {}; 49 launchData.intent.postResult = function() {};
50 chrome.Event.prototype.dispatch.call(this, launchData); 50 launchData.intent.postFailure = function() {};
51 break; 51 dispatch([launchData]);
52 default: 52 break;
53 console.error('Unexpected launch data format'); 53 default:
54 chrome.Event.prototype.dispatch.call(this); 54 console.error('Unexpected launch data format');
55 } 55 dispatch([]);
56 } else if (launchData) {
57 chrome.Event.prototype.dispatch.call(this, launchData);
58 } else {
59 chrome.Event.prototype.dispatch.call(this);
60 } 56 }
61 }; 57 } else if (launchData) {
58 dispatch([launchData]);
59 } else {
60 dispatch([]);
61 }
62 }); 62 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698