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

Side by Side Diff: extensions/renderer/resources/app_runtime_custom_bindings.js

Issue 2912883004: [Extensions Bindings] Don't allow `event` module with native bindings (Closed)
Patch Set: . Created 3 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 = apiBridge || require('binding').Binding.create('app.runtime'); 7 var binding = apiBridge || require('binding').Binding.create('app.runtime');
8 8
9 var AppViewGuestInternal = 9 var AppViewGuestInternal =
10 getInternalApi ? 10 getInternalApi ?
11 getInternalApi('appViewGuestInternal') : 11 getInternalApi('appViewGuestInternal') :
12 require('binding').Binding.create('appViewGuestInternal').generate(); 12 require('binding').Binding.create('appViewGuestInternal').generate();
13 var eventBindings = require('event_bindings'); 13 var registerArgumentMassager = bindingUtil ?
14 bindingUtil.registerEventArgumentMassager.bind(bindingUtil) :
jbroman 2017/06/12 15:09:49 Do we need to use $Function.bind here?
Devlin 2017/06/12 20:30:14 Done.
15 require('event_bindings').registerArgumentMassager;
14 var fileSystemHelpers = requireNative('file_system_natives'); 16 var fileSystemHelpers = requireNative('file_system_natives');
15 var GetIsolatedFileSystem = fileSystemHelpers.GetIsolatedFileSystem; 17 var GetIsolatedFileSystem = fileSystemHelpers.GetIsolatedFileSystem;
16 var entryIdManager = require('entryIdManager'); 18 var entryIdManager = require('entryIdManager');
17 19
18 eventBindings.registerArgumentMassager('app.runtime.onEmbedRequested', 20 registerArgumentMassager('app.runtime.onEmbedRequested',
19 function(args, dispatch) { 21 function(args, dispatch) {
20 var appEmbeddingRequest = args[0]; 22 var appEmbeddingRequest = args[0];
21 var id = appEmbeddingRequest.guestInstanceId; 23 var id = appEmbeddingRequest.guestInstanceId;
22 delete appEmbeddingRequest.guestInstanceId; 24 delete appEmbeddingRequest.guestInstanceId;
23 appEmbeddingRequest.allow = function(url) { 25 appEmbeddingRequest.allow = function(url) {
24 AppViewGuestInternal.attachFrame(url, id); 26 AppViewGuestInternal.attachFrame(url, id);
25 }; 27 };
26 28
27 appEmbeddingRequest.deny = function() { 29 appEmbeddingRequest.deny = function() {
28 AppViewGuestInternal.denyRequest(id); 30 AppViewGuestInternal.denyRequest(id);
29 }; 31 };
30 32
31 dispatch([appEmbeddingRequest]); 33 dispatch([appEmbeddingRequest]);
32 }); 34 });
33 35
34 eventBindings.registerArgumentMassager('app.runtime.onLaunched', 36 registerArgumentMassager('app.runtime.onLaunched', function(args, dispatch) {
35 function(args, dispatch) {
36 var launchData = args[0]; 37 var launchData = args[0];
37 if (launchData.items) { 38 if (launchData.items) {
38 // An onLaunched corresponding to file_handlers in the app's manifest. 39 // An onLaunched corresponding to file_handlers in the app's manifest.
39 var items = []; 40 var items = [];
40 var numItems = launchData.items.length; 41 var numItems = launchData.items.length;
41 var itemLoaded = function(err, item) { 42 var itemLoaded = function(err, item) {
42 if (err) { 43 if (err) {
43 console.error('Error getting fileEntry, code: ' + err.code); 44 console.error('Error getting fileEntry, code: ' + err.code);
44 } else { 45 } else {
45 $Array.push(items, item); 46 $Array.push(items, item);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 }); 79 });
79 } else { 80 } else {
80 // Default case. This currently covers an onLaunched corresponding to 81 // Default case. This currently covers an onLaunched corresponding to
81 // url_handlers in the app's manifest. 82 // url_handlers in the app's manifest.
82 dispatch([launchData]); 83 dispatch([launchData]);
83 } 84 }
84 }); 85 });
85 86
86 if (!apiBridge) 87 if (!apiBridge)
87 exports.$set('binding', binding.generate()); 88 exports.$set('binding', binding.generate());
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698