Index: chrome/browser/ui/browser.cc |
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc |
index 8cd337440a1443a2a048d6ba99b7108cc5965f7a..188adbfc998acb4fec365ae62649f86b984393f7 100644 |
--- a/chrome/browser/ui/browser.cc |
+++ b/chrome/browser/ui/browser.cc |
@@ -150,6 +150,7 @@ |
#include "components/bookmarks/browser/bookmark_utils.h" |
#include "components/google/core/browser/google_url_tracker.h" |
#include "components/startup_metric_utils/startup_metric_utils.h" |
+#include "components/web_modal/popup_manager.h" |
#include "components/web_modal/web_contents_modal_dialog_manager.h" |
#include "content/public/browser/devtools_manager.h" |
#include "content/public/browser/download_item.h" |
@@ -442,6 +443,12 @@ Browser::Browser(const CreateParams& params) |
} |
fullscreen_controller_.reset(new FullscreenController(this)); |
+ |
+ // Must be initialized after window_. |
+ // This would DCHECK on presence of the dialog host but tests |
+ // may not implement, and currently Cocoa does not either. |
+ popup_manager_.reset(new web_modal::PopupManager( |
+ GetWebContentsModalDialogHost())); |
} |
Browser::~Browser() { |
@@ -890,6 +897,10 @@ void Browser::TabInsertedAt(WebContents* contents, |
int index, |
bool foreground) { |
SetAsDelegate(contents, this); |
+ |
+ if (popup_manager_.get()) |
+ popup_manager_->RegisterWith(contents); |
+ |
SessionTabHelper* session_tab_helper = |
SessionTabHelper::FromWebContents(contents); |
session_tab_helper->SetWindowID(session_id()); |
@@ -931,6 +942,9 @@ void Browser::TabClosingAt(TabStripModel* tab_strip_model, |
content::Source<NavigationController>(&contents->GetController()), |
content::NotificationService::NoDetails()); |
+ if (popup_manager_.get()) |
+ popup_manager_->UnregisterWith(contents); |
+ |
// Sever the WebContents' connection back to us. |
SetAsDelegate(contents, NULL); |
} |
@@ -946,6 +960,10 @@ void Browser::TabDetachedAt(WebContents* contents, int index) { |
session_service->SetSelectedTabInWindow(session_id(), |
old_active_index - 1); |
} |
+ |
+ if (popup_manager_.get()) |
+ popup_manager_->UnregisterWith(contents); |
+ |
TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH); |
} |