Index: extensions/browser/extension_host.cc |
diff --git a/extensions/browser/extension_host.cc b/extensions/browser/extension_host.cc |
index 2f0572e5330abb1ec9c2c937c011f5e162e71fc3..68515044edbe3727c795ef9ed41b824a3b92ab72 100644 |
--- a/extensions/browser/extension_host.cc |
+++ b/extensions/browser/extension_host.cc |
@@ -362,6 +362,12 @@ void ExtensionHost::OnDecrementLazyKeepaliveCount() { |
pm->DecrementLazyKeepaliveCount(extension()); |
} |
+// ExtensionFunctionDispatcher::Delegate |
+ |
+content::WebContents* ExtensionHost::GetAssociatedWebContents() const { |
+ return host_contents(); |
+} |
+ |
// content::WebContentsObserver |
void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { |
@@ -392,18 +398,22 @@ void ExtensionHost::AddNewContents(WebContents* source, |
// the case of extensions in 'spanning' incognito mode, they can mismatch. |
// We don't want to end up putting a normal tab into an incognito window, or |
// vice versa. |
+ // |
// Note that we don't do this for popup windows, because we need to associate |
// those with their extension_app_id. |
if (disposition != NEW_POPUP) { |
- WebContents* associated_contents = GetAssociatedWebContents(); |
- if (associated_contents && |
- associated_contents->GetBrowserContext() == |
+ WebContents* visible_contents = GetVisibleWebContents(); |
+ if (visible_contents && |
+ visible_contents->GetBrowserContext() == |
new_contents->GetBrowserContext()) { |
- WebContentsDelegate* delegate = associated_contents->GetDelegate(); |
+ WebContentsDelegate* delegate = visible_contents->GetDelegate(); |
if (delegate) { |
- delegate->AddNewContents( |
- associated_contents, new_contents, disposition, initial_pos, |
- user_gesture, was_blocked); |
+ delegate->AddNewContents(visible_contents, |
+ new_contents, |
+ disposition, |
+ initial_pos, |
+ user_gesture, |
+ was_blocked); |
return; |
} |
} |