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