Index: extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc |
diff --git a/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc b/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc |
index a58e021b4ba8fe95482c2d568067581fc057d036..0b62a81733c3961b7283c27c77dfd388c526e03b 100644 |
--- a/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc |
+++ b/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc |
@@ -213,8 +213,17 @@ bool MimeHandlerViewGuest::PreHandleGestureEvent( |
content::JavaScriptDialogManager* |
MimeHandlerViewGuest::GetJavaScriptDialogManager( |
WebContents* source) { |
+ // WebContentsDelegates often service multiple WebContentses, and use the |
+ // WebContents* parameter to tell which WebContents made the request. If we |
+ // pass in our own pointer to the delegate call, the delegate will be asked, |
+ // "What's the JavaScriptDialogManager of this WebContents for which you are |
+ // not a delegate?" And it won't be able to answer that. |
+ // |
+ // So we pretend to be our owner WebContents, but only for the request to |
+ // obtain the JavaScriptDialogManager. During calls to the |
+ // JavaScriptDialogManager we will be honest about who we are. |
return owner_web_contents()->GetDelegate()->GetJavaScriptDialogManager( |
- web_contents()); |
+ owner_web_contents()); |
} |
bool MimeHandlerViewGuest::SaveFrame(const GURL& url, |