Chromium Code Reviews| 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; |
| 11 | 11 |
| 12 var WEB_VIEW_ATTRIBUTES = ['src', 'partition']; | 12 var WEB_VIEW_ATTRIBUTES = ['name', 'src', 'partition']; |
| 13 | 13 |
| 14 // All exposed api methods for <webview>, these are forwarded to the browser | 14 // All exposed api methods for <webview>, these are forwarded to the browser |
| 15 // plugin. | 15 // plugin. |
| 16 var WEB_VIEW_API_METHODS = [ | 16 var WEB_VIEW_API_METHODS = [ |
| 17 'back', | 17 'back', |
| 18 'canGoBack', | 18 'canGoBack', |
| 19 'canGoForward', | 19 'canGoForward', |
| 20 'forward', | 20 'forward', |
| 21 'getProcessId', | 21 'getProcessId', |
| 22 'go', | 22 'go', |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 */ | 118 */ |
| 119 WebView.prototype.handleMutation_ = function(mutation) { | 119 WebView.prototype.handleMutation_ = function(mutation) { |
| 120 this.objectNode_[mutation.attributeName] = | 120 this.objectNode_[mutation.attributeName] = |
| 121 this.node_.getAttribute(mutation.attributeName); | 121 this.node_.getAttribute(mutation.attributeName); |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 /** | 124 /** |
| 125 * @private | 125 * @private |
| 126 */ | 126 */ |
| 127 WebView.prototype.handleObjectMutation_ = function(mutation) { | 127 WebView.prototype.handleObjectMutation_ = function(mutation) { |
| 128 this.node_.setAttribute(mutation.attributeName, | 128 if (!this.objectNode_.hasAttribute(mutation.attributeName)) { |
|
Charlie Reis
2012/12/13 01:11:42
I'm not entirely sure which type of attribute chan
Fady Samuel
2012/12/13 17:46:45
Done.
| |
| 129 this.objectNode_.getAttribute(mutation.attributeName)); | 129 this.node_.removeAttribute(mutation.attributeName); |
| 130 } else { | |
| 131 this.node_.setAttribute(mutation.attributeName, | |
| 132 this.objectNode_.getAttribute(mutation.attributeName)); | |
| 133 } | |
| 130 }; | 134 }; |
| 131 | 135 |
| 132 /** | 136 /** |
| 133 * @private | 137 * @private |
| 134 */ | 138 */ |
| 135 WebView.prototype.setupEvent_ = function(eventname, attribs) { | 139 WebView.prototype.setupEvent_ = function(eventname, attribs) { |
| 136 var node = this.node_; | 140 var node = this.node_; |
| 137 this.objectNode_.addEventListener('-internal-' + eventname, function(e) { | 141 this.objectNode_.addEventListener('-internal-' + eventname, function(e) { |
| 138 var evt = new Event(eventname); | 142 var evt = new Event(eventname); |
| 139 var detail = e.detail ? JSON.parse(e.detail) : {}; | 143 var detail = e.detail ? JSON.parse(e.detail) : {}; |
| 140 attribs.forEach(function(attribName) { | 144 attribs.forEach(function(attribName) { |
| 141 evt[attribName] = detail[attribName]; | 145 evt[attribName] = detail[attribName]; |
| 142 }); | 146 }); |
| 143 node.dispatchEvent(evt); | 147 node.dispatchEvent(evt); |
| 144 }); | 148 }); |
| 145 } | 149 } |
| OLD | NEW |