Index: extensions/renderer/resources/guest_view/web_view/web_view.js |
diff --git a/extensions/renderer/resources/guest_view/web_view/web_view.js b/extensions/renderer/resources/guest_view/web_view/web_view.js |
index fd0e45c81b01e04239d6704d51194cc3d1cfff2d..8ec437d43206a24494c4e32e487ccefbd9832813 100644 |
--- a/extensions/renderer/resources/guest_view/web_view/web_view.js |
+++ b/extensions/renderer/resources/guest_view/web_view/web_view.js |
@@ -14,11 +14,17 @@ var WebViewConstants = require('webViewConstants').WebViewConstants; |
var WebViewEvents = require('webViewEvents').WebViewEvents; |
var WebViewInternal = require('webViewInternal').WebViewInternal; |
+var IdGenerator = requireNative('id_generator'); |
+var GuestViewInternalNatives = requireNative('guest_view_internal'); |
+ |
+var LOG = function(msg) { window.console.log(msg); }; |
+ |
// Represents the internal state of <webview>. |
function WebViewImpl(webviewElement) { |
GuestViewContainer.call(this, webviewElement, 'webview'); |
this.cachedZoom = 1; |
this.setupElementProperties(); |
+ this.isSitePerProcess = GuestViewInternalNatives.IsSitePerProcess(); |
new WebViewEvents(this, this.viewInstanceId); |
} |
@@ -59,6 +65,7 @@ WebViewImpl.prototype.onElementAttached = function() { |
for (var i in this.attributes) { |
this.attributes[i].dirty = true; |
} |
+ // FIXME: Not sure about this one. |
for (var i in this.attributes) { |
this.attributes[i].attach(); |
} |
@@ -92,7 +99,11 @@ WebViewImpl.prototype.setupElementProperties = function() { |
// dynamic getter value. |
Object.defineProperty(this.element, 'contentWindow', { |
get: function() { |
- return this.guest.getContentWindow(); |
+ if (this.isSitePerProcess) { |
+ return this.getBrowserPluginElement().contentWindow; |
+ } else { |
+ return this.guest.getContentWindow(); |
+ } |
}.bind(this), |
// No setter. |
enumerable: true |
@@ -189,9 +200,43 @@ WebViewImpl.prototype.attachWindow = function(opt_guestInstanceId) { |
this.guest = new GuestView('webview', opt_guestInstanceId); |
} |
+ if (this.isSitePerProcess) { |
+ return this.attachForSitePerProcess(); |
+ } |
+ |
+ if (!this.internalInstanceId) { |
+ return true; |
+ } |
+ |
return GuestViewContainer.prototype.attachWindow.call(this); |
}; |
+WebViewImpl.prototype.attachForSitePerProcess = function() { |
+ LOG('Guest will start attach'); |
+ var generatedId = IdGenerator.GetNextId(); |
+ this.internalInstanceId = generatedId; |
+ |
+ LOG('this.guest.getId() = ' + this.guest.getId()); |
+ window.console.log(this.getBrowserPluginElement()); |
+ var ret = GuestViewInternalNatives.AttachIframeGuest( |
+ this.internalInstanceId, this.guest.getId(), |
+ this.getBrowserPluginElement().contentWindow, function() { |
+ // No need to set contentWindow, we will use <iframe>.contentWindow. |
+ }.bind(this)); |
+ |
+ LOG('guestViewInternalNatives.AttachIframeGuest status: ' + ret); |
+ |
+ window.setTimeout(function() { |
+ LOG('<webview>: navigate'); |
+ var src = |
+ this.attributes[WebViewConstants.ATTRIBUTE_SRC].getValue(); |
+ WebViewInternal.navigate( |
+ this.guest.getId(), src); |
+ }.bind(this), 0); |
+ |
+ return true; |
+}; |
+ |
// Shared implementation of executeScript() and insertCSS(). |
WebViewImpl.prototype.executeCode = function(func, args) { |
if (!this.guest.getId()) { |