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/ui/browser_finder.h" | 8 #include "chrome/browser/ui/browser_finder.h" |
9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h" | 10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h" |
11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con
troller.h" | 11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con
troller.h" |
12 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 12 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
13 #include "components/web_modal/popup_manager.h" | 13 #include "components/web_modal/popup_manager.h" |
14 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 14 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
17 #include "extensions/browser/guest_view/web_view/web_view_guest.h" | 17 #include "extensions/browser/guest_view/guest_view_base.h" |
18 | 18 |
19 using web_modal::WebContentsModalDialogManager; | 19 using web_modal::WebContentsModalDialogManager; |
20 using web_modal::NativeWebContentsModalDialog; | 20 using web_modal::NativeWebContentsModalDialog; |
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 extensions::WebViewGuest* web_view_guest = | 31 extensions::GuestViewBase* guest_view = |
32 extensions::WebViewGuest::FromWebContents(web_contents); | 32 extensions::GuestViewBase::FromWebContents(web_contents); |
33 // For embedded WebContents, use the embedder's WebContents for constrained | 33 // For embedded WebContents, use the embedder's WebContents for constrained |
34 // window. | 34 // window. |
35 web_contents_ = web_view_guest && web_view_guest->embedder_web_contents() ? | 35 web_contents_ = guest_view && guest_view->embedder_web_contents() ? |
36 web_view_guest->embedder_web_contents() : web_contents; | 36 guest_view->embedder_web_contents() : web_contents; |
37 DCHECK(sheet_.get()); | 37 DCHECK(sheet_.get()); |
38 web_modal::PopupManager* popup_manager = | 38 web_modal::PopupManager* popup_manager = |
39 web_modal::PopupManager::FromWebContents(web_contents_); | 39 web_modal::PopupManager::FromWebContents(web_contents_); |
40 if (popup_manager) | 40 if (popup_manager) |
41 popup_manager->ShowModalDialog(this, web_contents_); | 41 popup_manager->ShowModalDialog(this, web_contents_); |
42 } | 42 } |
43 | 43 |
44 ConstrainedWindowMac::~ConstrainedWindowMac() { | 44 ConstrainedWindowMac::~ConstrainedWindowMac() { |
45 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 45 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
46 } | 46 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 NSWindow* ConstrainedWindowMac::GetParentWindow() const { | 94 NSWindow* ConstrainedWindowMac::GetParentWindow() const { |
95 // 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 |
96 // reason use a browser window if possible. | 96 // reason use a browser window if possible. |
97 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); | 97 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); |
98 if (browser) | 98 if (browser) |
99 return browser->window()->GetNativeWindow(); | 99 return browser->window()->GetNativeWindow(); |
100 | 100 |
101 return web_contents_->GetTopLevelNativeWindow(); | 101 return web_contents_->GetTopLevelNativeWindow(); |
102 } | 102 } |
OLD | NEW |