| Index: chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm
|
| diff --git a/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm b/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm
|
| index 510402e87e5f70efec6eef06cc40d403eab1f815..16f755c1971d44e92bfc34f6131b0128f3a3b67f 100644
|
| --- a/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm
|
| +++ b/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm
|
| @@ -11,57 +11,33 @@
|
| #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h"
|
| #import "chrome/browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.h"
|
| #include "components/guest_view/browser/guest_view_base.h"
|
| +#include "components/web_modal/web_contents_modal_dialog_manager.h"
|
| #include "content/public/browser/browser_thread.h"
|
|
|
| using web_modal::WebContentsModalDialogManager;
|
| -
|
| -std::unique_ptr<ConstrainedWindowMac> CreateAndShowWebModalDialogMac(
|
| - ConstrainedWindowMacDelegate* delegate,
|
| - content::WebContents* web_contents,
|
| - id<ConstrainedWindowSheet> sheet) {
|
| - ConstrainedWindowMac* window =
|
| - new ConstrainedWindowMac(delegate, web_contents, sheet);
|
| - window->ShowWebContentsModalDialog();
|
| - return std::unique_ptr<ConstrainedWindowMac>(window);
|
| -}
|
| -
|
| -std::unique_ptr<ConstrainedWindowMac> CreateWebModalDialogMac(
|
| - ConstrainedWindowMacDelegate* delegate,
|
| - content::WebContents* web_contents,
|
| - id<ConstrainedWindowSheet> sheet) {
|
| - return std::unique_ptr<ConstrainedWindowMac>(
|
| - new ConstrainedWindowMac(delegate, web_contents, sheet));
|
| -}
|
|
|
| ConstrainedWindowMac::ConstrainedWindowMac(
|
| ConstrainedWindowMacDelegate* delegate,
|
| content::WebContents* web_contents,
|
| id<ConstrainedWindowSheet> sheet)
|
| - : delegate_(delegate),
|
| - sheet_([sheet retain]) {
|
| + : delegate_(delegate) {
|
| DCHECK(sheet);
|
|
|
| // |web_contents| may be embedded within a chain of nested GuestViews. If it
|
| // is, follow the chain of embedders to the outermost WebContents and use it.
|
| - web_contents_ =
|
| + web_contents =
|
| guest_view::GuestViewBase::GetTopLevelWebContents(web_contents);
|
|
|
| - native_manager_.reset(
|
| - new SingleWebContentsDialogManagerCocoa(this, sheet_.get(),
|
| - GetDialogManager()));
|
| + auto manager = WebContentsModalDialogManager::FromWebContents(web_contents);
|
| + scoped_ptr<SingleWebContentsDialogManagerCocoa> native_manager(
|
| + new SingleWebContentsDialogManagerCocoa(this, sheet, manager));
|
| + manager->ShowDialogWithManager([sheet sheetWindow],
|
| + std::move(native_manager));
|
| }
|
|
|
| ConstrainedWindowMac::~ConstrainedWindowMac() {
|
| CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| - native_manager_.reset();
|
| DCHECK(!manager_);
|
| -}
|
| -
|
| -void ConstrainedWindowMac::ShowWebContentsModalDialog() {
|
| - scoped_ptr<SingleWebContentsDialogManagerCocoa> dialog_manager;
|
| - dialog_manager.reset(native_manager_.release());
|
| - GetDialogManager()->ShowDialogWithManager(
|
| - [sheet_.get() sheetWindow], std::move(dialog_manager));
|
| }
|
|
|
| void ConstrainedWindowMac::CloseWebContentsModalDialog() {
|
| @@ -73,13 +49,3 @@
|
| if (delegate_)
|
| delegate_->OnConstrainedWindowClosed(this);
|
| }
|
| -
|
| -bool ConstrainedWindowMac::DialogWasShown() {
|
| - // If the dialog was shown, |native_manager_| would have been released.
|
| - return !native_manager_;
|
| -}
|
| -
|
| -WebContentsModalDialogManager* ConstrainedWindowMac::GetDialogManager() {
|
| - DCHECK(web_contents_);
|
| - return WebContentsModalDialogManager::FromWebContents(web_contents_);
|
| -}
|
|
|