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 3c9dc5916e63b0fd7e4038649bdb239a165140a3..f132e5647ffea0e6a2bcaf8d7dc6654d46235946 100644 |
--- a/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm |
+++ b/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm |
@@ -19,6 +19,52 @@ |
using web_modal::WebContentsModalDialogManager; |
using web_modal::NativeWebContentsModalDialog; |
+namespace { |
+ |
+class NativeWebContentsModalDialogManagerCocoa |
+ : public web_modal::SingleWebContentsDialogManager { |
+ public: |
+ NativeWebContentsModalDialogManagerCocoa( |
+ ConstrainedWindowMac* owner) |
+ : owner_(owner) { |
+ DCHECK(owner); |
+ } |
+ |
+ ~NativeWebContentsModalDialogManagerCocoa() override {} |
+ |
+ // SingleWebContentsDialogManager overrides |
+ void Show() override { |
+ owner_->ShowWebContentsModalDialog(); |
+ } |
+ |
+ void Hide() override {} |
+ |
+ void Close() override { |
+ owner_->CloseWebContentsModalDialog(); |
+ } |
+ |
+ void Focus() override { |
+ owner_->FocusWebContentsModalDialog(); |
+ } |
+ |
+ void Pulse() override { |
+ owner_->PulseWebContentsModalDialog(); |
+ } |
+ |
+ void HostChanged(web_modal::WebContentsModalDialogHost* new_host) override {} |
+ |
+ NativeWebContentsModalDialog dialog() override { |
+ return owner_->GetNativeDialog(); |
+ } |
+ |
+ private: |
+ ConstrainedWindowMac* owner_; // Weak. Owns this. |
+ |
+ DISALLOW_COPY_AND_ASSIGN(NativeWebContentsModalDialogManagerCocoa); |
+}; |
+ |
+} // namespace |
+ |
ConstrainedWindowMac::ConstrainedWindowMac( |
ConstrainedWindowMacDelegate* delegate, |
content::WebContents* web_contents, |
@@ -35,10 +81,13 @@ ConstrainedWindowMac::ConstrainedWindowMac( |
web_contents_ = guest_view && guest_view->embedder_web_contents() ? |
guest_view->embedder_web_contents() : web_contents; |
DCHECK(sheet_.get()); |
- web_modal::PopupManager* popup_manager = |
- web_modal::PopupManager::FromWebContents(web_contents_); |
- if (popup_manager) |
- popup_manager->ShowModalDialog(this, web_contents_); |
+ WebContentsModalDialogManager* wm_manager = |
+ WebContentsModalDialogManager::FromWebContents(web_contents); |
+ if (wm_manager) { |
+ scoped_ptr<NativeWebContentsModalDialogManagerCocoa> manager( |
+ new NativeWebContentsModalDialogManagerCocoa(this)); |
+ wm_manager->ShowDialogWithManager(GetNativeDialog(), manager.Pass()); |
+ } |
} |
ConstrainedWindowMac::~ConstrainedWindowMac() { |
@@ -68,12 +117,12 @@ void ConstrainedWindowMac::CloseWebContentsModalDialog() { |
WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
WebContentsModalDialogManager::FromWebContents(web_contents_); |
- // Will result in the delegate being deleted. |
- if (delegate_) |
- delegate_->OnConstrainedWindowClosed(this); |
+ // Will cause our NativeWebContentsModalDialogManagerCocoa to be deleted. |
+ web_contents_modal_dialog_manager->WillClose(GetNativeDialog()); |
// Will cause this object to be deleted. |
- web_contents_modal_dialog_manager->WillClose(this); |
+ if (delegate_) |
+ delegate_->OnConstrainedWindowClosed(this); |
} |
void ConstrainedWindowMac::FocusWebContentsModalDialog() { |
@@ -88,5 +137,5 @@ NativeWebContentsModalDialog ConstrainedWindowMac::GetNativeDialog() { |
// TODO(wittman): Ultimately this should be changed to the |
// ConstrainedWindowSheet pointer, in conjunction with the corresponding |
// changes to NativeWebContentsModalDialogManagerCocoa. |
- return this; |
+ return [sheet_ sheetWindow]; |
} |