| 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 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 ConstrainedWindowMac::ConstrainedWindowMac( | 22 ConstrainedWindowMac::ConstrainedWindowMac( |
| 23 ConstrainedWindowMacDelegate* delegate, | 23 ConstrainedWindowMacDelegate* delegate, |
| 24 content::WebContents* web_contents, | 24 content::WebContents* web_contents, |
| 25 id<ConstrainedWindowSheet> sheet) | 25 id<ConstrainedWindowSheet> sheet) |
| 26 : delegate_(delegate), | 26 : delegate_(delegate), |
| 27 web_contents_(NULL), | 27 web_contents_(NULL), |
| 28 sheet_([sheet retain]), | 28 sheet_([sheet retain]), |
| 29 shown_(false) { | 29 shown_(false) { |
| 30 DCHECK(web_contents); | 30 DCHECK(web_contents); |
| 31 WebViewGuest* web_view_guest = WebViewGuest::FromWebContents(web_contents); | 31 extensions::WebViewGuest* web_view_guest = |
| 32 extensions::WebViewGuest::FromWebContents(web_contents); |
| 32 // For embedded WebContents, use the embedder's WebContents for constrained | 33 // For embedded WebContents, use the embedder's WebContents for constrained |
| 33 // window. | 34 // window. |
| 34 web_contents_ = web_view_guest && web_view_guest->embedder_web_contents() ? | 35 web_contents_ = web_view_guest && web_view_guest->embedder_web_contents() ? |
| 35 web_view_guest->embedder_web_contents() : web_contents; | 36 web_view_guest->embedder_web_contents() : web_contents; |
| 36 DCHECK(sheet_.get()); | 37 DCHECK(sheet_.get()); |
| 37 web_modal::PopupManager* popup_manager = | 38 web_modal::PopupManager* popup_manager = |
| 38 web_modal::PopupManager::FromWebContents(web_contents_); | 39 web_modal::PopupManager::FromWebContents(web_contents_); |
| 39 if (popup_manager) | 40 if (popup_manager) |
| 40 popup_manager->ShowModalDialog(this, web_contents_); | 41 popup_manager->ShowModalDialog(this, web_contents_); |
| 41 } | 42 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 93 |
| 93 NSWindow* ConstrainedWindowMac::GetParentWindow() const { | 94 NSWindow* ConstrainedWindowMac::GetParentWindow() const { |
| 94 // Tab contents in a tabbed browser may not be inside a window. For this | 95 // Tab contents in a tabbed browser may not be inside a window. For this |
| 95 // reason use a browser window if possible. | 96 // reason use a browser window if possible. |
| 96 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); | 97 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); |
| 97 if (browser) | 98 if (browser) |
| 98 return browser->window()->GetNativeWindow(); | 99 return browser->window()->GetNativeWindow(); |
| 99 | 100 |
| 100 return web_contents_->GetTopLevelNativeWindow(); | 101 return web_contents_->GetTopLevelNativeWindow(); |
| 101 } | 102 } |
| OLD | NEW |