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

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

Issue 564973004: Move ContentWindow from BrowserPlugin To GuestView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 (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 GuestViewInternal = 10 var GuestViewInternal =
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // already picked up a partition ID. Thus, we need to reset the initialization 159 // already picked up a partition ID. Thus, we need to reset the initialization
160 // state. However, it may be the case that beforeFirstNavigation is false BUT 160 // state. However, it may be the case that beforeFirstNavigation is false BUT
161 // guestInstanceId has yet to be initialized. This means that we have not 161 // guestInstanceId has yet to be initialized. This means that we have not
162 // heard back from createGuest yet. We will not reset the flag in this case so 162 // heard back from createGuest yet. We will not reset the flag in this case so
163 // that we don't end up allocating a second guest. 163 // that we don't end up allocating a second guest.
164 if (this.guestInstanceId) { 164 if (this.guestInstanceId) {
165 this.guestInstanceId = undefined; 165 this.guestInstanceId = undefined;
166 this.beforeFirstNavigation = true; 166 this.beforeFirstNavigation = true;
167 this.validPartitionId = true; 167 this.validPartitionId = true;
168 this.partition.validPartitionId = true; 168 this.partition.validPartitionId = true;
169 this.contentWindow = null;
lazyboy 2014/09/17 18:24:01 This should be done in the constructor as well.
Fady Samuel 2014/09/17 20:25:46 Done.
169 } 170 }
170 this.internalInstanceId = 0; 171 this.internalInstanceId = 0;
171 }; 172 };
172 173
173 // Sets <webview>.request property. 174 // Sets <webview>.request property.
174 WebViewInternal.prototype.setRequestPropertyOnWebViewNode = function(request) { 175 WebViewInternal.prototype.setRequestPropertyOnWebViewNode = function(request) {
175 Object.defineProperty( 176 Object.defineProperty(
176 this.webviewNode, 177 this.webviewNode,
177 'request', 178 'request',
178 { 179 {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 } 413 }
413 self.webviewNode.setAttribute('partition', value); 414 self.webviewNode.setAttribute('partition', value);
414 }, 415 },
415 enumerable: true 416 enumerable: true
416 }); 417 });
417 418
418 // We cannot use {writable: true} property descriptor because we want a 419 // We cannot use {writable: true} property descriptor because we want a
419 // dynamic getter value. 420 // dynamic getter value.
420 Object.defineProperty(this.webviewNode, 'contentWindow', { 421 Object.defineProperty(this.webviewNode, 'contentWindow', {
421 get: function() { 422 get: function() {
422 if (browserPluginNode.contentWindow) 423 if (this.contentWindow)
423 return browserPluginNode.contentWindow; 424 return this.contentWindow;
424 window.console.error(ERROR_MSG_CONTENTWINDOW_NOT_AVAILABLE); 425 window.console.error(ERROR_MSG_CONTENTWINDOW_NOT_AVAILABLE);
425 }, 426 }.bind(this),
426 // No setter. 427 // No setter.
427 enumerable: true 428 enumerable: true
428 }); 429 });
429 }; 430 };
430 431
431 /** 432 /**
432 * @private 433 * @private
433 */ 434 */
434 WebViewInternal.prototype.setupWebviewNodeAttributes = function() { 435 WebViewInternal.prototype.setupWebviewNodeAttributes = function() {
435 this.setupWebViewSrcAttributeMutationObserver(); 436 this.setupWebViewSrcAttributeMutationObserver();
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 } 569 }
569 570
570 if (!!this.guestInstanceId && this.guestInstanceId != 0) { 571 if (!!this.guestInstanceId && this.guestInstanceId != 0) {
571 window.setTimeout(function() { 572 window.setTimeout(function() {
572 var isNewWindow = this.deferredAttachState ? 573 var isNewWindow = this.deferredAttachState ?
573 this.deferredAttachState.isNewWindow : false; 574 this.deferredAttachState.isNewWindow : false;
574 var params = this.buildAttachParams(isNewWindow); 575 var params = this.buildAttachParams(isNewWindow);
575 guestViewInternalNatives.AttachGuest( 576 guestViewInternalNatives.AttachGuest(
576 this.internalInstanceId, 577 this.internalInstanceId,
577 this.guestInstanceId, 578 this.guestInstanceId,
578 params); 579 params,
580 function(w) {
581 this.contentWindow = w;
582 //window.console.log(w);
lazyboy 2014/09/17 18:24:01 Remove
Fady Samuel 2014/09/17 20:25:47 Done.
583 }.bind(this));
579 }.bind(this), 0); 584 }.bind(this), 0);
580 } 585 }
581 586
582 return; 587 return;
583 } 588 }
584 589
585 // This observer monitors mutations to attributes of the BrowserPlugin and 590 // This observer monitors mutations to attributes of the BrowserPlugin and
586 // updates the <webview> attributes accordingly. 591 // updates the <webview> attributes accordingly.
587 // |newValue| is null if the attribute |name| has been removed. 592 // |newValue| is null if the attribute |name| has been removed.
588 if (newValue != null) { 593 if (newValue != null) {
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 877
873 if (!this.isPluginInRenderTree()) { 878 if (!this.isPluginInRenderTree()) {
874 this.deferredAttachState = {isNewWindow: isNewWindow}; 879 this.deferredAttachState = {isNewWindow: isNewWindow};
875 return true; 880 return true;
876 } 881 }
877 882
878 this.deferredAttachState = null; 883 this.deferredAttachState = null;
879 return guestViewInternalNatives.AttachGuest( 884 return guestViewInternalNatives.AttachGuest(
880 this.internalInstanceId, 885 this.internalInstanceId,
881 this.guestInstanceId, 886 this.guestInstanceId,
882 params); 887 params, function(w) {
888 this.contentWindow = w;
889 }.bind(this));
883 }; 890 };
884 891
885 // Registers browser plugin <object> custom element. 892 // Registers browser plugin <object> custom element.
886 function registerBrowserPluginElement() { 893 function registerBrowserPluginElement() {
887 var proto = Object.create(HTMLObjectElement.prototype); 894 var proto = Object.create(HTMLObjectElement.prototype);
888 895
889 proto.createdCallback = function() { 896 proto.createdCallback = function() {
890 this.setAttribute('type', 'application/browser-plugin'); 897 this.setAttribute('type', 'application/browser-plugin');
891 this.setAttribute('id', 'browser-plugin-' + IdGenerator.GetNextId()); 898 this.setAttribute('id', 'browser-plugin-' + IdGenerator.GetNextId());
892 // The <object> node fills in the <webview> container. 899 // The <object> node fills in the <webview> container.
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 1045
1039 /** 1046 /**
1040 * Implemented when the experimental API is available. 1047 * Implemented when the experimental API is available.
1041 * @private 1048 * @private
1042 */ 1049 */
1043 WebViewInternal.prototype.setupExperimentalContextMenus = function() { 1050 WebViewInternal.prototype.setupExperimentalContextMenus = function() {
1044 }; 1051 };
1045 1052
1046 exports.WebView = WebView; 1053 exports.WebView = WebView;
1047 exports.WebViewInternal = WebViewInternal; 1054 exports.WebViewInternal = WebViewInternal;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698