| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Shim that simulates a <webview> tag via Mutation Observers. | 5 // Shim that simulates a <webview> tag via Mutation Observers. |
| 6 // | 6 // |
| 7 // The actual tag is implemented via the browser plugin. The internals of this | 7 // The actual tag is implemented via the browser plugin. The internals of this |
| 8 // are hidden via Shadow DOM. | 8 // are hidden via Shadow DOM. |
| 9 | 9 |
| 10 var watchForTag = require("tagWatcher").watchForTag; | 10 var watchForTag = require("tagWatcher").watchForTag; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 console.error('contentWindow is not available at this time. ' + | 122 console.error('contentWindow is not available at this time. ' + |
| 123 'It will become available when the page has finished loading.'); | 123 'It will become available when the page has finished loading.'); |
| 124 }, | 124 }, |
| 125 // No setter. | 125 // No setter. |
| 126 enumerable: true | 126 enumerable: true |
| 127 }); | 127 }); |
| 128 | 128 |
| 129 for (var eventName in WEB_VIEW_EVENTS) { | 129 for (var eventName in WEB_VIEW_EVENTS) { |
| 130 this.setupEvent_(eventName, WEB_VIEW_EVENTS[eventName]); | 130 this.setupEvent_(eventName, WEB_VIEW_EVENTS[eventName]); |
| 131 } | 131 } |
| 132 this.maybeSetupPermissionEvent_(); |
| 132 } | 133 } |
| 133 | 134 |
| 134 /** | 135 /** |
| 135 * @private | 136 * @private |
| 136 */ | 137 */ |
| 137 WebView.prototype.handleMutation_ = function(mutation) { | 138 WebView.prototype.handleMutation_ = function(mutation) { |
| 138 // This observer monitors mutations to attributes of the <webview> and | 139 // This observer monitors mutations to attributes of the <webview> and |
| 139 // updates the BrowserPlugin properties accordingly. In turn, updating | 140 // updates the BrowserPlugin properties accordingly. In turn, updating |
| 140 // a BrowserPlugin property will update the corresponding BrowserPlugin | 141 // a BrowserPlugin property will update the corresponding BrowserPlugin |
| 141 // attribute, if necessary. See BrowserPlugin::UpdateDOMAttribute for more | 142 // attribute, if necessary. See BrowserPlugin::UpdateDOMAttribute for more |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 WebView.prototype.setupEvent_ = function(eventname, attribs) { | 177 WebView.prototype.setupEvent_ = function(eventname, attribs) { |
| 177 var node = this.node_; | 178 var node = this.node_; |
| 178 this.objectNode_.addEventListener('-internal-' + eventname, function(e) { | 179 this.objectNode_.addEventListener('-internal-' + eventname, function(e) { |
| 179 var evt = new Event(eventname, { bubbles: true }); | 180 var evt = new Event(eventname, { bubbles: true }); |
| 180 var detail = e.detail ? JSON.parse(e.detail) : {}; | 181 var detail = e.detail ? JSON.parse(e.detail) : {}; |
| 181 attribs.forEach(function(attribName) { | 182 attribs.forEach(function(attribName) { |
| 182 evt[attribName] = detail[attribName]; | 183 evt[attribName] = detail[attribName]; |
| 183 }); | 184 }); |
| 184 node.dispatchEvent(evt); | 185 node.dispatchEvent(evt); |
| 185 }); | 186 }); |
| 186 } | 187 }; |
| 188 |
| 189 /** |
| 190 * Implemented when experimental permission is available. |
| 191 * @private |
| 192 */ |
| 193 WebView.prototype.maybeSetupPermissionEvent_ = function() {}; |
| 194 |
| 195 exports.WebView = WebView; |
| OLD | NEW |