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

Unified Diff: chrome/renderer/resources/extensions/web_view_events.js

Issue 558813002: <webview>: Fix an issue with destroying an opener that has unattached guests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix setTimeout call 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/resources/extensions/web_view_events.js
diff --git a/chrome/renderer/resources/extensions/web_view_events.js b/chrome/renderer/resources/extensions/web_view_events.js
index 1a7a504bd7ba6479576fb7a465df79bfdc3ed3a9..88a78adaf0e3df12a13ddc683c72d9a6a600cead 100644
--- a/chrome/renderer/resources/extensions/web_view_events.js
+++ b/chrome/renderer/resources/extensions/web_view_events.js
@@ -456,17 +456,31 @@ WebViewEvents.prototype.handleNewWindowEvent = function(event, webViewEvent) {
if (!attached) {
window.console.error(ERROR_MSG_NEWWINDOW_UNABLE_TO_ATTACH);
}
+
+ var guestInstanceId = getGuestInstanceId();
+ if (!guestInstanceId) {
+ // If the opener is already gone, then we won't have its
+ // guestInstanceId.
+ return;
+ }
+
// If the object being passed into attach is not a valid <webview>
// then we will fail and it will be treated as if the new window
// was rejected. The permission API plumbing is used here to clean
// up the state created for the new window if attaching fails.
WebView.setPermission(
- getGuestInstanceId(), requestId, attached ? 'allow' : 'deny');
+ guestInstanceId, requestId, attached ? 'allow' : 'deny');
}, 0);
},
discard: function() {
validateCall();
- WebView.setPermission(getGuestInstanceId(), requestId, 'deny');
+ var guestInstanceId = getGuestInstanceId();
+ if (!guestInstanceId) {
+ // If the opener is already gone, then we won't have its
+ // guestInstanceId.
+ return;
+ }
+ WebView.setPermission(guestInstanceId, requestId, 'deny');
}
};
webViewEvent.window = windowObj;
@@ -483,13 +497,21 @@ WebViewEvents.prototype.handleNewWindowEvent = function(event, webViewEvent) {
if (actionTaken) {
return;
}
+
+ var guestInstanceId = getGuestInstanceId();
+ if (!guestInstanceId) {
+ // If the opener is already gone, then we won't have its
+ // guestInstanceId.
+ return;
+ }
+
WebView.setPermission(
- getGuestInstanceId(), requestId, 'default', '', function(allowed) {
- if (allowed) {
- return;
- }
- showWarningMessage();
- });
+ guestInstanceId, requestId, 'default', '', function(allowed) {
+ if (allowed) {
+ return;
+ }
+ showWarningMessage();
+ });
});
} else {
actionTaken = true;

Powered by Google App Engine
This is Rietveld 408576698