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

Side by Side Diff: chrome/renderer/resources/extensions/web_view.js

Issue 11554030: <webview>: Add name attribute (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with ToT Created 7 years, 11 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/browser_plugin/browser_plugin_embedder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 for (var eventName in WEB_VIEW_EVENTS) { 111 for (var eventName in WEB_VIEW_EVENTS) {
112 this.setupEvent_(eventName, WEB_VIEW_EVENTS[eventName]); 112 this.setupEvent_(eventName, WEB_VIEW_EVENTS[eventName]);
113 } 113 }
114 } 114 }
115 115
116 /** 116 /**
117 * @private 117 * @private
118 */ 118 */
119 WebView.prototype.handleMutation_ = function(mutation) { 119 WebView.prototype.handleMutation_ = function(mutation) {
120 // This observer monitors mutations to attributes of the <webview> and
121 // updates the BrowserPlugin properties accordingly. In turn, updating
122 // a BrowserPlugin property will update the corresponding BrowserPlugin
123 // attribute, if necessary. See BrowserPlugin::UpdateDOMAttribute for more
124 // details.
120 this.objectNode_[mutation.attributeName] = 125 this.objectNode_[mutation.attributeName] =
121 this.node_.getAttribute(mutation.attributeName); 126 this.node_.getAttribute(mutation.attributeName);
122 }; 127 };
123 128
124 /** 129 /**
125 * @private 130 * @private
126 */ 131 */
127 WebView.prototype.handleObjectMutation_ = function(mutation) { 132 WebView.prototype.handleObjectMutation_ = function(mutation) {
128 this.node_.setAttribute(mutation.attributeName, 133 // This observer monitors mutations to attributes of the BrowserPlugin and
129 this.objectNode_.getAttribute(mutation.attributeName)); 134 // updates the <webview> attributes accordingly.
135 if (!this.objectNode_.hasAttribute(mutation.attributeName)) {
136 // If an attribute is removed from the BrowserPlugin, then remove it
137 // from the <webview> as well.
138 this.node_.removeAttribute(mutation.attributeName);
139 } else {
140 // Update the <webview> attribute to match the BrowserPlugin attribute.
141 this.node_.setAttribute(mutation.attributeName,
142 this.objectNode_.getAttribute(mutation.attributeName));
143 }
130 }; 144 };
131 145
132 /** 146 /**
133 * @private 147 * @private
134 */ 148 */
135 WebView.prototype.setupEvent_ = function(eventname, attribs) { 149 WebView.prototype.setupEvent_ = function(eventname, attribs) {
136 var node = this.node_; 150 var node = this.node_;
137 this.objectNode_.addEventListener('-internal-' + eventname, function(e) { 151 this.objectNode_.addEventListener('-internal-' + eventname, function(e) {
138 var evt = new Event(eventname); 152 var evt = new Event(eventname);
139 var detail = e.detail ? JSON.parse(e.detail) : {}; 153 var detail = e.detail ? JSON.parse(e.detail) : {};
140 attribs.forEach(function(attribName) { 154 attribs.forEach(function(attribName) {
141 evt[attribName] = detail[attribName]; 155 evt[attribName] = detail[attribName];
142 }); 156 });
143 node.dispatchEvent(evt); 157 node.dispatchEvent(evt);
144 }); 158 });
145 } 159 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/browser_plugin/browser_plugin_embedder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698