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

Side by Side Diff: extensions/renderer/resources/guest_view/guest_view_events.js

Issue 987473002: Added the onResize and onContentResize events to GuestViewEvents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 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 8
9 var CreateEvent = function(name) { 9 var CreateEvent = function(name) {
10 var eventOpts = {supportsListeners: true, supportsFilters: true}; 10 var eventOpts = {supportsListeners: true, supportsFilters: true};
11 return new EventBindings.Event(name, undefined, eventOpts); 11 return new EventBindings.Event(name, undefined, eventOpts);
12 }; 12 };
13 13
14 function GuestViewEvents(view) { 14 function GuestViewEvents(view) {
15 this.view = view; 15 this.view = view;
16 this.on = {}; 16 this.on = {};
17 17
18 // |setupEventProperty| is normally called automatically, but the
19 // 'resize' event is registered here because the event is fired from
20 // GuestViewContainer instead of in response to an extension event.
21 this.setupEventProperty('resize');
18 this.setupEvents(); 22 this.setupEvents();
19 } 23 }
20 24
21 // |GuestViewEvents.EVENTS| is a dictionary of extension events to be listened 25 // |GuestViewEvents.EVENTS| is a dictionary of extension events to be listened
22 // for, which specifies how each event should be handled. The events are 26 // for, which specifies how each event should be handled. The events are
23 // organized by name, and by default will be dispatched as DOM events with 27 // organized by name, and by default will be dispatched as DOM events with
24 // the same name. 28 // the same name.
25 // |cancelable| (default: false) specifies whether the DOM event's default 29 // |cancelable| (default: false) specifies whether the DOM event's default
26 // behavior can be canceled. If the default action associated with the event 30 // behavior can be canceled. If the default action associated with the event
27 // is prevented, then its dispatch function will return false in its event 31 // is prevented, then its dispatch function will return false in its event
28 // handler. The event must have a specified |handler| for this to be 32 // handler. The event must have a specified |handler| for this to be
29 // meaningful. 33 // meaningful.
30 // |evt| specifies a descriptor object for the extension event. An event 34 // |evt| specifies a descriptor object for the extension event. An event
31 // listener will be attached to this descriptor. 35 // listener will be attached to this descriptor.
32 // |fields| (default: none) specifies the public-facing fields in the DOM event 36 // |fields| (default: none) specifies the public-facing fields in the DOM event
33 // that are accessible to developers. 37 // that are accessible to developers.
34 // |handler| specifies the name of a handler function to be called each time 38 // |handler| specifies the name of a handler function to be called each time
35 // that extension event is caught by its event listener. The DOM event 39 // that extension event is caught by its event listener. The DOM event
36 // should be dispatched within this handler function (if desired). With no 40 // should be dispatched within this handler function (if desired). With no
37 // handler function, the DOM event will be dispatched by default each time 41 // handler function, the DOM event will be dispatched by default each time
38 // the extension event is caught. 42 // the extension event is caught.
39 GuestViewEvents.EVENTS = {}; 43 GuestViewEvents.EVENTS = {
44 'contentresize': {
45 evt: CreateEvent('guestViewInternal.onContentResize'),
46 fields: ['oldWidth', 'oldHeight', 'newWidth', 'newHeight']
47 }
48 };
40 49
41 // Sets up the handling of events. 50 // Sets up the handling of events.
42 GuestViewEvents.prototype.setupEvents = function() { 51 GuestViewEvents.prototype.setupEvents = function() {
43 for (var eventName in GuestViewEvents.EVENTS) { 52 for (var eventName in GuestViewEvents.EVENTS) {
44 this.setupEvent(eventName, GuestViewEvents.EVENTS[eventName]); 53 this.setupEvent(eventName, GuestViewEvents.EVENTS[eventName]);
45 } 54 }
46 55
47 var events = this.getEvents(); 56 var events = this.getEvents();
48 for (var eventName in events) { 57 for (var eventName in events) {
49 this.setupEvent(eventName, events[eventName]); 58 this.setupEvent(eventName, events[eventName]);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 enumerable: true 119 enumerable: true
111 }); 120 });
112 }; 121 };
113 122
114 // Implemented by the derived event manager, if one exists. 123 // Implemented by the derived event manager, if one exists.
115 GuestViewEvents.prototype.getEvents = function() { return {}; }; 124 GuestViewEvents.prototype.getEvents = function() { return {}; };
116 125
117 // Exports. 126 // Exports.
118 exports.GuestViewEvents = GuestViewEvents; 127 exports.GuestViewEvents = GuestViewEvents;
119 exports.CreateEvent = CreateEvent; 128 exports.CreateEvent = CreateEvent;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698