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

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

Issue 1033373003: GuestView: Lazily push attributes to the browser process on attach (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_sizing
Patch Set: Removed more unnecessary changes Created 5 years, 8 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
« no previous file with comments | « extensions/renderer/resources/guest_view/guest_view_attributes.js ('k') | no next file » | 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 // This module implements WebView (<webview>) as a custom element that wraps a 5 // This module implements WebView (<webview>) as a custom element that wraps a
6 // BrowserPlugin object element. The object element is hidden within 6 // BrowserPlugin object element. The object element is hidden within
7 // the shadow DOM of the WebView element. 7 // the shadow DOM of the WebView element.
8 8
9 var DocumentNatives = requireNative('document_natives'); 9 var DocumentNatives = requireNative('document_natives');
10 var GuestView = require('guestView').GuestView; 10 var GuestView = require('guestView').GuestView;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 createDefaultApiMethod(apiMethods[i]); 48 createDefaultApiMethod(apiMethods[i]);
49 } 49 }
50 } 50 }
51 51
52 // Forward proto.foo* method calls to WebViewImpl.foo*. 52 // Forward proto.foo* method calls to WebViewImpl.foo*.
53 GuestViewContainer.forwardApiMethods(proto, apiMethods); 53 GuestViewContainer.forwardApiMethods(proto, apiMethods);
54 }; 54 };
55 55
56 // Initiates navigation once the <webview> element is attached to the DOM. 56 // Initiates navigation once the <webview> element is attached to the DOM.
57 WebViewImpl.prototype.onElementAttached = function() { 57 WebViewImpl.prototype.onElementAttached = function() {
58 // Mark all attributes as dirty on attachment.
59 for (var i in this.attributes) {
60 this.attributes[i].dirty = true;
61 }
58 for (var i in this.attributes) { 62 for (var i in this.attributes) {
59 this.attributes[i].attach(); 63 this.attributes[i].attach();
60 } 64 }
61 }; 65 };
62 66
63 // Resets some state upon detaching <webview> element from the DOM. 67 // Resets some state upon detaching <webview> element from the DOM.
64 WebViewImpl.prototype.onElementDetached = function() { 68 WebViewImpl.prototype.onElementDetached = function() {
65 this.guest.destroy(); 69 this.guest.destroy();
66 for (var i in this.attributes) { 70 for (var i in this.attributes) {
71 this.attributes[i].dirty = false;
72 }
73 for (var i in this.attributes) {
67 this.attributes[i].detach(); 74 this.attributes[i].detach();
68 } 75 }
69 }; 76 };
70 77
71 // Sets the <webview>.request property. 78 // Sets the <webview>.request property.
72 WebViewImpl.prototype.setRequestPropertyOnWebViewElement = function(request) { 79 WebViewImpl.prototype.setRequestPropertyOnWebViewElement = function(request) {
73 Object.defineProperty( 80 Object.defineProperty(
74 this.element, 81 this.element,
75 'request', 82 'request',
76 { 83 {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 }; 167 };
161 168
162 WebViewImpl.prototype.onAttach = function(storagePartitionId) { 169 WebViewImpl.prototype.onAttach = function(storagePartitionId) {
163 this.attributes[WebViewConstants.ATTRIBUTE_PARTITION].setValueIgnoreMutation( 170 this.attributes[WebViewConstants.ATTRIBUTE_PARTITION].setValueIgnoreMutation(
164 storagePartitionId); 171 storagePartitionId);
165 }; 172 };
166 173
167 WebViewImpl.prototype.buildContainerParams = function() { 174 WebViewImpl.prototype.buildContainerParams = function() {
168 var params = { 'userAgentOverride': this.userAgentOverride }; 175 var params = { 'userAgentOverride': this.userAgentOverride };
169 for (var i in this.attributes) { 176 for (var i in this.attributes) {
170 params[i] = this.attributes[i].getValue(); 177 var value = this.attributes[i].getValueIfDirty();
178 if (value)
179 params[i] = value;
171 } 180 }
172 return params; 181 return params;
173 }; 182 };
174 183
175 WebViewImpl.prototype.attachWindow = function(opt_guestInstanceId) { 184 WebViewImpl.prototype.attachWindow = function(opt_guestInstanceId) {
176 // If |opt_guestInstanceId| was provided, then a different existing guest is 185 // If |opt_guestInstanceId| was provided, then a different existing guest is
177 // being attached to this webview, and the current one will get destroyed. 186 // being attached to this webview, and the current one will get destroyed.
178 if (opt_guestInstanceId) { 187 if (opt_guestInstanceId) {
179 if (this.guest.getId() == opt_guestInstanceId) { 188 if (this.guest.getId() == opt_guestInstanceId) {
180 return true; 189 return true;
(...skipping 30 matching lines...) Expand all
211 }.bind(this)); 220 }.bind(this));
212 }; 221 };
213 222
214 // Implemented when the ChromeWebView API is available. 223 // Implemented when the ChromeWebView API is available.
215 WebViewImpl.prototype.maybeSetupContextMenus = function() {}; 224 WebViewImpl.prototype.maybeSetupContextMenus = function() {};
216 225
217 GuestViewContainer.registerElement(WebViewImpl); 226 GuestViewContainer.registerElement(WebViewImpl);
218 227
219 // Exports. 228 // Exports.
220 exports.WebViewImpl = WebViewImpl; 229 exports.WebViewImpl = WebViewImpl;
OLDNEW
« no previous file with comments | « extensions/renderer/resources/guest_view/guest_view_attributes.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698