Index: extensions/renderer/resources/guest_view/web_view.js |
diff --git a/extensions/renderer/resources/guest_view/web_view.js b/extensions/renderer/resources/guest_view/web_view.js |
index 32f99f1ac59789a9a57203a4f8e2dd6431c89ea2..d3dcb946a234eca1168a10071b4514359139ae10 100644 |
--- a/extensions/renderer/resources/guest_view/web_view.js |
+++ b/extensions/renderer/resources/guest_view/web_view.js |
@@ -13,6 +13,11 @@ 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'); |
@@ -63,6 +68,7 @@ WebViewImpl.setupElement = function(proto) { |
// Initiates navigation once the <webview> element is attached to the DOM. |
WebViewImpl.prototype.onElementAttached = function() { |
+ // FIXME: Not sure about this one. |
this.attributes[WebViewConstants.ATTRIBUTE_SRC].parse(); |
Fady Samuel
2015/03/04 20:44:48
This code is old. What's the problem here?
|
}; |
@@ -196,6 +202,8 @@ WebViewImpl.prototype.onLoadCommit = function( |
this.entryCount = entryCount; |
this.processId = processId; |
var oldValue = this.attributes[WebViewConstants.ATTRIBUTE_SRC].getValue(); |
+ LOG('WebViewImpl.onLoadCommit, oldValue = ' + oldValue + |
+ ', newValue = ' + newValue); |
var newValue = url; |
if (isTopLevel && (oldValue != newValue)) { |
// Touching the src attribute triggers a navigation. To avoid |
@@ -230,6 +238,36 @@ WebViewImpl.prototype.attachWindow = function(opt_guestInstanceId) { |
this.guest = new GuestView('webview', opt_guestInstanceId); |
} |
+ /* |
+ if (!this.internalInstanceId) { |
+ return true; |
+ } |
+ */ |
+ |
+ LOG('Guest will start attach'); |
+ var generatedId = IdGenerator.GetNextId(); |
+ this.internalInstanceId = generatedId; |
+ |
+ LOG('this.guest.getId() = ' + this.guest.getId()); |
+ var ret = GuestViewInternalNatives.AttachIframeGuest( |
+ this.internalInstanceId, this.guest.getId(), |
+ this.getBrowserPluginElement(), function(contentWindow) { |
+ LOG(contentWindow); |
+ this.guest.setContentWindow(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); |
Fady Samuel
2015/03/04 20:44:48
This totally breaks the new window API.
|
+ }.bind(this), 0); |
+ |
+ return true; |
+ // Note: Following stuff IGNORED. |
return GuestViewContainer.prototype.attachWindow.call(this); |
}; |
@@ -244,6 +282,7 @@ WebViewImpl.prototype.executeCode = function(func, args) { |
if (this.baseUrlForDataUrl != '') { |
webviewSrc = this.baseUrlForDataUrl; |
} |
+ LOG('webviewSrc: ' + webviewSrc); |
args = $Array.concat([this.guest.getId(), webviewSrc], |
$Array.slice(args)); |