| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" | 5 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/guest_view/web_view/web_view_guest.h" | 8 #include "chrome/browser/guest_view/web_view/web_view_guest.h" |
| 9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
| 10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 web_contents_(NULL), | 26 web_contents_(NULL), |
| 27 sheet_([sheet retain]), | 27 sheet_([sheet retain]), |
| 28 shown_(false) { | 28 shown_(false) { |
| 29 DCHECK(web_contents); | 29 DCHECK(web_contents); |
| 30 WebViewGuest* web_view_guest = WebViewGuest::FromWebContents(web_contents); | 30 WebViewGuest* web_view_guest = WebViewGuest::FromWebContents(web_contents); |
| 31 // For embedded WebContents, use the embedder's WebContents for constrained | 31 // For embedded WebContents, use the embedder's WebContents for constrained |
| 32 // window. | 32 // window. |
| 33 web_contents_ = web_view_guest && web_view_guest->embedder_web_contents() ? | 33 web_contents_ = web_view_guest && web_view_guest->embedder_web_contents() ? |
| 34 web_view_guest->embedder_web_contents() : web_contents; | 34 web_view_guest->embedder_web_contents() : web_contents; |
| 35 DCHECK(sheet_.get()); | 35 DCHECK(sheet_.get()); |
| 36 WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 36 web_modal::PopupManager* popup_manager = |
| 37 WebContentsModalDialogManager::FromWebContents(web_contents_); | 37 web_modal::PopupManager::FromWebContents(web_contents_); |
| 38 web_contents_modal_dialog_manager->ShowModalDialog(this); | 38 if (popup_manager) |
| 39 popup_manager->ShowModalDialog(this, web_contents); |
| 39 } | 40 } |
| 40 | 41 |
| 41 ConstrainedWindowMac::~ConstrainedWindowMac() { | 42 ConstrainedWindowMac::~ConstrainedWindowMac() { |
| 42 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 43 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 43 } | 44 } |
| 44 | 45 |
| 45 void ConstrainedWindowMac::ShowWebContentsModalDialog() { | 46 void ConstrainedWindowMac::ShowWebContentsModalDialog() { |
| 46 if (shown_) | 47 if (shown_) |
| 47 return; | 48 return; |
| 48 | 49 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 91 |
| 91 NSWindow* ConstrainedWindowMac::GetParentWindow() const { | 92 NSWindow* ConstrainedWindowMac::GetParentWindow() const { |
| 92 // Tab contents in a tabbed browser may not be inside a window. For this | 93 // Tab contents in a tabbed browser may not be inside a window. For this |
| 93 // reason use a browser window if possible. | 94 // reason use a browser window if possible. |
| 94 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); | 95 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); |
| 95 if (browser) | 96 if (browser) |
| 96 return browser->window()->GetNativeWindow(); | 97 return browser->window()->GetNativeWindow(); |
| 97 | 98 |
| 98 return web_contents_->GetTopLevelNativeWindow(); | 99 return web_contents_->GetTopLevelNativeWindow(); |
| 99 } | 100 } |
| OLD | NEW |