| 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 = ['src', 'partition']; | 
|   13  |   13  | 
|   14 var WEB_VIEW_READONLY_ATTRIBUTES = ['contentWindow']; |  | 
|   15  |  | 
|   16 // 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 | 
|   17 // plugin. |   15 // plugin. | 
|   18 var WEB_VIEW_API_METHODS = [ |   16 var WEB_VIEW_API_METHODS = [ | 
|   19   'back', |   17   'back', | 
|   20   'canGoBack', |   18   'canGoBack', | 
|   21   'canGoForward', |   19   'canGoForward', | 
|   22   'forward', |   20   'forward', | 
|   23   'getProcessId', |   21   'getProcessId', | 
|   24   'go', |   22   'go', | 
|   25   'reload', |   23   'reload', | 
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   93       }, |   91       }, | 
|   94       set: function(value) { |   92       set: function(value) { | 
|   95         objectNode[attributeName] = value; |   93         objectNode[attributeName] = value; | 
|   96       }, |   94       }, | 
|   97       enumerable: true |   95       enumerable: true | 
|   98     }); |   96     }); | 
|   99   }, this); |   97   }, this); | 
|  100  |   98  | 
|  101   // We cannot use {writable: true} property descriptor because we want dynamic |   99   // We cannot use {writable: true} property descriptor because we want dynamic | 
|  102   // getter value. |  100   // getter value. | 
|  103   WEB_VIEW_READONLY_ATTRIBUTES.forEach(function(attributeName) { |  101   Object.defineProperty(this.node_, 'contentWindow', { | 
|  104     Object.defineProperty(this.node_, attributeName, { |  102     get: function() { | 
|  105       get: function() { |  103       // TODO(fsamuel): This is a workaround to enable | 
|  106         // Read these attributes from the plugin <object>. |  104       // contentWindow.postMessage until http://crbug.com/152006 is fixed. | 
|  107         return objectNode[attributeName]; |  105       return objectNode.contentWindow.self; | 
|  108       }, |  106     }, | 
|  109       // No setter. |  107     // No setter. | 
|  110       enumerable: true |  108     enumerable: true | 
|  111     }) |  109   }); | 
|  112   }, this); |  | 
|  113  |  110  | 
|  114   for (var eventName in WEB_VIEW_EVENTS) { |  111   for (var eventName in WEB_VIEW_EVENTS) { | 
|  115     this.setupEvent_(eventName, WEB_VIEW_EVENTS[eventName]); |  112     this.setupEvent_(eventName, WEB_VIEW_EVENTS[eventName]); | 
|  116   } |  113   } | 
|  117 } |  114 } | 
|  118  |  115  | 
|  119 /** |  116 /** | 
|  120  * @private |  117  * @private | 
|  121  */ |  118  */ | 
|  122 WebView.prototype.handleMutation_ = function(mutation) { |  119 WebView.prototype.handleMutation_ = function(mutation) { | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
|  139   var node = this.node_; |  136   var node = this.node_; | 
|  140   this.objectNode_.addEventListener('-internal-' + eventname, function(e) { |  137   this.objectNode_.addEventListener('-internal-' + eventname, function(e) { | 
|  141     var evt = new Event(eventname); |  138     var evt = new Event(eventname); | 
|  142     var detail = e.detail ? JSON.parse(e.detail) : {}; |  139     var detail = e.detail ? JSON.parse(e.detail) : {}; | 
|  143     attribs.forEach(function(attribName) { |  140     attribs.forEach(function(attribName) { | 
|  144       evt[attribName] = detail[attribName]; |  141       evt[attribName] = detail[attribName]; | 
|  145     }); |  142     }); | 
|  146     node.dispatchEvent(evt); |  143     node.dispatchEvent(evt); | 
|  147   }); |  144   }); | 
|  148 } |  145 } | 
| OLD | NEW |