Chromium Code Reviews| 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' | |
|
Fady Samuel
2015/03/13 01:43:07
add:
internal: true
lazyboy
2015/03/13 16:27:02
Done.
| |
| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 | 217 |
| 213 WebViewEvents.prototype.handleDialogEvent = function(event, eventName) { | 218 WebViewEvents.prototype.handleDialogEvent = function(event, eventName) { |
| 214 var webViewEvent = this.makeDomEvent(event, eventName); | 219 var webViewEvent = this.makeDomEvent(event, eventName); |
| 215 new WebViewActionRequests.Dialog(this.view, event, webViewEvent); | 220 new WebViewActionRequests.Dialog(this.view, event, webViewEvent); |
| 216 }; | 221 }; |
| 217 | 222 |
| 218 WebViewEvents.prototype.handleFrameNameChangedEvent = function(event) { | 223 WebViewEvents.prototype.handleFrameNameChangedEvent = function(event) { |
| 219 this.view.onFrameNameChanged(event.name); | 224 this.view.onFrameNameChanged(event.name); |
| 220 }; | 225 }; |
| 221 | 226 |
| 227 WebViewEvents.prototype.handleFullscreenExitEvent = function(event, eventName) { | |
| 228 document.webkitCancelFullScreen(); | |
| 229 }; | |
| 230 | |
| 222 WebViewEvents.prototype.handleLoadAbortEvent = function(event, eventName) { | 231 WebViewEvents.prototype.handleLoadAbortEvent = function(event, eventName) { |
| 223 var showWarningMessage = function(reason) { | 232 var showWarningMessage = function(reason) { |
| 224 var WARNING_MSG_LOAD_ABORTED = '<webview>: ' + | 233 var WARNING_MSG_LOAD_ABORTED = '<webview>: ' + |
| 225 'The load has aborted with reason "%1".'; | 234 'The load has aborted with reason "%1".'; |
| 226 window.console.warn(WARNING_MSG_LOAD_ABORTED.replace('%1', reason)); | 235 window.console.warn(WARNING_MSG_LOAD_ABORTED.replace('%1', reason)); |
| 227 }; | 236 }; |
| 228 var webViewEvent = this.makeDomEvent(event, eventName); | 237 var webViewEvent = this.makeDomEvent(event, eventName); |
| 229 if (this.view.dispatchEvent(webViewEvent)) { | 238 if (this.view.dispatchEvent(webViewEvent)) { |
| 230 showWarningMessage(event.reason); | 239 showWarningMessage(event.reason); |
| 231 } | 240 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 242 this.view.dispatchEvent(webViewEvent); | 251 this.view.dispatchEvent(webViewEvent); |
| 243 }; | 252 }; |
| 244 | 253 |
| 245 WebViewEvents.prototype.handleNewWindowEvent = function(event, eventName) { | 254 WebViewEvents.prototype.handleNewWindowEvent = function(event, eventName) { |
| 246 var webViewEvent = this.makeDomEvent(event, eventName); | 255 var webViewEvent = this.makeDomEvent(event, eventName); |
| 247 new WebViewActionRequests.NewWindow(this.view, event, webViewEvent); | 256 new WebViewActionRequests.NewWindow(this.view, event, webViewEvent); |
| 248 }; | 257 }; |
| 249 | 258 |
| 250 WebViewEvents.prototype.handlePermissionEvent = function(event, eventName) { | 259 WebViewEvents.prototype.handlePermissionEvent = function(event, eventName) { |
| 251 var webViewEvent = this.makeDomEvent(event, eventName); | 260 var webViewEvent = this.makeDomEvent(event, eventName); |
| 252 new WebViewActionRequests.PermissionRequest(this.view, event, webViewEvent); | 261 if (event.permission === 'fullscreen') { |
| 262 new WebViewActionRequests.FullscreenPermissionRequest( | |
| 263 this.view, event, webViewEvent); | |
| 264 } else { | |
| 265 new WebViewActionRequests.PermissionRequest(this.view, event, webViewEvent); | |
| 266 } | |
| 253 }; | 267 }; |
| 254 | 268 |
| 255 WebViewEvents.prototype.handleSizeChangedEvent = function(event, eventName) { | 269 WebViewEvents.prototype.handleSizeChangedEvent = function(event, eventName) { |
| 256 var webViewEvent = this.makeDomEvent(event, eventName); | 270 var webViewEvent = this.makeDomEvent(event, eventName); |
| 257 this.view.onSizeChanged(webViewEvent); | 271 this.view.onSizeChanged(webViewEvent); |
| 258 }; | 272 }; |
| 259 | 273 |
| 260 function DeclarativeWebRequestEvent(opt_eventName, | 274 function DeclarativeWebRequestEvent(opt_eventName, |
| 261 opt_argSchemas, | 275 opt_argSchemas, |
| 262 opt_eventOptions, | 276 opt_eventOptions, |
| 263 opt_webViewInstanceId) { | 277 opt_webViewInstanceId) { |
| 264 var subEventName = opt_eventName + '/' + IdGenerator.GetNextId(); | 278 var subEventName = opt_eventName + '/' + IdGenerator.GetNextId(); |
| 265 EventBindings.Event.call(this, | 279 EventBindings.Event.call(this, |
| 266 subEventName, | 280 subEventName, |
| 267 opt_argSchemas, | 281 opt_argSchemas, |
| 268 opt_eventOptions, | 282 opt_eventOptions, |
| 269 opt_webViewInstanceId); | 283 opt_webViewInstanceId); |
| 270 | 284 |
| 271 // TODO(lazyboy): When do we dispose this listener? | 285 // TODO(lazyboy): When do we dispose this listener? |
| 272 WebRequestMessageEvent.addListener(function() { | 286 WebRequestMessageEvent.addListener(function() { |
| 273 // Re-dispatch to subEvent's listeners. | 287 // Re-dispatch to subEvent's listeners. |
| 274 $Function.apply(this.dispatch, this, $Array.slice(arguments)); | 288 $Function.apply(this.dispatch, this, $Array.slice(arguments)); |
| 275 }.bind(this), {instanceId: opt_webViewInstanceId || 0}); | 289 }.bind(this), {instanceId: opt_webViewInstanceId || 0}); |
| 276 } | 290 } |
| 277 | 291 |
| 278 DeclarativeWebRequestEvent.prototype.__proto__ = EventBindings.Event.prototype; | 292 DeclarativeWebRequestEvent.prototype.__proto__ = EventBindings.Event.prototype; |
| 279 | 293 |
| 280 // Exports. | 294 // Exports. |
| 281 exports.WebViewEvents = WebViewEvents; | 295 exports.WebViewEvents = WebViewEvents; |
| OLD | NEW |