| 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 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 get: webRequestEvent, | 262 get: webRequestEvent, |
| 263 enumerable: true | 263 enumerable: true |
| 264 } | 264 } |
| 265 ); | 265 ); |
| 266 } | 266 } |
| 267 | 267 |
| 268 this.webViewImpl.setRequestPropertyOnWebViewNode(request); | 268 this.webViewImpl.setRequestPropertyOnWebViewNode(request); |
| 269 }; | 269 }; |
| 270 | 270 |
| 271 WebViewEvents.prototype.getEvents = function() { | 271 WebViewEvents.prototype.getEvents = function() { |
| 272 var experimentalEvents = this.webViewImpl.maybeGetExperimentalEvents(); | |
| 273 for (var eventName in experimentalEvents) { | |
| 274 WEB_VIEW_EVENTS[eventName] = experimentalEvents[eventName]; | |
| 275 } | |
| 276 var chromeEvents = this.webViewImpl.maybeGetChromeWebViewEvents(); | 272 var chromeEvents = this.webViewImpl.maybeGetChromeWebViewEvents(); |
| 277 for (var eventName in chromeEvents) { | 273 for (var eventName in chromeEvents) { |
| 278 WEB_VIEW_EVENTS[eventName] = chromeEvents[eventName]; | 274 WEB_VIEW_EVENTS[eventName] = chromeEvents[eventName]; |
| 279 } | 275 } |
| 280 return WEB_VIEW_EVENTS; | 276 return WEB_VIEW_EVENTS; |
| 281 }; | 277 }; |
| 282 | 278 |
| 283 WebViewEvents.prototype.setupEvent = function(name, info) { | 279 WebViewEvents.prototype.setupEvent = function(name, info) { |
| 284 info.evt.addListener(function(e) { | 280 info.evt.addListener(function(e) { |
| 285 var details = {bubbles: true}; | 281 var details = {bubbles: true}; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 var ERROR_MSG_DIALOG_ACTION_ALREADY_TAKEN = '<webview>: ' + | 316 var ERROR_MSG_DIALOG_ACTION_ALREADY_TAKEN = '<webview>: ' + |
| 321 'An action has already been taken for this "dialog" event.'; | 317 'An action has already been taken for this "dialog" event.'; |
| 322 | 318 |
| 323 if (actionTaken) { | 319 if (actionTaken) { |
| 324 throw new Error(ERROR_MSG_DIALOG_ACTION_ALREADY_TAKEN); | 320 throw new Error(ERROR_MSG_DIALOG_ACTION_ALREADY_TAKEN); |
| 325 } | 321 } |
| 326 actionTaken = true; | 322 actionTaken = true; |
| 327 }; | 323 }; |
| 328 | 324 |
| 329 var getGuestInstanceId = function() { | 325 var getGuestInstanceId = function() { |
| 330 return this.webViewImpl.getGuestInstanceId(); | 326 return this.webViewImpl.guestInstanceId; |
| 331 }.bind(this); | 327 }.bind(this); |
| 332 | 328 |
| 333 var dialog = { | 329 var dialog = { |
| 334 ok: function(user_input) { | 330 ok: function(user_input) { |
| 335 validateCall(); | 331 validateCall(); |
| 336 user_input = user_input || ''; | 332 user_input = user_input || ''; |
| 337 WebViewInternal.setPermission(getGuestInstanceId(), requestId, 'allow', | 333 WebViewInternal.setPermission(getGuestInstanceId(), requestId, 'allow', |
| 338 user_input); | 334 user_input); |
| 339 }, | 335 }, |
| 340 cancel: function() { | 336 cancel: function() { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 var ERROR_MSG_WEBVIEW_EXPECTED = '<webview> element expected.'; | 403 var ERROR_MSG_WEBVIEW_EXPECTED = '<webview> element expected.'; |
| 408 | 404 |
| 409 var showWarningMessage = function() { | 405 var showWarningMessage = function() { |
| 410 var WARNING_MSG_NEWWINDOW_BLOCKED = '<webview>: A new window was blocked.'; | 406 var WARNING_MSG_NEWWINDOW_BLOCKED = '<webview>: A new window was blocked.'; |
| 411 window.console.warn(WARNING_MSG_NEWWINDOW_BLOCKED); | 407 window.console.warn(WARNING_MSG_NEWWINDOW_BLOCKED); |
| 412 }; | 408 }; |
| 413 | 409 |
| 414 var requestId = event.requestId; | 410 var requestId = event.requestId; |
| 415 var actionTaken = false; | 411 var actionTaken = false; |
| 416 var getGuestInstanceId = function() { | 412 var getGuestInstanceId = function() { |
| 417 return this.webViewImpl.getGuestInstanceId(); | 413 return this.webViewImpl.guestInstanceId; |
| 418 }.bind(this); | 414 }.bind(this); |
| 419 | 415 |
| 420 var validateCall = function() { | 416 var validateCall = function() { |
| 421 if (actionTaken) { | 417 if (actionTaken) { |
| 422 throw new Error(ERROR_MSG_NEWWINDOW_ACTION_ALREADY_TAKEN); | 418 throw new Error(ERROR_MSG_NEWWINDOW_ACTION_ALREADY_TAKEN); |
| 423 } | 419 } |
| 424 actionTaken = true; | 420 actionTaken = true; |
| 425 }; | 421 }; |
| 426 | 422 |
| 427 var windowObj = { | 423 var windowObj = { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 | 519 |
| 524 var showWarningMessage = function(permission) { | 520 var showWarningMessage = function(permission) { |
| 525 var WARNING_MSG_PERMISSION_DENIED = '<webview>: ' + | 521 var WARNING_MSG_PERMISSION_DENIED = '<webview>: ' + |
| 526 'The permission request for "%1" has been denied.'; | 522 'The permission request for "%1" has been denied.'; |
| 527 window.console.warn( | 523 window.console.warn( |
| 528 WARNING_MSG_PERMISSION_DENIED.replace('%1', permission)); | 524 WARNING_MSG_PERMISSION_DENIED.replace('%1', permission)); |
| 529 }; | 525 }; |
| 530 | 526 |
| 531 var requestId = event.requestId; | 527 var requestId = event.requestId; |
| 532 var getGuestInstanceId = function() { | 528 var getGuestInstanceId = function() { |
| 533 return this.webViewImpl.getGuestInstanceId(); | 529 return this.webViewImpl.guestInstanceId; |
| 534 }.bind(this); | 530 }.bind(this); |
| 535 | 531 |
| 536 if (this.permissionTypes.indexOf(event.permission) < 0) { | 532 if (this.permissionTypes.indexOf(event.permission) < 0) { |
| 537 // The permission type is not allowed. Trigger the default response. | 533 // The permission type is not allowed. Trigger the default response. |
| 538 WebViewInternal.setPermission( | 534 WebViewInternal.setPermission( |
| 539 getGuestInstanceId(), requestId, 'default', '', function(allowed) { | 535 getGuestInstanceId(), requestId, 'default', '', function(allowed) { |
| 540 if (!allowed) | 536 if (!allowed) |
| 541 showWarningMessage(event.permission); | 537 showWarningMessage(event.permission); |
| 542 }); | 538 }); |
| 543 return; | 539 return; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 } | 593 } |
| 598 }; | 594 }; |
| 599 | 595 |
| 600 WebViewEvents.prototype.handleSizeChangedEvent = function( | 596 WebViewEvents.prototype.handleSizeChangedEvent = function( |
| 601 event, webViewEvent) { | 597 event, webViewEvent) { |
| 602 this.webViewImpl.onSizeChanged(webViewEvent); | 598 this.webViewImpl.onSizeChanged(webViewEvent); |
| 603 }; | 599 }; |
| 604 | 600 |
| 605 exports.WebViewEvents = WebViewEvents; | 601 exports.WebViewEvents = WebViewEvents; |
| 606 exports.CreateEvent = CreateEvent; | 602 exports.CreateEvent = CreateEvent; |
| OLD | NEW |