OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // Event management for GuestViewContainers. | 5 // Event management for GuestViewContainers. |
6 | 6 |
7 var EventBindings = require('event_bindings'); | 7 var EventBindings = require('event_bindings'); |
8 var GuestViewInternalNatives = requireNative('guest_view_internal'); | 8 var GuestViewInternalNatives = requireNative('guest_view_internal'); |
9 var MessagingNatives = requireNative('messaging_natives'); | 9 var MessagingNatives = requireNative('messaging_natives'); |
10 | 10 |
11 var CreateEvent = function(name) { | 11 var CreateEvent = function(name) { |
12 var eventOpts = {supportsListeners: true, supportsFilters: true}; | 12 var eventOpts = {supportsListeners: true, supportsFilters: true}; |
13 return new EventBindings.Event(name, undefined, eventOpts); | 13 return new EventBindings.Event(name, undefined, eventOpts); |
14 }; | 14 }; |
15 | 15 |
16 function GuestViewEvents(view) { | 16 function GuestViewEvents(view) { |
17 view.events = this; | 17 view.events = this; |
18 | 18 |
19 this.view = view; | 19 this.view = view; |
20 this.on = {}; | 20 this.on = {}; |
21 | 21 |
22 // |setupEventProperty| is normally called automatically, but these events are | 22 // |setupEventProperty| is normally called automatically, but these events are |
23 // are registered here because they are dispatched from GuestViewContainer | 23 // are registered here because they are dispatched from GuestViewContainer |
24 // instead of in response to extension events. | 24 // instead of in response to extension events. |
25 this.setupEventProperty('contentresize'); | 25 this.setupEventProperty('contentresize'); |
26 this.setupEventProperty('resize'); | 26 this.setupEventProperty('resize'); |
27 this.setupEvents(); | 27 this.setupEvents(); |
28 } | 28 } |
29 | 29 |
30 // Prevent GuestViewEvents inadvertently inheritng code from the global Object, | |
lazyboy
2017/03/13 18:15:14
OK.
How about adding WebViewActionRequest and gues
wjmaclean
2017/03/13 19:34:48
Done.
Will update. Yes, we are looking for more,
lazyboy
2017/03/13 19:46:06
Acknowledged.
| |
31 // allowing a pathway for unintended execution of user code. | |
32 GuestViewEvents.prototype.__proto__ = null; | |
33 | |
30 // |GuestViewEvents.EVENTS| is a dictionary of extension events to be listened | 34 // |GuestViewEvents.EVENTS| is a dictionary of extension events to be listened |
31 // for, which specifies how each event should be handled. The events are | 35 // for, which specifies how each event should be handled. The events are |
32 // organized by name, and by default will be dispatched as DOM events with | 36 // organized by name, and by default will be dispatched as DOM events with |
33 // the same name. | 37 // the same name. |
34 // |cancelable| (default: false) specifies whether the DOM event's default | 38 // |cancelable| (default: false) specifies whether the DOM event's default |
35 // behavior can be canceled. If the default action associated with the event | 39 // behavior can be canceled. If the default action associated with the event |
36 // is prevented, then its dispatch function will return false in its event | 40 // is prevented, then its dispatch function will return false in its event |
37 // handler. The event must have a specified |handler| for this to be | 41 // handler. The event must have a specified |handler| for this to be |
38 // meaningful. | 42 // meaningful. |
39 // |evt| specifies a descriptor object for the extension event. An event | 43 // |evt| specifies a descriptor object for the extension event. An event |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 return $Function.apply(func, view.events, $Array.slice(arguments)); | 173 return $Function.apply(func, view.events, $Array.slice(arguments)); |
170 }; | 174 }; |
171 }; | 175 }; |
172 | 176 |
173 // Implemented by the derived event manager, if one exists. | 177 // Implemented by the derived event manager, if one exists. |
174 GuestViewEvents.prototype.getEvents = function() { return {}; }; | 178 GuestViewEvents.prototype.getEvents = function() { return {}; }; |
175 | 179 |
176 // Exports. | 180 // Exports. |
177 exports.$set('GuestViewEvents', GuestViewEvents); | 181 exports.$set('GuestViewEvents', GuestViewEvents); |
178 exports.$set('CreateEvent', CreateEvent); | 182 exports.$set('CreateEvent', CreateEvent); |
OLD | NEW |