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

Side by Side Diff: chrome/renderer/resources/extensions/web_view_events.js

Issue 440463002: Fix display:none issue for <webview>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix back the merge change Created 6 years, 3 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 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 // Event management for WebViewInternal. 5 // Event management for WebViewInternal.
6 6
7 var DeclarativeWebRequestSchema = 7 var DeclarativeWebRequestSchema =
8 requireNative('schema_registry').GetSchema('declarativeWebRequest'); 8 requireNative('schema_registry').GetSchema('declarativeWebRequest');
9 var EventBindings = require('event_bindings'); 9 var EventBindings = require('event_bindings');
10 var IdGenerator = requireNative('id_generator'); 10 var IdGenerator = requireNative('id_generator');
11 var MessagingNatives = requireNative('messaging_natives'); 11 var MessagingNatives = requireNative('messaging_natives');
12 var WebRequestEvent = require('webRequestInternal').WebRequestEvent; 12 var WebRequestEvent = require('webRequestInternal').WebRequestEvent;
13 var WebRequestSchema = 13 var WebRequestSchema =
14 requireNative('schema_registry').GetSchema('webRequest'); 14 requireNative('schema_registry').GetSchema('webRequest');
15 var WebView = require('webViewInternal').WebView; 15 var WebView = require('webViewInternal').WebView;
16 16
17 var CreateEvent = function(name) { 17 var CreateEvent = function(name) {
18 var eventOpts = {supportsListeners: true, supportsFilters: true}; 18 var eventOpts = {supportsListeners: true, supportsFilters: true};
19 return new EventBindings.Event(name, undefined, eventOpts); 19 return new EventBindings.Event(name, undefined, eventOpts);
20 }; 20 };
21 21
22 var FrameNameChangedEvent = CreateEvent('webViewInternal.onFrameNameChanged'); 22 var FrameNameChangedEvent = CreateEvent('webViewInternal.onFrameNameChanged');
23 var PluginDestroyedEvent = CreateEvent('webViewInternal.onPluginDestroyed');
23 var WebRequestMessageEvent = CreateEvent('webViewInternal.onMessage'); 24 var WebRequestMessageEvent = CreateEvent('webViewInternal.onMessage');
24 25
25 // WEB_VIEW_EVENTS is a map of stable <webview> DOM event names to their 26 // WEB_VIEW_EVENTS is a map of stable <webview> DOM event names to their
26 // associated extension event descriptor objects. 27 // associated extension event descriptor objects.
27 // An event listener will be attached to the extension event |evt| specified in 28 // An event listener will be attached to the extension event |evt| specified in
28 // the descriptor. 29 // the descriptor.
29 // |fields| specifies the public-facing fields in the DOM event that are 30 // |fields| specifies the public-facing fields in the DOM event that are
30 // accessible to <webview> developers. 31 // accessible to <webview> developers.
31 // |customHandler| allows a handler function to be called each time an extension 32 // |customHandler| allows a handler function to be called each time an extension
32 // event is caught by its event listener. The DOM event should be dispatched 33 // event is caught by its event listener. The DOM event should be dispatched
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 // Constructor. 186 // Constructor.
186 function WebViewEvents(webViewInternal, viewInstanceId) { 187 function WebViewEvents(webViewInternal, viewInstanceId) {
187 this.webViewInternal = webViewInternal; 188 this.webViewInternal = webViewInternal;
188 this.viewInstanceId = viewInstanceId; 189 this.viewInstanceId = viewInstanceId;
189 this.setup(); 190 this.setup();
190 } 191 }
191 192
192 // Sets up events. 193 // Sets up events.
193 WebViewEvents.prototype.setup = function() { 194 WebViewEvents.prototype.setup = function() {
194 this.setupFrameNameChangedEvent(); 195 this.setupFrameNameChangedEvent();
196 this.setupPluginDestroyedEvent();
195 this.setupWebRequestEvents(); 197 this.setupWebRequestEvents();
196 this.webViewInternal.setupExperimentalContextMenus(); 198 this.webViewInternal.setupExperimentalContextMenus();
197 199
198 var events = this.getEvents(); 200 var events = this.getEvents();
199 for (var eventName in events) { 201 for (var eventName in events) {
200 this.setupEvent(eventName, events[eventName]); 202 this.setupEvent(eventName, events[eventName]);
201 } 203 }
202 }; 204 };
203 205
204 WebViewEvents.prototype.setupFrameNameChangedEvent = function() { 206 WebViewEvents.prototype.setupFrameNameChangedEvent = function() {
205 var self = this;
206 FrameNameChangedEvent.addListener(function(e) { 207 FrameNameChangedEvent.addListener(function(e) {
207 self.webViewInternal.onFrameNameChanged(e.name); 208 this.webViewInternal.onFrameNameChanged(e.name);
208 }, {instanceId: self.viewInstanceId}); 209 }.bind(this), {instanceId: this.viewInstanceId});
210 };
211
212 WebViewEvents.prototype.setupPluginDestroyedEvent = function() {
213 PluginDestroyedEvent.addListener(function(e) {
214 this.webViewInternal.onPluginDestroyed();
215 }.bind(this), {instanceId: this.viewInstanceId});
209 }; 216 };
210 217
211 WebViewEvents.prototype.setupWebRequestEvents = function() { 218 WebViewEvents.prototype.setupWebRequestEvents = function() {
212 var self = this; 219 var self = this;
213 var request = {}; 220 var request = {};
214 var createWebRequestEvent = function(webRequestEvent) { 221 var createWebRequestEvent = function(webRequestEvent) {
215 return function() { 222 return function() {
216 if (!self[webRequestEvent.name]) { 223 if (!self[webRequestEvent.name]) {
217 self[webRequestEvent.name] = 224 self[webRequestEvent.name] =
218 new WebRequestEvent( 225 new WebRequestEvent(
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 } 604 }
598 }; 605 };
599 606
600 WebViewEvents.prototype.handleSizeChangedEvent = function( 607 WebViewEvents.prototype.handleSizeChangedEvent = function(
601 event, webViewEvent) { 608 event, webViewEvent) {
602 this.webViewInternal.onSizeChanged(webViewEvent); 609 this.webViewInternal.onSizeChanged(webViewEvent);
603 }; 610 };
604 611
605 exports.WebViewEvents = WebViewEvents; 612 exports.WebViewEvents = WebViewEvents;
606 exports.CreateEvent = CreateEvent; 613 exports.CreateEvent = CreateEvent;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698