| 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 WebView. | 5 // Event management for WebView. |
| 6 | 6 |
| 7 var CreateEvent = require('guestViewEvents').CreateEvent; | 7 var CreateEvent = require('guestViewEvents').CreateEvent; |
| 8 var DeclarativeWebRequestSchema = | 8 var DeclarativeWebRequestSchema = |
| 9 requireNative('schema_registry').GetSchema('declarativeWebRequest'); | 9 requireNative('schema_registry').GetSchema('declarativeWebRequest'); |
| 10 var EventBindings = require('event_bindings'); | 10 var EventBindings = require('event_bindings'); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 handler: 'handleDialogEvent' | 48 handler: 'handleDialogEvent' |
| 49 }, | 49 }, |
| 50 'droplink': { | 50 'droplink': { |
| 51 evt: CreateEvent('webViewInternal.onDropLink'), | 51 evt: CreateEvent('webViewInternal.onDropLink'), |
| 52 fields: ['url'] | 52 fields: ['url'] |
| 53 }, | 53 }, |
| 54 'exit': { | 54 'exit': { |
| 55 evt: CreateEvent('webViewInternal.onExit'), | 55 evt: CreateEvent('webViewInternal.onExit'), |
| 56 fields: ['processId', 'reason'] | 56 fields: ['processId', 'reason'] |
| 57 }, | 57 }, |
| 58 'exitfullscreen': { |
| 59 evt: CreateEvent('webViewInternal.onExitFullscreen'), |
| 60 fields: ['url'], |
| 61 handler: 'handleFullscreenExitEvent', |
| 62 internal: true |
| 63 }, |
| 58 'findupdate': { | 64 'findupdate': { |
| 59 evt: CreateEvent('webViewInternal.onFindReply'), | 65 evt: CreateEvent('webViewInternal.onFindReply'), |
| 60 fields: [ | 66 fields: [ |
| 61 'searchText', | 67 'searchText', |
| 62 'numberOfMatches', | 68 'numberOfMatches', |
| 63 'activeMatchOrdinal', | 69 'activeMatchOrdinal', |
| 64 'selectionRect', | 70 'selectionRect', |
| 65 'canceled', | 71 'canceled', |
| 66 'finalUpdate' | 72 'finalUpdate' |
| 67 ] | 73 ] |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 218 |
| 213 WebViewEvents.prototype.handleDialogEvent = function(event, eventName) { | 219 WebViewEvents.prototype.handleDialogEvent = function(event, eventName) { |
| 214 var webViewEvent = this.makeDomEvent(event, eventName); | 220 var webViewEvent = this.makeDomEvent(event, eventName); |
| 215 new WebViewActionRequests.Dialog(this.view, event, webViewEvent); | 221 new WebViewActionRequests.Dialog(this.view, event, webViewEvent); |
| 216 }; | 222 }; |
| 217 | 223 |
| 218 WebViewEvents.prototype.handleFrameNameChangedEvent = function(event) { | 224 WebViewEvents.prototype.handleFrameNameChangedEvent = function(event) { |
| 219 this.view.onFrameNameChanged(event.name); | 225 this.view.onFrameNameChanged(event.name); |
| 220 }; | 226 }; |
| 221 | 227 |
| 228 WebViewEvents.prototype.handleFullscreenExitEvent = function(event, eventName) { |
| 229 document.webkitCancelFullScreen(); |
| 230 }; |
| 231 |
| 222 WebViewEvents.prototype.handleLoadAbortEvent = function(event, eventName) { | 232 WebViewEvents.prototype.handleLoadAbortEvent = function(event, eventName) { |
| 223 var showWarningMessage = function(reason) { | 233 var showWarningMessage = function(reason) { |
| 224 var WARNING_MSG_LOAD_ABORTED = '<webview>: ' + | 234 var WARNING_MSG_LOAD_ABORTED = '<webview>: ' + |
| 225 'The load has aborted with reason "%1".'; | 235 'The load has aborted with reason "%1".'; |
| 226 window.console.warn(WARNING_MSG_LOAD_ABORTED.replace('%1', reason)); | 236 window.console.warn(WARNING_MSG_LOAD_ABORTED.replace('%1', reason)); |
| 227 }; | 237 }; |
| 228 var webViewEvent = this.makeDomEvent(event, eventName); | 238 var webViewEvent = this.makeDomEvent(event, eventName); |
| 229 if (this.view.dispatchEvent(webViewEvent)) { | 239 if (this.view.dispatchEvent(webViewEvent)) { |
| 230 showWarningMessage(event.reason); | 240 showWarningMessage(event.reason); |
| 231 } | 241 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 242 this.view.dispatchEvent(webViewEvent); | 252 this.view.dispatchEvent(webViewEvent); |
| 243 }; | 253 }; |
| 244 | 254 |
| 245 WebViewEvents.prototype.handleNewWindowEvent = function(event, eventName) { | 255 WebViewEvents.prototype.handleNewWindowEvent = function(event, eventName) { |
| 246 var webViewEvent = this.makeDomEvent(event, eventName); | 256 var webViewEvent = this.makeDomEvent(event, eventName); |
| 247 new WebViewActionRequests.NewWindow(this.view, event, webViewEvent); | 257 new WebViewActionRequests.NewWindow(this.view, event, webViewEvent); |
| 248 }; | 258 }; |
| 249 | 259 |
| 250 WebViewEvents.prototype.handlePermissionEvent = function(event, eventName) { | 260 WebViewEvents.prototype.handlePermissionEvent = function(event, eventName) { |
| 251 var webViewEvent = this.makeDomEvent(event, eventName); | 261 var webViewEvent = this.makeDomEvent(event, eventName); |
| 252 new WebViewActionRequests.PermissionRequest(this.view, event, webViewEvent); | 262 if (event.permission === 'fullscreen') { |
| 263 new WebViewActionRequests.FullscreenPermissionRequest( |
| 264 this.view, event, webViewEvent); |
| 265 } else { |
| 266 new WebViewActionRequests.PermissionRequest(this.view, event, webViewEvent); |
| 267 } |
| 253 }; | 268 }; |
| 254 | 269 |
| 255 WebViewEvents.prototype.handleSizeChangedEvent = function(event, eventName) { | 270 WebViewEvents.prototype.handleSizeChangedEvent = function(event, eventName) { |
| 256 var webViewEvent = this.makeDomEvent(event, eventName); | 271 var webViewEvent = this.makeDomEvent(event, eventName); |
| 257 this.view.onSizeChanged(webViewEvent); | 272 this.view.onSizeChanged(webViewEvent); |
| 258 }; | 273 }; |
| 259 | 274 |
| 260 function DeclarativeWebRequestEvent(opt_eventName, | 275 function DeclarativeWebRequestEvent(opt_eventName, |
| 261 opt_argSchemas, | 276 opt_argSchemas, |
| 262 opt_eventOptions, | 277 opt_eventOptions, |
| 263 opt_webViewInstanceId) { | 278 opt_webViewInstanceId) { |
| 264 var subEventName = opt_eventName + '/' + IdGenerator.GetNextId(); | 279 var subEventName = opt_eventName + '/' + IdGenerator.GetNextId(); |
| 265 EventBindings.Event.call(this, | 280 EventBindings.Event.call(this, |
| 266 subEventName, | 281 subEventName, |
| 267 opt_argSchemas, | 282 opt_argSchemas, |
| 268 opt_eventOptions, | 283 opt_eventOptions, |
| 269 opt_webViewInstanceId); | 284 opt_webViewInstanceId); |
| 270 | 285 |
| 271 // TODO(lazyboy): When do we dispose this listener? | 286 // TODO(lazyboy): When do we dispose this listener? |
| 272 WebRequestMessageEvent.addListener(function() { | 287 WebRequestMessageEvent.addListener(function() { |
| 273 // Re-dispatch to subEvent's listeners. | 288 // Re-dispatch to subEvent's listeners. |
| 274 $Function.apply(this.dispatch, this, $Array.slice(arguments)); | 289 $Function.apply(this.dispatch, this, $Array.slice(arguments)); |
| 275 }.bind(this), {instanceId: opt_webViewInstanceId || 0}); | 290 }.bind(this), {instanceId: opt_webViewInstanceId || 0}); |
| 276 } | 291 } |
| 277 | 292 |
| 278 DeclarativeWebRequestEvent.prototype.__proto__ = EventBindings.Event.prototype; | 293 DeclarativeWebRequestEvent.prototype.__proto__ = EventBindings.Event.prototype; |
| 279 | 294 |
| 280 // Exports. | 295 // Exports. |
| 281 exports.WebViewEvents = WebViewEvents; | 296 exports.WebViewEvents = WebViewEvents; |
| OLD | NEW |