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 618823002: GuestView: Move lifetime management out of content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix extensionoptions cleanup Created 6 years, 2 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 * Resets some state upon reattaching <webview> element to the DOM. 135 * Resets some state upon reattaching <webview> element to the DOM.
136 */ 136 */
137 WebViewInternal.prototype.reset = function() { 137 WebViewInternal.prototype.reset = function() {
138 // If guestInstanceId is defined then the <webview> has navigated and has 138 // If guestInstanceId is defined then the <webview> has navigated and has
139 // already picked up a partition ID. Thus, we need to reset the initialization 139 // already picked up a partition ID. Thus, we need to reset the initialization
140 // state. However, it may be the case that beforeFirstNavigation is false BUT 140 // state. However, it may be the case that beforeFirstNavigation is false BUT
141 // guestInstanceId has yet to be initialized. This means that we have not 141 // guestInstanceId has yet to be initialized. This means that we have not
142 // heard back from createGuest yet. We will not reset the flag in this case so 142 // heard back from createGuest yet. We will not reset the flag in this case so
143 // that we don't end up allocating a second guest. 143 // that we don't end up allocating a second guest.
144 if (this.guestInstanceId) { 144 if (this.guestInstanceId) {
145 GuestViewInternal.destroyGuest(this.guestInstanceId);
lfg 2014/09/30 18:59:27 If a webview element is attached and immediatelly
Fady Samuel 2014/09/30 22:50:03 Fixed..I think but this code is VERY brittle now.
lfg 2014/09/30 23:29:42 Acknowledged.
145 this.guestInstanceId = undefined; 146 this.guestInstanceId = undefined;
146 this.beforeFirstNavigation = true; 147 this.beforeFirstNavigation = true;
147 this.validPartitionId = true; 148 this.validPartitionId = true;
148 this.partition.validPartitionId = true; 149 this.partition.validPartitionId = true;
149 this.contentWindow = null; 150 this.contentWindow = null;
150 } 151 }
151 this.internalInstanceId = 0; 152 this.internalInstanceId = 0;
152 }; 153 };
153 154
154 // Sets <webview>.request property. 155 // Sets <webview>.request property.
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 536
536 /** 537 /**
537 * @private 538 * @private
538 */ 539 */
539 WebViewInternal.prototype.handleBrowserPluginAttributeMutation = 540 WebViewInternal.prototype.handleBrowserPluginAttributeMutation =
540 function(name, oldValue, newValue) { 541 function(name, oldValue, newValue) {
541 if (name == 'internalinstanceid' && !oldValue && !!newValue) { 542 if (name == 'internalinstanceid' && !oldValue && !!newValue) {
542 this.browserPluginNode.removeAttribute('internalinstanceid'); 543 this.browserPluginNode.removeAttribute('internalinstanceid');
543 this.internalInstanceId = parseInt(newValue); 544 this.internalInstanceId = parseInt(newValue);
544 545
545 if (!this.deferredAttachState) {
546 this.parseAttributes();
547 return;
548 }
549
550 if (!!this.guestInstanceId && this.guestInstanceId != 0) { 546 if (!!this.guestInstanceId && this.guestInstanceId != 0) {
551 window.setTimeout(function() { 547 var isNewWindow = this.deferredAttachState ?
552 var isNewWindow = this.deferredAttachState ? 548 this.deferredAttachState.isNewWindow : false;
553 this.deferredAttachState.isNewWindow : false; 549 var params = this.buildAttachParams(isNewWindow);
554 var params = this.buildAttachParams(isNewWindow); 550 guestViewInternalNatives.AttachGuest(
555 guestViewInternalNatives.AttachGuest( 551 this.internalInstanceId,
556 this.internalInstanceId, 552 this.guestInstanceId,
557 this.guestInstanceId, 553 params,
558 params, 554 function(w) {
559 function(w) { 555 this.contentWindow = w;
560 this.contentWindow = w; 556 }.bind(this)
561 }.bind(this) 557 );
562 );
563 }.bind(this), 0);
564 } 558 }
565 559
566 return; 560 return;
567 } 561 }
568 }; 562 };
569 563
570 WebViewInternal.prototype.onSizeChanged = function(webViewEvent) { 564 WebViewInternal.prototype.onSizeChanged = function(webViewEvent) {
571 var newWidth = webViewEvent.newWidth; 565 var newWidth = webViewEvent.newWidth;
572 var newHeight = webViewEvent.newHeight; 566 var newHeight = webViewEvent.newHeight;
573 567
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 690
697 WebViewInternal.prototype.onFrameNameChanged = function(name) { 691 WebViewInternal.prototype.onFrameNameChanged = function(name) {
698 this.name = name || ''; 692 this.name = name || '';
699 if (this.name === '') { 693 if (this.name === '') {
700 this.webviewNode.removeAttribute('name'); 694 this.webviewNode.removeAttribute('name');
701 } else { 695 } else {
702 this.webviewNode.setAttribute('name', this.name); 696 this.webviewNode.setAttribute('name', this.name);
703 } 697 }
704 }; 698 };
705 699
706 WebViewInternal.prototype.onPluginDestroyed = function() {
707 this.reset();
708 };
709
710 WebViewInternal.prototype.dispatchEvent = function(webViewEvent) { 700 WebViewInternal.prototype.dispatchEvent = function(webViewEvent) {
711 return this.webviewNode.dispatchEvent(webViewEvent); 701 return this.webviewNode.dispatchEvent(webViewEvent);
712 }; 702 };
713 703
714 /** 704 /**
715 * Adds an 'on<event>' property on the webview, which can be used to set/unset 705 * Adds an 'on<event>' property on the webview, which can be used to set/unset
716 * an event handler. 706 * an event handler.
717 */ 707 */
718 WebViewInternal.prototype.setupEventProperty = function(eventName) { 708 WebViewInternal.prototype.setupEventProperty = function(eventName) {
719 var propertyName = 'on' + eventName.toLowerCase(); 709 var propertyName = 'on' + eventName.toLowerCase();
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 990
1001 /** 991 /**
1002 * Implemented when the experimental API is available. 992 * Implemented when the experimental API is available.
1003 * @private 993 * @private
1004 */ 994 */
1005 WebViewInternal.prototype.setupExperimentalContextMenus = function() { 995 WebViewInternal.prototype.setupExperimentalContextMenus = function() {
1006 }; 996 };
1007 997
1008 exports.WebView = WebView; 998 exports.WebView = WebView;
1009 exports.WebViewInternal = WebViewInternal; 999 exports.WebViewInternal = WebViewInternal;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698