| Index: chrome/browser/ui/browser.cc
|
| diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
|
| index 8cd337440a1443a2a048d6ba99b7108cc5965f7a..b2736f6655ce8444f0aa68a50af2f04f8e5858b3 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,13 @@ Browser::Browser(const CreateParams& params)
|
| }
|
|
|
| fullscreen_controller_.reset(new FullscreenController(this));
|
| +
|
| + // Must be initialized after window_.
|
| + // This would be a DCHECK but tests.
|
| + if (GetWebContentsModalDialogHost()) {
|
| + popup_manager_.reset(new web_modal::PopupManager(
|
| + GetWebContentsModalDialogHost()));
|
| + }
|
| }
|
|
|
| Browser::~Browser() {
|
| @@ -890,6 +898,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 +943,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 +961,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);
|
| }
|
|
|
|
|