Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2042)

Unified Diff: chrome/renderer/resources/extensions/web_view.js

Issue 11368071: browser-plugin: Remove event handling code, and use CustomEvents in webkit instead. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/web_view/main.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/resources/extensions/web_view.js
diff --git a/chrome/renderer/resources/extensions/web_view.js b/chrome/renderer/resources/extensions/web_view.js
index 2a299f7a1dc5ca55706b0f09f22daaf37c8034a8..13331c49bc21b843e98bdd4699766c430f39df3c 100644
--- a/chrome/renderer/resources/extensions/web_view.js
+++ b/chrome/renderer/resources/extensions/web_view.js
@@ -14,18 +14,26 @@ var WEB_VIEW_READONLY_ATTRIBUTES = ['contentWindow'];
// All exposed api methods for <webview>, these are forwarded to the browser
// plugin.
var WEB_VIEW_API_METHODS = [
- 'addEventListener',
- 'back',
- 'canGoBack',
- 'canGoForward',
- 'forward',
- 'getProcessId',
- 'go',
- 'reload',
- 'removeEventListener',
- 'stop',
- 'terminate'
- ];
+ 'back',
+ 'canGoBack',
+ 'canGoForward',
+ 'forward',
+ 'getProcessId',
+ 'go',
+ 'reload',
+ 'stop',
+ 'terminate'
+];
+
+var WEB_VIEW_EVENTS = {
+ 'exit' : ['processId', 'reason'],
+ 'loadabort' : ['url', 'isTopLevel', 'reason'],
+ 'loadcommit' : ['url', 'isTopLevel'],
+ 'loadredirect' : ['oldurl', 'newurl', 'isTopLevel'],
+ 'loadstart' : ['url', 'isTopLevel'],
+ 'loadstop' : [],
+ 'sizechanged': ['oldHeight', 'oldWidth', 'newHeight', 'newWidth'],
+};
window.addEventListener('DOMContentLoaded', function() {
// Handle <webview> tags already in the document.
@@ -111,6 +119,10 @@ function WebView(node) {
enumerable: true
})
}, this);
+
+ for (var eventName in WEB_VIEW_EVENTS) {
+ this.setupEvent_(eventName, WEB_VIEW_EVENTS[eventName]);
+ }
};
/**
@@ -138,3 +150,18 @@ WebView.prototype.copyAttribute_ = function(attributeName) {
this.objectNode_.setAttribute(
attributeName, this.node_.getAttribute(attributeName));
};
+
+/**
+ * @private
+ */
+WebView.prototype.setupEvent_ = function(eventname, attribs) {
+ var node = this.node_;
+ this.objectNode_.addEventListener('-internal-' + eventname, function(e) {
+ var evt = new Event(eventname);
+ var detail = e.detail ? JSON.parse(e.detail) : {};
+ attribs.forEach(function(attribName) {
+ evt[attribName] = detail[attribName];
+ });
+ node.dispatchEvent(evt);
+ });
+}
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/web_view/main.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698