| OLD | NEW |
| 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'); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // Constructor. | 177 // Constructor. |
| 178 function WebViewEvents(webViewInternal, viewInstanceId) { | 178 function WebViewEvents(webViewInternal, viewInstanceId) { |
| 179 this.webViewInternal = webViewInternal; | 179 this.webViewInternal = webViewInternal; |
| 180 this.viewInstanceId = viewInstanceId; | 180 this.viewInstanceId = viewInstanceId; |
| 181 this.setup(); | 181 this.setup(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 // Sets up events. | 184 // Sets up events. |
| 185 WebViewEvents.prototype.setup = function() { | 185 WebViewEvents.prototype.setup = function() { |
| 186 this.setupFrameNameChangedEvent(); | 186 this.setupFrameNameChangedEvent(); |
| 187 this.setupPluginDestroyedEvent(); | |
| 188 this.setupWebRequestEvents(); | 187 this.setupWebRequestEvents(); |
| 189 this.webViewInternal.setupExperimentalContextMenus(); | 188 this.webViewInternal.setupExperimentalContextMenus(); |
| 190 | 189 |
| 191 var events = this.getEvents(); | 190 var events = this.getEvents(); |
| 192 for (var eventName in events) { | 191 for (var eventName in events) { |
| 193 this.setupEvent(eventName, events[eventName]); | 192 this.setupEvent(eventName, events[eventName]); |
| 194 } | 193 } |
| 195 }; | 194 }; |
| 196 | 195 |
| 197 WebViewEvents.prototype.setupFrameNameChangedEvent = function() { | 196 WebViewEvents.prototype.setupFrameNameChangedEvent = function() { |
| 198 FrameNameChangedEvent.addListener(function(e) { | 197 FrameNameChangedEvent.addListener(function(e) { |
| 199 this.webViewInternal.onFrameNameChanged(e.name); | 198 this.webViewInternal.onFrameNameChanged(e.name); |
| 200 }.bind(this), {instanceId: this.viewInstanceId}); | 199 }.bind(this), {instanceId: this.viewInstanceId}); |
| 201 }; | 200 }; |
| 202 | 201 |
| 203 WebViewEvents.prototype.setupPluginDestroyedEvent = function() { | |
| 204 PluginDestroyedEvent.addListener(function(e) { | |
| 205 this.webViewInternal.onPluginDestroyed(); | |
| 206 }.bind(this), {instanceId: this.viewInstanceId}); | |
| 207 }; | |
| 208 | |
| 209 WebViewEvents.prototype.setupWebRequestEvents = function() { | 202 WebViewEvents.prototype.setupWebRequestEvents = function() { |
| 210 var request = {}; | 203 var request = {}; |
| 211 var createWebRequestEvent = function(webRequestEvent) { | 204 var createWebRequestEvent = function(webRequestEvent) { |
| 212 return function() { | 205 return function() { |
| 213 if (!this[webRequestEvent.name]) { | 206 if (!this[webRequestEvent.name]) { |
| 214 this[webRequestEvent.name] = | 207 this[webRequestEvent.name] = |
| 215 new WebRequestEvent( | 208 new WebRequestEvent( |
| 216 'webViewInternal.' + webRequestEvent.name, | 209 'webViewInternal.' + webRequestEvent.name, |
| 217 webRequestEvent.parameters, | 210 webRequestEvent.parameters, |
| 218 webRequestEvent.extraParameters, webRequestEvent.options, | 211 webRequestEvent.extraParameters, webRequestEvent.options, |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 } | 606 } |
| 614 }; | 607 }; |
| 615 | 608 |
| 616 WebViewEvents.prototype.handleSizeChangedEvent = function( | 609 WebViewEvents.prototype.handleSizeChangedEvent = function( |
| 617 event, webViewEvent) { | 610 event, webViewEvent) { |
| 618 this.webViewInternal.onSizeChanged(webViewEvent); | 611 this.webViewInternal.onSizeChanged(webViewEvent); |
| 619 }; | 612 }; |
| 620 | 613 |
| 621 exports.WebViewEvents = WebViewEvents; | 614 exports.WebViewEvents = WebViewEvents; |
| 622 exports.CreateEvent = CreateEvent; | 615 exports.CreateEvent = CreateEvent; |
| OLD | NEW |