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

Side by Side Diff: extensions/renderer/resources/guest_view/guest_view_container.js

Issue 972313002: Make <webview> use out-of-process iframe architecture. (Closed) Base URL: ssh://saopaulo.wat/mnt/dev/shared/src@testoopif2z-better-chrome
Patch Set: Revert unused changes from previous attempt + more cleanup. Created 5 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // This module implements the shared functionality for different guestview 5 // This module implements the shared functionality for different guestview
6 // containers, such as web_view, app_view, etc. 6 // containers, such as web_view, app_view, etc.
7 7
8 var DocumentNatives = requireNative('document_natives'); 8 var DocumentNatives = requireNative('document_natives');
9 var GuestView = require('guestView').GuestView; 9 var GuestView = require('guestView').GuestView;
10 var GuestViewInternalNatives = requireNative('guest_view_internal'); 10 var GuestViewInternalNatives = requireNative('guest_view_internal');
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 GuestViewContainer.prototype.createBrowserPluginElement = function() { 58 GuestViewContainer.prototype.createBrowserPluginElement = function() {
59 // We create BrowserPlugin as a custom element in order to observe changes 59 // We create BrowserPlugin as a custom element in order to observe changes
60 // to attributes synchronously. 60 // to attributes synchronously.
61 var browserPluginElement = 61 var browserPluginElement =
62 new GuestViewContainer[this.viewType + 'BrowserPlugin'](); 62 new GuestViewContainer[this.viewType + 'BrowserPlugin']();
63 privates(browserPluginElement).internal = this; 63 privates(browserPluginElement).internal = this;
64 return browserPluginElement; 64 return browserPluginElement;
65 }; 65 };
66 66
67 GuestViewContainer.prototype.getBrowserPluginElement = function() {
68 return privates(this).browserPluginElement;
69 };
70
67 GuestViewContainer.prototype.setupFocusPropagation = function() { 71 GuestViewContainer.prototype.setupFocusPropagation = function() {
68 if (!this.element.hasAttribute('tabIndex')) { 72 if (!this.element.hasAttribute('tabIndex')) {
69 // GuestViewContainer needs a tabIndex in order to be focusable. 73 // GuestViewContainer needs a tabIndex in order to be focusable.
70 // TODO(fsamuel): It would be nice to avoid exposing a tabIndex attribute 74 // TODO(fsamuel): It would be nice to avoid exposing a tabIndex attribute
71 // to allow GuestViewContainer to be focusable. 75 // to allow GuestViewContainer to be focusable.
72 // See http://crbug.com/231664. 76 // See http://crbug.com/231664.
73 this.element.setAttribute('tabIndex', -1); 77 this.element.setAttribute('tabIndex', -1);
74 } 78 }
75 this.element.addEventListener('focus', function(e) { 79 this.element.addEventListener('focus', function(e) {
76 // Focus the BrowserPlugin when the GuestViewContainer takes focus. 80 // Focus the BrowserPlugin when the GuestViewContainer takes focus.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 GuestViewContainer.prototype.onElementAttached = function() {}; 131 GuestViewContainer.prototype.onElementAttached = function() {};
128 GuestViewContainer.prototype.onElementDetached = function() { 132 GuestViewContainer.prototype.onElementDetached = function() {
129 this.guest.destroy(); 133 this.guest.destroy();
130 }; 134 };
131 GuestViewContainer.prototype.onElementResize = function(oldWidth, oldHeight, 135 GuestViewContainer.prototype.onElementResize = function(oldWidth, oldHeight,
132 newWidth, newHeight) {}; 136 newWidth, newHeight) {};
133 137
134 // Registers the browser plugin <object> custom element. |viewType| is the 138 // Registers the browser plugin <object> custom element. |viewType| is the
135 // name of the specific guestview container (e.g. 'webview'). 139 // name of the specific guestview container (e.g. 'webview').
136 function registerBrowserPluginElement(viewType) { 140 function registerBrowserPluginElement(viewType) {
137 var proto = Object.create(HTMLObjectElement.prototype); 141 //var proto = Object.create(HTMLObjectElement.prototype);
142 var proto = Object.create(HTMLIFrameElement.prototype);
138 143
139 proto.createdCallback = function() { 144 proto.createdCallback = function() {
140 this.setAttribute('type', 'application/browser-plugin'); 145 //this.setAttribute('type', 'application/browser-plugin');
141 this.setAttribute('id', 'browser-plugin-' + IdGenerator.GetNextId()); 146 //this.setAttribute('id', 'browser-plugin-' + IdGenerator.GetNextId());
142 this.style.width = '100%'; 147 this.style.width = '100%';
143 this.style.height = '100%'; 148 this.style.height = '100%';
144 }; 149 };
145 150
146 proto.attachedCallback = function() { 151 proto.attachedCallback = function() {
147 // Load the plugin immediately. 152 // Load the plugin immediately.
148 var unused = this.nonExistentAttribute; 153 var unused = this.nonExistentAttribute;
149 }; 154 };
150 155
156 /*
151 proto.attributeChangedCallback = function(name, oldValue, newValue) { 157 proto.attributeChangedCallback = function(name, oldValue, newValue) {
152 var internal = privates(this).internal; 158 var internal = privates(this).internal;
153 if (!internal) { 159 if (!internal) {
154 return; 160 return;
155 } 161 }
156 internal.handleBrowserPluginAttributeMutation(name, oldValue, newValue); 162 internal.handleBrowserPluginAttributeMutation(name, oldValue, newValue);
157 }; 163 };
164 */
158 165
159 GuestViewContainer[viewType + 'BrowserPlugin'] = 166 GuestViewContainer[viewType + 'BrowserPlugin'] =
160 DocumentNatives.RegisterElement(viewType + 'browserplugin', 167 DocumentNatives.RegisterElement(viewType + 'browserplugin',
161 {extends: 'object', prototype: proto}); 168 //{extends: 'object', prototype: proto});
169 {extends: 'iframe', prototype: proto});
162 170
163 delete proto.createdCallback; 171 delete proto.createdCallback;
164 delete proto.attachedCallback; 172 delete proto.attachedCallback;
165 delete proto.detachedCallback; 173 delete proto.detachedCallback;
166 delete proto.attributeChangedCallback; 174 delete proto.attributeChangedCallback;
167 }; 175 };
168 176
169 // Registers the guestview container as a custom element. 177 // Registers the guestview container as a custom element.
170 // |guestViewContainerType| is the type of guestview container 178 // |guestViewContainerType| is the type of guestview container
171 // (e.g.WebViewImpl). 179 // (e.g.WebViewImpl).
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // Delete the callbacks so developers cannot call them and produce unexpected 225 // Delete the callbacks so developers cannot call them and produce unexpected
218 // behavior. 226 // behavior.
219 delete proto.createdCallback; 227 delete proto.createdCallback;
220 delete proto.attachedCallback; 228 delete proto.attachedCallback;
221 delete proto.detachedCallback; 229 delete proto.detachedCallback;
222 delete proto.attributeChangedCallback; 230 delete proto.attributeChangedCallback;
223 } 231 }
224 232
225 // Exports. 233 // Exports.
226 exports.GuestViewContainer = GuestViewContainer; 234 exports.GuestViewContainer = GuestViewContainer;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698